Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp230128rwn; Wed, 7 Sep 2022 15:41:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR7en3Ap+RzYAJU9K9F7nVAyUjHurfZiljdeOssQwJqGlCAM/f+oDudRYu191Xbu7zycZYXQ X-Received: by 2002:a17:907:3f1f:b0:73d:90ae:f800 with SMTP id hq31-20020a1709073f1f00b0073d90aef800mr3986550ejc.466.1662590516446; Wed, 07 Sep 2022 15:41:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662590516; cv=none; d=google.com; s=arc-20160816; b=o8GsPvdMQ68aEZQvNukxc1sEzhn+g3NumiE0WoGGezqJdnhvDPPsuLwZT1WgGgp56o LVALGgfXhB+mgJPe/CCnA9ZJepSa5/3QpbqKCqntKwF88Bw9rMKsih4+OtZ4TmdOTGAX 7saS6U+f/5fnFJjRyS6Aq8X/ikQ6SxGhCdlKgAtKXakwRUNirMxgkb9NN/lSJPXdvgwJ Zm2leChBUyg3vzVwBN5Ta7I61ko9YVu/N0OAKJurJTpaMF+A0I7EG1ft43b4sF3Y0EPz f03N6Ua9x+Z5KsesayySIXoI7QRpYHuPe2/0sN1ESuLPtMbynqfBus2dq02O3k0Sjupu +Qng== 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=kHT3sj67C6kT6LyuL/IQLLnOkQW/3bhKZ4KTx7M39R0=; b=VWseNuWNxBDwm4mZql1zyATpJKV121fss/Fcr/RwLfSKLFsWHVJ+/Gvs2U0LOrI7Va oiDUUS/xLkPjnUuoRu1c3O2GUEhFrU5Y9yPap52eBBoBxowj9Kc8bZ6IEHKCDSWhb/Ka Ud+2szM7VY3QzFUpuJRnCF7Z/Avaa1SVDNucaxAFeEy5D0/0r9qQbtpcBhphIWGlqM7E Z8TX3RyadWxt6aDGH/tQtYhcABsIFGh7I9ckx83pwdHz+i7pI9Q0Wjt8S3+24Qa+cxfW J2i/4Hbf4wEzidEH7bA82x8UzWRxGG/cibDgkToVY4b8+5cBM0VyI5T2xeIQPWjugYQ1 b0Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="KT66x2/y"; 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 sa10-20020a1709076d0a00b00738cb93ba58si591962ejc.203.2022.09.07.15.41.31; Wed, 07 Sep 2022 15:41:56 -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="KT66x2/y"; 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 S229936AbiIGWKO (ORCPT + 99 others); Wed, 7 Sep 2022 18:10:14 -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 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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 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