From owner-svn-src-all@freebsd.org Mon May 28 23:17:59 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CAB55EFDE6D; Mon, 28 May 2018 23:17:58 +0000 (UTC) (envelope-from mmacy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7C13D6985A; Mon, 28 May 2018 23:17:58 +0000 (UTC) (envelope-from mmacy@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5D51413E23; Mon, 28 May 2018 23:17:58 +0000 (UTC) (envelope-from mmacy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w4SNHwb7001499; Mon, 28 May 2018 23:17:58 GMT (envelope-from mmacy@FreeBSD.org) Received: (from mmacy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w4SNHw1l001498; Mon, 28 May 2018 23:17:58 GMT (envelope-from mmacy@FreeBSD.org) Message-Id: <201805282317.w4SNHw1l001498@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmacy set sender to mmacy@FreeBSD.org using -f From: Matt Macy Date: Mon, 28 May 2018 23:17:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334301 - head/sys/dev/hwpmc X-SVN-Group: head X-SVN-Commit-Author: mmacy X-SVN-Commit-Paths: head/sys/dev/hwpmc X-SVN-Commit-Revision: 334301 X-SVN-Commit-Repository: base 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.26 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: Mon, 28 May 2018 23:17:59 -0000 Author: mmacy Date: Mon May 28 23:17:57 2018 New Revision: 334301 URL: https://svnweb.freebsd.org/changeset/base/334301 Log: hwpmc: make pmc class specification work to enable fixed function counters Modified: head/sys/dev/hwpmc/hwpmc_mod.c Modified: head/sys/dev/hwpmc/hwpmc_mod.c ============================================================================== --- head/sys/dev/hwpmc/hwpmc_mod.c Mon May 28 23:16:39 2018 (r334300) +++ head/sys/dev/hwpmc/hwpmc_mod.c Mon May 28 23:17:57 2018 (r334301) @@ -3253,7 +3253,17 @@ pmc_stop(struct pmc *pm) return (error); } +static struct pmc_classdep * +pmc_class_to_classdep(enum pmc_class class) +{ + int n; + for (n = 0; n < md->pmd_nclass; n++) + if (md->pmd_classdep[n].pcd_class == class) + return (&md->pmd_classdep[n]); + return (NULL); +} + #ifdef HWPMC_DEBUG static const char *pmc_op_to_name[] = { #undef __PMC_OP @@ -3816,16 +3826,14 @@ pmc_syscall_handler(struct thread *td, void *syscall_a caps |= PMC_CAP_INTERRUPT; /* A valid class specifier should have been passed in. */ - for (n = 0; n < md->pmd_nclass; n++) - if (md->pmd_classdep[n].pcd_class == pa.pm_class) - break; - if (n == md->pmd_nclass) { + pcd = pmc_class_to_classdep(pa.pm_class); + if (pcd == NULL) { error = EINVAL; break; } /* The requested PMC capabilities should be feasible. */ - if ((md->pmd_classdep[n].pcd_caps & caps) != caps) { + if ((pcd->pcd_caps & caps) != caps) { error = EOPNOTSUPP; break; } @@ -3852,7 +3860,7 @@ pmc_syscall_handler(struct thread *td, void *syscall_a if (PMC_IS_SYSTEM_MODE(mode)) { pmc_select_cpu(cpu); - for (n = 0; n < (int) md->pmd_npmc; n++) { + for (n = pcd->pcd_ri; n < (int) md->pmd_npmc; n++) { pcd = pmc_ri_to_classdep(md, n, &adjri); if (pmc_can_allocate_row(n, mode) == 0 && pmc_can_allocate_rowindex( @@ -3865,7 +3873,7 @@ pmc_syscall_handler(struct thread *td, void *syscall_a } } else { /* Process virtual mode */ - for (n = 0; n < (int) md->pmd_npmc; n++) { + for (n = pcd->pcd_ri; n < (int) md->pmd_npmc; n++) { pcd = pmc_ri_to_classdep(md, n, &adjri); if (pmc_can_allocate_row(n, mode) == 0 && pmc_can_allocate_rowindex( @@ -3929,6 +3937,7 @@ pmc_syscall_handler(struct thread *td, void *syscall_a } pmc->pm_state = PMC_STATE_ALLOCATED; + pmc->pm_class = pa.pm_class; /* * mark row disposition