lkml.org 
[lkml]   [2022]   [Aug]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: Re: [PATCH] bpf: Simplify code by using for_each_cpu_wrap()
Date
Hi Alexei,

Alexei Starovoitov <alexei.starovoitov@gmail.com> writes:

> On Wed, Aug 17, 2022 at 6:08 AM Punit Agrawal
> <punit.agrawal@bytedance.com> wrote:
>>
>> No functional change intended.
>
> ?
>
>> - orig_cpu = cpu = raw_smp_processor_id();
>> - while (1) {
>> + for_each_cpu_wrap(cpu, cpu_possible_mask, raw_smp_processor_id()) {
>> struct pcpu_freelist_head *head;
>>
>> head = per_cpu_ptr(s->freelist, cpu);
>> @@ -68,15 +67,10 @@ static inline void ___pcpu_freelist_push_nmi(struct pcpu_freelist *s,
>> raw_spin_unlock(&head->lock);
>> return;
>> }
>> - cpu = cpumask_next(cpu, cpu_possible_mask);
>> - if (cpu >= nr_cpu_ids)
>> - cpu = 0;
>> -
>> - /* cannot lock any per cpu lock, try extralist */
>> - if (cpu == orig_cpu &&
>> - pcpu_freelist_try_push_extra(s, node))
>> - return;
>> }
>> +
>> + /* cannot lock any per cpu lock, try extralist */
>> + pcpu_freelist_try_push_extra(s, node);
>
> This is obviously not equivalent!

Thanks for taking a look. You're right - I missed the fact that it's an
infinite loop until the node gets pushed to one of the lists.

I'll send an update with that fixed up.

\
 
 \ /
  Last update: 2022-08-17 18:59    [W:0.108 / U:0.884 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site