Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp132489pxf; Wed, 17 Mar 2021 00:56:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwoJdxhRqBNbSFIVkNZVgtyDyAPAkdkF6VsvTGTdYEClXTMnsEDJ8nf86bwFQ4ZUPsnYQWv X-Received: by 2002:aa7:d156:: with SMTP id r22mr41199672edo.18.1615967816253; Wed, 17 Mar 2021 00:56:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615967816; cv=none; d=google.com; s=arc-20160816; b=Yg/7TURSZ9MjLVyHoCF1rsi+kgFOA3kUyFywswwlXf3L8vj0Amp2Ix8K+QbEtm/dwy IFXFjFIo9qjHDbn4ULEZIPVLjyZpOxHzaWeXeyCuVuPUWumxgKrruLL9X/CmZlVRMEWG NBP2H9Fupl63I8vLM/+xr447LhF2W0nFVbIL0PFo917R+DqHuy1WFOjIMU8AAiF5gHIC bL6ZdRwo2IGzACZRaMHeKzrdF3u63mo9SWuNgSP5z4fNQ1VX5pnkbfocrPcysHHUFe6s sTqWsUYNQB7KTgYR6CbA+Mkcv0XYP5Cz6xjihczcXUYMLGM65/TDKaVm8fiTj4Jwnsiv FCWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=FcWJQbKY0rf47Yiz10+9MvbIFscPlj+AO0gFdoT6pW8=; b=TNy1LzbigtO3jmMIErjz46oBHQ4rKzQuVftaM1bKTpmRt1hQeefqJMKod9iZc+ePqC SYbFxgZlFdfxBcVn+kPnFuYrlEZeM58pQMhReWczHq5kwFK4gv7bLjyqNPOSrt9BQ1Ea Q+ZsFfIttJxVu0YFSoGyYiZYcYDgVzAC7x/tncUPB2FKmnoJrVaQEdIaV8XvY3jtF60L 5Mw6bQJr0Uj+s+GXicExE+t+JXC5t2W00tM1s91m4fqkcC54naQmykgL6CsTiabSg5xs w7uyryCus5Y2CC7XLdFhL5XlMp23kc225gvBefhPvpeR7W/zOT9qHPk07GT8dWFMT0nN xXEg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cx24si16062904edb.541.2021.03.17.00.56.34; Wed, 17 Mar 2021 00:56:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230099AbhCQHz3 (ORCPT + 99 others); Wed, 17 Mar 2021 03:55:29 -0400 Received: from out30-133.freemail.mail.aliyun.com ([115.124.30.133]:37004 "EHLO out30-133.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230354AbhCQHy5 (ORCPT ); Wed, 17 Mar 2021 03:54:57 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=xlpang@linux.alibaba.com;NM=1;PH=DS;RN=15;SR=0;TI=SMTPD_---0USESt84_1615967693; Received: from localhost(mailfrom:xlpang@linux.alibaba.com fp:SMTPD_---0USESt84_1615967693) by smtp.aliyun-inc.com(127.0.0.1); Wed, 17 Mar 2021 15:54:53 +0800 From: Xunlei Pang To: Christoph Lameter , Christoph Lameter , Pekka Enberg , Vlastimil Babka , Roman Gushchin , Konstantin Khlebnikov , David Rientjes , Matthew Wilcox , Shu Ming , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Wen Yang , James Wang , Xunlei Pang Subject: [PATCH v4 2/3] percpu: Export per_cpu_sum() Date: Wed, 17 Mar 2021 15:54:51 +0800 Message-Id: <1615967692-80524-3-git-send-email-xlpang@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1615967692-80524-1-git-send-email-xlpang@linux.alibaba.com> References: <1615967692-80524-1-git-send-email-xlpang@linux.alibaba.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org per_cpu_sum() is useful, and deserves to be exported. Tested-by: James Wang Signed-off-by: Xunlei Pang --- include/linux/percpu-defs.h | 10 ++++++++++ kernel/locking/percpu-rwsem.c | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h index dff7040..0e71b68 100644 --- a/include/linux/percpu-defs.h +++ b/include/linux/percpu-defs.h @@ -220,6 +220,16 @@ (void)__vpp_verify; \ } while (0) +#define per_cpu_sum(var) \ +({ \ + typeof(var) __sum = 0; \ + int cpu; \ + compiletime_assert_atomic_type(__sum); \ + for_each_possible_cpu(cpu) \ + __sum += per_cpu(var, cpu); \ + __sum; \ +}) + #ifdef CONFIG_SMP /* diff --git a/kernel/locking/percpu-rwsem.c b/kernel/locking/percpu-rwsem.c index 70a32a5..0980e51 100644 --- a/kernel/locking/percpu-rwsem.c +++ b/kernel/locking/percpu-rwsem.c @@ -178,16 +178,6 @@ bool __percpu_down_read(struct percpu_rw_semaphore *sem, bool try) } EXPORT_SYMBOL_GPL(__percpu_down_read); -#define per_cpu_sum(var) \ -({ \ - typeof(var) __sum = 0; \ - int cpu; \ - compiletime_assert_atomic_type(__sum); \ - for_each_possible_cpu(cpu) \ - __sum += per_cpu(var, cpu); \ - __sum; \ -}) - /* * Return true if the modular sum of the sem->read_count per-CPU variable is * zero. If this sum is zero, then it is stable due to the fact that if any -- 1.8.3.1