Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1123557rwe; Thu, 1 Sep 2022 12:58:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR4rWfkQOFDUGfus0OwcmZ6OJ5+9aJDRM/FQlo7JFdYOM/BDbWDnFNABql935lBu8I/zfYA1 X-Received: by 2002:a17:902:f712:b0:171:29d0:6f9f with SMTP id h18-20020a170902f71200b0017129d06f9fmr32420186plo.84.1662062293510; Thu, 01 Sep 2022 12:58:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662062293; cv=none; d=google.com; s=arc-20160816; b=NZliyszPWoywij+q8e8tPVBY00owy0FnK268hA8vJNTdgZCXgGlS0JhQECt0XLYulJ X23OTKR3mksnToXaycdS1BXLwB/+S9W46fb6hWsFPv0K+uLIbJk76F5OlnHtl5WUYT0f Pf+DPCIE0VoySO0NsDQM86FbDe6DYpxAOxucPsj0WIspyqZwKS+QGm/mBlUohNExQzee uSHayOQ9HVk5g1qQ6HhlxJ+WUexz3bbiN+nxK9+CeEdx8rZDEpQbdaB2EmvwAJE8hBkZ pn976HdteVmw4syqwv/t+xse1fggvZyIXqvMdQd56yxBn2FMQs758ZnwC9rPSRgUm8V0 ekxA== 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=rw5PRlxl7tO0yi2f42RcudRuneYpC4HLzAgnvXZWG5E=; b=fVRltRa37cUff/MHJfaS0ApGK86KIKptHVBpGYA+duPs9WMmMi0X0xqQ+/Gky0W44z R2IAYakwZdzlzhu39lnqllFz/DHeo70InjwQbEQZ60zWLqdUxWdN8Fi4X0Usx8ryEGAl pzZo5UHXBU3wTA2L3a2g3cPwj/4KDBWkDSWSFXewRKn3T5IwSSEqK3A0R+VLAK03JNdi 4D3pPm+gyVsngMQmg0DLjKO+lb4/uM4gCtBdDpAEEe60bzSixsXm9JLlfGG14D28ZnIK GUnl2NdiDMEOsgkI1dCfPw1dpHEwNGcJ0AiZpjmC23kAKObsJfADkVVjBmVUwKCBoGaU qFGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=lG3CtwEr; 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 r199-20020a632bd0000000b00430842205a5si1975078pgr.739.2022.09.01.12.57.54; Thu, 01 Sep 2022 12:58:13 -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=lG3CtwEr; 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 S234655AbiIATj2 (ORCPT + 99 others); Thu, 1 Sep 2022 15:39:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234595AbiIATjZ (ORCPT ); Thu, 1 Sep 2022 15:39:25 -0400 Received: from mail-yw1-x1134.google.com (mail-yw1-x1134.google.com [IPv6:2607:f8b0:4864:20::1134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B6C59A98B for ; Thu, 1 Sep 2022 12:39:23 -0700 (PDT) Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-33dc31f25f9so347061627b3.11 for ; Thu, 01 Sep 2022 12:39:23 -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=rw5PRlxl7tO0yi2f42RcudRuneYpC4HLzAgnvXZWG5E=; b=lG3CtwEra2JQqN/veO23yk3cgaTJHFCiebuuRZY/xNehRm+m0fM4bIsWwBppGA+dxf mGwrLGImeNf4NmD+qiiJAgJrRcvEAfMmmsjPutkxq2y7CzoFE7qGuyTBDkwrYwo0ghp+ DIdTURnQpZf4mS51OcBm4/JauLAis6X1OUJhsFMZ1Eii1uGdRpU21Q08G5BpjTO5hJLN 9L5Fsbu9o5yfqdUojSVuS9kjs1tQfCEVguOYiQkyDJxdrNwv3a8BIeLV7PQsB1938bTI TTsL41uELqXnesIe6dBtowmfUnvD7Y1/Zc9uEXdIILlsmZXFDiVnDH9hCWWOHKwToPd1 MnoA== 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=rw5PRlxl7tO0yi2f42RcudRuneYpC4HLzAgnvXZWG5E=; b=bWNkzZG9iJ6buoH0Ac5qdBaVoEvU7M3m4ZOfv/h4YEqkZWE57yvEC6I5Ua5OxLxqt5 yLImqqhnQGCXiLX2PVHJwvDis2zrYsRhiAeYRDcucbgu932SHBLreafahWkq6ZAyQIZ6 GKRES0o3cVeK9Gi3UYtXBBLhWGNZzn7DruY2ktMlKayM3irdGd0pE7fA2l+EnBlPc+cj LskQGqf2YB/+sgzx33QYHz/pp+/7TE1Ae8B/75/AKsH1pLBPJZWxlwZUdBvyWpvKNxWU poYIi7RdPXHt8CwVENAu7NRchF6zCrK7MOXRK1fZ1DEp/n2x8U6hAErNgoRsnUw6dcer WgGw== X-Gm-Message-State: ACgBeo0BwDtUMMSQnvx7Qa3eSAEtYj2CxR/spjdp6uxGUgToic1/X/yV pem35TDPlNzsFSyRmjFzOwbQIZSh57QO6HGMfU903A== X-Received: by 2002:a0d:d850:0:b0:340:d2c0:b022 with SMTP id a77-20020a0dd850000000b00340d2c0b022mr21758237ywe.469.1662061162404; Thu, 01 Sep 2022 12:39:22 -0700 (PDT) MIME-Version: 1.0 References: <20220830214919.53220-1-surenb@google.com> <20220831084230.3ti3vitrzhzsu3fs@moria.home.lan> <20220831101948.f3etturccmp5ovkl@suse.de> <20220831190154.qdlsxfamans3ya5j@moria.home.lan> In-Reply-To: From: Suren Baghdasaryan Date: Thu, 1 Sep 2022 12:39:11 -0700 Message-ID: Subject: Re: [RFC PATCH 00/30] Code tagging framework and applications To: Michal Hocko Cc: Kent Overstreet , 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 , Steven Rostedt , 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 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 Thu, Sep 1, 2022 at 12:15 PM Michal Hocko wrote: > > On Thu 01-09-22 08:33:19, Suren Baghdasaryan wrote: > > On Thu, Sep 1, 2022 at 12:18 AM Michal Hocko wrote: > [...] > > > So I find Peter's question completely appropriate while your response to > > > that not so much! Maybe ftrace is not the right tool for the intented > > > job. Maybe there are other ways and it would be really great to show > > > that those have been evaluated and they are not suitable for a), b) and > > > c) reasons. > > > > That's fair. > > For memory tracking I looked into using kmemleak and page_owner which > > can't match the required functionality at an overhead acceptable for > > production and pre-production testing environments. > > Being more specific would be really helpful. Especially when your cover > letter suggests that you rely on page_owner/memcg metadata as well to > match allocation and their freeing parts. kmemleak is known to be slow and it's even documented [1], so I hope I can skip that part. For page_owner to provide the comparable information we would have to capture the call stacks for all page allocations unlike our proposal which allows to do that selectively for specific call sites. I'll post the overhead numbers of call stack capturing once I'm finished with profiling the latest code, hopefully sometime tomorrow, in the worst case after the long weekend. > > > traces + BPF I > > haven't evaluated myself but heard from other members of my team who > > tried using that in production environment with poor results. I'll try > > to get more specific information on that. > > That would be helpful as well. Ack. > > > > E.g. Oscar has been working on extending page_ext to track number of > > > allocations for specific calltrace[1]. Is this 1:1 replacement? No! But > > > it can help in environments where page_ext can be enabled and it is > > > completely non-intrusive to the MM code. > > > > Thanks for pointing out this work. I'll need to review and maybe > > profile it before making any claims. > > > > > > > > If the page_ext overhead is not desirable/acceptable then I am sure > > > there are other options. E.g. kprobes/LivePatching framework can hook > > > into functions and alter their behavior. So why not use that for data > > > collection? Has this been evaluated at all? > > > > I'm not sure how I can hook into say alloc_pages() to find out where > > it was called from without capturing the call stack (which would > > introduce an overhead at every allocation). Would love to discuss this > > or other alternatives if they can be done with low enough overhead. > > Yes, tracking back the call trace would be really needed. The question > is whether this is really prohibitively expensive. How much overhead are > we talking about? There is no free lunch here, really. You either have > the overhead during runtime when the feature is used or on the source > code level for all the future development (with a maze of macros and > wrappers). Will post the overhead numbers soon. What I hear loud and clear is that we need a kernel command-line kill switch that mitigates the overhead for having this feature. That seems to be the main concern. Thanks, Suren. [1] https://docs.kernel.org/dev-tools/kmemleak.html#limitations-and-drawbacks > > Thanks! > -- > Michal Hocko > SUSE Labs