Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1190686rwr; Wed, 3 May 2023 11:18:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5aWWYqpU2XX5dHoGK8aX/PtdxVapHny1XvMfp9L7ty6lxpwjrf+Lm585x7QhVYy+FdCZsl X-Received: by 2002:a17:902:7b8f:b0:19c:a9b8:4349 with SMTP id w15-20020a1709027b8f00b0019ca9b84349mr841113pll.32.1683137879925; Wed, 03 May 2023 11:17:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683137879; cv=none; d=google.com; s=arc-20160816; b=xtHGMgj4HNDjo4eL6jYiSiDTpV1vIzwL23m2arP/lreINDMzMcxxzBleMUkDbvkUC0 7DY22yg3CBHCsilkrlRwokHphZcaM3AZF+SU9cvrCA9HqG/TCgbh08RNL9n4fS9x9mw8 0i9WNnW+XnQARJ8nqzpsCr5lqhanRdoWSO7jgKbN3x2x/OOrAm6zyYf1Yw+A3wlKf/sV siY8qEjJ7Sooa9+T5fbvu2fIzn7kGxZEAG3liYd0lzb1ODljEEU8stIhHMs0r6bzbmq3 QYmugtiWUcquL3O7tBHlBI67w1HtP511JW2zZgS0Imw/MxENZ/N6HXSHrjRPezFV6+rW E+og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=4cv7r3p/uGjVZzfVGJD3+oUJmj97nEyjDPWByIKN3z4=; b=kfzmXxySmIU0q/7A28hOgsNtr8Cgyrg6HkmneP0mxJs8HQ3ixfquZvaZUTnFKs/Ggx lySKXkpoEUXCLS5QNqTNR5Dinh2sej/t1AeDMvJiXhsgJQBHiBTYErMa9D74CPpXGSoa ssSl1ltmlTtlMdymqPma8rXGXh/p3q/xcWnnKwXjH0i1+TY0qrBnStqeh307nyWmWsKp 3RoNVLT4yx0vcXX4k1/bY9SEc5nfolkl0GltWP7uHvb4cjLve0qX2ESbyWPHHl7TinwU 70CqFA8TlOopV9ZnHJ6WIsVcMjyaz681H7D4TAWO4hHM9lOIo+z14G5TN9lKStvyM13N CKDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=kBIOUh53; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bg3-20020a1709028e8300b001ab16e0ef5fsi2952253plb.581.2023.05.03.11.17.47; Wed, 03 May 2023 11:17:59 -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=@gmail.com header.s=20221208 header.b=kBIOUh53; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229849AbjECSGQ (ORCPT + 99 others); Wed, 3 May 2023 14:06:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbjECSGO (ORCPT ); Wed, 3 May 2023 14:06:14 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D83CE4F; Wed, 3 May 2023 11:06:13 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-24de2954bc5so3464447a91.1; Wed, 03 May 2023 11:06:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683137173; x=1685729173; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=4cv7r3p/uGjVZzfVGJD3+oUJmj97nEyjDPWByIKN3z4=; b=kBIOUh53OZR1fn3Tl9vhMiJMS2FInFLP+lUhlPMor7jTDMLunrtCSmTdzMWMH2FwCJ YVGqfGBLCcFxyEZqWGvgdtkqh7q9mW9TITc2zQ1MEl9Z4dyRAIRBQgQ/GqXqe64yJJJD jtv1N2E+Q8wb/Xz4JW2RS+0z2DdUghhXRvmD4NcDBMi7YahwOEPgg0vNKS60VKG0vC0s rVXB8P21/jbXTCpjmQQRTHqlVfjdnNcak2Qa/aW6mlFKobaN4n+shXYE6Y3F+F5hgEAG f9bKyMjVy+ACvR4cf5kNhW2+TZwy4NkBNj9YXF9ja+6/87G38J+6YdFn2/3Ki55ZW1Z2 6s2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683137173; x=1685729173; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4cv7r3p/uGjVZzfVGJD3+oUJmj97nEyjDPWByIKN3z4=; b=IdecMYrgn5HnKH2bBZyz7SItyN3h3g5UQgqubjJZW49ajMWU76Ru4Tzb7SJ+o63R+B g15R2C9jw9dojo+Naqx68ySzis4D0XJUsJq0Kt2Zvbe6RYepCLtJjnSVUiYaAxGxBROu 1QjcuMy4OuEUAfCzxejxihfbR91lOr7/EO48X6aVl86XXexNeuTQuvJktrwa8IswxRr4 rmvJ5vhZXHFXLLAKCdkXQ3pzT3INFzVFyoVb2hmS96mws7WixrQ1z9gwPGMFI/02izE7 nH9JuwtoIoF7aBALNiG5uAiuDrhgesGjA8NyjDyz79CFtSxNP1I1K4Wsmnt0UFKpVt5h WZKg== X-Gm-Message-State: AC+VfDyTTD/c7MDpASy356D/Nu8PUk6U6LdnDdmGoL6YfxJ2Xh/0CnpL cTVVLVSXje7ao4yw7PISbzg= X-Received: by 2002:a17:90a:850a:b0:24e:1f8:b786 with SMTP id l10-20020a17090a850a00b0024e01f8b786mr11008096pjn.19.1683137172717; Wed, 03 May 2023 11:06:12 -0700 (PDT) Received: from localhost ([2620:10d:c090:400::5:6454]) by smtp.gmail.com with ESMTPSA id g4-20020a1709026b4400b001a183ade911sm21931204plt.56.2023.05.03.11.06.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 May 2023 11:06:12 -0700 (PDT) Sender: Tejun Heo Date: Wed, 3 May 2023 08:06:10 -1000 From: Tejun Heo To: Suren Baghdasaryan Cc: Kent Overstreet , Michal Hocko , akpm@linux-foundation.org, vbabka@suse.cz, hannes@cmpxchg.org, roman.gushchin@linux.dev, mgorman@suse.de, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, corbet@lwn.net, void@manifault.com, peterz@infradead.org, juri.lelli@redhat.com, ldufour@linux.ibm.com, catalin.marinas@arm.com, will@kernel.org, arnd@arndb.de, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, x86@kernel.org, peterx@redhat.com, david@redhat.com, axboe@kernel.dk, mcgrof@kernel.org, masahiroy@kernel.org, nathan@kernel.org, dennis@kernel.org, muchun.song@linux.dev, rppt@kernel.org, paulmck@kernel.org, pasha.tatashin@soleen.com, yosryahmed@google.com, yuzhao@google.com, dhowells@redhat.com, hughd@google.com, andreyknvl@gmail.com, keescook@chromium.org, ndesaulniers@google.com, gregkh@linuxfoundation.org, ebiggers@google.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, jbaron@akamai.com, rientjes@google.com, minchan@google.com, kaleshsingh@google.com, kernel-team@android.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, linux-arch@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, kasan-dev@googlegroups.com, cgroups@vger.kernel.org, Alexei Starovoitov , Andrii Nakryiko Subject: Re: [PATCH 00/40] Memory allocation profiling Message-ID: References: <20230501165450.15352-1-surenb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 Hello, Suren. On Wed, May 03, 2023 at 10:42:11AM -0700, Suren Baghdasaryan wrote: > > * The framework doesn't really have any runtime overhead, so we can have it > > deployed in the entire fleet and debug wherever problem is. > > Do you mean it has no runtime overhead when disabled? Yes, that's what I meant. > If so, do you know what's the overhead when enabled? I want to > understand if that's truly a viable solution to track all allocations > (including slab) all the time. (cc'ing Alexei and Andrii who know a lot better than me) I don't have enough concrete benchmark data on the hand to answer definitively but hopefully what my general impresison would help. We attach BPF programs to both per-packet and per-IO paths. They obviously aren't free but their overhead isn't signficantly higher than building in the same thing in C code. Once loaded, BPF progs are jit compiled into native code. The generated code will be a bit worse than regularly compiled C code but those are really micro differences. There's some bridging code to jump into BPF but again negligible / acceptable even in the hottest paths. In terms of execution overhead, I don't think there is a signficant disadvantage to doing these things in BPF. Bigger differences would likely be in tracking data structures and locking around them. One can definitely better integrate tracking into alloc / free paths piggybacking on existing locking and whatnot. That said, BPF hashtable is pretty fast and BPF is constantly improving in terms of data structure support. It really depends on the workload and how much overhead one considers acceptable and I'm sure persistent global tracking can be done more efficiently with built-in C code. That said, done right, the overhead difference most likely isn't gonna be orders of magnitude but more like in the realm of tens of percents, if that. So, it doesn't nullify the benefits a dedicated mechansim can bring but does change the conversation quite a bit. Is the extra code justifiable given that most of what it enables is already possible using a more generic mechanism, albeit at a bit higher cost? That may well be the case but it does raise the bar. Thanks. -- tejun