Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp2846127rwb; Mon, 5 Sep 2022 02:25:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR7R1uZRDW7cqgfFwE62JGhbEeGaALzB5KIfIfQI0tRwoOsspkamqLxhRMbNS2oHtraX3mnz X-Received: by 2002:aa7:d0c7:0:b0:44d:f0ed:75b8 with SMTP id u7-20020aa7d0c7000000b0044df0ed75b8mr6399146edo.50.1662369911825; Mon, 05 Sep 2022 02:25:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662369911; cv=none; d=google.com; s=arc-20160816; b=p/P+KR7NkEBO05KjSM9CUvTyEPU0UvFdK90jYH/cVGZ2v/RAobg9d8OfD9cP8l9vyd V9KGRBKV2SlTxJtwEuQJX18MHTdo+V0KoCeuUJqZImQDKxyy4TskmT/5VxuqOTssDlmh rtRQ/GawlfQyYBMFvYhxVRwo5UWVbp59zGu5AokiHRZ1kA2G/vTfe5l9/P5g5O/dTodS k4EzSkGMDzG+hs+Yl9Df4IisdOGYdU+mGp6oIadhv/j6xzSCgzEZqxYrZp3cHlrPrJDn Y65mGmosa5cCIN+Os8R4AGm4Q4+8kenaRS54dLkO2V5XMHal/md2JumanXZAUTNuh+iW idgg== 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=Mcscb+4yg14w1rBiRtYpdW9I8YuY8tTeWXrlK9wFWrU=; b=bXaYWP20iKDH4QNE4ceW2YbR1SwylFnBYzMGhjX1YluGpuA/odxHv0TCmWH3WKso1g TNJ8zw6cNTuGoQIZ8x82pgoVg/ftYzhtQ8NW6PGfMBq3oFYT7N1q7uvV37mKeFjmxecX mcAsrF99Yg6jvpoc3SmgLPSsFbq1oUKTHJr0YbynMpJpmLFoUwzCrykUKuZaOEjKBkYP R8Rs66ujlQ1wAi8s70Qxyd1JvM2g391BjWKz1Hhea6ddpyEPzKDUyEHTISgLe/JsM5Rj GdK5jVxU1CHc/ky30i2F8SGF5pYHEXrxI6JIELSiQxFbTXWEGUEOGF6uAyrYQx+4EqeM EwTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Z8sZwX0U; 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 n25-20020aa7c459000000b0044e946787a1si1088087edr.115.2022.09.05.02.24.46; Mon, 05 Sep 2022 02:25:11 -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=Z8sZwX0U; 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 S238004AbiIEI6s (ORCPT + 99 others); Mon, 5 Sep 2022 04:58:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237957AbiIEI6k (ORCPT ); Mon, 5 Sep 2022 04:58:40 -0400 Received: from mail-yw1-x1130.google.com (mail-yw1-x1130.google.com [IPv6:2607:f8b0:4864:20::1130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC7765006D for ; Mon, 5 Sep 2022 01:58:38 -0700 (PDT) Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-3378303138bso64245677b3.9 for ; Mon, 05 Sep 2022 01:58:38 -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=Mcscb+4yg14w1rBiRtYpdW9I8YuY8tTeWXrlK9wFWrU=; b=Z8sZwX0UrQNHUyE15uUzUljN1G5+XUXWn7ozlWkNQaPS0v+13+PWoolzvMZEH/2/s6 LYS6ZELiyvlMT62CZWUyH+h/p1jXfwfZLcOF83nbGfa1U5bzWw0uJywA1Nq6g4RggQN9 M+azNg9wtAjIuHGBIaj/LBqqtGG4wC1BksRWLrapbeVhca09DWdw9aO+S7lkiOmT419k B7LBrz0EVZ5dFwwSikfSkFiCRf8G7DmN1ptEdy0ZLUUkT5MXom1MAu8JaMJrJbPX6xsQ z/gVg/ZkLNO66Ao9RVZbmyzaUupGI6+7kFaD3U0bHdpOYObc1T0hLgrkbVZFP/rVpApA /zsg== 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=Mcscb+4yg14w1rBiRtYpdW9I8YuY8tTeWXrlK9wFWrU=; b=jjPYzrmk8hFaoJoFOvQ31KW9SQxkfe+R+Kf+2hXt8nvAshSzBnfi20daX5GKtmJDxA 3gNEvNf0d1o9fihEyPS7l80HwZsgXCyFxmlXMmbFLDonFxsyEUDsjaBxjmqL7rSNkQIl XECtCzTELwepIt0tmRPMPzCIwxyRFeqr+lcQYmYR8gwr71EH2IeTSKTN1Q3QMFAqfwOR o4J6XP+kGg5Cq9gL8WWhjDeixFbyKRGXL4uc1R6Ltuy79q5FYnYyKk1gv1TdQN714p48 1R77DVDdKLYN3bo62DS1HVfrDN4WkCqYy0bGbHGuwc1W2tXHkAdeT+KmKic+t92GrY8E 9R7w== X-Gm-Message-State: ACgBeo0gOdmm252xFem8/wyRX/993BEO4S/wB5Dv2q2bqW096YHMQ9lb 20jLCGXumaY050lxe5HHPYBZexJH+irhNbfq4qz+xg== X-Received: by 2002:a81:bb41:0:b0:328:fd1b:5713 with SMTP id a1-20020a81bb41000000b00328fd1b5713mr38838381ywl.238.1662368317652; Mon, 05 Sep 2022 01:58:37 -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: Marco Elver Date: Mon, 5 Sep 2022 10:58:01 +0200 Message-ID: Subject: Re: [RFC PATCH 00/30] Code tagging framework and applications To: Michal Hocko Cc: Suren Baghdasaryan , 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 , 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 Mon, 5 Sept 2022 at 10:12, Michal Hocko wrote: > On Sun 04-09-22 18:32:58, Suren Baghdasaryan wrote: > > On Thu, Sep 1, 2022 at 12:15 PM Michal Hocko wrote: > [...] > > > 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). > > > > As promised, I profiled a simple code that repeatedly makes 10 > > allocations/frees in a loop and measured overheads of code tagging, > > call stack capturing and tracing+BPF for page and slab allocations. > > Summary: > > > > Page allocations (overheads are compared to get_free_pages() duration): > > 6.8% Codetag counter manipulations (__lazy_percpu_counter_add + __alloc_tag_add) > > 8.8% lookup_page_ext > > 1237% call stack capture > > 139% tracepoint with attached empty BPF program > > Yes, I am not surprised that the call stack capturing is really > expensive comparing to the allocator fast path (which is really highly > optimized and I suspect that with 10 allocation/free loop you mostly get > your memory from the pcp lists). Is this overhead still _that_ visible > for somehow less microoptimized workloads which have to take slow paths > as well? > > Also what kind of stack unwinder is configured (I guess ORC)? This is > not my area but from what I remember the unwinder overhead varies > between ORC and FP. > > And just to make it clear. I do realize that an overhead from the stack > unwinding is unavoidable. And code tagging would logically have lower > overhead as it performs much less work. But the main point is whether > our existing stack unwiding approach is really prohibitively expensive > to be used for debugging purposes on production systems. I might > misremember but I recall people having bigger concerns with page_owner > memory footprint than the actual stack unwinder overhead. This is just to point out that we've also been looking at cheaper collection of the stack trace (for KASAN and other sanitizers). The cheapest way to unwind the stack would be a system with "shadow call stack" enabled. With compiler support it's available on arm64, see CONFIG_SHADOW_CALL_STACK. For x86 the hope is that at one point the kernel will support CET, which newer Intel and AMD CPUs support. Collecting the call stack would then be a simple memcpy.