From mboxrd@z Thu Jan 1 00:00:00 1970 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 CFECFC00144 for ; Mon, 1 Aug 2022 13:26:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2F0468E0001; Mon, 1 Aug 2022 09:26:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 29F3F6B0072; Mon, 1 Aug 2022 09:26:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 167BD8E0001; Mon, 1 Aug 2022 09:26:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 079F16B0071 for ; Mon, 1 Aug 2022 09:26:34 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id CE301120B14 for ; Mon, 1 Aug 2022 13:26:33 +0000 (UTC) X-FDA: 79751098266.11.91FF0C6 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by imf06.hostedemail.com (Postfix) with ESMTP id 720801800EB for ; Mon, 1 Aug 2022 13:26:33 +0000 (UTC) Received: by mail-pl1-f173.google.com with SMTP id z19so10450142plb.1 for ; Mon, 01 Aug 2022 06:26:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=pUtXn4Srqiw98c6ZMfop0pBP7n47z1GuwAi8jghCZ+s=; b=nssGIGZzaChy7gP3PfoTd0xKjIuhzB+EN89wB23nWZKgpFHs8X4ZYyZMT2A4Dably7 K0m3rkRyhLPmzsbIAEa5dNlOoOKcDAu3abQDIpGO88sSiPlknQ8lUAM9fMbIkbdQLCxo DIfkQzOonSJl/nx3G5ktS1Y8/nO5sr/FE/bWpdlONqICKh2Bd0j4/v4JEJq5Gp/I+3J7 ULAhimTAlK6h5TuSmZaNN5OALJkHQZWF6rFMeaSUu133a8AapB7pIWcTz7bWkrqYYyVn iicZd5LNfkNW+CQR37jSKBPwvjPvUBwQl64LUtTqNaI5nREpirkXUKGRvB9OLKhhflPF bddQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=pUtXn4Srqiw98c6ZMfop0pBP7n47z1GuwAi8jghCZ+s=; b=GDzowqwj5PJIjTVjYNhy3FzBl2hCcuuHqyZ898wO7JUR5InX3GV0GKIriNXYPYtlVN hDb2896dbXBTVIZK2rhBtnDTMu2ajkjfa7JqUyVn7+6++P7/2p5Jd7b2WHCHIhHZlOzQ Dg0Y7mxqPoF17wgYM55zvD2qzbuUMFVTHhtYnL+52A/TndO8+2OxZnrgdqps1sp3X9Vf 4oo+X1aru3liJSQbu4Zib4hqkZiXjgxTywwZUesfAnrbt4RMI8De1AZhryM+6yZ+81Rx bF8kWLjjEYRNHKYm75I098MJ4XfQDRZ/tydNuCgGLrrsZm2uVsq5qg8na7iOlOW60xpi t4wg== X-Gm-Message-State: ACgBeo0C+ea+k+C77DJZ+kTVBNoR5W/cES9sw1UVL3IeI2cj12Uyv/YT wpjeTjnrWQ2uBKkL3DqfS/k= X-Google-Smtp-Source: AA6agR7UbWrfPscOda8d2YX/X0p2+YAfWSSfxporgvGpT/DyslGeD5zt05U/LKt0ZZj/wqamXvWjhA== X-Received: by 2002:a17:902:f549:b0:16c:483f:3a9f with SMTP id h9-20020a170902f54900b0016c483f3a9fmr16623571plf.134.1659360392234; Mon, 01 Aug 2022 06:26:32 -0700 (PDT) Received: from hyeyoo ([114.29.91.56]) by smtp.gmail.com with ESMTPSA id n12-20020a170903110c00b0016c1b178628sm9651426plh.269.2022.08.01.06.26.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Aug 2022 06:26:31 -0700 (PDT) Date: Mon, 1 Aug 2022 22:26:24 +0900 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Vlastimil Babka Cc: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Roman Gushchin , Joe Perches , Vasily Averin , Matthew WilCox , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v3 06/15] mm/slab_common: fold kmalloc_order_trace() into kmalloc_large() Message-ID: References: <20220712133946.307181-1-42.hyeyoo@gmail.com> <20220712133946.307181-7-42.hyeyoo@gmail.com> <2e252179-0ffe-0d9c-9340-77e46f6ffdfd@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2e252179-0ffe-0d9c-9340-77e46f6ffdfd@suse.cz> ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659360393; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=pUtXn4Srqiw98c6ZMfop0pBP7n47z1GuwAi8jghCZ+s=; b=KoU83TkcsdPEAUycfJiOQ2YHOVfcy9gjvRH9s8ky3heikxQfoYHObJDwJXC+fN0VSuT/PX zP27DCJJBMXQT/oWGGsLn3MtGVNeAWGJosSxuVM13wLDG+579alfqghyz7zt3aogmMZXP8 bXloizn5I2KPPcKweguNEl9Afx2nxow= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=nssGIGZz; spf=pass (imf06.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.214.173 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659360393; a=rsa-sha256; cv=none; b=3Zp1C/QGgQrJDhYMCnAmdHqiAJ6H5ghBCNyV0sM2e3cJXmJw15SW2/Xf+YuZHWOlE3UKyM i5+YcMDTVjbIBC61xe5TWDWPytnfAMRZrU/ZZvjkFiUl/GWXWF6g1nVQv95lbh3EJ1/oyN n5EoyBaXGFyAUD2ZBSnl/p3qzHHUX5M= X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=nssGIGZz; spf=pass (imf06.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.214.173 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: i1zoftxep98ewfxree34thjjh4bzhpqj X-Rspamd-Queue-Id: 720801800EB X-Rspamd-Server: rspam10 X-HE-Tag: 1659360393-981893 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: On Thu, Jul 28, 2022 at 05:23:29PM +0200, Vlastimil Babka wrote: > On 7/12/22 15:39, Hyeonggon Yoo wrote: > > There is no caller of kmalloc_order_trace() except kmalloc_large(). > > Fold it into kmalloc_large() and remove kmalloc_order{,_trace}(). > > > > Also add tracepoint in kmalloc_large() that was previously > > in kmalloc_order_trace(). > > > > Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> > > Reviewed-by: Vlastimil Babka > Thank you for review. > Hmm noticed a small change in how we call trace_kmalloc() which will now > include the __GFP_COMP. Good catch. > I think we could just call alloc_pages() from > kmalloc_large() with flags | __GFP_COMP instead of doing flags |= > __GFP_COMP; first. I'll consider that in next version. > AFAICS both kasan_kmalloc_large() and kmemleak_alloc() > will filter it out anyway. AFAIK not passing __GFP_COMP to both kasan_kmalloc_large() and kmemleak_alloc() will affect their behavior. - kasan_kmalloc_large() only checks if flag has __GFP_DIRECT_RECLAIM, - kmemleak_alloc() only use it to allocate kmemleak_object from slab/pool, which does not require __GFP_COMP. simply calling alloc_pages() with flags | GFP_COMP kasan_kmalloc_large() with flags kmemleak_alloc() with flags trace_kmalloc() with flags will be okay. BTW this is fixed after patch 9. > > --- > > include/linux/slab.h | 22 ++-------------------- > > mm/slab_common.c | 14 +++----------- > > 2 files changed, 5 insertions(+), 31 deletions(-) > > > > diff --git a/include/linux/slab.h b/include/linux/slab.h > > index a0e57df3d5a4..15a4c59da59e 100644 > > --- a/include/linux/slab.h > > +++ b/include/linux/slab.h > > @@ -489,26 +489,8 @@ static __always_inline void *kmem_cache_alloc_node_trace(struct kmem_cache *s, g > > } > > #endif /* CONFIG_TRACING */ > > > > -extern void *kmalloc_order(size_t size, gfp_t flags, unsigned int order) __assume_page_alignment > > - __alloc_size(1); > > - > > -#ifdef CONFIG_TRACING > > -extern void *kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order) > > - __assume_page_alignment __alloc_size(1); > > -#else > > -static __always_inline __alloc_size(1) void *kmalloc_order_trace(size_t size, gfp_t flags, > > - unsigned int order) > > -{ > > - return kmalloc_order(size, flags, order); > > -} > > -#endif > > - > > -static __always_inline __alloc_size(1) void *kmalloc_large(size_t size, gfp_t flags) > > -{ > > - unsigned int order = get_order(size); > > - return kmalloc_order_trace(size, flags, order); > > -} > > - > > +void *kmalloc_large(size_t size, gfp_t flags) __assume_page_alignment > > + __alloc_size(1); > > /** > > * kmalloc - allocate memory > > * @size: how many bytes of memory are required. > > diff --git a/mm/slab_common.c b/mm/slab_common.c > > index 6c9aac5d8f4a..1f8af2106df0 100644 > > --- a/mm/slab_common.c > > +++ b/mm/slab_common.c > > @@ -932,10 +932,11 @@ gfp_t kmalloc_fix_flags(gfp_t flags) > > * directly to the page allocator. We use __GFP_COMP, because we will need to > > * know the allocation order to free the pages properly in kfree. > > */ > > -void *kmalloc_order(size_t size, gfp_t flags, unsigned int order) > > +void *kmalloc_large(size_t size, gfp_t flags) > > { > > void *ret = NULL; > > struct page *page; > > + unsigned int order = get_order(size); > > > > if (unlikely(flags & GFP_SLAB_BUG_MASK)) > > flags = kmalloc_fix_flags(flags); > > @@ -950,19 +951,10 @@ void *kmalloc_order(size_t size, gfp_t flags, unsigned int order) > > ret = kasan_kmalloc_large(ret, size, flags); > > /* As ret might get tagged, call kmemleak hook after KASAN. */ > > kmemleak_alloc(ret, size, 1, flags); > > - return ret; > > -} > > -EXPORT_SYMBOL(kmalloc_order); > > - > > -#ifdef CONFIG_TRACING > > -void *kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order) > > -{ > > - void *ret = kmalloc_order(size, flags, order); > > trace_kmalloc(_RET_IP_, ret, NULL, size, PAGE_SIZE << order, flags); > > return ret; > > } > > -EXPORT_SYMBOL(kmalloc_order_trace); > > -#endif > > +EXPORT_SYMBOL(kmalloc_large); > > > > #ifdef CONFIG_SLAB_FREELIST_RANDOM > > /* Randomize a generic freelist */ > -- Thanks, Hyeonggon