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 9FDCAC6FA83 for ; Mon, 5 Sep 2022 20:42:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3181A80204; Mon, 5 Sep 2022 16:42:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 29DF8801E6; Mon, 5 Sep 2022 16:42:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 118E280204; Mon, 5 Sep 2022 16:42:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id F2AF9801E6 for ; Mon, 5 Sep 2022 16:42:40 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C7CB2140210 for ; Mon, 5 Sep 2022 20:42:40 +0000 (UTC) X-FDA: 79879205280.05.310FE4C Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by imf17.hostedemail.com (Postfix) with ESMTP id D225740063 for ; Mon, 5 Sep 2022 20:42:38 +0000 (UTC) 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662410558; 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=WiGoaCLsrAtGX5WjZ54R9ZEwhVpr8CfiS3GHCMjFnnI=; b=yBhBNFM7BNaR23TVE896tB/HyjfudAMpr8BxUXNDMq7TLcuaAvd+MN/zdGugDXtW4khdoI 4exxCtqujEaW9gGZcl1VGvXzTIwDcjx2ZYPrGvcrweWxXGz2xYv/X2SVx/fwviQdxI3tS2 BZONWHc7cE1y0ZqSgTbEASg8QTGT/cM= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=hnmt3aHZ; spf=pass (imf17.hostedemail.com: domain of kent.overstreet@linux.dev designates 188.165.223.204 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662410558; a=rsa-sha256; cv=none; b=uiVt2mJFYWnKGRAfAFGNfmzSM3kClsU7S06qB2C4CR/Bqe90VxVK+s5be0iBXP2jOGpBrm aCsaQQr0A7QxKIL1ijmtrrBYwCGGXBS5gz+V1Fqo0k9ZDQIUR/uBYRoD8ZW9s2ZQBhG4sr XvG80UgJ0FjcPTX8QDLGzKC/rvgao0M= X-Rspam-User: Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=hnmt3aHZ; spf=pass (imf17.hostedemail.com: domain of kent.overstreet@linux.dev designates 188.165.223.204 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Rspamd-Server: rspam07 X-Stat-Signature: o1xwke5wajn5f3hk3iibo6qbfjopffu5 X-Rspamd-Queue-Id: D225740063 X-HE-Tag: 1662410558-680472 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 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.