From patchwork Tue Jun 1 06:51:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharata B Rao X-Patchwork-Id: 12290499 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95E62C4708F for ; Tue, 1 Jun 2021 06:52:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E35A661159 for ; Tue, 1 Jun 2021 06:52:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E35A661159 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6DB086B006C; Tue, 1 Jun 2021 02:52:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 689706B0070; Tue, 1 Jun 2021 02:52:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 466398D0002; Tue, 1 Jun 2021 02:52:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0D0A76B006C for ; Tue, 1 Jun 2021 02:52:09 -0400 (EDT) Received: from smtpin38.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A1B3A180AD804 for ; Tue, 1 Jun 2021 06:52:09 +0000 (UTC) X-FDA: 78204235578.38.319931E Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf08.hostedemail.com (Postfix) with ESMTP id 4917E8019364 for ; Tue, 1 Jun 2021 06:51:57 +0000 (UTC) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 1516irYN168573; Tue, 1 Jun 2021 02:52:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=NXsqMNBoC98BPGnpHRevq3Lw1e0YfOJOcwNnQISgXPc=; b=DW+u5irG2ITYH95DkrPvceVT4AzKkT1Q1q1z7WQH0fMMytP3sC4qQdnyJlCyggw55rzv jwq4L3M+A/cTh4xppN+K/ylpkWRNmdsGvJvQrtbYmmoQ4tk8l2NUOXbPijNuz/bBq0XE fkkcWOqfdrVURXuhPjQv28qAr2kMbELHUccqmRgNHuWedX529ZPA8iEWiiSDgjSKnsC3 x8Y3ZW2dj2dFgQKOQC3ltxyW/dCSgPUyPOk8kLJnxWR/5Q8lJwe5qSpIcM/Wi1cqz1+L mSXAHWCAptQuZoQW+y9Cjfqf9HjK8zTg/l6cf/mbJN0Yet6znlo1DlgXnFvmAwFbjw1Z bw== Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 38wfw8r51e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 01 Jun 2021 02:52:02 -0400 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1516l4Sj020323; Tue, 1 Jun 2021 06:52:00 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma04ams.nl.ibm.com with ESMTP id 38ud889f40-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 01 Jun 2021 06:51:59 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1516pvwh18284922 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 1 Jun 2021 06:51:57 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 10D7E11C052; Tue, 1 Jun 2021 06:51:57 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A494F11C04A; Tue, 1 Jun 2021 06:51:54 +0000 (GMT) Received: from bharata.ibmuc.com (unknown [9.77.195.136]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 1 Jun 2021 06:51:54 +0000 (GMT) From: Bharata B Rao To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, aneesh.kumar@linux.ibm.com, dennis@kernel.org, tj@kernel.org, cl@linux.com, akpm@linux-foundation.org, amakhalov@vmware.com, guro@fb.com, vbabka@suse.cz, srikar@linux.vnet.ibm.com, psampat@linux.ibm.com, ego@linux.vnet.ibm.com, Bharata B Rao Subject: [RFC PATCH v0 0/3] CPU hotplug awareness in percpu allocator Date: Tue, 1 Jun 2021 12:21:44 +0530 Message-Id: <20210601065147.53735-1-bharata@linux.ibm.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 1nuTsGCkU2yfKAHJ1afVLZpl4yivEbPH X-Proofpoint-GUID: 1nuTsGCkU2yfKAHJ1afVLZpl4yivEbPH X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-06-01_03:2021-05-31,2021-06-01 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 clxscore=1011 mlxlogscore=999 impostorscore=0 spamscore=0 malwarescore=0 mlxscore=0 bulkscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106010045 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=DW+u5irG; spf=pass (imf08.hostedemail.com: domain of bharata@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=bharata@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 4917E8019364 X-Stat-Signature: e56ssks8xzd4a445ttpqkzdbfd8xhewy X-HE-Tag: 1622530317-397916 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: Hi, This is an attempt to make the percpu allocator CPU hotplug aware. Currently the percpu allocator allocates memory for all the possible CPUs. This can lead to wastage of memory when possible number of CPUs is significantly higher than the number of online CPUs. This can be avoided if the percpu allocator were to allocate only for the online CPUs and extend the allocation for other CPUs as and when they become online. This early RFC work shows some good memory savings for a powerpc KVM guest that is booted with 16 online and 1024 possible CPUs. Here is the comparision of Percpu memory consumption from /proc/meminfo before and after creating 1000 memcgs. W/o patch W/ patch Before 1441792 kB 22528 kB After 1000 memcgs 4390912 kB 68608 kB Note that the Percpu reporting in meminfo has been changed in the patchset to reflect the allocation for online CPUs only. More details about the approach are present in the patch descriptions. Bharata B Rao (3): percpu: CPU hotplug support for alloc_percpu() percpu: Limit percpu allocator to online cpus percpu: Avoid using percpu ptrs of non-existing cpus fs/namespace.c | 4 +- include/linux/cpuhotplug.h | 2 + include/linux/percpu.h | 15 +++ kernel/cgroup/rstat.c | 20 +++- kernel/sched/cpuacct.c | 10 +- kernel/sched/psi.c | 14 ++- lib/percpu-refcount.c | 4 +- lib/percpu_counter.c | 2 +- mm/percpu-internal.h | 9 ++ mm/percpu-vm.c | 211 +++++++++++++++++++++++++++++++++- mm/percpu.c | 229 +++++++++++++++++++++++++++++++++++-- net/ipv4/fib_semantics.c | 2 +- net/ipv6/route.c | 6 +- 13 files changed, 490 insertions(+), 38 deletions(-)