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 353F5ECAAD2 for ; Thu, 1 Sep 2022 04:53:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 728776B0072; Thu, 1 Sep 2022 00:52:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D8A98D0002; Thu, 1 Sep 2022 00:52:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A02E8D0001; Thu, 1 Sep 2022 00:52:59 -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 48A4E6B0072 for ; Thu, 1 Sep 2022 00:52:59 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 1A6D140588 for ; Thu, 1 Sep 2022 04:52:59 +0000 (UTC) X-FDA: 79862296878.16.987D42E Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf11.hostedemail.com (Postfix) with ESMTP id B23194003F for ; Thu, 1 Sep 2022 04:52:58 +0000 (UTC) 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-out1.suse.de (Postfix) with ESMTPS id 4811C221FE; Thu, 1 Sep 2022 04:52:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1662007977; h=from:from:reply-to: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=eTDe59i5UNhXbLPqqFo4WrMbXbqRlxGLfSkkAQ8Fk/c=; b=MXuVo2yVstAVCBS1varMecEXswz7FuXIDAQoWezwenAAYl9Y3PpRhbQ5He3NmYqXLh+xPX jn8EotqxdKlpoHsOLAGA9/hldaOwN5qgNQ9dGNBfKhsAkMyZOy8dG2wdiqd/dEPEUn2GH3 2GWaydR4UCkectkbjmLF+pOVJTedvZg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1662007977; h=from:from:reply-to: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=eTDe59i5UNhXbLPqqFo4WrMbXbqRlxGLfSkkAQ8Fk/c=; b=g2uWhOe8Agl2O5OiQ5uOLDZi7V4xateLoucVNLb1+2O63J77RwR9Dmx9Wxfg3YF3VCD9bc vcZMMEi8r2KuRXCg== 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 67DE3139C4; Thu, 1 Sep 2022 04:52:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id E7aqFqY6EGPsewAAMHmgww (envelope-from ); Thu, 01 Sep 2022 04:52:54 +0000 Date: Thu, 1 Sep 2022 06:52:52 +0200 From: Oscar Salvador To: Suren Baghdasaryan Cc: akpm@linux-foundation.org, kent.overstreet@linux.dev, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, roman.gushchin@linux.dev, mgorman@suse.de, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, void@manifault.com, peterz@infradead.org, juri.lelli@redhat.com, ldufour@linux.ibm.com, peterx@redhat.com, david@redhat.com, axboe@kernel.dk, mcgrof@kernel.org, masahiroy@kernel.org, nathan@kernel.org, changbin.du@intel.com, ytcoode@gmail.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, bristot@redhat.com, vschneid@redhat.com, cl@linux.com, penberg@kernel.org, iamjoonsoo.kim@lge.com, 42.hyeyoo@gmail.com, glider@google.com, elver@google.com, dvyukov@google.com, shakeelb@google.com, songmuchun@bytedance.com, arnd@arndb.de, jbaron@akamai.com, rientjes@google.com, minchan@google.com, kaleshsingh@google.com, kernel-team@android.com, linux-mm@kvack.org, 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, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 00/30] Code tagging framework and applications Message-ID: References: <20220830214919.53220-1-surenb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220830214919.53220-1-surenb@google.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662007978; a=rsa-sha256; cv=none; b=2n3RE8fasYpZubR+ju6b50lPDaA397638NGKY2r+yeN7JJ5FCmpxSh2u4esUzyCeDHhiyP 2YFT00OpxB7HTsqZXVEpJBDBU2C3joXsE7GCos2SSkxofajZqj61bcvmyM0EuulVffNr/n oqigoCegXZZU/q9c/4WKrU8jLrKeMFI= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=MXuVo2yV; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=g2uWhOe8; spf=pass (imf11.hostedemail.com: domain of osalvador@suse.de designates 195.135.220.28 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662007978; 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=eTDe59i5UNhXbLPqqFo4WrMbXbqRlxGLfSkkAQ8Fk/c=; b=hlveMhilXK1FwQzjKIHxRbhPi2tr8IcctmAZb2exkfyOOjGRC9arwCriqPHdbvoxTZ5og6 UJjw2Q2cm4rii9jdAiONUtzIvg5fXE7T0UKflLLMbtiPW21ChTwwHrO9yrceRirD7sC25r RDZ8+jRXsubi9gXsmsOmMlxiWnX1Dos= X-Rspam-User: X-Stat-Signature: gqo61fq86jf3j8gtt9wb5dha94piyb9p X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: B23194003F Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=MXuVo2yV; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=g2uWhOe8; spf=pass (imf11.hostedemail.com: domain of osalvador@suse.de designates 195.135.220.28 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de X-HE-Tag: 1662007978-63010 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 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 Thanks -- Oscar Salvador SUSE Labs