Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5038026pxj; Wed, 9 Jun 2021 07:49:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEEQYCGMj+Lj8tUMjxWG1U3+V870Pm/mRkwyPp+gbk1F5oxnQPBPDgNTHTrlH0fKKuGoJ9 X-Received: by 2002:a17:906:7842:: with SMTP id p2mr199816ejm.487.1623250141027; Wed, 09 Jun 2021 07:49:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623250141; cv=none; d=google.com; s=arc-20160816; b=VhLtundpDdU1mzPfZsCMWXdUZLlcMPOKt5LRmgUegLMWNNUf1zlOgSLU9RasNRAHTC 8hN4smBO47qrFKy23d6Q+jQvwSzBUeE3Bm3JCNUrLYuGHXqSENgTIwsqqlwjVB/EZDBz u1tEqXQBarHb1PNpaRX9Uz6OqiihB9NUJ9AypcA61/MN5awp+FoBLam5J0tGU9ICTPAV 9bNY2ycLLv/CySSC2ILQAXmnbiKmHU3H7H4rRxd7AFqcafBM/6HdE7169JYceK2fbWhw vamKGUg6161UmejhESATM76Yj3vXN1lykvGZLgbqrlpwIuP8mqJizK6KcUKc6dj/o/Qt cd2A== 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:dkim-signature:dkim-signature:dkim-signature; bh=YZTiZ2krokRZPz74ttwlqY3E9OPfJw2MVLDApZp5kJ0=; b=OGBlVmsaWxHu9BTxm37hWjY61pM+YkbtA0Ww+nlhFe2ZUhtUo6ZVNLdUZNqIXAIV/r srKqgMwM+O5q9cMp+3e3h2QvyXtcLv5OuKLXeK9QuFZvpNqYpdFN3NOHQ9u9AjgRMsjn AQy50semZZiTWzkcIU50dLhxW+au3/LW+XZg91BSRfgX/LaNNx4Lp9sTDXweBe53lNAD tqdqLpntVtVjBH9KIe9jFoFJCARnQtS7BoXT+jPNrmNxTjgLaZ2XWYhCU9E7UAmJg2vG 9yMUSqi6AzFIPBPxQtq60Shc/F64rCYj9J2LQU9qNNoPxunxSgNjxq5VLn7hAao9M+vV BfGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=LDp5gkLs; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=LDp5gkLs; dkim=neutral (no key) header.i=@suse.cz header.b=z65b+i1N; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p3si50221ejy.228.2021.06.09.07.48.37; Wed, 09 Jun 2021 07:49:01 -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=@suse.cz header.s=susede2_rsa header.b=LDp5gkLs; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=LDp5gkLs; dkim=neutral (no key) header.i=@suse.cz header.b=z65b+i1N; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239253AbhFILmC (ORCPT + 99 others); Wed, 9 Jun 2021 07:42:02 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:46968 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239147AbhFILl3 (ORCPT ); Wed, 9 Jun 2021 07:41:29 -0400 Received: from imap.suse.de (imap-alt.suse-dmz.suse.de [192.168.254.47]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 7F3091FD64; Wed, 9 Jun 2021 11:39:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1623238773; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YZTiZ2krokRZPz74ttwlqY3E9OPfJw2MVLDApZp5kJ0=; b=LDp5gkLsDT1plakKx1QbWTNmHjfTbVB/ZEIRrspp9/GdglbQNNmsfwGjZkEpn/Sxy7U7/U zy0rjY96XUhFuNvSNBUY45+z6MUydML6SOyuq1HAgqSj1C7hvXRl13bX+p27x0FPiHEk72 drEpQmA9Kgi6O5+zbkdunga9lqCMy3A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1623238773; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YZTiZ2krokRZPz74ttwlqY3E9OPfJw2MVLDApZp5kJ0=; b=z65b+i1Nn4+r+AFVNc7LKQ3aYAOq7ZlkVGPjGctN+mrDVuLJ9vgCJ260MIpvYEty25LiyI O/d/ETQxIENCwTCw== Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id 507FE118DD; Wed, 9 Jun 2021 11:39:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1623238773; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YZTiZ2krokRZPz74ttwlqY3E9OPfJw2MVLDApZp5kJ0=; b=LDp5gkLsDT1plakKx1QbWTNmHjfTbVB/ZEIRrspp9/GdglbQNNmsfwGjZkEpn/Sxy7U7/U zy0rjY96XUhFuNvSNBUY45+z6MUydML6SOyuq1HAgqSj1C7hvXRl13bX+p27x0FPiHEk72 drEpQmA9Kgi6O5+zbkdunga9lqCMy3A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1623238773; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YZTiZ2krokRZPz74ttwlqY3E9OPfJw2MVLDApZp5kJ0=; b=z65b+i1Nn4+r+AFVNc7LKQ3aYAOq7ZlkVGPjGctN+mrDVuLJ9vgCJ260MIpvYEty25LiyI O/d/ETQxIENCwTCw== Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id OPssE3WowGD6XgAALh3uQQ (envelope-from ); Wed, 09 Jun 2021 11:39:33 +0000 From: Vlastimil Babka To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Christoph Lameter , David Rientjes , Pekka Enberg , Joonsoo Kim Cc: Sebastian Andrzej Siewior , Thomas Gleixner , Mel Gorman , Jesper Dangaard Brouer , Peter Zijlstra , Jann Horn , Vlastimil Babka Subject: [RFC v2 10/34] mm, slub: restructure new page checks in ___slab_alloc() Date: Wed, 9 Jun 2021 13:38:39 +0200 Message-Id: <20210609113903.1421-11-vbabka@suse.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210609113903.1421-1-vbabka@suse.cz> References: <20210609113903.1421-1-vbabka@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When we allocate slab object from a newly acquired page (from node's partial list or page allocator), we usually also retain the page as a new percpu slab. There are two exceptions - when pfmemalloc status of the page doesn't match our gfp flags, or when the cache has debugging enabled. The current code for these decisions is not easy to follow, so restructure it and add comments. The new structure will also help with the following changes. No functional change. Signed-off-by: Vlastimil Babka Acked-by: Mel Gorman --- mm/slub.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index ca7cfc7706cc..0d5c253a39b2 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2722,13 +2722,29 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, c->page = page; check_new_page: - if (likely(!kmem_cache_debug(s) && pfmemalloc_match(page, gfpflags))) - goto load_freelist; - /* Only entered in the debug case */ - if (kmem_cache_debug(s) && - !alloc_debug_processing(s, page, freelist, addr)) - goto new_slab; /* Slab failed checks. Next slab needed */ + if (kmem_cache_debug(s)) { + if (!alloc_debug_processing(s, page, freelist, addr)) + /* Slab failed checks. Next slab needed */ + goto new_slab; + else + /* + * For debug case, we don't load freelist so that all + * allocations go through alloc_debug_processing() + */ + goto return_single; + } + + if (unlikely(!pfmemalloc_match(page, gfpflags))) + /* + * For !pfmemalloc_match() case we don't load freelist so that + * we don't make further mismatched allocations easier. + */ + goto return_single; + + goto load_freelist; + +return_single: deactivate_slab(s, page, get_freepointer(s, freelist), c); return freelist; -- 2.31.1