From patchwork Mon Oct 24 08:14:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13016809 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9690C3A59D for ; Mon, 24 Oct 2022 08:14:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 73E208E0003; Mon, 24 Oct 2022 04:14:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6EE1E8E0001; Mon, 24 Oct 2022 04:14:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5DDC58E0003; Mon, 24 Oct 2022 04:14:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4D1FE8E0001 for ; Mon, 24 Oct 2022 04:14:53 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CAA0DC09A7 for ; Mon, 24 Oct 2022 08:14:52 +0000 (UTC) X-FDA: 80055132024.12.9B1A067 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf21.hostedemail.com (Postfix) with ESMTP id 811CA1C0006 for ; Mon, 24 Oct 2022 08:14:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666599291; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AT64JPjijrBa4KylaT1nTk9WXXduaxRTtCv2wVwy4QE=; b=fYXvzuBwfl2yR9fytxTERCo4p5drN8cS4tTENtuweQ3+oYIVV1YzvTLIt9ZcLLgdGHPjp0 6IatHz4BZXU+Pgvlk+xkeAOExz7Rl4uUPEyqo1diZjiiLV+gUnIWNdET602uvJKf/ENEnI NmFkJT3FOIItXYEEEr8bGaWWoxNZNdM= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-130-mSfA_UKmOI6tRH5XBi0jPw-1; Mon, 24 Oct 2022 04:14:48 -0400 X-MC-Unique: mSfA_UKmOI6tRH5XBi0jPw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ADB4B3C10144; Mon, 24 Oct 2022 08:14:46 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-35.pek2.redhat.com [10.72.12.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 493A840C6F9F; Mon, 24 Oct 2022 08:14:42 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: Dennis Zhou , Tejun Heo , Christoph Lameter , Andrew Morton , linux-mm@kvack.org, Baoquan He Subject: [PATCH 1/8] mm/percpu: remove unused pcpu_map_extend_chunks Date: Mon, 24 Oct 2022 16:14:28 +0800 Message-Id: <20221024081435.204970-2-bhe@redhat.com> In-Reply-To: <20221024081435.204970-1-bhe@redhat.com> References: <20221024081435.204970-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666599292; a=rsa-sha256; cv=none; b=Gg5ayhUTou4ib2WCPzZiOTl/V9a8ZM3s/iFTSuAk4r0y06x7dH/pQih1UCnwhKZnh7LokA 3Zn/FxWQaDKsZfcGens/xYDTA1A+HTic17imWLUxuxKBeCb5mZClYxb1lFlBhlp7nzL9WH IgpD8L3rDfeGplbDzV4s8EKyA68dA3A= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fYXvzuBw; spf=pass (imf21.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666599292; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=AT64JPjijrBa4KylaT1nTk9WXXduaxRTtCv2wVwy4QE=; b=VZHywg9rqDzaMfZTfkAUZBsCPiCkKZ/erhpvpVh2jwzx7EG4wYw5iz2oSN5306PZr80p8p DzeerrLos8NwU4dvsVi9SiGmTxuKmNl6mxXtZ1A9i1MaCC7tjd6hOGNbZ0OqGjo9UBTvR1 3o4vZC4n2DloCLBlygT885NwDfnKRKE= X-Stat-Signature: sccemied38fg5k4zbggfuag6dmp84mcm X-Rspamd-Queue-Id: 811CA1C0006 X-Rspam-User: X-Rspamd-Server: rspam03 Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fYXvzuBw; spf=pass (imf21.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1666599292-612112 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: Since commit 40064aeca35c ("percpu: replace area map allocator with bitmap"), it is unneeded. Signed-off-by: Baoquan He Acked-by: Dennis Zhou --- mm/percpu.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/mm/percpu.c b/mm/percpu.c index 27697b2429c2..26d8cd2ca323 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -174,9 +174,6 @@ static DEFINE_MUTEX(pcpu_alloc_mutex); /* chunk create/destroy, [de]pop, map ext struct list_head *pcpu_chunk_lists __ro_after_init; /* chunk list slots */ -/* chunks which need their map areas extended, protected by pcpu_lock */ -static LIST_HEAD(pcpu_map_extend_chunks); - /* * The number of empty populated pages, protected by pcpu_lock. * The reserved chunk doesn't contribute to the count. From patchwork Mon Oct 24 08:14:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13016810 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68472C3A59D for ; Mon, 24 Oct 2022 08:14:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0D4EA8E0005; Mon, 24 Oct 2022 04:14:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 085F58E0001; Mon, 24 Oct 2022 04:14:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB6958E0005; Mon, 24 Oct 2022 04:14:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id DDA318E0001 for ; Mon, 24 Oct 2022 04:14:55 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B1C39C0A61 for ; Mon, 24 Oct 2022 08:14:55 +0000 (UTC) X-FDA: 80055132150.20.4DB1ABE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 68FD34001C for ; Mon, 24 Oct 2022 08:14:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666599294; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=II9JgjXmJ1/1u2CpjGXaWwKe+WW1rdQe/wCmpKMP6aM=; b=JgrF9EyjNHEJYlFJAZ32Xx6VvsLY3n8VobP5XITfLLJZmikEcJL11kJVSrtnTcT2K01il5 r06xEUWyTbtgNUBBl0QlQBsEdPCdXi9Z/9cUiB5ur5A+tzm4tIplBZ64HqcV6v95kLLZwr /zSJCa84e6AcV3FgeLOKIHg/l+N5WVg= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-465-bJGbBwAUPae4Iz-zpeIZZw-1; Mon, 24 Oct 2022 04:14:51 -0400 X-MC-Unique: bJGbBwAUPae4Iz-zpeIZZw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AC69F3C10147; Mon, 24 Oct 2022 08:14:50 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-35.pek2.redhat.com [10.72.12.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 546C940C94EB; Mon, 24 Oct 2022 08:14:47 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: Dennis Zhou , Tejun Heo , Christoph Lameter , Andrew Morton , linux-mm@kvack.org, Baoquan He Subject: [PATCH 2/8] mm/percpu: use list_first_entry_or_null in pcpu_reclaim_populated() Date: Mon, 24 Oct 2022 16:14:29 +0800 Message-Id: <20221024081435.204970-3-bhe@redhat.com> In-Reply-To: <20221024081435.204970-1-bhe@redhat.com> References: <20221024081435.204970-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JgrF9Eyj; spf=pass (imf17.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666599295; a=rsa-sha256; cv=none; b=m2goTLdgg+C4HrotxVjuwArsLhCAYkvxRl/iP+3ohcpCRz7KjRDrzaav+ZhJfPfcAF/Xew jWwtTaqQ2t+efQW1YoH47uc6RSg8YVTtiJN6CnEXN+YaVkVKK1KWPlcAW7gD6vXNMqYwkj Nki9y1YoEgG4TMGH+lmUXL1gd7VFa3Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666599295; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=II9JgjXmJ1/1u2CpjGXaWwKe+WW1rdQe/wCmpKMP6aM=; b=z7VNtBrF1eH2gP53TSL1T2Xe06FFLZ9jmZqmyvcbMl+YbHAayGEs27CDXAKQZE+q0Oi97F v6yOu18Bs55t8fWMMBYurQkmxU/WV2j4sWkTF1Ev2Pkaq8kXrvLXhNrmGVXq1FDHGUWZe9 lMIj6RYB3CDIp6e3NGTRZOPahuk6LtY= Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JgrF9Eyj; spf=pass (imf17.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspam-User: X-Rspamd-Server: rspam10 X-Stat-Signature: p14othojx353b6mekw65wdeh9s63ihd4 X-Rspamd-Queue-Id: 68FD34001C X-HE-Tag: 1666599295-200550 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: To replace list_empty()/list_first_entry() pair to simplify code. Signed-off-by: Baoquan He Acked-by: Dennis Zhou --- mm/percpu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/percpu.c b/mm/percpu.c index 26d8cd2ca323..a3fde4ac03a4 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -2143,9 +2143,9 @@ static void pcpu_reclaim_populated(void) * other accessor is the free path which only returns area back to the * allocator not touching the populated bitmap. */ - while (!list_empty(&pcpu_chunk_lists[pcpu_to_depopulate_slot])) { - chunk = list_first_entry(&pcpu_chunk_lists[pcpu_to_depopulate_slot], - struct pcpu_chunk, list); + while (chunk = list_first_entry_or_null( + &pcpu_chunk_lists[pcpu_to_depopulate_slot], + struct pcpu_chunk, list)) { WARN_ON(chunk->immutable); /* From patchwork Mon Oct 24 08:14:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13016811 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5124CC3A59D for ; Mon, 24 Oct 2022 08:15:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B0E458E0006; Mon, 24 Oct 2022 04:15:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ABEA28E0001; Mon, 24 Oct 2022 04:15:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9AD9F8E0006; Mon, 24 Oct 2022 04:15:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 8E0678E0001 for ; Mon, 24 Oct 2022 04:15:01 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 43E851C63A3 for ; Mon, 24 Oct 2022 08:15:01 +0000 (UTC) X-FDA: 80055132402.29.C1453F7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf21.hostedemail.com (Postfix) with ESMTP id D9A471C0006 for ; Mon, 24 Oct 2022 08:15:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666599300; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EBzRuKDFM+71l7c7xLrT1+dLyWIbjD2WVMOLNE3ePAk=; b=Pf4aU5HWB2twkIjFjpBi5RPQaBxd5SqmKnO0lGjeWrDOLxbxvNmIXcaVFfifhxGMGYOFTs P3AMOQoj+llggNd4NS+4Kze+XXDW0e1VeyY6PcBrVZ4nPkSyWQ7rRt7JY6mlqnn3uGIuEr AhF+aTdKrUWYchUZmgVNdwHBWuepBQs= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-127-SP0uFmoMOeuzBev62VLccA-1; Mon, 24 Oct 2022 04:14:55 -0400 X-MC-Unique: SP0uFmoMOeuzBev62VLccA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 94E3D1C05132; Mon, 24 Oct 2022 08:14:54 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-35.pek2.redhat.com [10.72.12.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F37140C6F75; Mon, 24 Oct 2022 08:14:51 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: Dennis Zhou , Tejun Heo , Christoph Lameter , Andrew Morton , linux-mm@kvack.org, Baoquan He Subject: [PATCH 3/8] mm/percpu: Update the code comment when creating new chunk Date: Mon, 24 Oct 2022 16:14:30 +0800 Message-Id: <20221024081435.204970-4-bhe@redhat.com> In-Reply-To: <20221024081435.204970-1-bhe@redhat.com> References: <20221024081435.204970-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Pf4aU5HW; spf=pass (imf21.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666599300; a=rsa-sha256; cv=none; b=idVgQlLH+0Lb0Q4S2W6CAx8LVFlPPYzi8wKc+u2+C3EzF7h1BTVP9+A07E3wsWWIqeJFBz 6ZvzhWJwHB+JL7Ef9iS3jZQCjJvsmQNyJQEDS0YA+p+QWRPX5j1x/L1txI2NzxPbcz7FXr ZgZqEKkyW4vxsogS/g60vxqVTIkS/xQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666599300; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EBzRuKDFM+71l7c7xLrT1+dLyWIbjD2WVMOLNE3ePAk=; b=MYVZzpOFREeyjBQ4e/Z2LQatisQdTvpdoyaiztewFb9ljcI4H6lIKyg5noH/SnggE5W0u+ 5QW+T0NHKfKL+3uwMtC0p9XL6wABFldv6RQ81moIh5FjGMsDs+99GLdAZ3FEk3rG1ynPx5 +dnm03pG+g+EaILWL8FMfQTUXVDbx/g= Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Pf4aU5HW; spf=pass (imf21.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Stat-Signature: 3d15gt9rjig3chtwb97ncub6go9o84mx X-Rspamd-Queue-Id: D9A471C0006 X-Rspamd-Server: rspam02 X-Rspam-User: X-HE-Tag: 1666599300-822233 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: The lock pcpu_alloc_mutex taking code has been moved to the beginning of pcpu_allo() if it's non atomic allocation. So the code comment above above pcpu_create_chunk() callsite need be updated. Signed-off-by: Baoquan He Acked-by: Dennis Zhou --- mm/percpu.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mm/percpu.c b/mm/percpu.c index a3fde4ac03a4..a8121302a79c 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -1817,16 +1817,12 @@ static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved, spin_unlock_irqrestore(&pcpu_lock, flags); - /* - * No space left. Create a new chunk. We don't want multiple - * tasks to create chunks simultaneously. Serialize and create iff - * there's still no empty chunk after grabbing the mutex. - */ if (is_atomic) { err = "atomic alloc failed, no space left"; goto fail; } + /* No space left. Create a new chunk. */ if (list_empty(&pcpu_chunk_lists[pcpu_free_slot])) { chunk = pcpu_create_chunk(pcpu_gfp); if (!chunk) { From patchwork Mon Oct 24 08:14:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13016812 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCB3EC38A2D for ; Mon, 24 Oct 2022 08:15:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B71A8E0007; Mon, 24 Oct 2022 04:15:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 567808E0001; Mon, 24 Oct 2022 04:15:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 408DA8E0007; Mon, 24 Oct 2022 04:15:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 3333F8E0001 for ; Mon, 24 Oct 2022 04:15:03 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 05CAE40A2F for ; Mon, 24 Oct 2022 08:15:03 +0000 (UTC) X-FDA: 80055132486.18.08FF137 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf06.hostedemail.com (Postfix) with ESMTP id AAEAC18003A for ; Mon, 24 Oct 2022 08:15:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666599302; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L+dfYrksNn4TdevHXr7sUSqhlmuSgsZD4nCKZ/IkdDk=; b=I0NcVzyh+Zq5SqQslG89Q9rzzJFQMMUzZQz8qoTRp1nhBk5P5PEXQ2eu1dbFset84pox85 TO5xLMt6QKNdjmAs4jCTtZwRjYuVpphbvzk66J/oiihbEVeWgwt/VHC9yFE/ZEM6XpDbV+ EsQ1DPxKbiHyA7Zvfd3QQzDMOayCHnw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-458-6Bt9hgApOOS0VLkaDLvcJA-1; Mon, 24 Oct 2022 04:14:59 -0400 X-MC-Unique: 6Bt9hgApOOS0VLkaDLvcJA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ED68C185A78F; Mon, 24 Oct 2022 08:14:58 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-35.pek2.redhat.com [10.72.12.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C16240C6FA0; Mon, 24 Oct 2022 08:14:54 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: Dennis Zhou , Tejun Heo , Christoph Lameter , Andrew Morton , linux-mm@kvack.org, Baoquan He Subject: [PATCH 4/8] mm/percpu: add comment to state the empty populated pages accounting Date: Mon, 24 Oct 2022 16:14:31 +0800 Message-Id: <20221024081435.204970-5-bhe@redhat.com> In-Reply-To: <20221024081435.204970-1-bhe@redhat.com> References: <20221024081435.204970-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=I0NcVzyh; spf=pass (imf06.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666599302; a=rsa-sha256; cv=none; b=lWtIrpFPHa9/omhIehGmIvGCXqKDOJXaaWnRhoSak4TdOGpybfhoTWP+pmk3mXGBe85gY8 gc/yDzfeeRM1aYyvbhH5uINj7YIIzwF6FzI9xiwFCFj8zLfFoGUF6J3Nz+9rmM0KH2e61M 9gLNrVHIYKjUo4lmIrHNlrceE9mxDIg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666599302; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=L+dfYrksNn4TdevHXr7sUSqhlmuSgsZD4nCKZ/IkdDk=; b=UzNYWNiHT29/ub4TKADHJExtLlKGMRJ4V7bvONVqZXdAjBzR4VZ8RxO5Fyj5O347gpsx4k dyhDBzy1pyFHUWdmeM72vw2mA6js7PgCur6F8PXGnhzUBtL1KZJf/fm9kT/q3ousA8Qq57 /A0bHK7wjytjYgeghE2DOmxVPHoLW3g= X-Rspamd-Queue-Id: AAEAC18003A X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=I0NcVzyh; spf=pass (imf06.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam11 X-Stat-Signature: dkf7wiq9yxgfobpgt8dmrx9zxmx1jmy3 X-HE-Tag: 1666599302-625922 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: When allocating an area from a chunk, pcpu_block_update_hint_alloc() is called to update chunk metadata, including chunk's and global nr_empty_pop_pages. However, if the allocation is not atomic, some blocks may not be populated with pages yet, while we still account it here. The number of pages will be subtracted with pcpu_chunk_populated() when populating pages. Adding code comment to make that more understandable. Signed-off-by: Baoquan He Acked-by: Dennis Zhou --- mm/percpu.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/mm/percpu.c b/mm/percpu.c index a8121302a79c..09e407338573 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -831,13 +831,15 @@ static void pcpu_block_update_hint_alloc(struct pcpu_chunk *chunk, int bit_off, /* * Update s_block. - * block->first_free must be updated if the allocation takes its place. - * If the allocation breaks the contig_hint, a scan is required to - * restore this hint. */ if (s_block->contig_hint == PCPU_BITMAP_BLOCK_BITS) nr_empty_pages++; + /* + * block->first_free must be updated if the allocation takes its place. + * If the allocation breaks the contig_hint, a scan is required to + * restore this hint. + */ if (s_off == s_block->first_free) s_block->first_free = find_next_zero_bit( pcpu_index_alloc_map(chunk, s_index), @@ -912,6 +914,12 @@ static void pcpu_block_update_hint_alloc(struct pcpu_chunk *chunk, int bit_off, } } + /* + * If the allocation is not atomic, some blocks may not + * be populated with pages, while we account it here. + * The number of pages will be subtracted with + * pcpu_chunk_populated() when populating pages. + */ if (nr_empty_pages) pcpu_update_empty_pages(chunk, -nr_empty_pages); From patchwork Mon Oct 24 08:14:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13016813 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF4BEFA373F for ; Mon, 24 Oct 2022 08:15:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1FD2A8E0001; Mon, 24 Oct 2022 04:15:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1BC6D8E0008; Mon, 24 Oct 2022 04:15:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E1A558E0001; Mon, 24 Oct 2022 04:15:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D08268E0005 for ; Mon, 24 Oct 2022 04:15:14 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id ADE2480B17 for ; Mon, 24 Oct 2022 08:15:14 +0000 (UTC) X-FDA: 80055132948.14.5D281EE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 48C8810001F for ; Mon, 24 Oct 2022 08:15:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666599313; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lMCNuRuv+p/VyO8f2sd5NbLS+a0poTkVGW4v1nMo8cA=; b=LqFOsrk3CRFB9mV7hYid/wfXFxFFoQq7PtRYmHrZ0CmUIrSr+4sUbsdGRfAk6SDpIeVyhI 6e5Rqn9ectneSQJ6gCm3isi2rBweVNeO/vUVHdRi4uTqXVvOdAaN8B8fO/HYH2Cpidkie1 Jv8t1QmLYzs1EdQFEYfu4+gN+3sNbU4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-523-oh6QCyUQPPSLXucDD99q_w-1; Mon, 24 Oct 2022 04:15:04 -0400 X-MC-Unique: oh6QCyUQPPSLXucDD99q_w-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4611181DA23; Mon, 24 Oct 2022 08:15:03 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-35.pek2.redhat.com [10.72.12.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4C4640C6F9F; Mon, 24 Oct 2022 08:14:59 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: Dennis Zhou , Tejun Heo , Christoph Lameter , Andrew Morton , linux-mm@kvack.org, Baoquan He Subject: [PATCH 5/8] mm/percpu: replace the goto with break Date: Mon, 24 Oct 2022 16:14:32 +0800 Message-Id: <20221024081435.204970-6-bhe@redhat.com> In-Reply-To: <20221024081435.204970-1-bhe@redhat.com> References: <20221024081435.204970-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666599314; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=lMCNuRuv+p/VyO8f2sd5NbLS+a0poTkVGW4v1nMo8cA=; b=AsohQF0Ro7RwOKveO14RPuhpR9ryXC2pKPWu2NyLOW/5wq0msaIQfWqQpFXmRhwk68omhs kyg2YTZElNOWxsfciMTTigdKLnS1/XLTyjI8YtJdjOZG+NaAN7xrLjMiK5q8AXEGPuHlEq qxAe70AMMEGRSUUcxxQTq2BU1R++FBk= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LqFOsrk3; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666599314; a=rsa-sha256; cv=none; b=4ud5xpoD0Q1mB1ilvWBz7b1kJYRLX20nOqnm5yYhzAVqREkwwBdr2BSDVFTdGSs+ghtZgg MUEDGFad026h+YwvV8vSJHD9loB7u6QyyaYR3BSMcVyG82MfhgK/xg8G5ZvgsaBRakKPE8 LYkdCH9/NIzEsaSyaunr7ocR8i4n5nM= X-Rspam-User: X-Rspamd-Queue-Id: 48C8810001F X-Stat-Signature: abd1sg6cnatz1f5qsnae4w9q65f631ja Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LqFOsrk3; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com X-Rspamd-Server: rspam07 X-HE-Tag: 1666599314-203393 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: In function pcpu_reclaim_populated(), the line of goto jumping is unnecessary since the label 'end_chunk' is near the end of the for loop, use break instead. Signed-off-by: Baoquan He Acked-by: Dennis Zhou --- mm/percpu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/percpu.c b/mm/percpu.c index 09e407338573..954abf916c7d 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -2167,7 +2167,7 @@ static void pcpu_reclaim_populated(void) /* reintegrate chunk to prevent atomic alloc failures */ if (pcpu_nr_empty_pop_pages < PCPU_EMPTY_POP_PAGES_HIGH) { reintegrate = true; - goto end_chunk; + break; } /* @@ -2203,7 +2203,6 @@ static void pcpu_reclaim_populated(void) end = -1; } -end_chunk: /* batch tlb flush per chunk to amortize cost */ if (freed_page_start < freed_page_end) { spin_unlock_irq(&pcpu_lock); From patchwork Mon Oct 24 08:14:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13016814 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64A78C38A2D for ; Mon, 24 Oct 2022 08:15:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 050DF8E0006; Mon, 24 Oct 2022 04:15:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F044C8E0005; Mon, 24 Oct 2022 04:15:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA43C8E0006; Mon, 24 Oct 2022 04:15:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id CB5288E0001 for ; Mon, 24 Oct 2022 04:15:14 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9DE2E120A29 for ; Mon, 24 Oct 2022 08:15:14 +0000 (UTC) X-FDA: 80055132948.13.C3FCBB7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf21.hostedemail.com (Postfix) with ESMTP id 0A1F51C002E for ; Mon, 24 Oct 2022 08:15:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666599313; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g3MWDQZ+YEFLhc1+KrcZwWlcxn1kI2z+4saRqDzwGGg=; b=NtxNg0iHzGYBL0/u08pCAo8H38CwXaXcI/da0n/quz/rz6rEhuC33FTjAs4WiLP9Q7uvc2 UusPO2mNUOOukg2zbny3aQRKOZAeJpW9ywdf9tTFbEb9wR3bNfsSWXfzjh4xl/k+3UrmH4 pvfAvxG48RPpnnCmoE7+1fcHtldRmf8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-212-wHg3keIwOaOlWtfbqML-FQ-1; Mon, 24 Oct 2022 04:15:07 -0400 X-MC-Unique: wHg3keIwOaOlWtfbqML-FQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5A019101A56C; Mon, 24 Oct 2022 08:15:07 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-35.pek2.redhat.com [10.72.12.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE37940C6FA0; Mon, 24 Oct 2022 08:15:03 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: Dennis Zhou , Tejun Heo , Christoph Lameter , Andrew Morton , linux-mm@kvack.org, Baoquan He Subject: [PATCH 6/8] mm/percpu.c: remove the lcm code since block size is fixed at page size Date: Mon, 24 Oct 2022 16:14:33 +0800 Message-Id: <20221024081435.204970-7-bhe@redhat.com> In-Reply-To: <20221024081435.204970-1-bhe@redhat.com> References: <20221024081435.204970-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666599314; a=rsa-sha256; cv=none; b=Ut9orNkLhtNLSpqDGsz/fXP8PKVPDSV6qEluY7imIFZJx6WEoRhNcHTxTcKsd3K/Mup8mk GGewJ47oeNSIGoDKu/qvCyudf9qiQXVlf+MZ01DaV2HeUtTyWEVdMLhWVQ1kXyt/RsbX84 da0MS0u3LDdKOM4CJtDuOYwWxvnO378= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NtxNg0iH; spf=pass (imf21.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666599314; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=g3MWDQZ+YEFLhc1+KrcZwWlcxn1kI2z+4saRqDzwGGg=; b=mxGvX3meKsHwoHfw7k106TmpNlsTRTdUi2ODEvSujOYwklCqpet6eWT8vMaPvNqbpjzCha 0atVFjQgnGiNXyh1HTCSLcg8cFX1yRJ3wxr+P0O2h67KLL1cNOurqnvZdtRQ/G0SK3wJlc sMcb10zdFbkHrIsiN0mR7QGCC1nSmwo= X-Stat-Signature: a33zj6cubxcit57f5tqdaj9agpbc1ncu X-Rspamd-Queue-Id: 0A1F51C002E Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NtxNg0iH; spf=pass (imf21.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1666599313-784911 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: Since commit b239f7daf553 ("percpu: set PCPU_BITMAP_BLOCK_SIZE to PAGE_SIZE"), the PCPU_BITMAP_BLOCK_SIZE has been set to page size fixedly. So the lcm code in pcpu_alloc_first_chunk() doesn't make sense any more, clean it up. Signed-off-by: Baoquan He Acked-by: Dennis Zhou --- mm/percpu.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/mm/percpu.c b/mm/percpu.c index 954abf916c7d..96191f7b61ba 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -72,7 +72,6 @@ #include #include #include -#include #include #include #include @@ -1347,7 +1346,7 @@ static struct pcpu_chunk * __init pcpu_alloc_first_chunk(unsigned long tmp_addr, int map_size) { struct pcpu_chunk *chunk; - unsigned long aligned_addr, lcm_align; + unsigned long aligned_addr; int start_offset, offset_bits, region_size, region_bits; size_t alloc_size; @@ -1355,14 +1354,7 @@ static struct pcpu_chunk * __init pcpu_alloc_first_chunk(unsigned long tmp_addr, aligned_addr = tmp_addr & PAGE_MASK; start_offset = tmp_addr - aligned_addr; - - /* - * Align the end of the region with the LCM of PAGE_SIZE and - * PCPU_BITMAP_BLOCK_SIZE. One of these constants is a multiple of - * the other. - */ - lcm_align = lcm(PAGE_SIZE, PCPU_BITMAP_BLOCK_SIZE); - region_size = ALIGN(start_offset + map_size, lcm_align); + region_size = ALIGN(start_offset + map_size, PAGE_SIZE); /* allocate chunk */ alloc_size = struct_size(chunk, populated, From patchwork Mon Oct 24 08:14:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13016815 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0712AFA373D for ; Mon, 24 Oct 2022 08:15:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9887C8E0008; Mon, 24 Oct 2022 04:15:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9389F8E0005; Mon, 24 Oct 2022 04:15:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B52D8E0008; Mon, 24 Oct 2022 04:15:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 640948E0005 for ; Mon, 24 Oct 2022 04:15:17 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 33BCAA0B22 for ; Mon, 24 Oct 2022 08:15:17 +0000 (UTC) X-FDA: 80055133074.15.E696EBF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf28.hostedemail.com (Postfix) with ESMTP id D3324C001C for ; Mon, 24 Oct 2022 08:15:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666599316; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qhNjNie8t1+sw/Ww+09Nk0F1+B4cpGUlQfgZx8SKUOg=; b=fBbqTS4YDCDaKJjwxT6EfG/P+FLvYMvsTzpp5jGEPECZXzP7PWoo4kNrLrmJWQn7cuGtSL Q2tMnbvoRKcgs8UZa1SJUCv3zTfhoTwlf7Fii8udPLFOKSreK6QC7l0Z+xf0SXex+eesyW yxB2QWoWiQa85OmDzmk1z9TtejTzoNY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-298--o0yKi-_O3u9wnEwYSAFNQ-1; Mon, 24 Oct 2022 04:15:12 -0400 X-MC-Unique: -o0yKi-_O3u9wnEwYSAFNQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BBF3285A5B6; Mon, 24 Oct 2022 08:15:11 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-35.pek2.redhat.com [10.72.12.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 29F9D40C6F9F; Mon, 24 Oct 2022 08:15:07 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: Dennis Zhou , Tejun Heo , Christoph Lameter , Andrew Morton , linux-mm@kvack.org, Baoquan He Subject: [PATCH 7/8] mm/percpu: remove unused PERCPU_DYNAMIC_EARLY_SLOTS Date: Mon, 24 Oct 2022 16:14:34 +0800 Message-Id: <20221024081435.204970-8-bhe@redhat.com> In-Reply-To: <20221024081435.204970-1-bhe@redhat.com> References: <20221024081435.204970-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666599316; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qhNjNie8t1+sw/Ww+09Nk0F1+B4cpGUlQfgZx8SKUOg=; b=XM2ZRYw6N3YHim0d2ikdTQsrt9gnnP+xh8fNMTqh7M3oFdmcUKMK5veq03rQw4pTEnzwOF NdiKPPutbXiYLxZGwFuvysPjYGg4yJSvGSFd3gMRgJk1ES09YXTfHHXfzK9NRiRCq2ezp1 ODdUJt7Gxof739j0d9vkfjRDLdblIYg= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fBbqTS4Y; spf=pass (imf28.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666599316; a=rsa-sha256; cv=none; b=crmbdPk9YFLX7LpodacY594cTkQng6Q3bct2gFLhf3fnHsWPfLVJppsauIOwoOusMGjf3S 2tiJ32uxQxszAM2ZinCtIPRWnsdtIYGqH5ebpWQj6MXakU5aD5tXWruMqhw91dRfW2Amqg XVjldvP9w7wV/2bLjJmGO4yNf3yImTU= X-Stat-Signature: 3pj8scwdrx5fyrra3h4k4huskzr18gkp X-Rspam-User: Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fBbqTS4Y; spf=pass (imf28.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: D3324C001C X-HE-Tag: 1666599316-820616 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: Since commit 40064aeca35c ("percpu: replace area map allocator with bitmap"), there's no place to use PERCPU_DYNAMIC_EARLY_SLOTS. So clean it up. Signed-off-by: Baoquan He Acked-by: Dennis Zhou --- include/linux/percpu.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/linux/percpu.h b/include/linux/percpu.h index f1ec5ad1351c..70bc17db00a6 100644 --- a/include/linux/percpu.h +++ b/include/linux/percpu.h @@ -37,11 +37,10 @@ /* * Percpu allocator can serve percpu allocations before slab is * initialized which allows slab to depend on the percpu allocator. - * The following two parameters decide how much resource to - * preallocate for this. Keep PERCPU_DYNAMIC_RESERVE equal to or - * larger than PERCPU_DYNAMIC_EARLY_SIZE. + * The following parameter decide how much resource to preallocate + * for this. Keep PERCPU_DYNAMIC_RESERVE equal to or larger than + * PERCPU_DYNAMIC_EARLY_SIZE. */ -#define PERCPU_DYNAMIC_EARLY_SLOTS 128 #define PERCPU_DYNAMIC_EARLY_SIZE (12 << 10) /* From patchwork Mon Oct 24 08:14:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13016816 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5587C38A2D for ; Mon, 24 Oct 2022 08:15:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 84EE48E0005; Mon, 24 Oct 2022 04:15:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7FF198E0002; Mon, 24 Oct 2022 04:15:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6C73F8E0005; Mon, 24 Oct 2022 04:15:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5D5058E0002 for ; Mon, 24 Oct 2022 04:15:32 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2A8BF1401C9 for ; Mon, 24 Oct 2022 08:15:32 +0000 (UTC) X-FDA: 80055133704.03.7A30314 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf28.hostedemail.com (Postfix) with ESMTP id DC870C000D for ; Mon, 24 Oct 2022 08:15:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666599330; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oB5FHCqdQzRcpJOgYsd1zcN5d+GwusZuRHj9Ye7P85Q=; b=MVVPlPV/zqchGBRP0L9jJ4IXX1nNCVDaaVg/AR6d6GrM6k8ReNJrJzgu59nRLD4umPcNJg Sdvk4qEZNx2AdpLs5tmLwSiaIbzCScmh/rz+B9XVM5E3adN44QTZfqoZlDkcNm6ZKgug86 L5kBwgxIK7jeeB1ZdKOPMYcpWaEpSVY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-558-md_8dzoMOzCwdktsUExyUg-1; Mon, 24 Oct 2022 04:15:20 -0400 X-MC-Unique: md_8dzoMOzCwdktsUExyUg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 70B7E887400; Mon, 24 Oct 2022 08:15:19 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-35.pek2.redhat.com [10.72.12.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D63C40C6F9F; Mon, 24 Oct 2022 08:15:12 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: Dennis Zhou , Tejun Heo , Christoph Lameter , Andrew Morton , linux-mm@kvack.org, Baoquan He , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [PATCH 8/8] mm/slub, percpu: correct the calculation of early percpu allocation size Date: Mon, 24 Oct 2022 16:14:35 +0800 Message-Id: <20221024081435.204970-9-bhe@redhat.com> In-Reply-To: <20221024081435.204970-1-bhe@redhat.com> References: <20221024081435.204970-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666599330; a=rsa-sha256; cv=none; b=m88Im1XmciRv9SX8l8lmYdo2g/VLJ6+CBsOm489Nlnk9Wsv24BacCIo1eltop3/jL15MRl C0wmTgHr4CpkgH71I+hgaqE/2VxrskS+7jpAptNVPdKrNFY8DMSdd6GBfb5xMbEY2JJZq2 n2NS+El76+VYEnf2xdV+3T1KcR3Lbxc= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="MVVPlPV/"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666599330; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=oB5FHCqdQzRcpJOgYsd1zcN5d+GwusZuRHj9Ye7P85Q=; b=j3vsgF7WKlrITmvmp5xyFoacKDAkT0JgLnU3G8x44Ee4NoOUMlwrmnFaUUkDKaYo7qYPQm h/JMmTgyCVLdwSo3E5tUJiyAMJ5mMLrWa8YMAcC89z6gvWOaK0tp9eF3QFITFMqnaAYuF/ y8Ta8ax8pCxt5eal/kegnpwh8nOTtJo= Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="MVVPlPV/"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com X-Rspamd-Server: rspam04 X-Rspam-User: X-Stat-Signature: 8iiu9wsfx3mxnke96cic71xxzhhyq4a8 X-Rspamd-Queue-Id: DC870C000D X-HE-Tag: 1666599330-54839 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: SLUB allocator relies on percpu allocator to initialize its ->cpu_slab during early boot. For that, the dynamic chunk of percpu which serves the early allocation need be large enough to satisfy the kmalloc creation. However, the current BUILD_BUG_ON() in alloc_kmem_cache_cpus() doesn't consider the kmalloc array with NR_KMALLOC_TYPES length. Fix that with correct calculation. Signed-off-by: Baoquan He Cc: Christoph Lameter Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: Andrew Morton Cc: Vlastimil Babka Cc: Roman Gushchin Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com> Acked-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Acked-by: Dennis Zhou --- mm/slub.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/slub.c b/mm/slub.c index 157527d7101b..8ac3bb9a122a 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -4017,7 +4017,8 @@ init_kmem_cache_node(struct kmem_cache_node *n) static inline int alloc_kmem_cache_cpus(struct kmem_cache *s) { BUILD_BUG_ON(PERCPU_DYNAMIC_EARLY_SIZE < - KMALLOC_SHIFT_HIGH * sizeof(struct kmem_cache_cpu)); + NR_KMALLOC_TYPES * KMALLOC_SHIFT_HIGH * + sizeof(struct kmem_cache_cpu)); /* * Must align to double word boundary for the double cmpxchg