Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6093614pxv; Thu, 29 Jul 2021 06:23:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsO0446RFkh+Jg/X7cVZGO9HJ2Uupu0Z3ismL5itXXwwiDRJk7pJFuzEE0xWLEMaoWoeIj X-Received: by 2002:a05:6e02:1d0e:: with SMTP id i14mr3547836ila.50.1627565018937; Thu, 29 Jul 2021 06:23:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627565018; cv=none; d=google.com; s=arc-20160816; b=km+9xajPTtqOkGvzJ8z9uLncBXT3qFvOkM/HIXl0ML531B6sj+CvewCkwqqcrbf4vt bEcRCaAIE6znzknorDMHhcHSYBo7QBvRUGIWwKHkz5+QtSJjQKeICa5FpgJUH1w4sfGZ OtkUAkkrfCQgQPbxkWQ3tfLTYSEncYIz8pjFsOjOUf/AGvgMx2Z/7xoEdG6kePzIA+PH p81CsjYmphPdAQzFc3FM7Ij1eNtvQul7EMw3lL0VM/d5ROzLWgUru/WEeP3xFKQ4Tzrz 4XJHuo4g//nyEUI2xvMFHRVhmeCHXk7GjsjjQ05/JrapgmBvwqRVhJJJ3GaT9Y47XcjV 9zeg== 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=i6VhWY6JuMcwhpuUl6vau38Fqa9T1OGrHlS6+6xuZ1E=; b=V20mlUdOWw8YkxrNYvUuaE7bYK/rWu41KYqbWRGN4ugnNK9Wks2S4nLTimBKmjE1Q7 IQZUrFcGRLxnGVEN6aLWRhm1T+nz4c3GSZ5pncvdoxii0ycsR4QYajCRsLynWfqqzCxv 2H1wNBN/73spUOb8a61mEZAswWf008+WgQ/n8B2rraRIV14n91wStbrohuKuIbpM/gs6 lrTBwCI9ETpJckJ1t2WTy1a6G+ztsU3DwzmngCAiaV/f4bBjY4Nsv7D3ctA8b8dgtwFA c5CHb1fPWh1K1wHynCq5gEuErq5g9feQmVvRnpx/89DcoYDIi3rOnZNiuM3BL8yJ9OIp GiPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="RY/O1Ybf"; dkim=neutral (no key) header.i=@suse.cz header.b=TSD9acl5; 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 y11si3673052jat.64.2021.07.29.06.23.26; Thu, 29 Jul 2021 06:23:38 -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="RY/O1Ybf"; dkim=neutral (no key) header.i=@suse.cz header.b=TSD9acl5; 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 S237629AbhG2NWK (ORCPT + 99 others); Thu, 29 Jul 2021 09:22:10 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:38420 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237478AbhG2NVq (ORCPT ); Thu, 29 Jul 2021 09:21:46 -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 2BC25223D6; Thu, 29 Jul 2021 13:21:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1627564902; 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=i6VhWY6JuMcwhpuUl6vau38Fqa9T1OGrHlS6+6xuZ1E=; b=RY/O1YbfGAgR++RZwP1SuHk53RuWMLKjQbVQmzb2fZaZhjUF35+gTmsd/Ukd8LgYBeUSw7 6WV07VrUs806TIQ4L652IivEXxTa6owbIf2yHYZ++ntV2h7pW9T/5MdLbtRPLg2ohkAWgC cQG/T+uCQp0/PF2gT8D6DxfhhG5bZ0w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1627564902; 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=i6VhWY6JuMcwhpuUl6vau38Fqa9T1OGrHlS6+6xuZ1E=; b=TSD9acl5pCe+6x97JYBhWQgwRjdae41SDtt6CGUYdtIZ/UHWvpbawFYSfjI0CKMH/Zr2/0 rMMiMwELobeMHiDg== 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 F0F6313AE9; Thu, 29 Jul 2021 13:21:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YDA6OmWrAmF9AwAAMHmgww (envelope-from ); Thu, 29 Jul 2021 13:21:41 +0000 From: Vlastimil Babka To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Christoph Lameter , David Rientjes , Pekka Enberg , Joonsoo Kim Cc: Mike Galbraith , Sebastian Andrzej Siewior , Thomas Gleixner , Mel Gorman , Jesper Dangaard Brouer , Jann Horn , Vlastimil Babka Subject: [PATCH v3 10/35] mm, slub: restructure new page checks in ___slab_alloc() Date: Thu, 29 Jul 2021 15:21:07 +0200 Message-Id: <20210729132132.19691-11-vbabka@suse.cz> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210729132132.19691-1-vbabka@suse.cz> References: <20210729132132.19691-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 92a866adce3d..469aa8155663 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