Re: [PATCH 1/5] perf tools: Add fallback functions for cases where cpumode is insufficient

From: David Miller
Date: Mon Nov 05 2018 - 13:19:11 EST


From: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Date: Mon, 5 Nov 2018 14:29:46 -0300

>> @@ -2542,6 +2542,46 @@ int machine__get_kernel_start(struct machine *machine)
>> return err;
>> }
>>
>> +/*
>> + * machine__single_ku_as - Machine has same address space for kernel and user.
>> + * @machine: machine object
>> + *
>> + * Some architectures have a single address space for kernel and user addresses,
>> + * which makes it possible to determine if an address is in kernel space or user
>> + * space.
>> + */
>> +static bool machine__single_ku_as(struct machine *machine)
>> +{
>> + return strcmp(perf_env__arch(machine->env), "sparc");
>> +}
>
> Can we avoid having this strcmp be done repeatedly? I.e. just make this
> a boolean initialized at session start, when machine->env is setup, so
> we'd have:
>
> machine->single_address_space
>
> Instead of a function?

Agreed, doing this every time is wasteful.

We could also make it a define in some arch/foo file.