Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3846003pxj; Mon, 24 May 2021 16:43:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+uFyjSq0yOExbJGPjAbMXHwxotPZyezVOMOcMrrUHWeObLZT2LIVto4s7uvwNnmQ6AZs8 X-Received: by 2002:a17:906:3042:: with SMTP id d2mr26279163ejd.234.1621899785347; Mon, 24 May 2021 16:43:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621899785; cv=none; d=google.com; s=arc-20160816; b=Rj/e+YrBS9F07B5WepENzKkWmFflzhQ0vU+F2vkeGMWD5YnA1oXXi7sdyw/riLCRq0 ZHjUXGExSvVvecnaYUT9K99/mL890Hz7KH+8S8wwOdLyOrfBEVxtI4+y0BTn+8OMVcgJ /mbmBRP1/+zVVFkj0Db8DvOKT5yJfQOgIhlhkXo83qzYC6uy1shzEpDMsb0KgBFlk4Da vIxG74NqVfSVKJItcs3CFk/CHPhVFC1s9CwkBj8MjR2btkMONKkZiFG52yuy0q3N+8se z3+9A0Cz0lFbD63VXklzI2wKQ6M7ZoWPSXuIB0BblrdqXMKxECA3VYPGK44rmj2STtbi UdQQ== 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=1xmWeJ1b7AZlmflgkuweNV6NpHrLePBdboBsTBPbV/k=; b=sPb0eYYmqu65dk35IUCoCg6pQ4TxzGRQiVLt3ZgTXBHpQ/3KJyX8ICoGD7B8erxlVX ClzKMnDkpUaQVxw64x5Cy7lMclJ8UoNfXeDcmWZnKJ8uNfskFWfw6C4/Pl6DI64wPVV2 B3cGb0EQpF2Ss/xbwgVjRT3P4up9vu8QlRztq1UhUjAJJTRIXMMvr+zpDI3X5GcODJlZ i1hX69RNen4E8rqWm3eS5CFUFEVAu3I4Y+NmYnIWnt6TtYUYousvvNMCTxvoQ6MeaOMQ AnOmvCkKc9Sm9VYZdGPeFSMPZESC4TAKok3Jfqap3YvBSLPDO4ua3TsCOwNtULVqNH1N cOXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=JoaTF4rq; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 hq1si13188272ejc.659.2021.05.24.16.42.42; Mon, 24 May 2021 16:43:05 -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=JoaTF4rq; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 S230128AbhEXXmh (ORCPT + 99 others); Mon, 24 May 2021 19:42:37 -0400 Received: from mx2.suse.de ([195.135.220.15]:50688 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229875AbhEXXmU (ORCPT ); Mon, 24 May 2021 19:42:20 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1621899648; 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=1xmWeJ1b7AZlmflgkuweNV6NpHrLePBdboBsTBPbV/k=; b=JoaTF4rqBbwWtdHjrYUyCM/QqY0hcx8rqKdEwXsbGgayd9D7nrxrKjRRG96f1rr0pxkojB Q4Wq26PiCK1wcYmstYjpoDfT5IXgmDdqeCpHih3/V1+qCbGY6PockH5rxi7413yGns9vVO ZiBbgyoQxkBY5FQs/AGCcri2u4csPV4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1621899648; 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=1xmWeJ1b7AZlmflgkuweNV6NpHrLePBdboBsTBPbV/k=; b=E7m4pF7yX975qQIzoPzuGk7jsqfXsunkwKDsF+v818VG1L4hZR5aSd1yRJVN9IMmKuc/cL KfzO/8ZKmHl/pJDQ== Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 1BAFFAF21; Mon, 24 May 2021 23:40:48 +0000 (UTC) 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 08/26] mm, slub: restructure new page checks in ___slab_alloc() Date: Tue, 25 May 2021 01:39:28 +0200 Message-Id: <20210524233946.20352-9-vbabka@suse.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524233946.20352-1-vbabka@suse.cz> References: <20210524233946.20352-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. No functional change. Signed-off-by: Vlastimil Babka --- mm/slub.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index f240e424c861..06f30c9ad361 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2743,13 +2743,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