From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2166DECAAA1 for ; Fri, 9 Sep 2022 16:11:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B1D8F6B0072; Fri, 9 Sep 2022 12:11:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AA60B6B0073; Fri, 9 Sep 2022 12:11:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 920698D0001; Fri, 9 Sep 2022 12:11:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 828666B0072 for ; Fri, 9 Sep 2022 12:11:19 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 591FB1C5D9C for ; Fri, 9 Sep 2022 16:11:19 +0000 (UTC) X-FDA: 79893036678.21.118F03E Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by imf14.hostedemail.com (Postfix) with ESMTP id 907D8100084 for ; Fri, 9 Sep 2022 16:11:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662739878; x=1694275878; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=R7uldPIxQTD99q9iPRRhNcQ5enqGBJMtDCznMl2iRNE=; b=iG8GPzzpHsiqmxMoZf/ThRmdt/T4uzh9Jqngd4L2vfAuSRFzwrJAWh63 GulVWVKdDsLqByWOSOvSfD4jP6ln8wy6jGzgUDjipOM6stFTqo9XNoX+H VabOWlqvv4c6RR48PpJUp4/wRsFnqfDbiP4jOrqAZQNwbVJi5tOzbqhtK NG0jnMKXy7cDe0QUhx2nRsKnUF4skPjPCXleENZg25H1NxjBXlLLd4xNJ Abc65F8ToHWNZsMTcl9YqcKFPL7NMuiN2POg9dXR/6W9lwZ3hiXJMHDOn acwdBPOGOWzhJpTZoAaKr97ODWyVNjISgwpndZMCdB64NsQQa3vURlHsU w==; X-IronPort-AV: E=McAfee;i="6500,9779,10465"; a="295094061" X-IronPort-AV: E=Sophos;i="5.93,303,1654585200"; d="scan'208";a="295094061" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Sep 2022 09:11:17 -0700 X-IronPort-AV: E=Sophos;i="5.93,303,1654585200"; d="scan'208";a="611101556" Received: from schen9-mobl.amr.corp.intel.com ([10.212.177.99]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Sep 2022 09:11:16 -0700 Message-ID: Subject: Re: [PATCH v5 2/2] ipc/msg: mitigate the lock contention with percpu counter From: Tim Chen To: Jiebin Sun , akpm@linux-foundation.org, vasily.averin@linux.dev, shakeelb@google.com, dennis@kernel.org, tj@kernel.org, cl@linux.com, ebiederm@xmission.com, legion@kernel.org, manfred@colorfullife.com, alexander.mikhalitsyn@virtuozzo.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: tim.c.chen@intel.com, feng.tang@intel.com, ying.huang@intel.com, tianyou.li@intel.com, wangyang.guo@intel.com Date: Fri, 09 Sep 2022 09:11:16 -0700 In-Reply-To: <20220909203636.2652466-3-jiebin.sun@intel.com> References: <20220902152243.479592-1-jiebin.sun@intel.com> <20220909203636.2652466-1-jiebin.sun@intel.com> <20220909203636.2652466-3-jiebin.sun@intel.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=iG8GPzzp; spf=none (imf14.hostedemail.com: domain of tim.c.chen@linux.intel.com has no SPF policy when checking 192.55.52.93) smtp.mailfrom=tim.c.chen@linux.intel.com; dmarc=fail reason="No valid SPF" header.from=intel.com (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662739878; a=rsa-sha256; cv=none; b=xBauw6MHLrY4gB5NGrdKQHQn9LVEme93zFu0e7a8k8lwidTGcZ3PjJvLFeLce80WkiEwXd BhqR7VK+O9IZ9oubaMLZ8I+yhAVMAPEXRSAQUSDpioGnInKB2rg90idiTZmKSDRXMqiKcd qWYlYV+Igm3444XvcUaATGEXlv09M5c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662739878; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=UxRMUOG40/37d/m2fzDMycXDsX0lYIeYQVuKohghFQI=; b=oWvTf1p+QqXH4YjsHa6wRlzjbSzkFdo4B52rX9XCt7OB8Xs3kBVqAtPUO1IAhj8OEzQK3K jrNerdCb5X6fb6bFRxEA3LczE8AYG+VkpFK3VZMl2UCUMI52rxKP4NFPCR/H7NSyIcIG8n sbWlOuxujaIK+f9PUC6dikN6fY0oHX8= X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 907D8100084 Authentication-Results: imf14.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=iG8GPzzp; spf=none (imf14.hostedemail.com: domain of tim.c.chen@linux.intel.com has no SPF policy when checking 192.55.52.93) smtp.mailfrom=tim.c.chen@linux.intel.com; dmarc=fail reason="No valid SPF" header.from=intel.com (policy=none) X-Stat-Signature: cotwoappk4rx54wq1i8kipsnzxwy8m8n X-Rspam-User: X-HE-Tag: 1662739878-774980 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, 2022-09-10 at 04:36 +0800, Jiebin Sun wrote: > 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) Reviewed-by: Tim Chen > > Signed-off-by: Jiebin Sun > --- >