From patchwork Mon Nov 13 19:13:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13454373 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 8D49CC072A2 for ; Mon, 13 Nov 2023 19:15:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8644A6B0283; Mon, 13 Nov 2023 14:14:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 753E66B0287; Mon, 13 Nov 2023 14:14:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 385AC6B028B; Mon, 13 Nov 2023 14:14:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id EB4DE6B028A for ; Mon, 13 Nov 2023 14:14:18 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C4C8F16010E for ; Mon, 13 Nov 2023 19:14:18 +0000 (UTC) X-FDA: 81453881796.18.B5FA6F1 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf13.hostedemail.com (Postfix) with ESMTP id DDFD52000F for ; Mon, 13 Nov 2023 19:14:16 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Cb9azOi+; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=YZzAxb8Q; spf=pass (imf13.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699902857; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Yc0ydpEKadjGMZmR6AOilRcjjCaikOgVLMhJfLa5KNY=; b=X6d905bGX0OzOKJo57CLJe3zjY3yaWBltgXjgVTMPt+R8xwIQYwFDWh6LnhiFxE5qkUwCS 21DkDZOivoSwD7POCque2woJFQNi9fsplsDbw3JcEaFwciTehdo5xV+nOQ3aEtjQBJlhFo 2F+x21rrDPCZto51kj3dLSBCGGMRq2U= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699902857; a=rsa-sha256; cv=none; b=lmmoahBqLNK9G2IgqUDK3BuaBea+wFjqVH8bsRxl+kUf83JQhH45iOaTxVdjK9GbT1zml6 k8lU7JVPiAbhcE1QAlp7PjYEtqwak8JQ+JbJ9a7qvLM1aGZpFrtUFcf9UkUN0YzxqT9luc lzDZRo62mfrICS5aeaybxVxs4BJPMPE= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Cb9azOi+; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=YZzAxb8Q; spf=pass (imf13.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none 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-out1.suse.de (Postfix) with ESMTPS id 893D52193C; Mon, 13 Nov 2023 19:14:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1699902855; 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=Yc0ydpEKadjGMZmR6AOilRcjjCaikOgVLMhJfLa5KNY=; b=Cb9azOi+79RTNG1eEAaRK2qKO08RdjEozYg5VQaWSgjm9ZtEhKXDtBAnNZSXPOGfqbZ5Yx zjyoWUbZWmftG6lgXdDLymTg9Eq0TbgJJoTL9ePBdM+V3LwH5TQf8gQMZUYvaz7iGhzAtV Qnmt4KB+99CZs9Oky9jRP7dc8P9XkBY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1699902855; 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=Yc0ydpEKadjGMZmR6AOilRcjjCaikOgVLMhJfLa5KNY=; b=YZzAxb8QZCafpYhSWsUv7cmsWbx/IMh0AC7UrukpeAEDxfHnpnbLPFz7TSL4WQSuD7NdVi vwsIBz9/OyMbwQCw== 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 3EDFC13398; Mon, 13 Nov 2023 19:14:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id eOW7Dod1UmVFOgAAMHmgww (envelope-from ); Mon, 13 Nov 2023 19:14:15 +0000 From: Vlastimil Babka To: David Rientjes , Christoph Lameter , Pekka Enberg , Joonsoo Kim Cc: Andrew Morton , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Roman Gushchin , linux-mm@kvack.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Marco Elver , Johannes Weiner , Michal Hocko , Shakeel Butt , Muchun Song , Kees Cook , kasan-dev@googlegroups.com, cgroups@vger.kernel.org, Vlastimil Babka Subject: [PATCH 18/20] mm/slub: remove slab_alloc() and __kmem_cache_alloc_lru() wrappers Date: Mon, 13 Nov 2023 20:13:59 +0100 Message-ID: <20231113191340.17482-40-vbabka@suse.cz> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231113191340.17482-22-vbabka@suse.cz> References: <20231113191340.17482-22-vbabka@suse.cz> MIME-Version: 1.0 X-Rspamd-Queue-Id: DDFD52000F X-Rspam-User: X-Stat-Signature: gkrk5eha7nutsrfpsxsyio5qpnzt4pgb X-Rspamd-Server: rspam03 X-HE-Tag: 1699902856-297434 X-HE-Meta: U2FsdGVkX19mSMCr4xGQLpQqISDh9+tdcSLL/tMC4yQNoInZiSwS3DqJmfJ0V1YTICh4CqigBca5rbmNQpTCoPP4RwWWwz03H/HyuXAgEwoMvds0tK3dYNuA9b/0zJS+iT5kNbyEhrOMzha3jajttiYqM8c0sWxbusXLhQAEeEmXotmTS2ZgunDXAc9Z7PNOyIPhczC4w4DIxXR6X0CjZW7u8sbEpIP5VwczufXCGPDQOVmAYh48lIQX5geLnnrr5JiDpjYRAyHvTTj1sd/PdLeOVmrr4Zp1cgQx3JzV3yL759PT2nktMWTdjFnYZEllyOIV2piY7j584oZwHp6J990afDP0T7Of6PwwR3Y2JPCuOk8dD2cokk0RQO3LgwWzmcQbqXWUaBZpgYJK01ZpVdL+yRR5HXSxrRlVfjF4UUMBscXPlHJktSNNpNvL4qe5Y23YXBSGeomrd9L1QEiR7fJof74224nfudhv6vHAqUyRcAbj2ndyQNeHZcjuf/lj1UFEk69JAsH7wdRO4dWqCBDqzvUPQT9+NvyBjCcDS3gYL6QgWC6xfKVCkrnGgzpBWLFowk4H4ZAg0b16bl/jgthm2TU72QWSyYdWbRMbVFyahzfy5DyktvoZwGbkYrNy1ELhRBn0jdBw2PDN6HUtXRUHw/LHtJS2UzMfEsNdWj1gBKADW4oUH1f6BwjHSPwh1TgAJtoHt8EuOILsVwDtwnVW64SdyN0vKbrced7/SsIFmF1S9V49+YYct7+oTs5B4AUTrC52Dwk8hxSYLeW4jiBhS569Fq3o+GQNGTGbJsQte2BLbY+YREBVfzHv8773h/q5yfrBNqYpE9ozkmDemq7Lu2AU2MD8PU1qa2JG2ssowVn5Uc+3adKUe+vrm/RwYzgmIg5/xbRQjXJIXoVFgDtUSXXlDO6peTjlCfvXkzsGDAIJ0qbgTPF0HkuM+VFExmTTXedWGhGGu87pv1K +sYuOmrX TBKd5uR4t49kF/chLfkEaLwTT6JqU+RhMfUybs2KUgo+5qiMwZnotTcftqHuUmm4Bxxj/r9mRcMqIeBCGvSa1BsRKfW4SEbeNdG2kfaaKztwwaV0SJjJJRq3UWH/qcYuAJOqLwAQWL5hA21lWrvMFPRvc4beGXeGEyYlc6k+pZo4SfR4y09uQJqaWSYHfp4OTXrJAbb5LZcBGRoMebr1afiMDDU0ygDOw0csSbi+L0WX77HcpNY6BfvsEIczN3Ua5ptMruFW1cWdr9GA2pz/KlRSM76AUAok2s1BLuOrytZrk3xTzqiUfOVIFvQ== 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. Signed-off-by: Vlastimil Babka Reviewed-by: Kees Cook --- mm/slub.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index b44243e7cc5e..d2363b91d55c 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3821,39 +3821,33 @@ 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); void *kmem_cache_alloc_node(struct kmem_cache *s, gfp_t gfpflags, int node) { - void *ret = slab_alloc_node(s, NULL, gfpflags, node, _RET_IP_, s->object_size); + void *ret = slab_alloc_node(s, NULL, gfpflags, node, _RET_IP_, + s->object_size); trace_kmem_cache_alloc(_RET_IP_, ret, s, gfpflags, node);