From owner-svn-src-head@freebsd.org Tue May 24 12:06:58 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 208DDB43E05; Tue, 24 May 2016 12:06:58 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E55991987; Tue, 24 May 2016 12:06:57 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4OC6vQk066393; Tue, 24 May 2016 12:06:57 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4OC6vxt066392; Tue, 24 May 2016 12:06:57 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201605241206.u4OC6vxt066392@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Tue, 24 May 2016 12:06:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300604 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 May 2016 12:06:58 -0000 Author: andrew Date: Tue May 24 12:06:56 2016 New Revision: 300604 URL: https://svnweb.freebsd.org/changeset/base/300604 Log: Limit calling pmc_hook to when the interrupt comes while running userspace. We may enable interrupts from within the callback, e.g. in a data abort during copyin. If we receive an interrupt at that time pmc_hook will be called again and, as it is handling userspace stack tracing, will hit a KASSERT as it checks if the trapframe is from userland. With this I can run hwpmc with intrng on a ThunderX and have it trace all CPUs. Obtained from: ABT Systems Ltd Sponsored by: The FreeBSD Foundation Modified: head/sys/kern/subr_intr.c Modified: head/sys/kern/subr_intr.c ============================================================================== --- head/sys/kern/subr_intr.c Tue May 24 11:47:14 2016 (r300603) +++ head/sys/kern/subr_intr.c Tue May 24 12:06:56 2016 (r300604) @@ -317,7 +317,8 @@ intr_irq_handler(struct trapframe *tf) td->td_intr_frame = oldframe; critical_exit(); #ifdef HWPMC_HOOKS - if (pmc_hook && (PCPU_GET(curthread)->td_pflags & TDP_CALLCHAIN)) + if (pmc_hook && TRAPF_USERMODE(tf) && + (PCPU_GET(curthread)->td_pflags & TDP_CALLCHAIN)) pmc_hook(PCPU_GET(curthread), PMC_FN_USER_CALLCHAIN, tf); #endif }