Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5153736pxj; Wed, 9 Jun 2021 10:19:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrPpqRTGwkL0gPhjly+PPyS8Idj2+R3yaEQn8cqWf8ximN6fhYcCOvgV3+QEvrDJN6Cexz X-Received: by 2002:aa7:d54c:: with SMTP id u12mr494900edr.242.1623259182759; Wed, 09 Jun 2021 10:19:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623259182; cv=none; d=google.com; s=arc-20160816; b=KkGC/BGTFOd0e37ZNFX+PytOrlhf6EDTPmYuQEh9bosuWhF49/SVgZKfNcjVVe/o4m ROF//IphxjlfrJFTtcgW0hhu6n1geF3yjCGutXTFKECnW+9XQYeFNrLL9e+NcYLzpiPJ Z1ZuFIYnxGvXsLuiLVsrAA/2+1F+g0Yzn4TOkMvYtOTh2YCzUfW3x++QJEQ3MfUWAp7o 71N0BcGrS3GBELdwNLBK/896dToBDyRqWhN2rhAHDjhUA10dPdZVnKTnGeYRaSbRgZ7h ve7C1cjGKjYeSAcXYozGmHQ1+v/t5L/2iq+ihJXJl3Jl2yYNCa9ugnl2SX+ZW05gCH1b 3zVQ== 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=MP6gY1FO49owhq4IXmCsqEM0wX1JIeYz2iR8RuLeKzs=; b=z0VcFLcPk72wlwc/mFB0jkDQB7AsabKiLbAlerPPPmjP0u/NprypjFaiYVPrFREsgi qLKXPFTvf+dtRNJ6CmMp54WTbG+Lfh72lOMZVFkhZ0F0k587Pf5hOR66lUFsRstX4Hy7 3wYB5k0T+TAPFhtkIrGX1wTe47J9qVcbAuJ8jtxW0PzmWNxzlqOmEx9PYl9LQUWLOmkv XezdXi8wafdy5HA/Ut/q4VuloI8zTHvjP54O2lc0xyGb8XeO3mZjt0UnahaQjwKDuH3T NPoTmVkD88mIuDKLfc+UkAIvwl7w0LiBJVqtaECKU2M8ryB6inNtIfZswukZgrsJlFSr rorA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=V8FHGEI4; dkim=neutral (no key) header.i=@suse.cz; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=V8FHGEI4; dkim=neutral (no key) header.i=@suse.cz; 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 oy3si270539ejb.550.2021.06.09.10.19.18; Wed, 09 Jun 2021 10:19:42 -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=V8FHGEI4; dkim=neutral (no key) header.i=@suse.cz; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=V8FHGEI4; dkim=neutral (no key) header.i=@suse.cz; 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 S239254AbhFILls (ORCPT + 99 others); Wed, 9 Jun 2021 07:41:48 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:46884 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239144AbhFILl2 (ORCPT ); Wed, 9 Jun 2021 07:41:28 -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 1E8681FD61; 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=MP6gY1FO49owhq4IXmCsqEM0wX1JIeYz2iR8RuLeKzs=; b=V8FHGEI4P8WxPddKk/LZH2BMfi9s9m7qRpZAJLGT2feGyXEA8FTdsmKjBZNWadQxLFQUiT V/ZP0clOdhvk/IjoVdzJ44DcjpMaZtZ+xJ7azBjv5jXg7BrzfVICwpeKmOLDeBRoxMDMsK Mrv3WVt6qvFCdN3M7N25U/n6Qzu6NiA= 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=MP6gY1FO49owhq4IXmCsqEM0wX1JIeYz2iR8RuLeKzs=; b=gRRa2lgyuO6eUIZ/b/bgZn4ZAf2Jx9qQ7KZvvitRhlT7Qi+oCsDSg6bDJ1kQOHQyvVw8c3 t5cKvFrVti1+r6Dg== Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id E2588118DD; Wed, 9 Jun 2021 11:39:32 +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=MP6gY1FO49owhq4IXmCsqEM0wX1JIeYz2iR8RuLeKzs=; b=V8FHGEI4P8WxPddKk/LZH2BMfi9s9m7qRpZAJLGT2feGyXEA8FTdsmKjBZNWadQxLFQUiT V/ZP0clOdhvk/IjoVdzJ44DcjpMaZtZ+xJ7azBjv5jXg7BrzfVICwpeKmOLDeBRoxMDMsK Mrv3WVt6qvFCdN3M7N25U/n6Qzu6NiA= 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=MP6gY1FO49owhq4IXmCsqEM0wX1JIeYz2iR8RuLeKzs=; b=gRRa2lgyuO6eUIZ/b/bgZn4ZAf2Jx9qQ7KZvvitRhlT7Qi+oCsDSg6bDJ1kQOHQyvVw8c3 t5cKvFrVti1+r6Dg== Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id 4EvANnSowGD6XgAALh3uQQ (envelope-from ); Wed, 09 Jun 2021 11:39:32 +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 08/34] mm, slub: dissolve new_slab_objects() into ___slab_alloc() Date: Wed, 9 Jun 2021 13:38:37 +0200 Message-Id: <20210609113903.1421-9-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 The later patches will need more fine grained control over individual actions in ___slab_alloc(), the only caller of new_slab_objects(), so dissolve it there. This is a preparatory step with no functional change. The only minor change is moving WARN_ON_ONCE() for using a constructor together with __GFP_ZERO to new_slab(), which makes it somewhat less frequent, but still able to catch a development change introducing a systematic misuse. Signed-off-by: Vlastimil Babka Acked-by: Christoph Lameter Acked-by: Mel Gorman --- mm/slub.c | 50 ++++++++++++++++++-------------------------------- 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 38256e87dde8..87f652bf8e4d 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1825,6 +1825,8 @@ static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node) if (unlikely(flags & GFP_SLAB_BUG_MASK)) flags = kmalloc_fix_flags(flags); + WARN_ON_ONCE(s->ctor && (flags & __GFP_ZERO)); + return allocate_slab(s, flags & (GFP_RECLAIM_MASK | GFP_CONSTRAINT_MASK), node); } @@ -2550,36 +2552,6 @@ slab_out_of_memory(struct kmem_cache *s, gfp_t gfpflags, int nid) #endif } -static inline void *new_slab_objects(struct kmem_cache *s, gfp_t flags, - int node, struct kmem_cache_cpu **pc) -{ - void *freelist = NULL; - struct kmem_cache_cpu *c = *pc; - struct page *page; - - WARN_ON_ONCE(s->ctor && (flags & __GFP_ZERO)); - - page = new_slab(s, flags, node); - if (page) { - c = raw_cpu_ptr(s->cpu_slab); - if (c->page) - flush_slab(s, c); - - /* - * No other reference to the page yet so we can - * muck around with it freely without cmpxchg - */ - freelist = page->freelist; - page->freelist = NULL; - - stat(s, ALLOC_SLAB); - c->page = page; - *pc = c; - } - - return freelist; -} - static inline bool pfmemalloc_match(struct page *page, gfp_t gfpflags) { if (unlikely(PageSlabPfmemalloc(page))) @@ -2726,13 +2698,27 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, if (freelist) goto check_new_page; - freelist = new_slab_objects(s, gfpflags, node, &c); + page = new_slab(s, gfpflags, node); - if (unlikely(!freelist)) { + if (unlikely(!page)) { slab_out_of_memory(s, gfpflags, node); return NULL; } + c = raw_cpu_ptr(s->cpu_slab); + if (c->page) + flush_slab(s, c); + + /* + * No other reference to the page yet so we can + * muck around with it freely without cmpxchg + */ + freelist = page->freelist; + page->freelist = NULL; + + stat(s, ALLOC_SLAB); + c->page = page; + check_new_page: page = c->page; if (likely(!kmem_cache_debug(s) && pfmemalloc_match(page, gfpflags))) -- 2.31.1