Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp814389pxb; Thu, 24 Mar 2022 07:29:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFbTAGnepUdQ7jI/3e0oR1R7xBwaL2EafNFAqlLaWhl9rQKeGRkVf+YWtCQisjBIDKXheP X-Received: by 2002:a17:906:b74f:b0:6df:cc38:fff1 with SMTP id fx15-20020a170906b74f00b006dfcc38fff1mr6168599ejb.78.1648132168809; Thu, 24 Mar 2022 07:29:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648132168; cv=none; d=google.com; s=arc-20160816; b=oGVprVtza101b5kdys7fMJDkdULAIWeA/kdjcXiAISOSQcQzDMfjuo5GJhrwS2B7eF xFLFdce84SiRO2BAupML9JdNPjunqOclSAoDjFHGdVadZANsdP5FfUlVOMHJev2rMyI5 lNY8iwerlewzkpXZyyqwrcFkowg3zao/6fAZI6i0CGdfFiK2HWk6l06fsF0I0XyeGaoW gVGulRmHuFFIKB6gNeNgXk49k6oYFlYM28Tze+4vGWgVsMro3I6E1Hx8KfDGX4ipdZzp uRfef/g7QEjBWIuTKaIY8b+r6xaDpLBKiR0s6Q6sQ/HvMgrqVa1fnzFsW2Jt2TanmdFS IWgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BKf6jB0gbxzfxKMTwtGAqqdjGZr2rSaHYmUmfoDqc2M=; b=GJ9syrMUsItLc/b8YNg0zTX1SbXnH9AQpKHX6fxP/+uEDj96B1iTBcOLRf+88OBUIG wwpMCL31iGALMENdDX6UDth4nwvAa86gTQJMUxLu6sddNxc0+fUPOn1jivaU9OwGZDOq WQG7el8bN5V+Bqko56CmSBmfaYySvL9EM5vlqJRGgG9y32j3215Gev6zmOhkNjxGeYHf 6et8GV0dxwRN116YyWIwDgNkVgYXMR0SoGuMa8mH/GvTqVCgmFVMF0dNtvJeo3FfKDTP FjWqUBRovw06mGAXyP5t9Ww5qyLSg3Q93INeBIdA/QWa2PsVnO1rOag0xHwsUvY1hGxc RrXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=BHH7IXDo; 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=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id os18-20020a170906af7200b006df76385d7fsi14956755ejb.543.2022.03.24.07.29.01; Thu, 24 Mar 2022 07:29:28 -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=@linux.dev header.s=key1 header.b=BHH7IXDo; 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=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245260AbiCWPfN (ORCPT + 99 others); Wed, 23 Mar 2022 11:35:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245192AbiCWPej (ORCPT ); Wed, 23 Mar 2022 11:34:39 -0400 Received: from out0.migadu.com (out0.migadu.com [IPv6:2001:41d0:2:267::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79AC3D8D for ; Wed, 23 Mar 2022 08:33:06 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1648049585; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BKf6jB0gbxzfxKMTwtGAqqdjGZr2rSaHYmUmfoDqc2M=; b=BHH7IXDotxEtbDywjIVk+wOZWOrLCY8o1Y0wKr7beWzVUIIg6NcRjZo4Ng098t1O+hRQBY Hj+XGflhkg2q6NrW+V2es5S1tFSC2M9D+KPkQyagcNNNo5WUxx/gSWh9/nZ8KEiacAZ/0J wefcvgBqi5K7ERAx+/NxwhoJ1KWavK4= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko , Catalin Marinas , Will Deacon , Andrew Morton Cc: Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mark Rutland , Vincenzo Frascino , Sami Tolvanen , Peter Collingbourne , Evgenii Stepanov , Florian Mayer , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH v2 4/4] kasan: use stack_trace_save_shadow Date: Wed, 23 Mar 2022 16:32:55 +0100 Message-Id: <7027b9b6b0cae2921ff65739582ae499bf61470c.1648049113.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Andrey Konovalov Now that stack_trace_save_shadow() is implemented by arm64, use it whenever CONFIG_HAVE_SHADOW_STACKTRACE is enabled. This improves the boot time of a defconfig build by ~30% for all KASAN modes. Signed-off-by: Andrey Konovalov --- mm/kasan/common.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mm/kasan/common.c b/mm/kasan/common.c index d9079ec11f31..8d9d35c6562b 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -33,10 +33,13 @@ depot_stack_handle_t kasan_save_stack(gfp_t flags, bool can_alloc) { unsigned long entries[KASAN_STACK_DEPTH]; - unsigned int nr_entries; + unsigned int size; - nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 0); - return __stack_depot_save(entries, nr_entries, flags, can_alloc); + if (IS_ENABLED(CONFIG_HAVE_SHADOW_STACKTRACE)) + size = stack_trace_save_shadow(entries, ARRAY_SIZE(entries), 0); + else + size = stack_trace_save(entries, ARRAY_SIZE(entries), 0); + return __stack_depot_save(entries, size, flags, can_alloc); } void kasan_set_track(struct kasan_track *track, gfp_t flags) -- 2.25.1