Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp2192552rwn; Fri, 9 Sep 2022 09:46:51 -0700 (PDT) X-Google-Smtp-Source: AA6agR7liM8lwvGFyyOxeFkTSxe6meOi395wZnlV4q0T7CvIv44928m+wVtW0q69Ug7bptMSWjR/ X-Received: by 2002:a17:907:7241:b0:779:2fc:9a40 with SMTP id ds1-20020a170907724100b0077902fc9a40mr4778626ejc.173.1662742010917; Fri, 09 Sep 2022 09:46:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662742010; cv=none; d=google.com; s=arc-20160816; b=IKIJ+5+dDrDtPFHBGLiuMkwijL4vFNWHlZZa+VR7IMg0M+Plox8lN1HlO6fyWQO/SK bIBJitYBWmerDrQXxQ5w1uby5IVaZLGhVe0G0JJnUA1J86puxKF+prb5DcuA61NLGUc+ Lkoo7TS6i3jeX8dSiyezb89rMuBs5vj1hPJJ/ID4+vQeBfBJMpiFqmkmhh+PDEGzCOap bAuywMksJIR4OvGJStOuUu+cJWnCCXe04AB3SljUw1qltU+VwtCyZWwtfTU/H2b6d47R CkeXfRxwpeUy1sFpqE+unfU31fav67JEjDJWUnF2f/H2rzeHPWgF/CxXzi0koD+ObkQv fWIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=UxRMUOG40/37d/m2fzDMycXDsX0lYIeYQVuKohghFQI=; b=MImNjO7eQ5MGHSHqOPCsB6aEPPe49lmkBEa59dT4gBrkjX3XSTf0iElS9mdqyM6w56 HNfXsGy8YnDnNnJQ7O44ttf4mHet/DAEEGcaWl2UMi784kMG2E6nL+2/wOydL/ULrFVQ bXBnJHl7g4d/tWLVBrwi/7eAOvPK5PfcpuZAQkT6s8mPkxjnilQudDTmBCgWYJ0Fp/7H NeODwYTU+TgONbNzcTFm/KBlVcBv0927tpWPUD6VEp70WxOBfCLCN4MuhnXY9LTJ63Xw wo9DrR6akJL/470VtXd0M/DS4JdZu054Ov+Fwz8CSadZPDONAfqCnUcpCYeRmyaIQUyu CQhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Tr7UWzu8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w20-20020a056402071400b0043c1908e995si791056edx.113.2022.09.09.09.46.24; Fri, 09 Sep 2022 09:46:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Tr7UWzu8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230388AbiIIQL5 (ORCPT + 99 others); Fri, 9 Sep 2022 12:11:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230264AbiIIQLx (ORCPT ); Fri, 9 Sep 2022 12:11:53 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92EB3FA6AA for ; Fri, 9 Sep 2022 09:11:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662739911; x=1694275911; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=R7uldPIxQTD99q9iPRRhNcQ5enqGBJMtDCznMl2iRNE=; b=Tr7UWzu81Xib/jQICErXnxaFWVL5fPIxfu8vsPWFLhr6CMAnsY9RcjvU 6PfM8poKRLmc9S3SLud8V1PfrADrwC0YkEcFBvbfqa+eR4XxLU3shnfhp 6vM94BXczHgYfCRSbCOIq8iNRZ7pooS5UcgDvFV0gIGeAg/t6r/B6X8sU H/0r7kUzYA2m7tV9ZLvzEBzNouSGpSSDIP0EqVAw+6Rak6rQkxAyhStXJ IGXGynf9sVBm49dLmISslGNwzBYpfsIClVcSyF4ZKZeoE9TYarTHdCfTm 5h5gW5PtqUvhQxGsK6NlGNWag29hWt+RlPdpjF+BHK0Or0kcRvpIMe5B7 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10465"; a="298849762" X-IronPort-AV: E=Sophos;i="5.93,303,1654585200"; d="scan'208";a="298849762" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.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 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- >