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

Tim Chen
2022-09-07T22:10:18Z

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