Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp316591rwe; Wed, 31 Aug 2022 23:02:50 -0700 (PDT) X-Google-Smtp-Source: AA6agR4F3KwIYMq0GqnHMS+Qba9FDqjQze7saXB/vX6fzrFEfVd/emQVMHIgWiFaVKVTkyd9X0Hh X-Received: by 2002:a50:8e11:0:b0:447:cf39:10a1 with SMTP id 17-20020a508e11000000b00447cf3910a1mr25432239edw.382.1662012170533; Wed, 31 Aug 2022 23:02:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662012170; cv=none; d=google.com; s=arc-20160816; b=Ak5/wUQbBB4Jbe6cBySe4TXiFIrA34D/uZG8R66WfP/88gwV0DrkeUaAYPAFQY7rLH aNgctNcyj38BX4BgiFBLCz3j9OPiXLTODReviYhnvl1i/YLtMQJrSE1vlIqBH0Ykq8iH JOMecUWkdYMxBpXnQBGEB9K+rqNbH6fhoQwHpTQLCvUxFpOzu9W/OY9Mm4XhlcnnWGNg 3cKxFfS1ltK9UisF+yC2Jifg9wYH+ljph7LknFO9O090Y9vSK7eD4oBtJiEa/jUngGBF vrO6QpjOR95GyHZaoGN05ckETM3H7utQHJ03WcChGiPhAYPGBo3Q7Be85U6KcE0aiWbw fLeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ktZOhU9M+eiBxoPfSKrBwsk5VZxY64ML34Vei/rqz2s=; b=y8vZALpf5jq9sFLAtmXY05g8Qy3/TPQPQBdbyLDATdPsarymaOJ1esiJiw4VWfuTUi XdKSdfvQ5wTRrF/nzb48k5yZq+EdCjPDnx5h2z+PJg3QDI7j7I7yiyzk/9iA3kBfnVsj MHxAwFBIV0SCKJK3LFkTFinF1ChJyuJHwlQ36Gkj9rKF8I9syrEvrMNjoaBxeuUDQ+5i 7nUomQAqWA9+/zKSXRdAtqpd0Ir/anfOqoLfIMUlUmNmqG20VJtpGhWjaGQs3eXEJAIt vs6Wa4lOj5+mEoL29ZqtBFmF/FJzHEQZs82Sep0wcT+zkHEMF6M5aYFr4kBL5lE+IZTH CcTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=UnvyXVMI; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ky13-20020a170907778d00b0072f97d98a50si11482774ejc.945.2022.08.31.23.02.08; Wed, 31 Aug 2022 23:02:50 -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=@google.com header.s=20210112 header.b=UnvyXVMI; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232714AbiIAFFq (ORCPT + 99 others); Thu, 1 Sep 2022 01:05:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232718AbiIAFFm (ORCPT ); Thu, 1 Sep 2022 01:05:42 -0400 Received: from mail-yw1-x112c.google.com (mail-yw1-x112c.google.com [IPv6:2607:f8b0:4864:20::112c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5185FF9957 for ; Wed, 31 Aug 2022 22:05:40 -0700 (PDT) Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-3321c2a8d4cso326159737b3.5 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=FgDPwt5ITBZXYtC/9G/3wijDcv2UT628+22TeUWzJ+kE92Ok2aFF3+PIU5L1XFRU0q DeWtiu6hJUOkvg6Lk2A14rhWRX6HniXrXqDQquxKQiS4uEB2lvu7gTu/aNO1c0RqwEjO BHjSh74Z9CabQr4KjtWUqzQcJKU1NVVg+mP7jNhQ3zcD9OzUZ7gX6njDs87RPJzV/oML 6PWoKFF+6sU+6X5IJmNovnuoXi3Ui+/FaCYuU0loAQBeqbkOK1b8tAgHTWK85EkjMGKU vXr1P5tH1f7zsDqkFf0ouSlN9XqDJ3tEQwOA+I/jRGuqA+a8c0+hd3EXoIothKbRBgF6 FZEg== X-Gm-Message-State: ACgBeo3YQ5tc5eCvuuKtSUvYoIFyHsrUXDUw/7Ba53Ql9kHt7MdSbIPl SBv1tWYxUA9piu1rq1Qyjb6M6TswaYBfZQsO+x5lqA== 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" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 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