From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18D9DECAAD3 for ; Mon, 5 Sep 2022 18:07:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7C45F801F6; Mon, 5 Sep 2022 14:07:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 772D2801E6; Mon, 5 Sep 2022 14:07:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5817C801F6; Mon, 5 Sep 2022 14:07:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 42AF4801E6 for ; Mon, 5 Sep 2022 14:07:38 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F11C6ABA06 for ; Mon, 5 Sep 2022 18:07:37 +0000 (UTC) X-FDA: 79878814554.05.F2BC15E Received: from mail-io1-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) by imf25.hostedemail.com (Postfix) with ESMTP id 95F86A0080 for ; Mon, 5 Sep 2022 18:07:37 +0000 (UTC) Received: by mail-io1-f45.google.com with SMTP id e195so7307751iof.1 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=54UQY/UAihq7uL1Ou6GfdM9C3k/V2DbFL80CvH0fNabfAUIEq30RNsVbazBlDi4Qf3 u/uI6ySOHM3BjnSo1ritR0/g4AJh0F/HdFL0do13wQk2bXTiq/9F6a7olel3U8fjsc4b Vbwn91kWUExcoiLrEpMzLNWd8vYEJwFjYMs51cw4DdybhhQWXsiRQ/3QmI6YkykFGm5E hRjDu/iaZFfxlzDR4SDpxu30c2+IjNP7TWh8ZI4NrIMOtHoHnWNzLSa1lclH6Lq8VGwM jQWmindy+arC/UHOk4g3gteVXCHD2bsL93Sw2uTcYZkcgpLhAgK9+zrYmhgs23bMlNXb PmuA== X-Gm-Message-State: ACgBeo0/aQM8sOY3oDmC4fB4e8QqwXqJ+Gn5uHQi75KzrdyWVCAT71y3 T9NBfwWnfxZp2OWph4uND130Rg7jMu4uH9C/DuVgJA== X-Google-Smtp-Source: AA6agR6r5XgehoMYjBLme4+OWXroqyk9NqBwquoUHJYNtZV3MpkU67zLpVv3eXPms5QzjDOiUeZjqJqeUZuYSAeGarw= 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662401257; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Bum5cdqCm4gIf+I6AQy+wa1rXRQMNTd23PbVP2YAzEs=; b=42bLxG0Mv2xjanK4eFCwo12TP9YFRR5BAE74WoWzWBgVMWeiWhnWr1b6wyQUHVYE0XejaB p1+LoJhXEb/zYzHuvVGvyVpPRyLVD6kKFoVJTmZ979IxyRhT6EH1Wxdb8z1mBZECAiCU85 gCrV3SYxH0wD5NdIM9PQozNRvj30oLQ= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=P1Rb3fVw; spf=pass (imf25.hostedemail.com: domain of surenb@google.com designates 209.85.166.45 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662401257; a=rsa-sha256; cv=none; b=jVI8Nm/5yTwc0coCP5OOz3qotrMeA1b0lhfh78JVqK1uXyDizP570/GCL1usvsT8/fch+t XfC1B1SxXoIsTWG2z2J/PYyqCzKTsRB2BTbQ9BLUgUOICVCFQ8bXpXV1v+53qDCa2RrzhJ JGjsgvXOri+toBIOi/GocXol9wQYjio= X-Rspam-User: X-Stat-Signature: ueb4trod66kr5fa33qw8pbe6eubcf1g6 X-Rspamd-Queue-Id: 95F86A0080 Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=P1Rb3fVw; spf=pass (imf25.hostedemail.com: domain of surenb@google.com designates 209.85.166.45 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam04 X-HE-Tag: 1662401257-954736 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.