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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18D9EC6FA82 for ; Wed, 7 Sep 2022 22:10:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229989AbiIGWKP (ORCPT ); Wed, 7 Sep 2022 18:10:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229489AbiIGWKN (ORCPT ); Wed, 7 Sep 2022 18:10:13 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E672E6C for ; Wed, 7 Sep 2022 15:10:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662588612; x=1694124612; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=+WGzlmVGQfVQKwWsQ/nLccXRYPuiLkLOyjP7dhlNJe8=; b=KT66x2/yvbsQZ4iBCtkohZG65fSX6f4Y/5qTI0sFO+4dfHhGWT+np12H ObdQPfWZYDP7v5Z0zHFPmerBUyhy08ZdfhjECGCCSM6FccIzwraEn8qmV Z7LLwvVs0eMP7kbr769drwkG/JixHy2BcNush173+8pI1PKsrHie2LoKm Il7iNVgD1F1AlhT/8EAIcbEha7XQAZs8E/qfh+2lggxwa+upb5osaBBcG bqcWypBRnq10KfGXkjKsecpfdPR+yTt1ROHC9taJYHiFlS9slrgGAY2eD qcoPU8sKacQ+yf9oUa3qjz6ITt8LwI7FoFI7tE2WjaBofV7hD3IQOQg91 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10463"; a="284027574" X-IronPort-AV: E=Sophos;i="5.93,298,1654585200"; d="scan'208";a="284027574" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2022 15:10:12 -0700 X-IronPort-AV: E=Sophos;i="5.93,298,1654585200"; d="scan'208";a="644804153" Received: from schen9-mobl.amr.corp.intel.com ([10.209.53.232]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2022 15:10:11 -0700 Message-ID: Subject: Re: [PATCH v4] ipc/msg: mitigate the lock contention with percpu counter From: Tim Chen To: Andrew Morton Cc: Jiebin Sun , 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, tim.c.chen@intel.com, feng.tang@intel.com, ying.huang@intel.com, tianyou.li@intel.com, wangyang.guo@intel.com Date: Wed, 07 Sep 2022 15:10:11 -0700 In-Reply-To: <20220907143427.0ce54bbf096943ffca197fee@linux-foundation.org> References: <20220907172516.1210842-1-jiebin.sun@intel.com> <20220907143427.0ce54bbf096943ffca197fee@linux-foundation.org> 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2022-09-07 at 14:34 -0700, Andrew Morton wrote: > > I think this concept of a percpu_counter_add() which is massively > biased to the write side and with very rare reading is a legitimate > use-case. Perhaps it should become an addition to the formal interface. > Something like > > /* > * comment goes here > */ > static inline void percpu_counter_add_local(struct percpu_counter *fbc, > s64 amount) > { > percpu_counter_add_batch(fbc, amount, INT_MAX); > } > > and percpu_counter_sub_local(), I guess. > > The only instance I can see is > block/blk-cgroup-rwstat.h:blkg_rwstat_add() which is using INT_MAX/2 > because it always uses percpu_counter_sum_positive() on the read side. > > But that makes two! Sure. We can create this function and use it for both cases. No objections. Tim