Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3342337iob; Mon, 16 May 2022 20:03:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAdTDItYqQ6ZNu0HwZ/xVWN+CMimFGF4R5frYYqQuvoWhuYwdB+24NRBCcEEoyb8UKIzQF X-Received: by 2002:a17:90b:1249:b0:1df:257a:539a with SMTP id gx9-20020a17090b124900b001df257a539amr13917963pjb.47.1652756619755; Mon, 16 May 2022 20:03:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652756619; cv=none; d=google.com; s=arc-20160816; b=oNZ+//VeTYltZcFzzZQo13dKgSog3JTBSanKg8CHVaymXQ0lfVb8prgXybN/LA5SN3 ER/BT8U8BHgwxj66ZEdTgE2NyxjS3xCTtxwbd7kifFAWQW/8A4g4z0bHie9/gAcuxI2L 5I+vBIkPD4MqBNGGC8uvRoL2TMa/xa4sRHxCF6RNUqU1x3JWhT8W0uhjjc2KtMaWKvNp ZIqkLrBcXq32OhLzt8rdYHJGs8sshHOUqUQulN/UPXNtw+g5Xe4atVa0xLFPjMveUFW9 gpOU/kvqSflHGdV+7PaI8bLaTrYbVYPgEOhYM5MBYIrsVA+yJmcGVQ1ArLo3sQI1z60H 2umQ== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=HovTC6FiGf3ja40F9c2fQ83eYmm4tQXXZRRsLYbnnew=; b=Pmz+QF49KU9TKdY8i2SS/3LvVmsuJ92h5GDWjAONZCcGD6slGG7e4yK5Bjn+kDFlR6 pmrfWsrNXVQ8xOxxqoEq4H2eoFHf2PH9y28AzdqSPZ0PaG6WmJIRD++dJ/6+WL0S1Yar ph2VTqoRn2jigE8c3MgrRRJ9mbkLFdSshrBo8f3Y3O+RfEpaEJST/r0D4SYdocwcNODq aWGFtTj8bhsQOggJcglj7GXEytt3JWNP7NGbZGTCDCCheycjIFy1+2tCf+FGM8a937IR fkxchl66pEJdMhnhsSP/xeBae5w0KD+VxjZMvj5sSgeqEUnZwA3KYpmZVjKVi+koK5Pq sA+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=C4uCBBXf; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s14-20020a056a0008ce00b005103c78638asi15376290pfu.205.2022.05.16.20.03.27; Mon, 16 May 2022 20:03:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=C4uCBBXf; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348255AbiEPVmq (ORCPT + 99 others); Mon, 16 May 2022 17:42:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240045AbiEPVmp (ORCPT ); Mon, 16 May 2022 17:42:45 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E68F41FAC for ; Mon, 16 May 2022 14:42:43 -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-out2.suse.de (Postfix) with ESMTPS id 5D8741F92F; Mon, 16 May 2022 21:42:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1652737362; 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=HovTC6FiGf3ja40F9c2fQ83eYmm4tQXXZRRsLYbnnew=; b=C4uCBBXfemb8MP3PaJvLlMu9yHsXfZqNCeK0/wzvpjZNdf6aNz5aWaRHx0KH4pl4kueyrB FJGLewWXchFIshCwRnNFYpncf2B63+m1+M3wbEGERstAdf37CLhR/B6chyUuSRAhyXfDZR uzcaEocfzBK/NNpFy9C8jpi5Q5KkWpM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1652737362; 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=HovTC6FiGf3ja40F9c2fQ83eYmm4tQXXZRRsLYbnnew=; b=6x2VDOQWPLaOaelqHEiu5a2K30qWoyibm1xQOrvQu2BG7G0HPFg7eFDozfYY3bXC2VEcxw vwDcUi/pKd3NTMBQ== 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 189A113AAB; Mon, 16 May 2022 21:42:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6GyHBFLFgmIBOwAAMHmgww (envelope-from ); Mon, 16 May 2022 21:42:42 +0000 Message-ID: <8eccb3bc-e6b1-354b-e1de-bd3d896dcb35@suse.cz> Date: Mon, 16 May 2022 23:41:27 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH] tracing: add ACCOUNT flag for allocations from marked slab caches Content-Language: en-US To: Shakeel Butt , Vasily Averin Cc: Roman Gushchin , Andrew Morton , Joonsoo Kim , David Rientjes , Pekka Enberg , Christoph Lameter , kernel@openvz.org, Linux MM , LKML , Michal Hocko , Hyeonggon Yoo <42.hyeyoo@gmail.com> References: <1fd21e25-b095-e055-fc2e-abda640a0575@openvz.org> From: Vlastimil Babka In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 5/16/22 21:10, Shakeel Butt wrote: > On Mon, May 16, 2022 at 11:53 AM Vasily Averin wrote: >> >> Slab caches marked with SLAB_ACCOUNT force accounting for every >> allocation from this cache even if __GFP_ACCOUNT flag is not passed. >> Unfortunately, at the moment this flag is not visible in ftrace output, >> and this makes it difficult to analyze the accounted allocations. >> >> This patch adds the __GFP_ACCOUNT flag for allocations from slab caches >> marked with SLAB_ACCOUNT to the ftrace output. >> >> Signed-off-by: Vasily Averin >> --- >> mm/slab.c | 3 +++ >> mm/slub.c | 3 +++ >> 2 files changed, 6 insertions(+) >> >> diff --git a/mm/slab.c b/mm/slab.c >> index 0edb474edef1..4c3da8dfcbdb 100644 >> --- a/mm/slab.c >> +++ b/mm/slab.c >> @@ -3492,6 +3492,9 @@ void *__kmem_cache_alloc_lru(struct kmem_cache *cachep, struct list_lru *lru, > > What about kmem_cache_alloc_node()? > >> { >> void *ret = slab_alloc(cachep, lru, flags, cachep->object_size, _RET_IP_); >> >> + if (cachep->flags & SLAB_ACCOUNT) > > Should this 'if' be unlikely() or should we trace cachep->flags > explicitly to avoid this branch altogether? Hm I think ideally the tracepoint accepts cachep instead of current cachep->*size parameters and does the necessary extraction and modification in its fast_assign. > >> + flags |= __GFP_ACCOUNT; >> + >> trace_kmem_cache_alloc(_RET_IP_, ret, >> cachep->object_size, cachep->size, flags); >> >> diff --git a/mm/slub.c b/mm/slub.c >> index ed5c2c03a47a..670bbfef9e49 100644 >> --- a/mm/slub.c >> +++ b/mm/slub.c >> @@ -3231,6 +3231,9 @@ void *__kmem_cache_alloc_lru(struct kmem_cache *s, struct list_lru *lru, >> { >> void *ret = slab_alloc(s, lru, gfpflags, _RET_IP_, s->object_size); >> >> + if (s->flags & SLAB_ACCOUNT) >> + gfpflags |= __GFP_ACCOUNT; >> + >> trace_kmem_cache_alloc(_RET_IP_, ret, s->object_size, >> s->size, gfpflags); >> >> -- >> 2.25.1 >>