On 2/24/25 09:04, Harry Yoo wrote:
>> +static void barn_shrink(struct kmem_cache *s, struct node_barn *barn)
>> +{
>> +    struct list_head empty_list;
>> +    struct list_head full_list;
>> +    struct slab_sheaf *sheaf, *sheaf2;
>> +    unsigned long flags;
>> +
>> +    INIT_LIST_HEAD(&empty_list);
>> +    INIT_LIST_HEAD(&full_list);
>> +
>> +    spin_lock_irqsave(&barn->lock, flags);
>> +
>> +    list_splice_init(&barn->sheaves_full, &full_list);
>> +    barn->nr_full = 0;
>> +    list_splice_init(&barn->sheaves_empty, &empty_list);
>> +    barn->nr_empty = 0;
>> +
>> +    spin_unlock_irqrestore(&barn->lock, flags);
>> +
>> +    list_for_each_entry_safe(sheaf, sheaf2, &full_list, barn_list) {
>> +            sheaf_flush(s, sheaf);
>> +            list_move(&sheaf->barn_list, &empty_list);
>> +    }
> 
> nit: is this list_move() necessary?

You mean I can just do free_empty_sheaf(s, sheaf); ? Yeah why not.

>> +
>> +    list_for_each_entry_safe(sheaf, sheaf2, &empty_list, barn_list)
>> +            free_empty_sheaf(s, sheaf);
>> +}
> 
> Otherwise looks good to me.

Thanks.


Reply via email to