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 C403FECAAD2 for ; Thu, 1 Sep 2022 05:05:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5592A6B0073; Thu, 1 Sep 2022 01:05:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4B9926B0074; Thu, 1 Sep 2022 01:05:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2242C8D0001; Thu, 1 Sep 2022 01:05:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 0CE2D6B0073 for ; Thu, 1 Sep 2022 01:05:41 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B9B81160907 for ; Thu, 1 Sep 2022 05:05:40 +0000 (UTC) X-FDA: 79862328840.13.48FA804 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) by imf09.hostedemail.com (Postfix) with ESMTP id 571F914005A for ; Thu, 1 Sep 2022 05:05:40 +0000 (UTC) Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-33dba2693d0so325306227b3.12 for ; Wed, 31 Aug 2022 22:05:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=ktZOhU9M+eiBxoPfSKrBwsk5VZxY64ML34Vei/rqz2s=; b=UnvyXVMIRiciK0rqi4Rla4SS9BjEhBuxvGCuhtbiGji3fDuHUeDlC2C4TbCLRZRSwR +328Kj0pV/r/xNPqU1581dA9M6WZOvrs39FcqOg6hNQT5ifEu0MLEP+Zz/2G+jRm7WMN 7axpEQrwYULoaAc5UOWeK4pidUhWzYApn91X0NwQTEXfOOrYw3wXsfjb2f2S21BvY7t3 Zg1V8M6rEvRQMEwY0dY+iYzvNIKUl0aPxff0C2lbwvD8YaEzrAOwphxkhABpA5cqFwfx wpTyALvpTmRkdUhm9RVjdaatnoaqYeLhUBKhA4+4MYeMDI/E+7MF6YajUpv+RJVJmtfD MOWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=ktZOhU9M+eiBxoPfSKrBwsk5VZxY64ML34Vei/rqz2s=; b=Vqp4ayF3K0qkdCW+rMmBAzACZSQHTJlePDAyAy23SafTcrNRXZaJ4HBKpqIoo3qJyj GPaE5Zz/L/f/BLjuDXXRfKYlFSXjGj7nmSoul2u1SN6Rhv61U0HztHQHLWTtGZf1SfkR YK0nZSzBTK4u9K0MCAMzSqnve23C2WHssqOmqN9UfLuDK1tV+RrYIWtJOATxWAnmetLp RkAL0jlj5xcpYzfkK7G4Mj33jFMF1hyi+D6hxzqSRV+330LkUz9sPJAHM7WZK79Jnr4n R0p2VObE9RfVrg4yK5XqyiUOOWoalVvhDIio9wAnbqdJ2469GlvTDQvfNVPXf9Ahe/o3 3WkA== X-Gm-Message-State: ACgBeo3n1C0YYrPAr+N0TR4M0YVcJjcvouwVhEawjFpZh45zgJ+eu9/o f6vH63Q8O5ZA7dasNtEOzE8n5XKsDGODrSMXAQzUXA== X-Google-Smtp-Source: AA6agR6X7FU4pvrjt5vMDUM/DC2IsE6vILG7I4DBJ25hoCu+6BelY82RpFQkl53Zm+EyPsuJsyRbi+nPLdvdkyesITk= X-Received: by 2002:a81:a04c:0:b0:340:4c27:dfc6 with SMTP id x73-20020a81a04c000000b003404c27dfc6mr20996289ywg.507.1662008739346; Wed, 31 Aug 2022 22:05:39 -0700 (PDT) MIME-Version: 1.0 References: <20220830214919.53220-1-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Wed, 31 Aug 2022 22:05:28 -0700 Message-ID: Subject: Re: [RFC PATCH 00/30] Code tagging framework and applications To: Oscar Salvador Cc: Andrew Morton , Kent Overstreet , Michal Hocko , Vlastimil Babka , Johannes Weiner , Roman Gushchin , Mel Gorman , Davidlohr Bueso , Matthew Wilcox , "Liam R. Howlett" , David Vernet , Peter Zijlstra , Juri Lelli , Laurent Dufour , Peter Xu , David Hildenbrand , Jens Axboe , mcgrof@kernel.org, masahiroy@kernel.org, nathan@kernel.org, ytcoode@gmail.com, Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Benjamin Segall , Daniel Bristot de Oliveira , Valentin Schneider , Christopher Lameter , Pekka Enberg , Joonsoo Kim , 42.hyeyoo@gmail.com, Alexander Potapenko , Marco Elver , dvyukov@google.com, 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 Content-Type: text/plain; charset="UTF-8" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662008740; 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=ktZOhU9M+eiBxoPfSKrBwsk5VZxY64ML34Vei/rqz2s=; b=ms/k906S/zJ7QToeFr4Pfic2sL48H17XRpdLHVGU86zEVjL0O2Bo4lZ7GqXnpgnZPFir1A t2MwKfrfGmkKpFXw2V69ncN79Rz2eIgNgHN+BqKmkDWndL8HPnVc8kgSGabVTkMxnIdW/J NRot0yDaSfJp1xdN7gG97Ai2V7zLDuI= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=UnvyXVMI; spf=pass (imf09.hostedemail.com: domain of surenb@google.com designates 209.85.128.175 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662008740; a=rsa-sha256; cv=none; b=zW6h1RKnwHjT0QGCkfet1ijjsgTHSdcb5PCKv8oE1cdC/0h11EYjUpCMoRbql65BYkvY6g K9GRzMO8Fmb822Z3s6zzBcY9zJ0tk2DGwMXhxtqSj0iAxnodMYJ4s/KoULRrDSP5qkMJon NZ47H1nF15r9Q4Wq+D/J8kZaHkmzJtw= X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 571F914005A X-Rspam-User: Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=UnvyXVMI; spf=pass (imf09.hostedemail.com: domain of surenb@google.com designates 209.85.128.175 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: 39tfi3octn63ofr3aywrkj53kwp76he3 X-HE-Tag: 1662008740-362544 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 Wed, Aug 31, 2022 at 9:52 PM Oscar Salvador wrote: > > On Tue, Aug 30, 2022 at 02:48:49PM -0700, Suren Baghdasaryan wrote: > > =========================== > > Code tagging framework > > =========================== > > Code tag is a structure identifying a specific location in the source code > > which is generated at compile time and can be embedded in an application- > > specific structure. Several applications of code tagging are included in > > this RFC, such as memory allocation tracking, dynamic fault injection, > > latency tracking and improved error code reporting. > > Basically, it takes the old trick of "define a special elf section for > > objects of a given type so that we can iterate over them at runtime" and > > creates a proper library for it. > > > > =========================== > > Memory allocation tracking > > =========================== > > The goal for using codetags for memory allocation tracking is to minimize > > performance and memory overhead. By recording only the call count and > > allocation size, the required operations are kept at the minimum while > > collecting statistics for every allocation in the codebase. With that > > information, if users are interested in mode detailed context for a > > specific allocation, they can enable more in-depth context tracking, > > which includes capturing the pid, tgid, task name, allocation size, > > timestamp and call stack for every allocation at the specified code > > location. > > Memory allocation tracking is implemented in two parts: > > > > part1: instruments page and slab allocators to record call count and total > > memory allocated at every allocation in the source code. Every time an > > allocation is performed by an instrumented allocator, the codetag at that > > location increments its call and size counters. Every time the memory is > > freed these counters are decremented. To decrement the counters upon free, > > allocated object needs a reference to its codetag. Page allocators use > > page_ext to record this reference while slab allocators use memcg_data of > > the slab page. > > The data is exposed to the user space via a read-only debugfs file called > > alloc_tags. > > Hi Suren, > > I just posted a patch [1] and reading through your changelog and seeing your PoC, > I think we have some kind of overlap. > My patchset aims to give you the stacktrace <-> relationship information and it is > achieved by a little amount of extra code mostly in page_owner.c/ and lib/stackdepot. > > Of course, your works seems to be more complete wrt. the information you get. > > I CCed you in case you want to have a look > > [1] https://lkml.org/lkml/2022/9/1/36 Hi Oscar, Thanks for the note. I'll take a look most likely on Friday and will follow up with you. Thanks, Suren. > > Thanks > > > -- > Oscar Salvador > SUSE Labs