[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4677dda8-6a3b-1908-775e-3510091abda5@linux.intel.com>
Date: Mon, 8 Mar 2021 11:12:25 +0800
From: "Jin, Yao" <yao.jin@...ux.intel.com>
To: Jiri Olsa <jolsa@...hat.com>
Cc: acme@...nel.org, jolsa@...nel.org, peterz@...radead.org,
mingo@...hat.com, alexander.shishkin@...ux.intel.com,
Linux-kernel@...r.kernel.org, ak@...ux.intel.com,
kan.liang@...el.com, yao.jin@...el.com
Subject: Re: [PATCH v2] perf pmu: Validate raw event with sysfs exported
format bits
Hi Jiri,
On 3/7/2021 3:12 AM, Jiri Olsa wrote:
> actualy we do have bitmap_scnprintf, which is already doing the
> printing in a nice way.. we could use it like below, only compile
> tested
>
> jirka
>
>
> ---
> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
> index 31e975b75766..37ca5eee2667 100644
> --- a/tools/perf/util/pmu.c
> +++ b/tools/perf/util/pmu.c
> @@ -1818,7 +1818,7 @@ void perf_pmu__warn_invalid_config(struct perf_pmu *pmu, __u64 config,
> {
> struct perf_pmu_format *format;
> __u64 masks = 0, bits;
> - struct strbuf buf = STRBUF_INIT;
> + char buf[50];
> unsigned int i;
>
> list_for_each_entry(format, &pmu->format, list) {
> @@ -1836,25 +1836,15 @@ void perf_pmu__warn_invalid_config(struct perf_pmu *pmu, __u64 config,
> * Kernel doesn't export any valid format bits.
> */
> if (masks == 0)
> - goto out;
> + return;
>
> bits = config & ~masks;
> if (bits == 0)
> - goto out;
> -
> - for_each_set_bit(i, (unsigned long *)&bits, sizeof(bits) * 8)
> - strbuf_addf(&buf, " %d", i);
> + return;
>
> - if (name) {
> - pr_warning("WARNING: event '%s' not valid (bits%s of config "
> - "'%llx' not supported by kernel)!\n",
> - name, buf.buf, config);
> - } else {
> - pr_warning("WARNING: event not valid (bits%s of config "
> - "'%llx' not supported by kernel)!\n",
> - buf.buf, config);
> - }
> + bitmap_scnprintf((unsigned long *)&bits, sizeof(bits) * 8, buf, sizeof(buf));
>
> -out:
> - strbuf_release(&buf);
> + pr_warning("WARNING: event '%s' not valid (bits%s of config "
> + "'%llx' not supported by kernel)!\n",
> + name ?: "N/A", buf, config);
> }
The bitmap_scnprintf works fine. Yes, it's really better than original 'strbuf' way, thanks!
BTW, I added "Co-developed-by: Jiri Olsa <jolsa@...hat.com>" in v3, but the patch checking shows the
warning:
WARNING: Co-developed-by and Signed-off-by: name/email do not match
#76:
Co-developed-by: Jiri Olsa <jolsa@...hat.com>
Signed-off-by: Jin Yao <yao.jin@...ux.intel.com>
I'm not sure if this warning is important or not, but anyway I add the line to v3. Thanks for your
help!
Jin Yao
Powered by blists - more mailing lists