From: Sandipan Das <sandipan.das@amd.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [bug report] perf/x86/amd/uncore: Refactor uncore management
Date: Tue, 9 Dec 2025 12:56:27 +0530 [thread overview]
Message-ID: <0e64db3d-042d-4066-a04d-68e1dd573b5b@amd.com> (raw)
In-Reply-To: <aTaI0ci3vZ44lmBn@stanley.mountain>
Hi Dan,
Thanks for reporting this.
On 12/8/2025 1:44 PM, Dan Carpenter wrote:
> Hello Sandipan Das,
>
> Commit d6389d3ccc13 ("perf/x86/amd/uncore: Refactor uncore
> management") from Oct 5, 2023 (linux-next), leads to the following
> Smatch static checker warning:
>
> arch/x86/events/amd/uncore.c:660 amd_uncore_df_event_init()
> warn: set error code if 'pmu_version < 2'
>
> arch/x86/events/amd/uncore.c
> 654 static int amd_uncore_df_event_init(struct perf_event *event)
> 655 {
> 656 struct hw_perf_event *hwc = &event->hw;
> 657 int ret = amd_uncore_event_init(event);
> 658
> 659 if (ret || pmu_version < 2)
> --> 660 return ret;
>
> If pmu_version is < 2, do we really want to just return success?
>
> 661
> 662 hwc->config = event->attr.config &
> 663 (pmu_version >= 2 ? AMD64_PERFMON_V2_RAW_EVENT_MASK_NB :
> 664 AMD64_RAW_EVENT_MASK_NB);
>
> Or do we want to set:
>
> hwc->config = event->attr.config & AMD64_RAW_EVENT_MASK_NB;
>
> And then return success?
>
Right. If amd_uncore_event_init() returns an error, this should bail out
irrespective of pmu_version. I think it should be okay to set hwc->config
even if amd_uncore_event_init() errors out so that this can be simplified
further.
@@ -656,14 +656,11 @@ static int amd_uncore_df_event_init(struct perf_event *event)
struct hw_perf_event *hwc = &event->hw;
int ret = amd_uncore_event_init(event);
- if (ret || pmu_version < 2)
- return ret;
-
hwc->config = event->attr.config &
(pmu_version >= 2 ? AMD64_PERFMON_V2_RAW_EVENT_MASK_NB :
AMD64_RAW_EVENT_MASK_NB);
- return 0;
+ return ret;
}
static int amd_uncore_df_add(struct perf_event *event, int flags
> 665
> 666 return 0;
> 667 }
>
prev parent reply other threads:[~2025-12-09 7:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-08 8:14 [bug report] perf/x86/amd/uncore: Refactor uncore management Dan Carpenter
2025-12-09 7:26 ` Sandipan Das [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0e64db3d-042d-4066-a04d-68e1dd573b5b@amd.com \
--to=sandipan.das@amd.com \
--cc=dan.carpenter@linaro.org \
--cc=linux-perf-users@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).