From patchwork Thu Mar 21 12:14:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thibault Ferrante X-Patchwork-Id: 1914390 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0kv31jGSz1yWs for ; Thu, 21 Mar 2024 23:15:42 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1rnHKK-0007tg-5T; Thu, 21 Mar 2024 12:15:20 +0000 Received: from smtp-relay-canonical-1.internal ([10.131.114.174] helo=smtp-relay-canonical-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1rnHK9-0007sq-R0 for kernel-team@lists.ubuntu.com; Thu, 21 Mar 2024 12:15:09 +0000 Received: from Q58-sff.buildd (2.general.thibf.uk.vpn [10.172.200.120]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id 94E2E40EB6; Thu, 21 Mar 2024 12:15:09 +0000 (UTC) From: Thibault Ferrante To: kernel-team@lists.ubuntu.com Subject: [SRU][J][PATCH 0/9] ipc/msg: mitigate the lock contention with percpu counter Date: Thu, 21 Mar 2024 13:14:48 +0100 Message-ID: <20240321121457.362921-1-thibault.ferrante@canonical.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/2058485 [Impact] 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. [Fix] Backport: 72d1e611082e ipc/msg: mitigate the lock contention with percpu counter For clean backport/build, those are also required: 5d0ce3595ab75 percpu: add percpu_counter_add_local and percpu_counter_sub_local 38cd5b12b7854 ipc: Remove extra braces 0889f44e28103 ipc: Check permissions for checkpoint_restart sysctls at open time dd141a4955d5e ipc: Remove extra1 field abuse to pass ipc namespace def7343ff03bb ipc: Use the same namespace to modify and validate 1f5c135ee509e ipc: Store ipc sysctls in the ipc namespace dc55e35f9e810 ipc: Store mqueue sysctls in the ipc namespace 0e9beb8a96f21 ipc/ipc_sysctl.c: remove fallback for !CONFIG_PROC_SYSCTL 5563cabdde7ee ipc: check checkpoint_restore_ns_capable() to modify C/R proc files [Test Plan] Test as the original patch, with pts/stress-ng message passing and compare performance. [Where problems could occur] Performance regression in IPC communication/workload. Alexey Gladkov (5): ipc: Store mqueue sysctls in the ipc namespace ipc: Store ipc sysctls in the ipc namespace ipc: Use the same namespace to modify and validate ipc: Remove extra1 field abuse to pass ipc namespace ipc: Check permissions for checkpoint_restart sysctls at open time Jiebin Sun (2): percpu: add percpu_counter_add_local and percpu_counter_sub_local ipc/msg: mitigate the lock contention with percpu counter Manfred Spraul (1): ipc/ipc_sysctl.c: remove fallback for !CONFIG_PROC_SYSCTL Michal Clapinski (1): ipc: check checkpoint_restore_ns_capable() to modify C/R proc files include/linux/ipc_namespace.h | 42 ++++++- include/linux/percpu_counter.h | 32 ++++++ ipc/ipc_sysctl.c | 204 ++++++++++++++++++++------------- ipc/mq_sysctl.c | 121 ++++++++++--------- ipc/mqueue.c | 10 +- ipc/msg.c | 48 +++++--- ipc/namespace.c | 15 ++- ipc/util.h | 4 +- 8 files changed, 315 insertions(+), 161 deletions(-) Acked-by: Stefan Bader Acked-by: Roxana Nicolescu