[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5033835b-195f-2712-d621-c3c06cc61a08@arm.com>
Date: Fri, 22 Apr 2022 12:10:36 +0100
From: Vincent Donnefort <vincent.donnefort@....com>
To: Tao Zhou <tao.zhou@...ux.dev>
Cc: peterz@...radead.org, mingo@...hat.com, vincent.guittot@...aro.org,
linux-kernel@...r.kernel.org, dietmar.eggemann@....com,
morten.rasmussen@....com, chris.redpath@....com, qperret@...gle.com
Subject: Re: [PATCH v4 1/7] sched/fair: Provide u64 read for 32-bits arch
helper
[...]
>> +#ifdef CONFIG_64BIT
>> +# define u64_u32_load_copy(var, copy) var
>> +# define u64_u32_store_copy(var, copy, val) (var = val)
>> +#else
>> +# define u64_u32_load_copy(var, copy) \
>> +({ \
>> + u64 __val, __val_copy; \
>> + do { \
>> + __val_copy = copy; \
>> + /* \
>> + * paired with u64_u32_store, ordering access \
>> + * to var and copy. \
>> + */ \
>> + smp_rmb(); \
>> + __val = var; \
>> + } while (__val != __val_copy); \
>> + __val; \
>> +})
>> +# define u64_u32_store_copy(var, copy, val) \
>> +do { \
>> + typeof(val) __val = (val); \
>> + var = __val; \
>> + /* \
>> + * paired with u64_u32_load, ordering access to var and \
>> + * copy. \
>> + */ \
>> + smp_wmb(); \
>> + copy = __val; \
>
> `copy = __val;` should be `copy = var`.
>
> If var equal to val we do not need to do store. Check this condition
> in the above macro to avoid a redundant store.
>
> if (var != __val)
> var = __val;
Judging by the users of this macro, var = val is very much unlikely to
happen. Also, I don't think we want to waste a if here.
[...]
Powered by blists - more mailing lists