Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3846025pxj; Mon, 24 May 2021 16:43:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0FpNLp34Z0L2FMVcpOph2HqMLtBEnwWYN8nR2DQkQtsaQK+VScobHjAqK6Vdz7HoOZyyf X-Received: by 2002:a05:6402:50d2:: with SMTP id h18mr29011068edb.10.1621899787748; Mon, 24 May 2021 16:43:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621899787; cv=none; d=google.com; s=arc-20160816; b=cptfG9mvEC+UfTg8dv2f1CEUPcq/j320smtnQOC7QwBAvMjqKbHk1w5NALg0B/tAE8 qmkM1RpUh3qUpfpU6dSN4EImx3RniRmdJltLvdlXBizvAWk0wW+gz2bRNB3Qt5c/Ifsv Jh6jb5wL2RoTmYSbc60yeVF1l/sHQTVgj/e1v6QoAjpnjaS8FWjhU9V01eTexd64+Evu tesRtYurM7aQx5/Wqy4rzJBtO1DlwoWbJz7gXR64/DfvwHGB0HOXjif5mudFiKH3yGg+ YXJaeEsntLLyGZB07yhPChIQicb9pgpGG+hHBp1HUdXWJL+LPgfbgarDcapd8CAgc05g WEdQ== 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=tig2eA8Wm758Dr7faUoCLnxKmtvXTVhcR/nltsYptMY=; b=DbhuCBMtnl0EmBzTwiphx6HVmHmG3v72/ltWDoQcjxcAHOeaGdtFSFqrlqPeC2ZT32 o7J4u3dBn+fPTVj0WE5xD8igghweazlGpRRj5fENOU9G7xOYXjVESbzIDppgEgSBDs3m zZCNM50I5KGRTW0FY43EAUB2XnmDfJeC26WhS2knDL/9c+EDPAkGPLZI4iUToocdzfii LSGmrIY8jeMYUt2rmIFnvluXabsMFdI+0x4U8f5KqxEdp461/KSUA6HcZrJj+PQUwjPt r9IbYXCWkeueHEDd14t7hEF0KsfuHSpOpPsGUNk4dcyFPRkmYAw5/LFrmDyM14OvhzSM u3Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=W95lkie0; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=brdgGJUH; 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 h10si11461394edv.387.2021.05.24.16.42.45; Mon, 24 May 2021 16:43:07 -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=W95lkie0; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=brdgGJUH; 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 S229963AbhEXXml (ORCPT + 99 others); Mon, 24 May 2021 19:42:41 -0400 Received: from mx2.suse.de ([195.135.220.15]:50692 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229854AbhEXXmU (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=tig2eA8Wm758Dr7faUoCLnxKmtvXTVhcR/nltsYptMY=; b=W95lkie0++iNBRygHiOD8HtHFg83IEXp9u/DPb9Miui4K7XapaxeupuL7fH2VBfSdg8t5v I2qQUhzM4/8rAccH2IyX0yY0W3kDf/vn5UUgKqdYpxU+tY4mRY+tzj4Cbu8h8ChfBpKkrw 1PJ8d3SsfweZ6KGIVsruk4Vja8dHSi4= 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=tig2eA8Wm758Dr7faUoCLnxKmtvXTVhcR/nltsYptMY=; b=brdgGJUHkP+/mQvGiqKV41bN1djB9U8c/rAZRGi8aj3Zb7ubEqc9ocplMt/1Gezwn6xMTx oLIqhkfL67UYGoCQ== Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 41C1CAF2F; 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 06/26] mm, slub: dissolve new_slab_objects() into ___slab_alloc() Date: Tue, 25 May 2021 01:39:26 +0200 Message-Id: <20210524233946.20352-7-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 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 misuse. Signed-off-by: Vlastimil Babka --- mm/slub.c | 50 ++++++++++++++++++-------------------------------- 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 7973bcd42bc7..9d1d872f5ab9 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1839,6 +1839,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); } @@ -2571,36 +2573,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))) @@ -2747,13 +2719,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