Message ID | 20231221093802.20612-1-jialong.yang@shingroup.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-8156-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp295183dyi; Thu, 21 Dec 2023 01:43:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IFC8Exxpis6l22GRbnELGqASIxWSCSU8WOW/yvxQpqrxDRneCh9OlSRE+IMT0qxse71i9Lt X-Received: by 2002:a05:6830:1e76:b0:6db:b035:b5aa with SMTP id m22-20020a0568301e7600b006dbb035b5aamr1518920otr.28.1703151794851; Thu, 21 Dec 2023 01:43:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703151794; cv=none; d=google.com; s=arc-20160816; b=BWeX/cGQtC8Vb3bwxj8yG0a/HYWo5kYU3hUa1hagbwmkO0eY28A2+uoBd3muYxT7hu 3y+WwQOIAcv2IlTIzJk/3ySfcj1osPOzfdUnCDRqJ3fUYh5Ae/zSzYj4oPRSlM5Nlkig lOhMxXBUALum3bOOeBCUZ3vy/J/bmxJF6eS9XsX1PzMMDsq9sQMdUbZKmM3qxIu93lAX YZkX3lZAoAPFpQo4InODqt94FyN3Nb1UJDXMvANJ2QR0Fz1QtZ5vP04QFhRrMWjpSXZO nTEFkYtafuUazD4u2IazejA7m1EpAkI73PxAJFffkIijH0mRPWZhO60F6nhKlNeZm+sd 1ElQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=feedback-id:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=ZXOzwjpzAEYalRgSH0JDviCDKsz9uKQ44MOPY+G2AHE=; fh=+J+RQ6dQE/8hw9xppGIQAAVej0ZWaQywlnQVxD6QLdg=; b=vzVQM73Mcz+3j5qnW5RxhlY8J8ImiHyj8cdhvo3aGx4rXaDb8yzx41BGsZJxPC04tv Ke+Wghnpkfm3zA0e/r9DpCaKOpKdH9dOLSZcrEllK1MSmU22zVFTDnJ2ep+wNRUXp/Df UgZYy0KyEVCzbI1CeM0sfqpV4m1xqRzK83hb341T19x5JJXUlR/H1NjeHddLgSZEOe+W jGfzJrW0GZXpfMqHCs+XwBKlCEG5kU6B3d5Lgn8K8Zot5SPmoH0xSvJIypK+6TTCsYlz HWAkGLA3xYQ7dKamU/dXlVQgx1YTDQ9vGIRgUPg4Hpdgj/WJB+eF0EjTx0ndDk5st8PP DNdw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-8156-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8156-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=shingroup.cn Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g16-20020a633750000000b005cdba908620si1283474pgn.32.2023.12.21.01.43.14 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 01:43:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8156-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-8156-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8156-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=shingroup.cn Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9DF59280359 for <ouuuleilei@gmail.com>; Thu, 21 Dec 2023 09:43:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EB0E63A8D0; Thu, 21 Dec 2023 09:39:08 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from bg1.exmail.qq.com (bg1.exmail.qq.com [114.132.65.219]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D2CC21A17 for <linux-kernel@vger.kernel.org>; Thu, 21 Dec 2023 09:39:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=shingroup.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shingroup.cn X-QQ-mid: bizesmtp90t1703151503t28eopg7 Received: from HX01040022.powercore.com.cn ( [223.112.234.130]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 21 Dec 2023 17:38:21 +0800 (CST) X-QQ-SSF: 01400000000000B0B000000A0000000 X-QQ-FEAT: +ynUkgUhZJnjMoY4gOOx27e0bd5FjgOXH7xQMXerutlnj6SyN+ZyFlxFHokp/ b+Z/WaNSkU7Nawdh3Dx3auVcz3fXEJDb3Ye37GaLRPm3qU4yQYJA/9n4hPdYZR90NJXuS7n Tjww8M7lMdbqKmxiCpOZ8/Ld+MbJSWhJ5X7M3xa5QsllHEw0pa/pNp4NUtrsxf7z8h/RHov Mn6Jeg8p4gwdDZ3STEnXmp0PIBjB7OHPrXJkQMf7V8kg9wskjJAt6D67tKgUQVSerSvLGXK yl7/Qsr/9FvWOZ2VoUDEOjyLXJX6EX8nv3ug+TjSrMtFgHvBpzzKJR/lfC4jY8gVrnDwuvq +KfivO6I/Y3Nn/O4oR/Ji42Ah/jGu+ZRBU9RUz8d0+hsGgSG2qrtankkq3W0ZutS0RNTgEb yiJTxRoJ/Gw= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 12415120465097514307 From: "JiaLong.Yang" <jialong.yang@shingroup.cn> To: Will Deacon <will@kernel.org>, Mark Rutland <mark.rutland@arm.com> Cc: shenghui.qu@shingroup.cn, ke.zhao@shingroup.cn, zhijie.ren@shingroup.cn, "JiaLong.Yang" <jialong.yang@shingroup.cn>, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] perf/arm_smmuv3: Omit the two judgements which done in framework Date: Thu, 21 Dec 2023 17:38:01 +0800 Message-Id: <20231221093802.20612-1-jialong.yang@shingroup.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:shingroup.cn:qybglogicsvrgz:qybglogicsvrgz6a-1 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785884096491082078 X-GMAIL-MSGID: 1785884096491082078 |
Series |
perf/arm_smmuv3: Omit the two judgements which done in framework
|
|
Commit Message
JiaLong.Yang
Dec. 21, 2023, 9:38 a.m. UTC
'event->attr.type != event->pmu->type' has been done in
core.c::perf_init_event() ,core.c::perf_event_modify_attr(), etc.
This PMU is an uncore one. The core framework has disallowed
uncore-task events. So the judgement to event->cpu < 0 is no mean.
The two judgements have been done in kernel/events/core.c
Signed-off-by: JiaLong.Yang <jialong.yang@shingroup.cn>
---
drivers/perf/arm_smmuv3_pmu.c | 8 --------
1 file changed, 8 deletions(-)
Comments
On Thu, Dec 21, 2023 at 05:38:01PM +0800, JiaLong.Yang wrote: > 'event->attr.type != event->pmu->type' has been done in > core.c::perf_init_event() ,core.c::perf_event_modify_attr(), etc. > > This PMU is an uncore one. The core framework has disallowed > uncore-task events. So the judgement to event->cpu < 0 is no mean. It would be great to refer to the changes which added those checks to the perf core code. From reading the code myself, I can't convince myself that perf_try_init_event() won't call into the driver. > > The two judgements have been done in kernel/events/core.c > > Signed-off-by: JiaLong.Yang <jialong.yang@shingroup.cn> > --- > drivers/perf/arm_smmuv3_pmu.c | 8 -------- > 1 file changed, 8 deletions(-) It looks like _many_ perf drivers have these checks, so if they really aren't needed, we can clean this up bveyond SMMU. However, as I said above, I'm not quite convinced we can drop them. Will
On 2024-02-09 4:09 pm, Will Deacon wrote: > On Thu, Dec 21, 2023 at 05:38:01PM +0800, JiaLong.Yang wrote: >> 'event->attr.type != event->pmu->type' has been done in >> core.c::perf_init_event() ,core.c::perf_event_modify_attr(), etc. >> >> This PMU is an uncore one. The core framework has disallowed >> uncore-task events. So the judgement to event->cpu < 0 is no mean. > > It would be great to refer to the changes which added those checks to > the perf core code. From reading the code myself, I can't convince myself > that perf_try_init_event() won't call into the driver. > >> >> The two judgements have been done in kernel/events/core.c >> >> Signed-off-by: JiaLong.Yang <jialong.yang@shingroup.cn> >> --- >> drivers/perf/arm_smmuv3_pmu.c | 8 -------- >> 1 file changed, 8 deletions(-) > > It looks like _many_ perf drivers have these checks, so if they really > aren't needed, we can clean this up bveyond SMMU. However, as I said > above, I'm not quite convinced we can drop them. Right, I think the logic prevents events with a specific PMU type being offered to other PMUs, but as far as I'm aware doesn't apply the other way round to stop generic events (PERF_TYPE_HARDWARE etc.) being offered to all PMUs, so it's those that system PMUs need to reject. It's been on my wishlist for a long time to have a capability flag to say "I don't handle generic events, please only ever give me events of my exact type" so we *can* truly factor this into the core. Thanks, Robin.
在 2024/2/10 0:32, Robin Murphy 写道: > On 2024-02-09 4:09 pm, Will Deacon wrote: >> On Thu, Dec 21, 2023 at 05:38:01PM +0800, JiaLong.Yang wrote: >>> 'event->attr.type != event->pmu->type' has been done in >>> core.c::perf_init_event() ,core.c::perf_event_modify_attr(), etc. >>> >>> This PMU is an uncore one. The core framework has disallowed >>> uncore-task events. So the judgement to event->cpu < 0 is no mean. >> >> It would be great to refer to the changes which added those checks to >> the perf core code. From reading the code myself, I can't convince myself >> that perf_try_init_event() won't call into the driver. >> >>> >>> The two judgements have been done in kernel/events/core.c >>> >>> Signed-off-by: JiaLong.Yang <jialong.yang@shingroup.cn> >>> --- >>> drivers/perf/arm_smmuv3_pmu.c | 8 -------- >>> 1 file changed, 8 deletions(-) >> >> It looks like _many_ perf drivers have these checks, so if they really >> aren't needed, we can clean this up bveyond SMMU. However, as I said >> above, I'm not quite convinced we can drop them. > > Right, I think the logic prevents events with a specific PMU type being > offered to other PMUs, but as far as I'm aware doesn't apply the other > way round to stop generic events (PERF_TYPE_HARDWARE etc.) being offered > to all PMUs, so it's those that system PMUs need to reject. > > It's been on my wishlist for a long time to have a capability flag to > say "I don't handle generic events, please only ever give me events of > my exact type" so we *can* truly factor this into the core. It's core framework's responsible to differ generic events and others, or uncore pmu and core pmu. Here we have flag PERF_TYPE_HARDWARE, PERF_TYPE_HW_CACHE, PERF_PMU_CAP_EXTENDED_HW_TYPE doing this. again: rcu_read_lock(); pmu = idr_find(&pmu_idr, type); rcu_read_unlock(); if (pmu) { if (event->attr.type != type && type != PERF_TYPE_RAW && !(pmu->capabilities & PERF_PMU_CAP_EXTENDED_HW_TYPE)) goto fail; /* generic event with no ability pmu */ This can avoid driver code (event->attr.type != event->pmu->type). And, code: if (pmu->task_ctx_nr == perf_invalid_context && (task || cgroup_fd != -1)) { err = -EINVAL; goto err_pmu; } can promise not uncore-task event. We should confirm that uncore event should be cpu >= 0. > > Thanks, > Robin. >
On 19/02/2024 6:37 am, Yang Jialong 杨佳龙 wrote: > > > 在 2024/2/10 0:32, Robin Murphy 写道: >> On 2024-02-09 4:09 pm, Will Deacon wrote: >>> On Thu, Dec 21, 2023 at 05:38:01PM +0800, JiaLong.Yang wrote: >>>> 'event->attr.type != event->pmu->type' has been done in >>>> core.c::perf_init_event() ,core.c::perf_event_modify_attr(), etc. >>>> >>>> This PMU is an uncore one. The core framework has disallowed >>>> uncore-task events. So the judgement to event->cpu < 0 is no mean. >>> >>> It would be great to refer to the changes which added those checks to >>> the perf core code. From reading the code myself, I can't convince >>> myself >>> that perf_try_init_event() won't call into the driver. >>> >>>> >>>> The two judgements have been done in kernel/events/core.c >>>> >>>> Signed-off-by: JiaLong.Yang <jialong.yang@shingroup.cn> >>>> --- >>>> drivers/perf/arm_smmuv3_pmu.c | 8 -------- >>>> 1 file changed, 8 deletions(-) >>> >>> It looks like _many_ perf drivers have these checks, so if they really >>> aren't needed, we can clean this up bveyond SMMU. However, as I said >>> above, I'm not quite convinced we can drop them. >> >> Right, I think the logic prevents events with a specific PMU type >> being offered to other PMUs, but as far as I'm aware doesn't apply the >> other way round to stop generic events (PERF_TYPE_HARDWARE etc.) being >> offered to all PMUs, so it's those that system PMUs need to reject. > >> It's been on my wishlist for a long time to have a capability flag to >> say "I don't handle generic events, please only ever give me events of >> my exact type" so we *can* truly factor this into the core. > > > It's core framework's responsible to differ generic events and others, > or uncore pmu and core pmu. > Here we have flag PERF_TYPE_HARDWARE, PERF_TYPE_HW_CACHE, > PERF_PMU_CAP_EXTENDED_HW_TYPE doing this. > > again: > rcu_read_lock(); > pmu = idr_find(&pmu_idr, type); > rcu_read_unlock(); > if (pmu) { > if (event->attr.type != type && type != PERF_TYPE_RAW && > !(pmu->capabilities & PERF_PMU_CAP_EXTENDED_HW_TYPE)) > goto fail; /* generic event with no ability pmu */ > This can avoid driver code (event->attr.type != event->pmu->type). Now consider the other case below that, where "type" has not matched anything registered, so "pmu" is NULL, and the event is then offered to *every* registered PMU to see if anyone accepts it. Note that even CPU PMUs don't always register as PERF_TYPE_RAW, and in particular arm_pmu doesn't. Thanks, Robin.
在 2024/2/27 2:57, Robin Murphy 写道: > On 19/02/2024 6:37 am, Yang Jialong 杨佳龙 wrote: >> >> >> 在 2024/2/10 0:32, Robin Murphy 写道: >>> On 2024-02-09 4:09 pm, Will Deacon wrote: >>>> On Thu, Dec 21, 2023 at 05:38:01PM +0800, JiaLong.Yang wrote: >>>>> 'event->attr.type != event->pmu->type' has been done in >>>>> core.c::perf_init_event() ,core.c::perf_event_modify_attr(), etc. >>>>> >>>>> This PMU is an uncore one. The core framework has disallowed >>>>> uncore-task events. So the judgement to event->cpu < 0 is no mean. >>>> >>>> It would be great to refer to the changes which added those checks to >>>> the perf core code. From reading the code myself, I can't convince >>>> myself >>>> that perf_try_init_event() won't call into the driver. >>>> >>>>> >>>>> The two judgements have been done in kernel/events/core.c >>>>> >>>>> Signed-off-by: JiaLong.Yang <jialong.yang@shingroup.cn> >>>>> --- >>>>> drivers/perf/arm_smmuv3_pmu.c | 8 -------- >>>>> 1 file changed, 8 deletions(-) >>>> >>>> It looks like _many_ perf drivers have these checks, so if they really >>>> aren't needed, we can clean this up bveyond SMMU. However, as I said >>>> above, I'm not quite convinced we can drop them. >>> >>> Right, I think the logic prevents events with a specific PMU type >>> being offered to other PMUs, but as far as I'm aware doesn't apply >>> the other way round to stop generic events (PERF_TYPE_HARDWARE etc.) >>> being offered to all PMUs, so it's those that system PMUs need to >>> reject. > >>> It's been on my wishlist for a long time to have a capability flag to >>> say "I don't handle generic events, please only ever give me events >>> of my exact type" so we *can* truly factor this into the core. >> >> >> It's core framework's responsible to differ generic events and others, >> or uncore pmu and core pmu. >> Here we have flag PERF_TYPE_HARDWARE, PERF_TYPE_HW_CACHE, >> PERF_PMU_CAP_EXTENDED_HW_TYPE doing this. >> >> again: >> rcu_read_lock(); >> pmu = idr_find(&pmu_idr, type); >> rcu_read_unlock(); >> if (pmu) { >> if (event->attr.type != type && type != PERF_TYPE_RAW && >> !(pmu->capabilities & >> PERF_PMU_CAP_EXTENDED_HW_TYPE)) >> goto fail; /* generic event with no ability >> pmu */ >> This can avoid driver code (event->attr.type != event->pmu->type). > > Now consider the other case below that, where "type" has not matched > anything registered, so "pmu" is NULL, and the event is then offered to > *every* registered PMU to see if anyone accepts it. Note that even CPU > PMUs don't always register as PERF_TYPE_RAW, and in particular arm_pmu > doesn't. > arm_pmu has flag PERF_PMU_CAP_EXTENDED_HW_TYPE. From below command, we can say that generic events is related to the pmus with type PERF_TYPE_RAW. ~/real_kernel $ grep -nr "PERF_TYPE_HARDWARE" arch/ drivers/ |cut -d: -f1|xargs egrep -c "perf_pmu_register.*PERF_TYPE_RAW" arch/alpha/kernel/perf_event.c:1 arch/alpha/kernel/perf_event.c:1 arch/arc/kernel/perf_event.c:1 arch/csky/kernel/perf_event.c:1 arch/loongarch/kernel/perf_event.c:1 arch/loongarch/kernel/perf_event.c:1 arch/mips/kernel/perf_event_mipsxx.c:1 arch/mips/kernel/perf_event_mipsxx.c:1 arch/powerpc/perf/8xx-pmu.c:1 arch/powerpc/perf/core-fsl-emb.c:1 arch/powerpc/perf/core-book3s.c:1 arch/riscv/kvm/vcpu_pmu.c:0 arch/s390/kernel/perf_cpum_sf.c:1 arch/s390/kernel/perf_cpum_cf.c:0 arch/s390/kernel/perf_cpum_cf.c:0 arch/s390/kernel/perf_cpum_cf.c:0 arch/s390/kernel/perf_cpum_cf.c:0 arch/sh/kernel/perf_event.c:1 arch/sh/kernel/perf_event.c:1 arch/sparc/kernel/perf_event.c:1 arch/x86/events/amd/ibs.c:0 arch/x86/events/intel/core.c:0 arch/x86/events/core.c:1 arch/xtensa/kernel/perf_event.c:1 drivers/perf/arm_pmu.c:0 drivers/perf/arm_pmu.c:0 drivers/perf/riscv_pmu.c:0 drivers/perf/riscv_pmu_legacy.c:1 drivers/perf/arm_pmuv3.c:0 drivers/perf/riscv_pmu_sbi.c:1 From this, we can say that generic events is related to the pmus with capability PERF_PMU_CAP_EXTENDED_HW_TYPE. ~/real_kernel $ grep -nr "PERF_TYPE_HARDWARE" arch/ drivers/ |cut -d: -f1|xargs grep -c "PERF_PMU_CAP_EXTENDED_HW_TYPE" arch/alpha/kernel/perf_event.c:0 arch/alpha/kernel/perf_event.c:0 arch/arc/kernel/perf_event.c:0 arch/csky/kernel/perf_event.c:0 arch/loongarch/kernel/perf_event.c:0 arch/loongarch/kernel/perf_event.c:0 arch/mips/kernel/perf_event_mipsxx.c:0 arch/mips/kernel/perf_event_mipsxx.c:0 arch/powerpc/perf/8xx-pmu.c:0 arch/powerpc/perf/core-fsl-emb.c:0 arch/powerpc/perf/core-book3s.c:0 arch/riscv/kvm/vcpu_pmu.c:0 arch/s390/kernel/perf_cpum_sf.c:0 arch/s390/kernel/perf_cpum_cf.c:0 arch/s390/kernel/perf_cpum_cf.c:0 arch/s390/kernel/perf_cpum_cf.c:0 arch/s390/kernel/perf_cpum_cf.c:0 arch/sh/kernel/perf_event.c:0 arch/sh/kernel/perf_event.c:0 arch/sparc/kernel/perf_event.c:0 arch/x86/events/amd/ibs.c:0 arch/x86/events/intel/core.c:0 arch/x86/events/core.c:1 arch/xtensa/kernel/perf_event.c:0 drivers/perf/arm_pmu.c:2 drivers/perf/arm_pmu.c:2 drivers/perf/riscv_pmu.c:0 drivers/perf/riscv_pmu_legacy.c:0 drivers/perf/arm_pmuv3.c:0 drivers/perf/riscv_pmu_sbi.c:0 **************************** Something bad belows: ~/real_kernel $ grep -nr "PERF_TYPE_HARDWARE" arch/ drivers/ |cut -d: -f1|xargs egrep -c "perf_pmu_register.*-1" arch/alpha/kernel/perf_event.c:0 arch/alpha/kernel/perf_event.c:0 arch/arc/kernel/perf_event.c:0 arch/csky/kernel/perf_event.c:0 arch/loongarch/kernel/perf_event.c:0 arch/loongarch/kernel/perf_event.c:0 arch/mips/kernel/perf_event_mipsxx.c:0 arch/mips/kernel/perf_event_mipsxx.c:0 arch/powerpc/perf/8xx-pmu.c:0 arch/powerpc/perf/core-fsl-emb.c:0 arch/powerpc/perf/core-book3s.c:0 arch/riscv/kvm/vcpu_pmu.c:0 arch/s390/kernel/perf_cpum_sf.c:0 arch/s390/kernel/perf_cpum_cf.c:2 arch/s390/kernel/perf_cpum_cf.c:2 arch/s390/kernel/perf_cpum_cf.c:2 arch/s390/kernel/perf_cpum_cf.c:2 arch/sh/kernel/perf_event.c:0 arch/sh/kernel/perf_event.c:0 arch/sparc/kernel/perf_event.c:0 arch/x86/events/amd/ibs.c:1 arch/x86/events/intel/core.c:0 arch/x86/events/core.c:0 arch/xtensa/kernel/perf_event.c:0 drivers/perf/arm_pmu.c:1 drivers/perf/arm_pmu.c:1 drivers/perf/riscv_pmu.c:0 drivers/perf/riscv_pmu_legacy.c:0 drivers/perf/arm_pmuv3.c:0 drivers/perf/riscv_pmu_sbi.c:0 The pmus::event_init handled PERF_TYPE_HARDWARE, but they was registered with perf_pmu_register(*, *, -1) without CAP_EXTENDED_HW_TPYE. Can we unify them with PERF_TYPE_RAW or CAP_EXTENDED_HW_TYPE? Maybe the latter is well. So we can assign idr PERF_TYPE_HARDWARE and PERF_TYPE_HW_CACHE a known pmu in perf_pmu_register just like: if(is_support_generic(pmu)) { ret = idr_alloc(&pmu_idr, pmu, PERF_TYPE_HARDWAR, PERF_TYPE_HARDWARE + 1, GFP_KERNEL); if(ret < 0) goto free_pdc; ret = idr_alloc(&pmu_idr, pmu, PERF_TYPE_HW_CACHE, PERF_TYPE_HW_CACHE + 1, GFP_KERNEL); if(ret < 0) goto free_pdc; } We will has a easy and rational way to write code in core.c::perf_init_event and perf_try_init_event about generic events. We can judge cpu < 0 in perf_try_init_event for uncore pmus. > Thanks, > Robin. >
diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c index 6303b82566f9..8ea4a3227165 100644 --- a/drivers/perf/arm_smmuv3_pmu.c +++ b/drivers/perf/arm_smmuv3_pmu.c @@ -401,19 +401,11 @@ static int smmu_pmu_event_init(struct perf_event *event) int group_num_events = 1; u16 event_id; - if (event->attr.type != event->pmu->type) - return -ENOENT; - if (hwc->sample_period) { dev_dbg(dev, "Sampling not supported\n"); return -EOPNOTSUPP; } - if (event->cpu < 0) { - dev_dbg(dev, "Per-task mode not supported\n"); - return -EOPNOTSUPP; - } - /* Verify specified event is supported on this PMU */ event_id = get_event(event); if (event_id < SMMU_PMCG_ARCH_MAX_EVENTS &&