Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp935598pxb; Wed, 6 Apr 2022 04:46:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7uUUde/i4eA9Dal1DFZQWFdz2uyNPq9+5h5N8hZfsOiwMZUAMEvJ19jEBI+hMr0d31kef X-Received: by 2002:a17:90a:cc0d:b0:1ca:c47f:a8f6 with SMTP id b13-20020a17090acc0d00b001cac47fa8f6mr9386000pju.1.1649245597607; Wed, 06 Apr 2022 04:46:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649245597; cv=none; d=google.com; s=arc-20160816; b=bMftoQtHaooAA4i0JsijgATLMIVjbqCVsYZXEf8g8XQiYAVjiVaN8UHDIAY5tXXthZ 68HihUgxlx1F/hnBNFx2yU9dBivAvjAd9Qw0deJQI7RawYLfbLc0bUfUWBQbPe7U5D+A aE+iqqbPOZv7zaoHAhMp34hcESyJH+FH3ABl1DhgK04Nle7voylOpzju4QqSq77RhLuk 1bXKwK/Ih8YHDHbCf4h8QUBy7jYDoXb5lXSKditgMzCK/SB6ZEFY8tOmtS5Ya4aCd/J3 /Wz5239u3dRt24+UXQuFuxj858dg5JIx3SbRO/MFttFsrt3VufX7+2eohi5fphWNg+Vw VjhA== 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=FtaEgz69DQ819AKh/JUIG3OQ4Q+fmie3I0z6sDwsCCk=; b=qsChHBIvuiBRLmEwcmR3AOSEqE8gt3SWkumpw5QkA/hs6iXjkqwTQKReHu7L0At8XT sf4AWgp4Fllaqiiym06xNYfIIhxNSPabRJ1eF5bP3u1X/yxHdgRRn6ArTLp7TRIly8mC ZR4FqTaUslxMxiHYsgSVYFuqNgvYElTQ7ewSLu3GGJU1jYjV75IdJQoFqCmD+wMoEyCg rZ4wHYJLhhypwVPHNbkiv+9c/MFHeEYoL5QGULuO91qyZHPnYfEnPYGDQBfPkFGMmN04 0UDveMKyIze1rGpfM77TI1bV/RJdScCreXWO/byvCWMwTIh+bZe87uHEHCM2D+hHauZO r5rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dFZM9Jrm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id o25-20020a635a19000000b003816043efe7si16054278pgb.476.2022.04.06.04.46.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 04:46:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dFZM9Jrm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BA4C813C719; Wed, 6 Apr 2022 03:03:30 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384221AbiDEUFJ (ORCPT + 99 others); Tue, 5 Apr 2022 16:05:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1457297AbiDEQDE (ORCPT ); Tue, 5 Apr 2022 12:03:04 -0400 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 742F024F39 for ; Tue, 5 Apr 2022 08:37:18 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id h63so15561021iof.12 for ; Tue, 05 Apr 2022 08:37:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FtaEgz69DQ819AKh/JUIG3OQ4Q+fmie3I0z6sDwsCCk=; b=dFZM9Jrm29mfxGpXaOsvIRZmFBKbc0AgfvSqpX3EioHJtIEsvWDD/GYPxV+38Ss6kK aSi5BlXbacPVXocOH787r6+R/vBk3hUUaZKk6t1gUvTV1szQ4wil+I9AUrXlJushPlL0 AUBAoWK2P/GkBgUjPd2KTB1I+cGHLXiYQLVf8QiRIZP2IuJwEOOq9A221Zbju6o70rWR Ti+4hXQ5CukVYwGcjeurbmjEzT6ndHMrkpAgA3Zx+OtFytIL3FcUgvGTIxPJLyKTB9SS SGZ37SJm00UTH/TDwyQGs9OOhfNB8HHKRQ33tHsCsm2Iybrwo2AwkIFF07Y/u09MzsvZ 3s4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FtaEgz69DQ819AKh/JUIG3OQ4Q+fmie3I0z6sDwsCCk=; b=ZmjCWbDpxNhMGGoIiRiPpx73h8U/15RQMx9aEr8js1UjwXdGzLMAvOztUmeikQRi6z 1FsNo9WqRy+K0q+EF2j5FpS8R94wpcenDqeA9RLxUjpRqGEcvHekPK7ueG+S/boPMLOT grirEILVTMVbhaJe+odL72ct5nRY+fUos8bofZ26gw2BEOH1xE5oA6iwiFU6Z4YROH4c M7wn9W8Da2onVcCPxmgVfbZhcMGRUfeg0wmxG6fkssePOj/HyfZnbwPvwOqP5vm+4YJ8 MC2i9lPq2wiGJWNP4ING8HfLAHNCCjbpHF3gMGFGBuUkG6H6TvAcA6FRuO9kSM7EeNXb 35/g== X-Gm-Message-State: AOAM5331OTjvyDgRbiQRJu1EN6SVjQwRZNZ9PgJtdcPCTvwKIqPbDDxG IlzoGNvFs2e0oPwPI7JNbsaR9onzeP9dX0Qpslk= X-Received: by 2002:a02:b687:0:b0:323:60e7:121a with SMTP id i7-20020a02b687000000b0032360e7121amr2473005jam.22.1649173037888; Tue, 05 Apr 2022 08:37:17 -0700 (PDT) MIME-Version: 1.0 References: <21e3e20ea58e242e3c82c19abbfe65b579e0e4b8.1648049113.git.andreyknvl@google.com> In-Reply-To: From: Andrey Konovalov Date: Tue, 5 Apr 2022 17:37:06 +0200 Message-ID: Subject: Re: [PATCH v2 1/4] stacktrace: add interface based on shadow call stack To: Mark Rutland Cc: andrey.konovalov@linux.dev, Marco Elver , Alexander Potapenko , Catalin Marinas , Will Deacon , Andrew Morton , Dmitry Vyukov , Andrey Ryabinin , kasan-dev , Vincenzo Frascino , Sami Tolvanen , Peter Collingbourne , Evgenii Stepanov , Florian Mayer , Linux Memory Management List , LKML , Andrey Konovalov Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,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 On Thu, Mar 31, 2022 at 11:19 AM Mark Rutland wrote: > > > Collecting stack traces this way is significantly faster: boot time > > of a defconfig build with KASAN enabled gets descreased by ~30%. > > Hmm... just to check, do ou know if that's just because of hte linear copy, or > because we're skipping other work we have to do in the regular stacktrace? No, I haven't looked into this. > > The implementation of the added interface is not meant to use > > stack_trace_consume_fn to avoid making a function call for each > > collected frame to further improve performance. > > ... because we could easily provide an inline-optimized stack copy *without* > having to write a distinct unwinder, and I'd *really* like to avoid having a > bunch of distinct unwinders for arm64, as it really hinders maintenance. We're > working on fixing/improving the arm64 unwinder for things like > RELIABLE_STACKTRACE, and I know that some of that work is non-trivial to make > work with an SCS-based unwind rather than an FP-based unwind, and/or will > undermine the saving anyway. Responded on the cover letter wrt this. > > +int stack_trace_save_shadow(unsigned long *store, unsigned int size, > > + unsigned int skipnr) > > +{ > > + /* > > + * Do not use stack_trace_consume_fn to avoid making a function > > + * call for each collected frame to improve performance. > > + * Skip + 1 frame to skip stack_trace_save_shadow. > > + */ > > + return arch_stack_walk_shadow(store, size, skipnr + 1); > > +} > > +#endif > > If we really need this, can we make it an __always_inline in a header so that > we can avoid the skip? Generally the skipping is problematic due to > inlining/outlining and LTO, and I'd like to avoid adding more of it > unnecessarily. Yes, I think this should work. However, if we keep the implementation in mm/kasan, this integration will not be required. Thanks!