Re: [PATCH v2 4/6] debugobjects: Don't start fill if there are remaining nodes locally

From: Leizhen (ThunderTown)
Date: Tue Sep 10 2024 - 21:21:38 EST




On 2024/9/10 23:29, Leizhen (ThunderTown) wrote:
>
>
> On 2024/9/9 21:51, Leizhen (ThunderTown) wrote:
>> +static void fill_pool(void)
>> +{
>> + gfp_t gfp = __GFP_HIGH | __GFP_NOWARN;
>> + static atomic_t cpus_allocating;
>>
>> if (unlikely(!obj_cache))
>> return;
>>
>> + /*
>> + * Avoid allocation and lock contention when
>> + *
>> + * - the CPU local pool has at least 2 objects left
>> + * - another CPU is already in the allocation path
>> + * - the global pool has not reached the critical level yet
>> + */
>> + if (this_cpu_read(percpu_obj_pool.obj_free) > 1 && atomic_read(&cpus_allocating) &&
>
> I rethink that 'cpus_allocating' and 'percpu_obj_pool.obj_free > 1' should be
> contradictory. We can only choose one of them. If 'cpus_allocating' can work,
> there's no need for another. Since I had no way to prove that 'cpus_allocating'

Sorry, I mistyped in a hurry yesterday, and it's 'percpu_obj_pool.obj_free > 1'
that should be deleted.


> would work, I removed it in V3.
>
>> + READ_ONCE(obj_pool_free) > (debug_objects_pool_min_level / 2))
>> + return;
>> +
>> + atomic_inc(&cpus_allocating);
>> while (READ_ONCE(obj_pool_free) < debug_objects_pool_min_level) {
>> struct debug_obj *new[ODEBUG_BATCH_SIZE];
>> int cnt;
>

--
Regards,
Zhen Lei