Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp650411pxt; Thu, 5 Aug 2021 08:24:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxw77hWXD2obtqd5ap/Haa3OpN+S8jajzLzmFU7pDFfuFYKMAz1OJQbrOp38lJYyONm0SbL X-Received: by 2002:a02:b190:: with SMTP id t16mr5239815jah.85.1628177087883; Thu, 05 Aug 2021 08:24:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628177087; cv=none; d=google.com; s=arc-20160816; b=oEV4bnTb3aOhmOD6YbXID5uxO/WNyzjM8SOQMo19zNLUUr2IeDxee6F3ad7rX95HHV A125+QSKPFXhI3T1JLfv1xxBim3jfFgqRkjVDGIAmQHJFOwqpdQF/Q9i/2xr9SnvUzh+ TAa6oIZ2bKUXM5aCSOZj/nMPeVhBqsLdVVmUwboJDOOkTsHLCl5VIDQ6LXEQmWBCJOde UaunCps2Wwge0/xb9nYDuguyGte3nlpl/vEdmEYyLzlD/Kd0HgZc+8wWCqm8SSk9lvcQ EbgXu9TQ1eDX7HyA1pBclW8XwnGCj7Sjo7AZQy8Ay8trZT1kTNjlFPgzCUW+zvIdNkXa JfIA== 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; bh=y9lBj6qb24z5zNK5TR3EA2ovHlu+OdWtU23hVPY3atw=; b=WvoRDgHMtNrI53hiUsi8CBBkYT1Lobz7p7ODBf8fQ4Ny1hHJcugsYPikY/UnIDsImz lOkCFpt7u7ZysElsqeUd0ul/c+GeLPsi944z9LCj8kW7uAHaZA8O1U1jrjtMkZVdC+Z7 RoV19+Z1H7MsG/VrprUKyJyE1Xzu8qe7nvtolDrVY8DNtFe4Bx2bduqjqKt+v5klxGlx Z8RvVG0vy/oP0OcNDN/vA3Eh6ju+AwFbUO98w01NCzWmWQWu4x8kmPbdciNqRABDo4M5 50JVLKJKx1zIE2V3dgV5L4atXZd4U/MBl9k3miqeluD3x68TvaZIJyBSA9EltgXlHw38 LqDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=TsnWaSpH; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=tRgQTUMr; 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 m8si6173675jav.78.2021.08.05.08.24.34; Thu, 05 Aug 2021 08:24:47 -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=TsnWaSpH; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=tRgQTUMr; 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 S242073AbhHEPWK (ORCPT + 99 others); Thu, 5 Aug 2021 11:22:10 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:33984 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241953AbhHEPUV (ORCPT ); Thu, 5 Aug 2021 11:20:21 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 0EBDB2238F; Thu, 5 Aug 2021 15:20:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1628176806; 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=y9lBj6qb24z5zNK5TR3EA2ovHlu+OdWtU23hVPY3atw=; b=TsnWaSpH5LFKAiK0qEokbW6ocUvf5egK2mIqmMYQ666CfYqyYHgs5wskM0Pxh+VV+oCwWr 8y8YUhFBEW/OmSFwANBodmddZFagE7ywxiSvRzDcEoGcwn34Dk6UAkU/n0lk3bWsHxyfvH bl5daEpDCHZ7dMo0aUcatg2relEp2dw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1628176806; 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=y9lBj6qb24z5zNK5TR3EA2ovHlu+OdWtU23hVPY3atw=; b=tRgQTUMr19GP4GUASPNxj2jYrwo6SiPksFDc7puU2QhApFv4w0DnzD0PQTCmg6tyHrLQlT eknsxxCWyjDzoEDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D523C13DA8; Thu, 5 Aug 2021 15:20:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qO5sM6UBDGFDdQAAMHmgww (envelope-from ); Thu, 05 Aug 2021 15:20:05 +0000 From: Vlastimil Babka To: Andrew Morton , Christoph Lameter , David Rientjes , Pekka Enberg , Joonsoo Kim Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mike Galbraith , Sebastian Andrzej Siewior , Thomas Gleixner , Mel Gorman , Jesper Dangaard Brouer , Jann Horn , Vlastimil Babka Subject: [PATCH v4 10/35] mm, slub: restructure new page checks in ___slab_alloc() Date: Thu, 5 Aug 2021 17:19:35 +0200 Message-Id: <20210805152000.12817-11-vbabka@suse.cz> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210805152000.12817-1-vbabka@suse.cz> References: <20210805152000.12817-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 ed18fa3157ad..c32048353645 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2765,13 +2765,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.32.0