Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4398432ioa; Wed, 27 Apr 2022 03:01:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzD7/xHKW+DKg/rAQ6Zb1MSmX0ZWxo6o6kmSqtwIAUebdmYoOhwP2OGBf/N2SJPx329tw5T X-Received: by 2002:a05:6a00:1895:b0:50a:6a91:e833 with SMTP id x21-20020a056a00189500b0050a6a91e833mr29378229pfh.26.1651053693290; Wed, 27 Apr 2022 03:01:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651053693; cv=none; d=google.com; s=arc-20160816; b=NEDXUOErunMDb2KMwWVe1rdtnTwQzH8AlMPWkiPLGkpWTdwj3WAPgXt5kXf/UauJu4 H974CgZZNLiic2V9znBi4mTQfTNBtxayzYnpOrz1GW8jMdZnh4VEmivVni7HKOP3MslL qQ7Ehe0saAZgKjtk15+n2dqy3izk/6Xxaj7XIJp9Q0fcLOhffRvZiYqRI1isBuiTf7sr qDd+Hb2C3mLp4nyIatBE6Rg5cI0sdIYoAvzSCqriqBpZToastRern3kKPMvQxxoeIU39 ZOZa353oDyiteiz+l4Y8LQ+MHmsvQx52BuM6U1eUb0mhJ1ZIP1/Q4FwYNhVeK0f3Rc9r 9oYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature; bh=dvV2nJBzNibHRnWgDFAzy5khPlxaeLLn78Tf6Vn7WqQ=; b=Vqm/mEgUQskxbo6YWIVdgRLLiSWKvn4qqlXJbSzR5LVwp5hK4zWyN1ZY5JpGrW28lx dyHXhcuh9rmhysya2EIF63iGUaeZemZvyKuvowK45DcxP6+rQeeL2mO47Ruhokp8WC54 uVqvb7YcZZrAj7/UgtMBV8wvUoe+2WNlTlANOJzDGoVfMZh4u96I+MVWU9j3Vjlfqyzz +v2i+POicvtNiQDElnAvqB0fWEX4AigRS2OaQuv9xS08cfofKgLZWHo5GiW2R3rxKpFD ODqgyY843FGRJs3P8fwXUM+rx96aqzUUwT2rOmnTsoZ+b8J1rEWvGWuVyFaQATEKuoDz vasg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=ssga9CwJ; dkim=neutral (no key) header.i=@suse.cz; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id l17-20020a170902f69100b0015cdd65c1easi1232127plg.565.2022.04.27.03.01.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 03:01:33 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=ssga9CwJ; dkim=neutral (no key) header.i=@suse.cz; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2A84B2D71DF; Wed, 27 Apr 2022 02:28:34 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349014AbiDZRTT (ORCPT + 99 others); Tue, 26 Apr 2022 13:19:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353458AbiDZRSQ (ORCPT ); Tue, 26 Apr 2022 13:18:16 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D69526E8 for ; Tue, 26 Apr 2022 10:15:08 -0700 (PDT) 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 BD090210EA; Tue, 26 Apr 2022 17:15:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1650993306; 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=dvV2nJBzNibHRnWgDFAzy5khPlxaeLLn78Tf6Vn7WqQ=; b=ssga9CwJbOWK1c4zQuqN7zMjsjrJvUiAf4lSZv8141vNqAz90Qjw7dA9+A2nDDREXMIRE9 AOT9tfFzRYlvmgiSHhZe6hzSBCvGTq2L6nZUi85XYXb/zko4VJWac1w2vRaEfvmB2UHYJi X24l560Rqy63nd+qvycSDJdbMmLf5CI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1650993306; 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=dvV2nJBzNibHRnWgDFAzy5khPlxaeLLn78Tf6Vn7WqQ=; b=qcui5A9TMEGwqvNzmE38B/X/KwhTA7UQOoUXO4fZsVpXyoZY+WzFaXBBJecilbkoitQMaA 7Oe+6lmuxppQXtAw== 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 8EBAD13AD5; Tue, 26 Apr 2022 17:15:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Vk26IZooaGIGFQAAMHmgww (envelope-from ); Tue, 26 Apr 2022 17:15:06 +0000 Message-ID: <37811df5-b0f5-355b-41cf-2e491fb3cd6c@suse.cz> Date: Tue, 26 Apr 2022 19:15:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Content-Language: en-US To: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: Marco Elver , Matthew WilCox , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Roman Gushchin , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20220414085727.643099-1-42.hyeyoo@gmail.com> <20220414085727.643099-9-42.hyeyoo@gmail.com> From: Vlastimil Babka Subject: Re: [PATCH v2 08/23] mm/slab_common: make kmalloc_large_node() consistent with kmalloc_large() In-Reply-To: <20220414085727.643099-9-42.hyeyoo@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/14/22 10:57, Hyeonggon Yoo wrote: > Move tracepoints into kmalloc_large_node() and add missing flag fix code. > > Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Hm so there's a problem with the tracepoint's caller. kmalloc_large() is only called from kmalloc() which is an inline thus the callsite of kmalloc() calls directly kmalloc_large(). So when kmalloc_large() does "trace_kmalloc(_RET_IP_, ...)" the _RET_IP_ is the callsite of kmalloc(), which is what we want. But with kmalloc_large_node()... > --- > mm/slab_common.c | 6 ++++++ > mm/slub.c | 22 ++++------------------ > 2 files changed, 10 insertions(+), 18 deletions(-) > > diff --git a/mm/slab_common.c b/mm/slab_common.c > index e72089515030..cf17be8cd9ad 100644 > --- a/mm/slab_common.c > +++ b/mm/slab_common.c > @@ -955,6 +955,9 @@ void *kmalloc_large_node(size_t size, gfp_t flags, int node) > void *ptr = NULL; > unsigned int order = get_order(size); > > + if (unlikely(flags & GFP_SLAB_BUG_MASK)) > + flags = kmalloc_fix_flags(flags); > + > flags |= __GFP_COMP; > page = alloc_pages_node(node, flags, order); > if (page) { > @@ -966,6 +969,9 @@ void *kmalloc_large_node(size_t size, gfp_t flags, int node) > ptr = kasan_kmalloc_large(ptr, size, flags); > /* As ptr might get tagged, call kmemleak hook after KASAN. */ > kmemleak_alloc(ptr, size, 1, flags); > + trace_kmalloc_node(_RET_IP_, ptr, > + size, PAGE_SIZE << order, > + flags, node); ... the _RET_IP_ here would be __kmalloc_node() which is not useful. > return ptr; > } > diff --git a/mm/slub.c b/mm/slub.c > index 640712706f2b..f10a892f1772 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -4396,15 +4396,8 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node) > struct kmem_cache *s; > void *ret; > > - if (unlikely(size > KMALLOC_MAX_CACHE_SIZE)) { > - ret = kmalloc_large_node(size, flags, node); > - > - trace_kmalloc_node(_RET_IP_, ret, > - size, PAGE_SIZE << get_order(size), > - flags, node); Here it was OK because __kmalloc_node is expanded from something inline coming from slab.h. > - > - return ret; > - } > + if (unlikely(size > KMALLOC_MAX_CACHE_SIZE)) > + return kmalloc_large_node(size, flags, node); > > s = kmalloc_slab(size, flags); > > @@ -4861,15 +4854,8 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags, > struct kmem_cache *s; > void *ret; > > - if (unlikely(size > KMALLOC_MAX_CACHE_SIZE)) { > - ret = kmalloc_large_node(size, gfpflags, node); > - > - trace_kmalloc_node(caller, ret, > - size, PAGE_SIZE << get_order(size), > - gfpflags, node); > - > - return ret; > - } > + if (unlikely(size > KMALLOC_MAX_CACHE_SIZE)) > + return kmalloc_large_node(size, gfpflags, node); And here it even forgets the 'caller'. > > s = kmalloc_slab(size, gfpflags); >