Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp3424321rwb; Mon, 5 Sep 2022 11:23:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR7ep6yDUE+sMlop++3aXhFgYGo6r8kpian531/ylPcYDtFGTat2+fJlOEVPpssVMK3Qf41u X-Received: by 2002:a05:6402:e98:b0:44d:c2e0:d8b0 with SMTP id h24-20020a0564020e9800b0044dc2e0d8b0mr8618465eda.165.1662402179599; Mon, 05 Sep 2022 11:22:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662402179; cv=none; d=google.com; s=arc-20160816; b=luuB+owrlEAn5iZiQq5zENZZJXQLnD6mPJmqHOwaYWlhKhGlqt4w8B9yfnCgUjXhy5 HaKqCfn5bS+Sg7VP2ljR9hZZasmhl5BYkbCgJq/hLvMP04nkmPckjzQtpxR+8J86TpbJ seXQLGf2bL2K9lHnhKAplE8axBf/eyokYZsWTsoai4/ssNR5LipfZyeizYr/2e6dmOzK H6oPEsPF7EtcSimPDt+W5XcgFKWGpkJeaAdvHbC2G7BU60rElNJnIM2PhrYc5QZABGhX cfkto+O3QGZthOExQLvc6bVSqoJyPnsP5ORzziHCd3/oetGUtHGfDur5NcEMePC0iHpD J6vw== 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=Bum5cdqCm4gIf+I6AQy+wa1rXRQMNTd23PbVP2YAzEs=; b=cSYSuZlRMNOHRWyGWDxMUUiZcwqhSQthNoGVI7hES4YPRqAc+EcWbAXGFKLLAlRMAE eAQE1utcyFBa9l9oq6jTNjBFzMwtGBj7vzXdJ0EL1vc/lIQ1V38Sa8pNTvqmvgUT302W 17TwTD6vFNxY6FUH6eEDJRX5JW/N64gef9c31qOjWjiK2eirwmwiyDaubSrKtoumLAsu UTeg19sKCnGeLW95ozza0WXRco3uMLPyTZpn39hemo1MLGgcYxPctkiuNjGnkeDAm0Hl TvDwpcDLThsfRNcDR1YEwaMnhF7jTMXPsHK+uh7+FwLDu8DgQZlxc+4yoQQaEjeQB3Wb rZ7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=P1Rb3fVw; 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 hv16-20020a17090760d000b0073c5d9b3440si6928851ejc.781.2022.09.05.11.22.33; Mon, 05 Sep 2022 11:22: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=@google.com header.s=20210112 header.b=P1Rb3fVw; 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 S231981AbiIESHn (ORCPT + 99 others); Mon, 5 Sep 2022 14:07:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231256AbiIESHm (ORCPT ); Mon, 5 Sep 2022 14:07:42 -0400 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EDF05EDEA for ; Mon, 5 Sep 2022 11:07:37 -0700 (PDT) Received: by mail-io1-xd2c.google.com with SMTP id z72so7255708iof.12 for ; Mon, 05 Sep 2022 11:07:37 -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=Bum5cdqCm4gIf+I6AQy+wa1rXRQMNTd23PbVP2YAzEs=; b=P1Rb3fVwlXmtVf21S4DMQt260sMuniAXM5U5+atV+MhvCaumM2tXM3K6KXNyMSjZe0 3nRcAmBfF+7W6/WOVR2XOADKxyQte4OnojdLmDBhMFh9NdRikO81nZDemeys0l200+Ya BtEOzumSQwgu7ZWm3QeSZrXIo15d7vuotOaip8lu87RHKwjf3TUmogDdVvisjKKDmHLO PI+YQ7orIzFlOARyvXxCAIGW+yY5UcwZ3NgJ+U4tIgdfF/EioIbKjubkaR07oZSndJ0y pThgMzg7BhFJemuG5SPivo5QOLrPUeLBb55vYf5zQYtWTw5SjAAGq1FqYgp+ZLnBdvd/ Qr0g== 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=Bum5cdqCm4gIf+I6AQy+wa1rXRQMNTd23PbVP2YAzEs=; b=33z1kGpGkvGmQM5tY8BfCaoEnOYvX9cukeKdkNfOnhiqdRhVvUAVkXYNZs/fpV456+ gNsDDX2LLBbDfVmz4F6CqboI4y3rnEV5M8QiPxEcDPPMeHJbbwyFioNbH4ZLrIF/o0Hd LXBiQsM+d5vhF9sjPTXpvoB8bGi2jsMPtTXgEpBChQeQVOiA5AbZj2ZTRE/MzMIUHgbj zllla3ek3PTe6aEJobemraYZ4C8xi+0/ZFHM1ll0EpO8pJYbsmCRkaB3Eg5HRZtxud2y Yms6Z/ZVmecdn2byfR3g77MRBF5P7p0BKWeYH07zU96v+ZnVoElK69SbEEEEeXIQAbiN evaQ== X-Gm-Message-State: ACgBeo2BWXj4rX0/cntfeQZ7BRrx+P034XIR9jRgQxwwcuvBo5mDE4u3 cHnjE5ahSuBl2836FkUHrdRMXb15TyJDUAo/BCKzaA== X-Received: by 2002:a05:6638:1492:b0:34c:d42:ac2f with SMTP id j18-20020a056638149200b0034c0d42ac2fmr13910620jak.305.1662401256621; Mon, 05 Sep 2022 11:07:36 -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: Mon, 5 Sep 2022 11:07:25 -0700 Message-ID: Subject: Re: [RFC PATCH 00/30] Code tagging framework and applications To: Marco Elver Cc: Michal Hocko , 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=unavailable 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, Sep 5, 2022 at 1:58 AM Marco Elver wrote: > > 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. Thanks for the note Marco! I'll check out the CONFIG_SHADOW_CALL_STACK on Android.