[lkml]   [2022]   [Mar]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH 16/19] context_tracking: Convert state to atomic_t
On Wed, Mar 02, 2022 at 04:48:07PM +0100, Frederic Weisbecker wrote:
> +static __always_inline int __ct_state(void)
> +{
> + return atomic_read(this_cpu_ptr(&context_tracking.state));
> +}

One arguably horrible thing to do would be to write it like:

return __this_cpu_read(context_tracking.state.counter);

IIRC that will actually DTRT since atomic_read() is basically defined to
be READ_ONCE() and this_cpu_read() implies the same.

Only PowerPC and s390 implement arch_atomic_read() in asm, but I don't
think they have a particularly good reason to. The only other weird case
is Alpha, where READ_ONCE() implies smp_mb() because Alpha. I'm not sure
we care about that case, hmm?

The same can be done for ct_dynticks(), which is basically the same
function with a different mask.

As mentioned elsewhere, ct_state() appears unused at the end of the

 \ /
  Last update: 2022-03-12 23:56    [W:0.348 / U:0.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site