Re: [patch 1/3] lib/percpu_counter: Fix CPU hotplug handling

From: Thomas Gleixner
Date: Mon Apr 17 2023 - 04:09:26 EST


On Mon, Apr 17 2023 at 12:09, Dave Chinner wrote:
> On Fri, Apr 14, 2023 at 06:30:43PM +0200, Thomas Gleixner wrote:
>> - percpu_counter_batch = max(32, nr*2);
>> +static int percpu_counter_cpu_starting(unsigned int cpu)
>> +{
>> + /* If invoked during hotplug @cpu is not yet marked online. */
>> + compute_batch_value(cpu_online(cpu) ? 0 : 1);
>> return 0;
>> }
>
> So this changes the batch size based on whether the CPU is starting
> or dying to try to get _compare() to fall into the slow path
> correctly?

Right. That's not new. The original code did the same.

> How is this supposed to work with counters that have caller supplied
> custom batch sizes? i.e. use percpu_counter_add_batch() and
> __percpu_counter_compare() with their own batch sizes directly?
> Do they now need to add their own cpu hotplug hooks to
> screw around with their batch sizes as well?

Now? Nothing has changed here. Just the point where the batch size
computation is called is different. The original code did it in the
dynamic online callback late on hotplug and in the dead (cleanup)
callback late on unplug.

The external batch sizes always have been independent of this.

Thanks,

tglx