1
0
mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2026-01-18 20:40:22 +00:00
Shakeel Butt f689054aac percpu_counter: add percpu_counter_sum_all interface
The percpu_counter is used for scenarios where performance is more
important than the accuracy.  For percpu_counter users, who want more
accurate information in their slowpath, percpu_counter_sum is provided
which traverses all the online CPUs to accumulate the data.  The reason it
only needs to traverse online CPUs is because percpu_counter does
implement CPU offline callback which syncs the local data of the offlined
CPU.

However there is a small race window between the online CPUs traversal of
percpu_counter_sum and the CPU offline callback.  The offline callback has
to traverse all the percpu_counters on the system to flush the CPU local
data which can be a lot.  During that time, the CPU which is going offline
has already been published as offline to all the readers.  So, as the
offline callback is running, percpu_counter_sum can be called for one
counter which has some state on the CPU going offline.  Since
percpu_counter_sum only traverses online CPUs, it will skip that specific
CPU and the offline callback might not have flushed the state for that
specific percpu_counter on that offlined CPU.

Normally this is not an issue because percpu_counter users can deal with
some inaccuracy for small time window.  However a new user i.e.  mm_struct
on the cleanup path wants to check the exact state of the percpu_counter
through check_mm().  For such users, this patch introduces
percpu_counter_sum_all() which traverses all possible CPUs and it is used
in fork.c:check_mm() to avoid the potential race.

This issue is exposed by the later patch "mm: convert mm's rss stats into
percpu_counter".

Link: https://lkml.kernel.org/r/20221109012011.881058-1-shakeelb@google.com
Signed-off-by: Shakeel Butt <shakeelb@google.com>
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2022-11-30 15:58:40 -08:00
..
2022-10-10 09:27:46 -07:00
2022-10-07 16:48:26 -07:00
2022-10-07 16:13:55 -07:00
2022-10-26 17:38:46 -07:00
2022-10-13 09:58:42 -07:00
2022-10-07 16:48:26 -07:00
2022-10-10 13:28:06 -07:00
2022-09-21 11:18:28 +09:00
2022-09-26 12:19:12 -07:00
2022-09-26 19:46:29 -07:00
2022-09-26 10:13:13 -07:00
2022-09-26 10:13:13 -07:00
2022-10-14 13:03:00 -07:00
2022-10-17 18:52:43 -07:00
2022-09-15 09:32:06 -07:00
2022-10-10 10:21:22 -07:00
2022-09-26 10:13:14 -07:00
2022-10-10 19:45:17 -07:00
2022-10-17 13:49:45 +02:00
2022-10-10 19:45:17 -07:00
2022-10-03 14:02:45 -07:00
2022-10-10 13:28:06 -07:00
2022-09-08 12:59:00 -06:00
2022-09-26 13:31:20 +02:00
2022-10-03 14:03:19 -07:00
2022-10-07 10:48:49 -07:00
2022-10-03 17:51:52 -07:00
2022-09-26 10:13:13 -07:00
2022-10-03 17:34:32 -07:00
2022-09-26 19:46:27 -07:00
2022-09-26 19:46:09 -07:00
2022-11-08 17:37:18 -08:00
2022-10-11 11:08:18 -07:00
2022-10-17 16:32:05 +02:00
2022-10-04 20:52:38 +02:00
2022-10-11 17:42:58 -06:00
2022-09-19 06:17:05 -07:00
2022-10-11 17:42:58 -06:00
2022-10-09 14:05:15 -07:00
2022-10-10 09:10:28 -07:00
2022-09-29 15:20:29 +02:00
2022-09-22 16:12:34 +02:00
2022-09-22 16:12:34 +02:00
2022-09-16 10:56:08 +01:00
2022-10-07 09:32:40 -04:00
2022-10-07 08:10:52 -06:00
2022-09-26 19:46:18 -07:00
2022-09-26 19:46:18 -07:00
2022-09-28 10:00:16 +02:00