Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1368374rdb; Wed, 6 Dec 2023 17:36:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IFI/E+o5wo6PMOwhAS3MzTHIkr+iQXGp8ebnx55qU3HWgjuQ6QQ381W5VY0Bku4UXNa1Krl X-Received: by 2002:a05:6a20:258f:b0:18f:97c:8245 with SMTP id k15-20020a056a20258f00b0018f097c8245mr1359222pzd.79.1701912963524; Wed, 06 Dec 2023 17:36:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701912963; cv=none; d=google.com; s=arc-20160816; b=n2PWaqqqY9M8eUdEGd6as+/ssr7KkLIYw/EBSqKHKhtVus1eGcJ5TNS/1WctQdX0p0 lmuQ2WKOGF5V4UplFrqRRCLecgOuNsfHO8SZGALO7HErG9eToDGAR2xPhpDoSXQ98rmx 64IYydaRLyVwPyGNQfwu8xz6V9luZSPTnoHCvt2Z6nHvCQhRsiyk644dBT5BTb/OpK1w zn046vZiQVEceWlbroAzhkuYpMm7CJXeAkf3T19jmdDmnLEFegZ/9hOCByz9oTYWdLbn c7JMx4zjLVCt6VOw3T8/DuWFNUOyLmglOboFMGj1ooHeu/vBnmpYHrBJt9arbBvhDvGa INag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=d4xrwcnzIgg/3xKCyJBP6G5sTr9I0S6hKhfLAnFc++o=; fh=ezGgTJoHdqijbJ6IWHiSjHZUYI0p+VPBCX/sPRmQd+E=; b=hjaR6uVMg0ghblY417KuDJbh8VgoVn6vYmvqvBqSSh+3kr1zfB/Viz9nVpWE0vmXKY FE3RUm4oUQ9p8j5SwQXQSgGvc8gFbXNdRi5eh0mGWhVjLnIt7pgnx/JRUaEkPIQjagbY kkXaX1yTZ/3SmleziXCIjEaWgF2icbN38iTbPg/Y3llvFPD0EpFe4eC1U88uNFolX5s2 Dxq1P7LuUD/a7SXjU0YcA+ofH4ntPBkJEcFIpehOWvvv0D+tPpM3ioi8QVCSjKQswkTg b88IgYXWBZrootjXnaPUx6QCL3ZG0iZjQvJLL/duKOgLiR8f8ARTM2/YP6Em4KHX497j lY9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=P2nemQi4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id w7-20020a17090a8a0700b0028515d4c7f9si122988pjn.45.2023.12.06.17.36.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 17:36:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=P2nemQi4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id EEBD980A32E6; Wed, 6 Dec 2023 17:36:00 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442975AbjLGBfq (ORCPT + 99 others); Wed, 6 Dec 2023 20:35:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442979AbjLGBfp (ORCPT ); Wed, 6 Dec 2023 20:35:45 -0500 Received: from mail-oo1-xc2c.google.com (mail-oo1-xc2c.google.com [IPv6:2607:f8b0:4864:20::c2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51FDED65; Wed, 6 Dec 2023 17:35:51 -0800 (PST) Received: by mail-oo1-xc2c.google.com with SMTP id 006d021491bc7-58df5988172so104015eaf.0; Wed, 06 Dec 2023 17:35:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701912950; x=1702517750; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=d4xrwcnzIgg/3xKCyJBP6G5sTr9I0S6hKhfLAnFc++o=; b=P2nemQi4FvJkCh+XdvdWviHfR1K9O/ZmIbjgs8YAw2cP7rke8oN6HTdQ5CzlzY9qpY bZ8Df4gBvbuv7rmo5EPVPkuFvIBFwPg8mHfW0KewLLXZvbIcsVrxv1mgBcJRQkq3heGP wLbp+D8dUZCS2Rz8ZseSUYje1lff4GJDt/uP+lgu5gYhGgkdiYt8dWpq2eXcOFfYbfhF iJK93D3MprPqb9YK+16bZQ3uXg2/rVw1WIiugRS3sAZO+WY2oPOv2OH4G1HJ97y9pFqY V31lGvH3yxCO8zVNcrSoKcXaZDoygEd+UV1wgA9yGkszIAbqT3uDc7VWgCq1sTyKKOoN 6/UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701912950; x=1702517750; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=d4xrwcnzIgg/3xKCyJBP6G5sTr9I0S6hKhfLAnFc++o=; b=uHJ9mqYPXK54SusYUF8dFdCrjhr9eC22rX8vv4GMBxcJ2fTaWzMMScPKi3fFacO0Vp zir8dJRV0vNXJZv/ST00K88NosSNMF+jfdPOxoAc1vXzuVvRh/GgOwfO0LW7hdrCwAX+ 3/FqF33BZrbNqQhNbRQRzIvEGPmXqfv0iAf5ToG4RxkbA8WumNlJXSFUTFzjBYzaCUrQ rFwZ1DequJ+ws89A7zTypoH7kXckHTUjJ8lW02MlkdmlMOWl8vagJZOmO0EVh0whChOr 28geoq8QEenLqyRbMA9bubySSMIxLisS20GPjG5wfE1aBT1+kuD8StR+O0uZj7FX5G7j 8y/Q== X-Gm-Message-State: AOJu0YwDkttJnC556yDqHZC0cq9aXgCWCDlsutP7be9jCb2TWMiYJGnK 2nLthp+rqWUFoi1rEww+byxp3cTr1i7TlA== X-Received: by 2002:a05:6359:2d96:b0:170:17eb:203c with SMTP id rn22-20020a0563592d9600b0017017eb203cmr1939426rwb.37.1701912950403; Wed, 06 Dec 2023 17:35:50 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id g3-20020a056a0023c300b006c0685422e0sm149828pfc.214.2023.12.06.17.35.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 17:35:49 -0800 (PST) Date: Thu, 7 Dec 2023 10:35:41 +0900 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Vlastimil Babka Cc: David Rientjes , Christoph Lameter , Pekka Enberg , Joonsoo Kim , Andrew Morton , 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 Subject: Re: [PATCH v2 19/21] mm/slub: remove slab_alloc() and __kmem_cache_alloc_lru() wrappers Message-ID: References: <20231120-slab-remove-slab-v2-0-9c9c70177183@suse.cz> <20231120-slab-remove-slab-v2-19-9c9c70177183@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231120-slab-remove-slab-v2-19-9c9c70177183@suse.cz> X-Spam-Status: No, score=0.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 06 Dec 2023 17:36:01 -0800 (PST) On Mon, Nov 20, 2023 at 07:34:30PM +0100, Vlastimil Babka wrote: > 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 > --- > 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); Looks good to me, Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> > > > -- > 2.42.1 > >