lkml.org 
[lkml]   [2023]   [Apr]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 2/7] perf tools: Add util function for overriding user set config values
From


On 24/04/2023 16:36, Adrian Hunter wrote:
> On 24/04/23 16:47, James Clark wrote:
>> There is some duplicated code to only override config values if they
>> haven't already been set by the user so make a util function for this.
>>
>> Signed-off-by: James Clark <james.clark@arm.com>
>
> One minor comment, nevertheless:
>
> Acked-by: Adrian Hunter <adrian.hunter@intel.com>
>

Thanks for the review

>> ---
>> tools/perf/arch/arm64/util/arm-spe.c | 26 ++-----------------------
>> tools/perf/arch/x86/util/intel-pt.c | 22 ++-------------------
>> tools/perf/util/evsel.c | 29 ++++++++++++++++++++++++++++
>> tools/perf/util/evsel.h | 3 +++
>> 4 files changed, 36 insertions(+), 44 deletions(-)
>>
[...]
>> }
>> }
>> +
>> +/*
>> + * Set @config_name to @val as long as the user hasn't already set or cleared it
>> + * by passing a config term on the command line.
>> + *
>> + * @val is the value to put into the bits specified by @config_name rather than
>> + * the bit pattern. It is shifted into position by this function, so to set
>> + * something to true, pass 1 for val rather than a pre shifted value.
>> + */
>> +#define field_prep(_mask, _val) (((_val) << (ffsll(_mask) - 1)) & (_mask))
>
> I notice there is already tools/include/linux/bitfield.h
> so may FIELD_PREP from there could be used?

I tried that first, but it seems like quite a lot of effort went into it
to make it work on const only values so it doesn't work here. There is
this [1] change to make a non const one but it doesn't look like it went
anywhere:

[1]:
https://patchwork.kernel.org/project/linux-omap/patch/3a54a6703879d10f08cf0275a2a69297ebd2b1d4.1637592133.git.geert+renesas@glider.be/#24610749

\
 
 \ /
  Last update: 2023-04-24 18:44    [W:0.053 / U:1.936 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site