From patchwork Mon Nov 20 18:34:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13461893 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5AFFC197A0 for ; Mon, 20 Nov 2023 18:35:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB51C6B03AC; Mon, 20 Nov 2023 13:34:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CF1496B0425; Mon, 20 Nov 2023 13:34:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A8DF6B040E; Mon, 20 Nov 2023 13:34:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id BE1866B041D for ; Mon, 20 Nov 2023 13:34:48 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 86B25C05F9 for ; Mon, 20 Nov 2023 18:34:48 +0000 (UTC) X-FDA: 81479183856.29.A6A3406 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf13.hostedemail.com (Postfix) with ESMTP id 393F52000F for ; Mon, 20 Nov 2023 18:34:45 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=lMWFwPye; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=2WYXGeth; dmarc=none; spf=pass (imf13.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700505286; a=rsa-sha256; cv=none; b=wEMl+1fXEgk1ui67patdp3Z2xi923mIX0vcqgjQ77w8mXGTrRMNyY9dXr6B9q3EJQrbdGX 2C9SuI70uixG80Hm4cadJYV9fuqHyYYpP56CU1K9WT0RznpVHJeqSTaHEgjfgzHBP2iUvl DUgrk4ga54kj12DoMulLe9HIKRdmP5I= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=lMWFwPye; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=2WYXGeth; dmarc=none; spf=pass (imf13.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700505286; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=66Fcft8CxLuyGHKa/ns5P/AtbVP/SvETjQ6dsoMJ/dY=; b=tN02jw2hy5PgUnDrILjFKwOV/h9+tezpJBT0znXLjjILP1I3Wxveg4fa4nFPuexdzIixLE AbL/90AJyN2Lj5b89vbLtaU79zf7CJiUyvlPD2EUTbYdbeypglQbUDG8Ge8ExIBcMKs9Wy PKtybkSs3StVXY1kHj9ZqLI82vnqiL0= 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 150A71F8AB; Mon, 20 Nov 2023 18:34:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1700505284; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=66Fcft8CxLuyGHKa/ns5P/AtbVP/SvETjQ6dsoMJ/dY=; b=lMWFwPyefenNyh7/clvx/qk+stHQQ5N7hb9zBmCMeupxTPI+D6dGU/TADQ1u5M32UH+IBC fbQGY+u8lJJ8xR7VIM1PukvUBJEbUUw6tEAIWsnx+w1U5RfwCcRoqU/FIRxofF8z90UkRm 3dW6SMf1sSFeVNgXgr0JhhA3Fozsnbk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1700505284; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=66Fcft8CxLuyGHKa/ns5P/AtbVP/SvETjQ6dsoMJ/dY=; b=2WYXGethB6aGSlwwFVtp6ZCxtnU8BDR7TlSKHnTc/eY0M0e5JG5Si0/T6HS0tBqTGGaxCU vUR3uQ9DA9xC1JCA== 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 C8DFC13912; Mon, 20 Nov 2023 18:34:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ULBvMMOmW2UUMgAAMHmgww (envelope-from ); Mon, 20 Nov 2023 18:34:43 +0000 From: Vlastimil Babka Date: Mon, 20 Nov 2023 19:34:30 +0100 Subject: [PATCH v2 19/21] mm/slub: remove slab_alloc() and __kmem_cache_alloc_lru() wrappers MIME-Version: 1.0 Message-Id: <20231120-slab-remove-slab-v2-19-9c9c70177183@suse.cz> References: <20231120-slab-remove-slab-v2-0-9c9c70177183@suse.cz> In-Reply-To: <20231120-slab-remove-slab-v2-0-9c9c70177183@suse.cz> To: David Rientjes , Christoph Lameter , Pekka Enberg , Joonsoo Kim Cc: Andrew Morton , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Roman Gushchin , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Marco Elver , Johannes Weiner , Michal Hocko , Shakeel Butt , Muchun Song , Kees Cook , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, cgroups@vger.kernel.org, linux-hardening@vger.kernel.org, Vlastimil Babka X-Mailer: b4 0.12.4 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 393F52000F X-Stat-Signature: qrrzh1jh6596omcgf9thkhs68bkrh5zx X-HE-Tag: 1700505285-227739 X-HE-Meta: U2FsdGVkX18hnQEegZEC/DsES/Wlw98u2/jaiw7R99DH4X2gcRap7fldM9hjEMqaHBN32kSfI5lLE+V9r6DNszxYaV2QLQKGg95spi/LrKB8x2QSh3yz9S2mJuzVEOrwSIyRRV/XCyKGENs+3dDrN2UafhzN3QwAWIAIOKs1IJglv3B77VL6gev5auIuLqP5Y7bMxD5D9TXq3usKKZwKYdsA6HsSwSuMGqql1xeuMM3zae1itD8FwVGnCfyBS86Av1hICEz96bVbVRAuDmxiMperq4jW+QedKCq6Iap/uKOgoMOhEPeKt5l2Id3eLcW+3PHOpxTYAJ8b6D+YSz6ESdYT7t/Jpv++5SQiq2zLWxDpWe1sJMCbrrNKhz+AYsQXEuEhDvB6SQNyiZdu/L83FwfEYuzWaYda0RQ0REPOISLZQtytxSfhrErnxC7s0HwRguWTZti4iM44sHuom0F1Bg55fNW9jXARtPfz9lT3PAzAkATRwZFU0TjgDJMVzwFkcRkQ82RdjzSXBkDqK8NnJbyPdvjXKt3gYHAmPOBd5W5vvHyqgRX7r8shIUkSUU8U0dsiWN2qOj2p0uAMifizFcmYgVtGfdpgUwJ/zNaCt51px8u7pXj7pTb1iK26cEmAerc4fc1KW8iv6Ee8JW0zzhvEVM7g/OcgRP3B6lU0VnFUgDVAOotqHN0YqFbDB5v7ytj+Tme3X8coRqMX2z/bybAkr+0xGcH/a+84p++iyuvjzDfoUFr//GcWfEe28BkISa9UvcpwcyuODyTINjRDaLZGA4C8l5scqvluTHK0wNpPCx0pzA7q7n+BZsPPRe5RndIvIOZ/zx3BpVUnq+PJCYpH0/66pdA54Hs5rjszEDtNPdWppeqCgMz4p3zrSYccWcYZrcuz/RFBz1UbVgmuF6RpYOdlTNlaBeofco87jvAkU6YZAjXdqoelrbaQxd/mX+IZqUUuQXIRQFCpsX9 LaknxldJ zOlJOthFTeSBKac3jvkdr0vcOXpFDIGGkv4+nl9ZdlcOAsDuWgc0MwBX/jyBTrSdArc3uFpgLFR6FShgN8HG6cCqcogkuR8An9I6YU7xIPuOi1h1sida+xaznbKfhfkyRnlgodnvqH1vRPevg/kvOCgqQmzDmtbZ8bqANFxnptCP7vnFH/STkjgEmgJc97hfR0cv75V0LZi19m1I4V8GLPqQS8pzk8hw+K607NSqBBV6kC4qtbJaU1nhTlHD11ky/J0aoe+hRLzqsWP25f79Fv/b+fl9QMWXCLFKJQtC77dHBE5AuZ2ZfZ7OzE9uJCBU05GWG5JAXTeqIhjHYdH7W3Svrq0lWBzS8H5Ho37BO9cNzq2K9LX0j4Y0sYivwipT7ZmDk X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: slab_alloc() is a thin wrapper around slab_alloc_node() with only one caller. Replace with direct call of slab_alloc_node(). __kmem_cache_alloc_lru() itself is a thin wrapper with two callers, so replace it with direct calls of slab_alloc_node() and trace_kmem_cache_alloc(). This also makes sure _RET_IP_ has always the expected value and not depending on inlining decisions. Reviewed-by: Kees Cook Signed-off-by: Vlastimil Babka Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/slub.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index d6bc15929d22..5683f1d02e4f 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3821,33 +3821,26 @@ static __fastpath_inline void *slab_alloc_node(struct kmem_cache *s, struct list return object; } -static __fastpath_inline void *slab_alloc(struct kmem_cache *s, struct list_lru *lru, - gfp_t gfpflags, unsigned long addr, size_t orig_size) -{ - return slab_alloc_node(s, lru, gfpflags, NUMA_NO_NODE, addr, orig_size); -} - -static __fastpath_inline -void *__kmem_cache_alloc_lru(struct kmem_cache *s, struct list_lru *lru, - gfp_t gfpflags) +void *kmem_cache_alloc(struct kmem_cache *s, gfp_t gfpflags) { - void *ret = slab_alloc(s, lru, gfpflags, _RET_IP_, s->object_size); + void *ret = slab_alloc_node(s, NULL, gfpflags, NUMA_NO_NODE, _RET_IP_, + s->object_size); trace_kmem_cache_alloc(_RET_IP_, ret, s, gfpflags, NUMA_NO_NODE); return ret; } - -void *kmem_cache_alloc(struct kmem_cache *s, gfp_t gfpflags) -{ - return __kmem_cache_alloc_lru(s, NULL, gfpflags); -} EXPORT_SYMBOL(kmem_cache_alloc); void *kmem_cache_alloc_lru(struct kmem_cache *s, struct list_lru *lru, gfp_t gfpflags) { - return __kmem_cache_alloc_lru(s, lru, gfpflags); + void *ret = slab_alloc_node(s, lru, gfpflags, NUMA_NO_NODE, _RET_IP_, + s->object_size); + + trace_kmem_cache_alloc(_RET_IP_, ret, s, gfpflags, NUMA_NO_NODE); + + return ret; } EXPORT_SYMBOL(kmem_cache_alloc_lru);