Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp3547709rwb; Mon, 5 Sep 2022 13:55:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR5s5jhxpkYnAP2i9E09FSkF2hcYZ7zEWSN3L1LrRcl9F0IfE9TastyQjQ0fpgghaqdKZK42 X-Received: by 2002:a17:907:3f88:b0:73e:484d:9d6c with SMTP id hr8-20020a1709073f8800b0073e484d9d6cmr34691800ejc.283.1662411315201; Mon, 05 Sep 2022 13:55:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662411315; cv=none; d=google.com; s=arc-20160816; b=aGd6/gJXSpugZ5fynEDxFGuwhDsr0LIfkAcNFHjsWQWKFbCMrkSoQYDBQQDQvMUN2y sjQRV0zEjSPvZX5AuRpYVv54rusHI8SxI/ENYxTSfAkA6LZvtB/29oaIsMz2EyJ4eOyk wRxINoA/lTBr6wEQr7ctdYVQpCMfTgZcpYPiVaB+BsyqbDaTFns+dgL0b7WcJjIBK3ou w0v31XMdWtZ+I/nOl7De1XGeUMKccNjlsJ2E3dMak/ZgUqofRKjPWFCXlZMNqlAggqxX uRRBF2DFichHF/mIJEnSWYsxjPJg4xT4qDH3br5A7n1LO13qWSQsOrOxCJI1ZIvRRi0e 11kg== 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:dkim-signature:date; bh=WiGoaCLsrAtGX5WjZ54R9ZEwhVpr8CfiS3GHCMjFnnI=; b=PQmIBIBIA+t6PIYLJeHRsrcO1MNuhVCEuyLHMyu1Ab5yatYWbUjeJ/HAOzTqbgwJsq RXbQJmAJ6vQu83pWklmD6CXT4cOgCBe0NB9Y5MLlzTE2BmOaMdqLWatmY1zL1nXGpmYX 3XLvwi3EY/KIa/M3SUj95JTMDM/4y0uLw3uPemtTWs0M7YaZfMFFKi8wnhR9iqVlv/HY 8VG1yGDyh1XN84vihBOvzbdjA631QFSY4ZmtIkBzr1Z+BD+/5/B6f+LwuY+5Ql3JlwmH ZjSrpPgAu2Bny/y3X9rUPL0Bx1F662e+d0NK6+M4kJPLivgllZXQYGsRuUswLAeqk9Uu WRSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=hnmt3aHZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020a056402084900b00446e658cfdbsi9972154edz.240.2022.09.05.13.54.49; Mon, 05 Sep 2022 13:55:15 -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=@linux.dev header.s=key1 header.b=hnmt3aHZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232095AbiIEUml (ORCPT + 99 others); Mon, 5 Sep 2022 16:42:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229546AbiIEUmj (ORCPT ); Mon, 5 Sep 2022 16:42:39 -0400 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75E9A65645; Mon, 5 Sep 2022 13:42:38 -0700 (PDT) Date: Mon, 5 Sep 2022 16:42:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1662410556; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=WiGoaCLsrAtGX5WjZ54R9ZEwhVpr8CfiS3GHCMjFnnI=; b=hnmt3aHZjiqk4ERDUnjQhKqTOVd36AXDvGfghBFkI6MlG+YAV38zdha6mLi0wPB8rg9d9p f+XQ8HrbJOiH4ZgK5Kz3JWnaEEtobK791M/A4ImHaFUKx2pGDzECdjOHQ8Ioeny6lWxRc5 3ffslWYfmfssKDR8OUSYZcd0xfFRct0= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Suren Baghdasaryan Cc: Steven Rostedt , Michal Hocko , Mel Gorman , Peter Zijlstra , Andrew Morton , Vlastimil Babka , Johannes Weiner , Roman Gushchin , Davidlohr Bueso , Matthew Wilcox , "Liam R. Howlett" , David Vernet , Juri Lelli , Laurent Dufour , Peter Xu , David Hildenbrand , Jens Axboe , mcgrof@kernel.org, masahiroy@kernel.org, nathan@kernel.org, changbin.du@intel.com, ytcoode@gmail.com, Vincent Guittot , Dietmar Eggemann , Benjamin Segall , Daniel Bristot de Oliveira , Valentin Schneider , Christopher Lameter , Pekka Enberg , Joonsoo Kim , 42.hyeyoo@gmail.com, Alexander Potapenko , Marco Elver , Dmitry Vyukov , Shakeel Butt , Muchun Song , arnd@arndb.de, jbaron@akamai.com, David Rientjes , Minchan Kim , Kalesh Singh , kernel-team , linux-mm , iommu@lists.linux.dev, kasan-dev@googlegroups.com, io-uring@vger.kernel.org, linux-arch@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-modules@vger.kernel.org, LKML Subject: Re: [RFC PATCH 00/30] Code tagging framework and applications Message-ID: <20220905204229.xqrqxmaax37n3ody@moria.home.lan> References: <20220831084230.3ti3vitrzhzsu3fs@moria.home.lan> <20220831101948.f3etturccmp5ovkl@suse.de> <20220831190154.qdlsxfamans3ya5j@moria.home.lan> <20220905110713.27304149@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, 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 Mon, Sep 05, 2022 at 11:08:21AM -0700, Suren Baghdasaryan wrote: > On Mon, Sep 5, 2022 at 8:06 AM Steven Rostedt wrote: > > > > On Sun, 4 Sep 2022 18:32:58 -0700 > > Suren Baghdasaryan wrote: > > > > > Page allocations (overheads are compared to get_free_pages() duration): > > > 6.8% Codetag counter manipulations (__lazy_percpu_counter_add + __alloc_tag_add) > > > 8.8% lookup_page_ext > > > 1237% call stack capture > > > 139% tracepoint with attached empty BPF program > > > > Have you tried tracepoint with custom callback? > > > > static void my_callback(void *data, unsigned long call_site, > > const void *ptr, struct kmem_cache *s, > > size_t bytes_req, size_t bytes_alloc, > > gfp_t gfp_flags) > > { > > struct my_data_struct *my_data = data; > > > > { do whatever } > > } > > > > [..] > > register_trace_kmem_alloc(my_callback, my_data); > > > > Now the my_callback function will be called directly every time the > > kmem_alloc tracepoint is hit. > > > > This avoids that perf and BPF overhead. > > Haven't tried that yet but will do. Thanks for the reference code! Is it really worth the effort of benchmarking tracing API overhead here? The main cost of a tracing based approach is going to to be the data structure for remembering outstanding allocations so that free events can be matched to the appropriate callsite. Regardless of whether it's done with BFP or by attaching to the tracepoints directly, that's going to be the main overhead.