From owner-svn-src-all@FreeBSD.ORG Tue Oct 30 15:10:51 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6ABEF3FF; Tue, 30 Oct 2012 15:10:51 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3710C8FC12; Tue, 30 Oct 2012 15:10:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q9UFApWt017090; Tue, 30 Oct 2012 15:10:51 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q9UFAoek017087; Tue, 30 Oct 2012 15:10:50 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201210301510.q9UFAoek017087@svn.freebsd.org> From: Attilio Rao Date: Tue, 30 Oct 2012 15:10:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r242361 - in head/sys: dev/hwpmc kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Oct 2012 15:10:51 -0000 Author: attilio Date: Tue Oct 30 15:10:50 2012 New Revision: 242361 URL: http://svn.freebsd.org/changeset/base/242361 Log: Fixup r240246: hwpmc needs to retain the pinning until ASTs are not executed. This means past the point where userret() is generally executed. Skip the td_pinned check if a callchain tracing is currently happening and add a more robust check to pmc_capture_user_callchain() in order to catch td_pinned leak past ast() in hwpmc case. Reported and tested by: fabient MFC after: 1 week X-MFC: r240246 Modified: head/sys/dev/hwpmc/hwpmc_mod.c head/sys/kern/subr_trap.c Modified: head/sys/dev/hwpmc/hwpmc_mod.c ============================================================================== --- head/sys/dev/hwpmc/hwpmc_mod.c Tue Oct 30 13:22:39 2012 (r242360) +++ head/sys/dev/hwpmc/hwpmc_mod.c Tue Oct 30 15:10:50 2012 (r242361) @@ -4248,7 +4248,7 @@ pmc_capture_user_callchain(int cpu, int ("[pmc,%d] cpu %d didn't find a sample to collect", __LINE__, cpu)); - KASSERT(td->td_pinned > 0, + KASSERT(td->td_pinned == 1, ("[pmc,%d] invalid td_pinned value", __LINE__)); sched_unpin(); /* Can migrate safely now. */ Modified: head/sys/kern/subr_trap.c ============================================================================== --- head/sys/kern/subr_trap.c Tue Oct 30 13:22:39 2012 (r242360) +++ head/sys/kern/subr_trap.c Tue Oct 30 15:10:50 2012 (r242361) @@ -145,6 +145,11 @@ userret(struct thread *td, struct trapfr /* * Check for misbehavior. + * + * In case there is a callchain tracing ongoing because of + * hwpmc(4), skip the scheduler pinning check. + * hwpmc(4) subsystem, infact, will collect callchain informations + * at ast() checkpoint, which is past userret(). */ WITNESS_WARN(WARN_PANIC, NULL, "userret: returning"); KASSERT(td->td_critnest == 0, @@ -155,7 +160,7 @@ userret(struct thread *td, struct trapfr ("userret: Returning with pagefaults disabled")); KASSERT((td->td_pflags & TDP_NOSLEEPING) == 0, ("userret: Returning with sleep disabled")); - KASSERT(td->td_pinned == 0, + KASSERT(td->td_pinned == 0 || (td->td_pflags & TDP_CALLCHAIN) != 0, ("userret: Returning with with pinned thread")); KASSERT(td->td_vp_reserv == 0, ("userret: Returning while holding vnode reservation"));