Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1789420iob; Thu, 19 May 2022 14:54:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdM0Pjt8nkwYuVUpklDqI1qSF8DW2+Ne56Jz+zeZK0kxJTHFh72OVldP4zMsC8ztkAUHlu X-Received: by 2002:a17:90b:1c02:b0:1df:d8b8:6eb1 with SMTP id oc2-20020a17090b1c0200b001dfd8b86eb1mr5201779pjb.90.1652997242270; Thu, 19 May 2022 14:54:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652997242; cv=none; d=google.com; s=arc-20160816; b=fx0xtbOLA8I3UCuIPKJ6UWO+CgdegeQLhTrNF98W1vRO52THSNidaC+7FnK8Edk4Px YmNtBxTcOYFM6EszNqajAeqc6pGnJumuH97XFpbIktWV/bcTIKcxm9GDCp7iJjQzHPzP 81jH9z8a0LOFD6t1Gw4OlL9KP3JpT38z3Gvico1UXE8yUHLkNcV02iQf0FD7JzXwqoyV NdhbyruRGFRdYDzTKItRvG+ocAndrCD+XouDZRKadRfjXIcno9gEZcDBAvdDF9TJxc9J lgt4nHr9HA+vG6P3avVHjMYZbtFUPG/RR3sdeSZwOhsgMAYtCZQQjh8P1fEguWBYV4MH wlBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=HAlMabNFQsWctX14KAFLAhMC/BnBSj7l0knKLMC1IXM=; b=eZw6zelZXgCoYEEOSiFoA5luPX4AlAkbEKhwZIF3uS8/9/BRGa/UnG3lipD6ub/SF+ xOLeGrUFCpTNKcoo+xdL5uNdW1Lw9IEnf/PgVvoRggfgLIx2oY3NRSkOwvmsPuJ0an8w ucOxgzFMiONWerQDifHi/FZc0lps4jXH6nXm/YVi+XygaX7ShtC2JZyovtCKYPQr/SiL RCcdgAv3BwxNCIZAEVn64O7A4J6sbynGNw9A4E9eH+xK/UKdhqdyV9o64GxgHTWgzr/Q U+bqBhzZQrJPWY6qDtarfWKUhsxj5PBNVGXMSlkoq+TrR74r9j0usEV7hlXZ1eSMIVgm TVXA== ARC-Authentication-Results: i=1; mx.google.com; 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 t3-20020a17090aba8300b001d95105b9f5si784004pjr.90.2022.05.19.14.53.51; Thu, 19 May 2022 14:54:02 -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; 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 S238842AbiESOD4 (ORCPT + 99 others); Thu, 19 May 2022 10:03:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238688AbiESODy (ORCPT ); Thu, 19 May 2022 10:03:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 359D438AB for ; Thu, 19 May 2022 07:03:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C6AF4618A8; Thu, 19 May 2022 14:03:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A09DC385AA; Thu, 19 May 2022 14:03:50 +0000 (UTC) Date: Thu, 19 May 2022 10:03:48 -0400 From: Steven Rostedt To: Vasily Averin Cc: YoPOhRctb8wwbmY5@carbon, Shakeel Butt , Roman Gushchin , Vlastimil Babka , Matthew Wilcox , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Muchun Song , kernel@openvz.org, linux-kernel@vger.kernel.org, Ingo Molnar , Andrew Morton , linux-mm@kvack.org, Joonsoo Kim , David Rientjes , Pekka Enberg , Christoph Lameter , Michal Hocko Subject: Re: [PATCH v3] tracing: add 'accounted' entry into output of allocation tracepoints Message-ID: <20220519100348.101d027d@gandalf.local.home> In-Reply-To: References: <20220518160447.20a7b96f@gandalf.local.home> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,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 Thu, 19 May 2022 14:35:46 +0300 Vasily Averin wrote: > >> @@ -33,42 +35,46 @@ DECLARE_EVENT_CLASS(kmem_alloc, > >> __entry->bytes_req = bytes_req; > >> __entry->bytes_alloc = bytes_alloc; > >> __entry->gfp_flags = (__force unsigned long)gfp_flags; > >> + __entry->accounted = (gfp_flags & __GFP_ACCOUNT) || > >> + (s && s->flags & SLAB_ACCOUNT); > > > > Now you could make this even faster in the fast path and save just the > > s->flags. > > > > __entry->sflags = s ? s->flags : 0; > > > >> ), > >> > >> - TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s", > >> + TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s accounted=%s", > >> (void *)__entry->call_site, > >> __entry->ptr, > >> __entry->bytes_req, > >> __entry->bytes_alloc, > >> - show_gfp_flags(__entry->gfp_flags)) > >> + show_gfp_flags(__entry->gfp_flags), > >> + __entry->accounted ? "true" : "false") > > > > And then have: "accounted=%s": > > > > (__entry->gfp_flags & __GFP_ACCOUNT) || > > (__entry->sflags & SLAB_ACCOUNT) ? "true" : "false" > > Unfortunately this returns back sparse warnings about bitwise gfp_t and slab_flags_t casts. > Could you please explain why your variant is faster? Micro-optimization, grant you, but it is faster because it moves some of the logic into the slow path (the read side), and takes it out of the fast path (the write side). The idea of tracing is to squeeze out every cycle we can to keep the tracing overhead down. But it's really up to you if you need that. I'm not going to let this be a blocker. This is more of an FYI than anything else. -- Steve