Re: [PATCH v4] ipc/msg: mitigate the lock contention with percpu counter

From: Tim Chen
Date: Wed Sep 07 2022 - 18:10:18 EST


On Wed, 2022-09-07 at 14:34 -0700, Andrew Morton wrote:
>
> I think this concept of a percpu_counter_add() which is massively
> biased to the write side and with very rare reading is a legitimate
> use-case. Perhaps it should become an addition to the formal interface.
> Something like
>
> /*
> * comment goes here
> */
> static inline void percpu_counter_add_local(struct percpu_counter *fbc,
> s64 amount)
> {
> percpu_counter_add_batch(fbc, amount, INT_MAX);
> }
>
> and percpu_counter_sub_local(), I guess.
>
> The only instance I can see is
> block/blk-cgroup-rwstat.h:blkg_rwstat_add() which is using INT_MAX/2
> because it always uses percpu_counter_sum_positive() on the read side.
>
> But that makes two!

Sure. We can create this function and use it for both cases. No objections.

Tim