ipc/msg: mitigate the lock contention in ipc/msg
Status from this message: [merged mm-nonmm-stable] percpu-add-percpu_counter_add_local-and-percpu_counter_sub_local.patch removed from -mm tree
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v6 Latest2 patches 6 repliesApplied 2/2
- v52 patches 2 repliesSuperseded
- v41 patch 6 repliesSuperseded
Earlier versions · 2
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v3 | 2 patches | 0 replies | Superseded | |
| v2 | 2 patches | 2 replies | Superseded |
Changes in v6 from the cover letter
1. Revise the code comment of percpu_counter_add_local in patch 1/2.
2. Get percpu_counter_sub_local from percpu_counter_add_local rather than that from percpu_counter_add_batch for SMP and percpu_counter_sub for non-SMP to reduce code modification.
Patches in v6 All 2 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | percpu: Add percpu_counter_add_local and percpu_counter_sub_localinclude/ | +32 | 2 replies | Applied |
| 2/2 | ipc/msg: mitigate the lock contention with percpu counterinclude/ ipc/ ipc/ +1 more | +39 | 5 replies | Applied |
Reviews trailers per patch
All 2 patches have a Reviewed-by or Acked-by.
| Patch | Tim Chen | Manfred Spraul |
|---|---|---|
| 1/2 | R-b | |
| 2/2 | R-b R-b | R-b R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v6 0/2] ipc/msg: mitigate the lock contention in ipc/msg
Hi,
Here are two patches to mitigate the lock contention in ipc/msg.
The 1st patch is to add the new interface percpu_counter_add_local and percpu_counter_sub_local. The batch size in percpu_counter_add_batch should be very large in heavy writing and rare reading case. Add the "_local" version, and mostly it will do local adding, reduce the global updating and mitigate lock contention in writing.
The 2nd patch is to use percpu_counter instead of atomic update in ipc/msg. The msg_bytes and msg_hdrs atomic counters are frequently updated when IPC msg queue is in heavy use, causing heavy cache bounce and overhead. Change them to percpu_counter greatly improve the performance. Since there is one percpu struct per namespace, additional memory cost is minimal. Reading of the count done in msgctl call, which is infrequent. So the need to sum up the counts in each CPU is infrequent.
Changes in v6:
1. Revise the code comment of percpu_counter_add_local in patch 1/2.
2. Get percpu_counter_sub_local from percpu_counter_add_local rather than that from percpu_counter_add_batch for SMP and percpu_counter_sub for non-SMP to reduce code modification.
Changes in v5:
1. Use INT_MAX as the large batch size in percpu_counter_local_add and percpu_counter_sub_local.
2. Use the latest kernel 6.0-rc4 as the baseline for performance test.
3. Move the percpu_counter_local_add and percpu_counter_sub_local from percpu_counter.c to percpu_counter.h.
Changes in v3:
1. Add comment and change log for the new function percpu_counter_add_local. Who should use it and who shouldn't.
Changes in v2:
1. Separate the original patch into two patches.
2. Add error handling for percpu_counter_init.
The performance gain increases as the threads of workload become larger. Performance gain: 3.99x
CPU: ICX 8380 x 2 sockets
Core number: 40 x 2 physical cores
Benchmark: pts/stress-ng-1.4.0
-- system v message passing (160 threads)
Regards
Jiebin