Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp792241pxt; Thu, 5 Aug 2021 11:47:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPNSxgIuynTAe2XOxAJk8OSngVfC3wDOo49g+UYT537IjcgKCxQh3oNTWcZrH2WkQYlxwX X-Received: by 2002:a05:6402:d67:: with SMTP id ec39mr8382573edb.117.1628189247477; Thu, 05 Aug 2021 11:47:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628189247; cv=none; d=google.com; s=arc-20160816; b=E8NBM0DmP5kZwUoBc11g87Or7DrczWHMeom/C+RM6KKYnKvXhpmOGmVGWWOd//c6mg ycKORRSZCWQx00QdJzklQAL7N3TnmrSri218V8GACUd+3ZzFZMOkQN7oM15rVOHr2S7Q qZ8ATifxwV4bx7+JrCwRrEugE4Z500WnUhRRsNnM6l0YFIsujEUhRSA5lf3D6b1H6osd 3knQmmGK6RgCqvldUOd7czui48JWjDxSfMVGHHxWtAk88uQZzn4XpBRJJK4MmAjAhnSj aduhE7OxfLLBZvnOhUjHhpbyxgeEHWHt1XGIwKGmGYwyABBCAzs0eX5XBHdG0xCEMxKo Kp1A== 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=WZdoIvX+DRNWMgta6QGPTF4DImZV6OBCG41yU7Hz0C4=; b=fWjEtdkf8/ioqo5QbSzj4iumh1B0zMiZCehb51jBGxLjXwxGwmDWMTb38Bi+Yk61bt WMwBS400k2XpG0w1+vX1bnpkAJf67XsHQo0u8PBQ+Q6O5TfGgN35RCIX1m8RS+lIR6zY MMDstckgAHf6VkVl2fR9VnpfPxffAd97tVzJDnopSpgqzytPDKTKjFTZS5d1JAQoq3av ZULzmcnEOiwsVlifPn8+fUTdeeERscf7zxVMIwhaXhIEpiScFKw3QKFwJdlvC6kO8JDo USOC4TGLGWejekeMwHW3UtpPdsSK4SfJrgxcEEuJxoo5JeZkfSgKTUlFa9mN6ztZcUqm 1jGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=nHvm2y5c; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=h1mRTXam; 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 h1si6465812ejf.90.2021.08.05.11.47.03; Thu, 05 Aug 2021 11:47:27 -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=nHvm2y5c; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=h1mRTXam; 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 S242043AbhHEPX7 (ORCPT + 99 others); Thu, 5 Aug 2021 11:23:59 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:59212 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241906AbhHEPUV (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-out2.suse.de (Postfix) with ESMTPS id A52662024B; Thu, 5 Aug 2021 15:20:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1628176805; 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=WZdoIvX+DRNWMgta6QGPTF4DImZV6OBCG41yU7Hz0C4=; b=nHvm2y5cduTtm2uEWeJGjmPQblIh0YvQKVSsKifZslWdv4G44DBCXlA6b81wD5mKsFkvhE DlFM8ihgPizmvjqCl1faIUxlPQ7pVvh+iQAHW8Z+RBqGfmx9WurKAbygcvZBUQqt5qzBjk L/HBj0OzJqvKCntxutFXEerviXrHZ1o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1628176805; 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=WZdoIvX+DRNWMgta6QGPTF4DImZV6OBCG41yU7Hz0C4=; b=h1mRTXamLUmEYcBwA/3BTGwevXdNxDh2jYYpSOIQC3wAJEV4sc9ukH0QHyjx/RNTTN5qIL ZX+73gfdg974F6BA== 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 727E013DA8; 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 4MNUG6UBDGFDdQAAMHmgww (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 08/35] mm, slub: dissolve new_slab_objects() into ___slab_alloc() Date: Thu, 5 Aug 2021 17:19:33 +0200 Message-Id: <20210805152000.12817-9-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 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 25f102acf5b4..3222ea51fb50 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1868,6 +1868,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); } @@ -2593,36 +2595,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))) @@ -2769,13 +2741,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.32.0