Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp84607pxf; Wed, 7 Apr 2021 20:59:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMBoqdqzthkdVK/mJvTi2AGj4dO5NYNINzsq6XHgciNyHRZyFkpeRBHlWbRXDf14E4Xm8N X-Received: by 2002:a17:907:2cec:: with SMTP id hz12mr208271ejc.372.1617854371454; Wed, 07 Apr 2021 20:59:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617854371; cv=none; d=google.com; s=arc-20160816; b=HEuJmzDID1XMCyjmWxGOjbCazD6LApo6iLc6feO+28kjycEtUSJNTblz9ndfh4dWn9 iY7wQOID1qHYP/TCIAYYbJQLR7qtvUzywqhIdmv0mtRb/sDbJjurnRaq2/KcGJsCI5Oa 1BGkb6RgmvWkTX+CUK9xakH7bBXUdS3CZ5rxG8EqnbuQc5JiZ89DZkzv85obB7veIL65 bgHgZmKdLkJamZ/m+e+Sct6sR7or3bjiT72shw4ajEUjQSNJnJdKKIkYOeJYuoDgOURn geD2Xi3dPdo7iR4XPuzKgdYdl7GXbAbi0TkIdxmAzt525JnbptO/LB0WDAJvnqWwilrZ zsQQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4vZaaBFsaOB4F8XygoHlUQdcYtLDpiQQyW830Fvwijw=; b=EUIb90YKR6H8bm79CTqymKrxKbZZgtrINkBUZR/NfwyCaIoPuQeho5biXFVeUkkC1v 1Anadczo2JShvSw042yukGk6iqgMhgawyz9zJV3FxWb/CTzMNRch21/K+N1LuqnU07cl qGdGk1JiEISIPaQqDKN0GsrnWK+7/U2hXGxEqJDPGrxk/n7L5X5GOk001ZseFGNipuIa 4if2anPWlEXkTZmRaF3oAGD9amcy0jG3bVdtdI/+EoO913EL5ja+RdNcT5nJFqnWbCXX vWTNvzX59DtdoYcomzg/woeYG8rcragt9Ipmv9hOqmTQ5u2EGncCkefK4Z1qI2Qe6+OO pVgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=KWiObgVq; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id kl2si15683035ejc.82.2021.04.07.20.58.46; Wed, 07 Apr 2021 20:59:31 -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; dkim=pass header.i=@fb.com header.s=facebook header.b=KWiObgVq; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229732AbhDHD6B (ORCPT + 99 others); Wed, 7 Apr 2021 23:58:01 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:57714 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbhDHD56 (ORCPT ); Wed, 7 Apr 2021 23:57:58 -0400 Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 1383uMGZ008445 for ; Wed, 7 Apr 2021 20:57:48 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=4vZaaBFsaOB4F8XygoHlUQdcYtLDpiQQyW830Fvwijw=; b=KWiObgVqOxfkfQkH1qAh7b5fYEAlSnSYcTTE8iRyF0B4mgOIvljh3uRP+QOTqdRLIxT5 njVsxBaUwod7byvxvrYBuiV0HAgdtsncXakWZ7Fp/zSYFsrheB3eaZxJPoiIs0Rw1Q1L Idt34p0xB0X/ptTKxOCPc2D858YX19KrNBw= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com with ESMTP id 37sg04kmv5-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 07 Apr 2021 20:57:48 -0700 Received: from intmgw001.05.prn6.facebook.com (2620:10d:c085:208::f) by mail.thefacebook.com (2620:10d:c085:11d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 7 Apr 2021 20:57:47 -0700 Received: by devvm3388.prn0.facebook.com (Postfix, from userid 111017) id 61F75602B010; Wed, 7 Apr 2021 20:57:41 -0700 (PDT) From: Roman Gushchin To: Dennis Zhou CC: Tejun Heo , Christoph Lameter , Andrew Morton , Vlastimil Babka , , , Roman Gushchin Subject: [PATCH v3 3/6] percpu: make pcpu_nr_empty_pop_pages per chunk type Date: Wed, 7 Apr 2021 20:57:33 -0700 Message-ID: <20210408035736.883861-4-guro@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210408035736.883861-1-guro@fb.com> References: <20210408035736.883861-1-guro@fb.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-ORIG-GUID: MSBdqoRxc97nSY0EkfyXMNXRNreq_-hl X-Proofpoint-GUID: MSBdqoRxc97nSY0EkfyXMNXRNreq_-hl X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-04-08_01:2021-04-07,2021-04-08 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 adultscore=0 mlxscore=0 suspectscore=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 clxscore=1015 mlxlogscore=999 phishscore=0 malwarescore=0 spamscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104080023 X-FB-Internal: deliver Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org nr_empty_pop_pages is used to guarantee that there are some free populated pages to satisfy atomic allocations. Accounted and non-accounted allocations are using separate sets of chunks, so both need to have a surplus of empty pages. This commit makes pcpu_nr_empty_pop_pages and the corresponding logic per chunk type. Signed-off-by: Roman Gushchin --- mm/percpu-internal.h | 2 +- mm/percpu-stats.c | 9 +++++++-- mm/percpu.c | 14 +++++++------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/mm/percpu-internal.h b/mm/percpu-internal.h index 18b768ac7dca..095d7eaa0db4 100644 --- a/mm/percpu-internal.h +++ b/mm/percpu-internal.h @@ -87,7 +87,7 @@ extern spinlock_t pcpu_lock; =20 extern struct list_head *pcpu_chunk_lists; extern int pcpu_nr_slots; -extern int pcpu_nr_empty_pop_pages; +extern int pcpu_nr_empty_pop_pages[]; =20 extern struct pcpu_chunk *pcpu_first_chunk; extern struct pcpu_chunk *pcpu_reserved_chunk; diff --git a/mm/percpu-stats.c b/mm/percpu-stats.c index c8400a2adbc2..f6026dbcdf6b 100644 --- a/mm/percpu-stats.c +++ b/mm/percpu-stats.c @@ -145,6 +145,7 @@ static int percpu_stats_show(struct seq_file *m, void= *v) int slot, max_nr_alloc; int *buffer; enum pcpu_chunk_type type; + int nr_empty_pop_pages; =20 alloc_buffer: spin_lock_irq(&pcpu_lock); @@ -165,7 +166,11 @@ static int percpu_stats_show(struct seq_file *m, voi= d *v) goto alloc_buffer; } =20 -#define PL(X) \ + nr_empty_pop_pages =3D 0; + for (type =3D 0; type < PCPU_NR_CHUNK_TYPES; type++) + nr_empty_pop_pages +=3D pcpu_nr_empty_pop_pages[type]; + +#define PL(X) \ seq_printf(m, " %-20s: %12lld\n", #X, (long long int)pcpu_stats_ai.X) =20 seq_printf(m, @@ -196,7 +201,7 @@ static int percpu_stats_show(struct seq_file *m, void= *v) PU(nr_max_chunks); PU(min_alloc_size); PU(max_alloc_size); - P("empty_pop_pages", pcpu_nr_empty_pop_pages); + P("empty_pop_pages", nr_empty_pop_pages); seq_putc(m, '\n'); =20 #undef PU diff --git a/mm/percpu.c b/mm/percpu.c index 7e31e1b8725f..61339b3d9337 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -176,10 +176,10 @@ struct list_head *pcpu_chunk_lists __ro_after_init;= /* chunk list slots */ static LIST_HEAD(pcpu_map_extend_chunks); =20 /* - * The number of empty populated pages, protected by pcpu_lock. The - * reserved chunk doesn't contribute to the count. + * The number of empty populated pages by chunk type, protected by pcpu_= lock. + * The reserved chunk doesn't contribute to the count. */ -int pcpu_nr_empty_pop_pages; +int pcpu_nr_empty_pop_pages[PCPU_NR_CHUNK_TYPES]; =20 /* * The number of populated pages in use by the allocator, protected by @@ -559,7 +559,7 @@ static inline void pcpu_update_empty_pages(struct pcp= u_chunk *chunk, int nr) { chunk->nr_empty_pop_pages +=3D nr; if (chunk !=3D pcpu_reserved_chunk) - pcpu_nr_empty_pop_pages +=3D nr; + pcpu_nr_empty_pop_pages[pcpu_chunk_type(chunk)] +=3D nr; } =20 /* @@ -1835,7 +1835,7 @@ static void __percpu *pcpu_alloc(size_t size, size_= t align, bool reserved, mutex_unlock(&pcpu_alloc_mutex); } =20 - if (pcpu_nr_empty_pop_pages < PCPU_EMPTY_POP_PAGES_LOW) + if (pcpu_nr_empty_pop_pages[type] < PCPU_EMPTY_POP_PAGES_LOW) pcpu_schedule_balance_work(); =20 /* clear the areas and return address relative to base address */ @@ -2013,7 +2013,7 @@ static void pcpu_balance_populated(enum pcpu_chunk_= type type) pcpu_atomic_alloc_failed =3D false; } else { nr_to_pop =3D clamp(PCPU_EMPTY_POP_PAGES_HIGH - - pcpu_nr_empty_pop_pages, + pcpu_nr_empty_pop_pages[type], 0, PCPU_EMPTY_POP_PAGES_HIGH); } =20 @@ -2595,7 +2595,7 @@ void __init pcpu_setup_first_chunk(const struct pcp= u_alloc_info *ai, =20 /* link the first chunk in */ pcpu_first_chunk =3D chunk; - pcpu_nr_empty_pop_pages =3D pcpu_first_chunk->nr_empty_pop_pages; + pcpu_nr_empty_pop_pages[PCPU_CHUNK_ROOT] =3D pcpu_first_chunk->nr_empty= _pop_pages; pcpu_chunk_relocate(pcpu_first_chunk, -1); =20 /* include all regions of the first chunk */ --=20 2.30.2