From patchwork Thu Feb 22 13:02:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 204757 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp240642dyb; Thu, 22 Feb 2024 05:12:32 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUlo2fhH5b8qDp8ZoakZ3sha/aYUl5BzF3WPBPcBTwJLexYzv5sFBEppPFNnA5NlITxLGHvDssJ2IVB+vYLJySu9r3OYA== X-Google-Smtp-Source: AGHT+IEAySAXuCw5t3EGgkrN7NHANQMBEVCpCF+O7GjW/DsTsk/1qCPCX2HiCjSbyyjJIfCgNjVn X-Received: by 2002:a05:6a00:2da6:b0:6e3:b4a5:4b53 with SMTP id fb38-20020a056a002da600b006e3b4a54b53mr16699429pfb.24.1708607551917; Thu, 22 Feb 2024 05:12:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708607551; cv=pass; d=google.com; s=arc-20160816; b=sVfkffzKbfoeMmLoo+0x1dA+qPuF7lgIxfRruUR3OICti7rej9BsozoA4t358zFiyN LwvNiOjM+Y4Uw21/SHbDsAFl2Mo6bOkE88188T/d9NcM6GyKhdjfAaCZmWmPauqR5K0V 9TAzIw8dfu7HsW3AZoJicKBSrMw0AdUsYodnww1tKTTGK50DoU9obcqM7MZ3Jfl+Mwdb eOH/keIcJTlNScEdRjX802zkwYyIFGg0MXk1djCTfQ2Sgd0T7kcN8pSALheg8nNotseX Rw5rzXOG2rPQLE0+ynzXIBxWvD5kdCyPirfIccfgbpsaqOC85yin0QHkRbgY43RCaCzM +HKw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=IDulxroE9ikP839kUNCu1ABivghSCv1a1QMz7sde4n4=; fh=91Ob1BzqBtFWTsPz0hVaQpPPn3Wo6fgXNC2c0a9+bfc=; b=OHl9U6pyEbXb7E9POk2O4K0l9dGM4DZjuLdFYz1vNjVPG0oi55Or9RLOH+n/4i5h5K vWKlA3OyJ49sdYOGksRA5cX5fLvMs2skvE3tjVdY8Imx3My+aP2KE7xqKDudMgbjDkjq HgXBClVQJwdljdSHliXh6onZFc5oZVd7BKK2n6Ey2GYeQQuSry8GGT6TcQUWFiE0rDxe ZdaHGOOLrEsKmrVy9SxHy2+vObEA08/WBT/c8Jc+bsotgydSds5PiPaCZXQEdQa/Rdvn yQuFFi0yxoB7xHOUP2m3D+sBKkEl+QYBg7MV8K/X5GF3rWsvPJURyjqL+SMO4cQV8mRC 7UDw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=fOrUDGkk; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-76556-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76556-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id fh26-20020a056a00391a00b006e0945e03fasi10236441pfb.162.2024.02.22.05.12.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 05:12:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76556-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=fOrUDGkk; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-76556-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76556-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 7661BB2360F for ; Thu, 22 Feb 2024 13:03:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 372EF131728; Thu, 22 Feb 2024 13:03:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="fOrUDGkk" Received: from out-185.mta1.migadu.com (out-185.mta1.migadu.com [95.215.58.185]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2315812E1EB for ; Thu, 22 Feb 2024 13:03:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.185 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708606991; cv=none; b=ZFrDV0rBTfMHh2lWgQvkMtkP6HGF6cUuGww1mH5XttesT/7U46BwKPUM8fQMvQsCGZ5fmx5aJKtk0MZls7qXBuqC0OlkGqr+unVazEDZtNI8R1a869H1axDaTjsq/0IAOVuCLF45QDAcGYTrITHs5jfMgGAL5g0RQr6tQOpyKdQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708606991; c=relaxed/simple; bh=EjE7mXBdc338IIDo0nEmWwYag2fsZw52u8AZJ06oaSw=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=lKgmZg5S6hZRo10MYl4ncO99HIA/ZpbEsjB/f7rEYeHu5KrCsTPmeqPmTX7dVDmdpybljOXFprckcfeg1/DSY8tsLkEtXvGUnh5qPvf80E6fMCPmd3sDjtsj0Zj+khm/psC+Ts6xZHu+SM7WGjGTPmv6rkOEuXdJei9s+kwRBiM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=fOrUDGkk; arc=none smtp.client-ip=95.215.58.185 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1708606985; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=IDulxroE9ikP839kUNCu1ABivghSCv1a1QMz7sde4n4=; b=fOrUDGkk1lp2vm3txHxBJ5StMHBBYoXpFBOz2bCJg65nm+ucWy3mlMyi4W0RPaFF7wtx5U rgVxHY6vd/SOiSK7lTlJy0pSb0L92bsLzlm/2KPhYjihS4Hfj2zdVAnyKKfrwGqlEm5pDo EUog2L0gJV2Qlxfm4Aui8nW36E8nJNw= From: chengming.zhou@linux.dev To: vbabka@suse.cz, cl@linux.com Cc: penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, roman.gushchin@linux.dev, 42.hyeyoo@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, chengming.zhou@linux.dev Subject: [PATCH] mm, slab: remove the corner case of inc_slabs_node() Date: Thu, 22 Feb 2024 13:02:33 +0000 Message-Id: <20240222130233.2880176-1-chengming.zhou@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791604871939588470 X-GMAIL-MSGID: 1791604871939588470 From: Chengming Zhou We already have the inc_slabs_node() after kmem_cache_node->node[node] initialized in early_kmem_cache_node_alloc(), this special case of inc_slabs_node() can be removed. Then we don't need to consider the existence of kmem_cache_node in inc_slabs_node() anymore. Signed-off-by: Chengming Zhou --- mm/slub.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 284b751b3b64..3f413e5e1415 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1500,16 +1500,8 @@ static inline void inc_slabs_node(struct kmem_cache *s, int node, int objects) { struct kmem_cache_node *n = get_node(s, node); - /* - * May be called early in order to allocate a slab for the - * kmem_cache_node structure. Solve the chicken-egg - * dilemma by deferring the increment of the count during - * bootstrap (see early_kmem_cache_node_alloc). - */ - if (likely(n)) { - atomic_long_inc(&n->nr_slabs); - atomic_long_add(objects, &n->total_objects); - } + atomic_long_inc(&n->nr_slabs); + atomic_long_add(objects, &n->total_objects); } static inline void dec_slabs_node(struct kmem_cache *s, int node, int objects) { @@ -4877,7 +4869,6 @@ static void early_kmem_cache_node_alloc(int node) slab = new_slab(kmem_cache_node, GFP_NOWAIT, node); BUG_ON(!slab); - inc_slabs_node(kmem_cache_node, slab_nid(slab), slab->objects); if (slab_nid(slab) != node) { pr_err("SLUB: Unable to allocate memory from node %d\n", node); pr_err("SLUB: Allocating a useless per node structure in order to be able to continue\n");