mirror of
https://github.com/lkl/linux.git
synced 2025-12-19 16:13:19 +09:00
ipc/msg: mitigate the lock contention with percpu counter
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. Apply the patch and test the pts/stress-ng-1.4.0 -- system v message passing (160 threads). Score 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) [akpm@linux-foundation.org: coding-style cleanups] [jiebin.sun@intel.com: avoid negative value by overflow in msginfo] Link: https://lkml.kernel.org/r/20220920150809.4014944-1-jiebin.sun@intel.com [akpm@linux-foundation.org: fix min() warnings] Link: https://lkml.kernel.org/r/20220913192538.3023708-3-jiebin.sun@intel.com Signed-off-by: Jiebin Sun <jiebin.sun@intel.com> Reviewed-by: Tim Chen <tim.c.chen@linux.intel.com> Cc: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com> Cc: Alexey Gladkov <legion@kernel.org> Cc: Christoph Lameter <cl@linux.com> Cc: Davidlohr Bueso <dave@stgolabs.net> Cc: Dennis Zhou <dennis@kernel.org> Cc: "Eric W . Biederman" <ebiederm@xmission.com> Cc: Manfred Spraul <manfred@colorfullife.com> Cc: Shakeel Butt <shakeelb@google.com> Cc: Tejun Heo <tj@kernel.org> Cc: Vasily Averin <vasily.averin@linux.dev> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
committed by
Andrew Morton
parent
5d0ce3595a
commit
72d1e61108
@@ -11,6 +11,7 @@
|
||||
#include <linux/refcount.h>
|
||||
#include <linux/rhashtable-types.h>
|
||||
#include <linux/sysctl.h>
|
||||
#include <linux/percpu_counter.h>
|
||||
|
||||
struct user_namespace;
|
||||
|
||||
@@ -36,8 +37,8 @@ struct ipc_namespace {
|
||||
unsigned int msg_ctlmax;
|
||||
unsigned int msg_ctlmnb;
|
||||
unsigned int msg_ctlmni;
|
||||
atomic_t msg_bytes;
|
||||
atomic_t msg_hdrs;
|
||||
struct percpu_counter percpu_msg_bytes;
|
||||
struct percpu_counter percpu_msg_hdrs;
|
||||
|
||||
size_t shm_ctlmax;
|
||||
size_t shm_ctlall;
|
||||
|
||||
Reference in New Issue
Block a user