Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1321183rwe; Thu, 1 Sep 2022 16:52:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR6VjLDeDLPRsw7dniI7Q1mHtannp0zhISXoptzxITKoXPzDHVAWmEt+Vyix0kK3FCvlBhEN X-Received: by 2002:a05:6402:248f:b0:440:9bb3:5936 with SMTP id q15-20020a056402248f00b004409bb35936mr31398868eda.178.1662076328432; Thu, 01 Sep 2022 16:52:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662076328; cv=none; d=google.com; s=arc-20160816; b=SL0nJTcCyzVbMnFTIBCjfon0iuqkWOYt5VQXmVMO2mJDH4biOipm1849j2abu/+j9U iNHIbE/J+/v862zXGalticRh422BRKQMn4K+HQyheNQ5TIYpNpl79v/qKTt6PjNEBgBD XTZEO0e/CjcPEUVt0Urov/TeT0Ck5Y8XMD2P+Ye2s1Br3GDRpMbXYRXHez6UQUFocrRC osgC1E4SLjzwT9Ng6XgPeHzgzwZPTqVTJavzBqYP7Xz0rdNKgBJYRra8uuNjf7e/jLk8 7GNbkxSLvrUcC5mEXCIwpzHk+4nmzdliuHZbSieGClHPDnkln/BxwXHJg1nJp3nF2wbV dlCw== 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=5pc1SgOf8Owl6sShRuirH1QWrWtPdJIgt3qepozMpkE=; b=vSvIpWPRock65YiOBVUDKQ9U7zMiOS5XqJSt/RW5VuYSmfRHL1Tjpv+TmMt72cM5Fn K4NjxYVV0MwTuBMFeAAGo/S7/6B9SYILJ2scIuBYAlZ86RqZA6Z6QHAnlU5Za7axw4nx dD4TWHNZAV88TPIsRKI72x0nC21ccfY1AaR/KU4Crjkf6tFBt72mDVUahRaWYqvGkJNC I++WKA6Fh8LFkLLQT0tjodOhXMfjGn4lCwa0V4yM5lDibHyps+REuh86Xan5PM27gjmC UQPgY5zk8LNpGOkezGd8mQfm4i3rR8MovlYiRTWOpVkP6dYwNpDSZnddCZbNyKe+Ew4v KhDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=QPtBN+jZ; 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 z19-20020a05640235d300b004479f85b42esi395954edc.509.2022.09.01.16.51.42; Thu, 01 Sep 2022 16:52:08 -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=QPtBN+jZ; 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 S235169AbiIAXgk (ORCPT + 99 others); Thu, 1 Sep 2022 19:36:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235116AbiIAXgh (ORCPT ); Thu, 1 Sep 2022 19:36:37 -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 23E51A404B for ; Thu, 1 Sep 2022 16:36:36 -0700 (PDT) Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-33dce2d4bc8so2326797b3.4 for ; Thu, 01 Sep 2022 16:36:36 -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=5pc1SgOf8Owl6sShRuirH1QWrWtPdJIgt3qepozMpkE=; b=QPtBN+jZZjR+fJQ+f+TgwZFy47TE1rR8gr1i8rB6mNu2nigO0JdCAAjMoUMaOVDYnd PiHulcKqQEwjGxjDADddZzXOUg5TYr/Y37FY0mLnlnZh9oqDpuWtb21NiE8K+MvKfMRy 5X2JycO4tSVca0qzV4Yx+TBoNNmpSKbKbCfgMYwA7K5CFp+VszB2v0xi3C2mZ4ZpAFpk VGoNBkpcZXTh7tuDysjYq/uSfLBayYSiQwhTFjGtzTF3WK2rRSdy71A7E9l9S18szgn+ hw0Qy3jClG1SDJCQ3AEQ+kyF5TgjSC7WKM1l7PFAPgZmXyevNIAyCBELnZOO/Zt3zo42 CuWw== 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=5pc1SgOf8Owl6sShRuirH1QWrWtPdJIgt3qepozMpkE=; b=qvOfg4rRqUxFKnnQ0H6iw1qQc0XVlzkMQhS0pCFHJf1Vds/A0pfXorPuyWU8Y3BZVN on52hUOuOaMz/9iYqvGLWmflnZDzduZO3v5FdUALczQSRoSy3vNP+YfrA7WB3UbXQlJi YaOMcRJ4thZQjWd6XzWJFiFg8Nlsk+XomJWpytFzB/zSm5KZXbiurH1PztIODkFEPILJ DhTgAjl+1qgWVvEtE5Pd83QENppP1mqeIQwPngDJaTl0kZd4mwbx8e9rC5cqnr/jlKPX SyTZZ3nEVLJ/4uEgPEwrD1PjY/adaDX8XIsDO3be1eYqXcEdCWXGEZ5b4253GcBMSzir l10A== X-Gm-Message-State: ACgBeo0iCqFbl1oKRDVp+36nK7m06eLn09Cze61p6m3qxk2pwBCEjy17 Xy14XOdZTETKMqWraFTBCeStkMDuAaH+bfPSVvMTuQ== X-Received: by 2002:a0d:c981:0:b0:330:dc03:7387 with SMTP id l123-20020a0dc981000000b00330dc037387mr25216063ywd.380.1662075395130; Thu, 01 Sep 2022 16:36:35 -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> <20220901223720.e4gudprscjtwltif@moria.home.lan> In-Reply-To: From: Suren Baghdasaryan Date: Thu, 1 Sep 2022 16:36:23 -0700 Message-ID: Subject: Re: [RFC PATCH 00/30] Code tagging framework and applications To: Roman Gushchin Cc: Kent Overstreet , Yosry Ahmed , Michal Hocko , Mel Gorman , Peter Zijlstra , Andrew Morton , Vlastimil Babka , Johannes Weiner , 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 , Christoph 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, Linux Kernel Mailing List 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 3:54 PM Roman Gushchin wrote: > > On Thu, Sep 01, 2022 at 06:37:20PM -0400, Kent Overstreet wrote: > > On Thu, Sep 01, 2022 at 03:27:27PM -0700, Roman Gushchin wrote: > > > On Wed, Aug 31, 2022 at 01:56:08PM -0700, Yosry Ahmed wrote: > > > > This is very interesting work! Do you have any data about the overhead > > > > this introduces, especially in a production environment? I am > > > > especially interested in memory allocations tracking and detecting > > > > leaks. > > > > > > +1 > > > > > > I think the question whether it indeed can be always turned on in the production > > > or not is the main one. If not, the advantage over ftrace/bpf/... is not that > > > obvious. Otherwise it will be indeed a VERY useful thing. > > > > Low enough overhead to run in production was my primary design goal. > > > > Stats are kept in a struct that's defined at the callsite. So this adds _no_ > > pointer chasing to the allocation path, unless we've switch to percpu counters > > at that callsite (see the lazy percpu counters patch), where we need to deref > > one percpu pointer to save an atomic. > > > > Then we need to stash a pointer to the alloc_tag, so that kfree() can find it. > > For slab allocations this uses the same storage area as memcg, so for > > allocations that are using that we won't be touching any additional cachelines. > > (I wanted the pointer to the alloc_tag to be stored inline with the allocation, > > but that would've caused alignment difficulties). > > > > Then there's a pointer deref introduced to the kfree() path, to get back to the > > original alloc_tag and subtract the allocation from that callsite. That one > > won't be free, and with percpu counters we've got another dependent load too - > > hmm, it might be worth benchmarking with just atomics, skipping the percpu > > counters. > > > > So the overhead won't be zero, I expect it'll show up in some synthetic > > benchmarks, but yes I do definitely expect this to be worth enabling in > > production in many scenarios. > > I'm somewhat sceptical, but I usually am. And in this case I'll be really happy > to be wrong. > > On a bright side, maybe most of the overhead will come from few allocations, > so an option to explicitly exclude them will do the trick. > > I'd suggest to run something like iperf on a fast hardware. And maybe some > io_uring stuff too. These are two places which were historically most sensitive > to the (kernel) memory accounting speed. Thanks for the suggestions, Roman. I'll see how I can get this done. I'll have to find someone with access to fast hardware (Android is not great for that) and backporting the patchset to the supported kernel version. Will do my best. Thanks, Suren. > > Thanks! > > -- > To unsubscribe from this group and stop receiving emails from it, send an email to kernel-team+unsubscribe@android.com. >