Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1483081pxb; Thu, 14 Apr 2022 07:12:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/rh7y3Rdg9jB5HKNEbHyUoCVgeKGNBANJaQcKqAy0fOYL81v19Kdv7mZ8mze+ZDxc0Zaz X-Received: by 2002:a63:6802:0:b0:37c:6bc1:f602 with SMTP id d2-20020a636802000000b0037c6bc1f602mr2530961pgc.128.1649945542509; Thu, 14 Apr 2022 07:12:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649945542; cv=none; d=google.com; s=arc-20160816; b=cvIgiCEvVYf+zS9PvvJ0CtW3itN5BMknY5Q7+R8wQ33tL2z/X6935P2ykXYHkwKhla PE4FvkAC6QCDK2/c9/wwNZ3TBQjQcN9oOlNmE0Fpnd4AaMbjkiExlVQUW2H5FC3C/3vX c9bJk4mM/Dm6Zy/LZVHDXiwB6EorV2B14+4KLq8bJkDYX1JKBOIYZ6lPci2sNMyU5L+H 0A9b7EvBTs4iOb9fbcbzzgK70xoRgh2g1GcxFbXFimR5oEULC8qO6tZvx53WU3s7WhfK sCHzIR74pfPOMTgRBZBGcxT+fJIe9jzsslkrwMD5yqNY/keoBS4Ws4ADZJ3MQo+F6JNv 3aRA== 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=JDSn48VO/uynw53/sb4SAMVT5nBlYcr9rW/XWz8GxpM=; b=L3qnedrcysg6LSaoIwYmWq250J1TLd0sdZcuyEiwZcHIDNqWjDAly7A9452zshCrUA eb49EIZd8/ICEITureDa4uqsrSrB8rS+TXq69DTFUTqFMCZ+QfnhhOqZHtOzXvD3L9/1 wZ6Koe9buStYCaipa9rokdIIZ+ggIBd9P2e3FEhHJp+gSyCbHxPaze25phOu/563YtmV upjE/nKd/R4X/ND+okuq/mIj+k3wInUNnAbFPI8hk7nA1503CuPrbXjhpLRlrgRAnAmP nSrhj2gWGQGr+iHBJ6MaNpGQMNnz8hRp34nL+arn9xmQ8yTZffTqCAk5VRZMyEgbakaK hWcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=sgF7TidZ; 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 q19-20020a170902bd9300b00156547bdf87si14355080pls.495.2022.04.14.07.12.07; Thu, 14 Apr 2022 07:12:22 -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=sgF7TidZ; 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 S238378AbiDMTaz (ORCPT + 99 others); Wed, 13 Apr 2022 15:30:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235254AbiDMTam (ORCPT ); Wed, 13 Apr 2022 15:30:42 -0400 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C013273041 for ; Wed, 13 Apr 2022 12:28:20 -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=1649878097; 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=JDSn48VO/uynw53/sb4SAMVT5nBlYcr9rW/XWz8GxpM=; b=sgF7TidZ/P5xqTORl4THKhdzQ00G5F6Fn39wehah+VVZmo+WJOxBeHdzsNbNNIShn9WE6w Qt9Bazc4jEh/KaM/hD9VnKJ780fSIt7YjOm05xnrVlhblVT2a3/vrvFbj/2vEF002aW9G4 2nQnx8WcHwg902UfuFYSedzVMroR/2M= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko , Mark Rutland Cc: Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Catalin Marinas , Will Deacon , Vincenzo Frascino , Sami Tolvanen , linux-arm-kernel@lists.infradead.org, Peter Collingbourne , Evgenii Stepanov , Florian Mayer , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH v3 3/3] kasan: use stack_trace_save_shadow Date: Wed, 13 Apr 2022 21:26:46 +0200 Message-Id: <05fb7a41510f471f82aa1f3930ed3aac8abe2410.1649877511.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 Use stack_trace_save_shadow() to collect stack traces 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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/kasan/common.c b/mm/kasan/common.c index 23b30fa6e270..00fef2e5fe90 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -97,7 +97,9 @@ depot_stack_handle_t kasan_save_stack(gfp_t flags, bool can_alloc) unsigned long entries[KASAN_STACK_DEPTH]; unsigned int nr_entries; - nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 0); + nr_entries = stack_trace_save_shadow(entries, ARRAY_SIZE(entries)); + if (nr_entries < 0) + nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 0); return __stack_depot_save(entries, nr_entries, flags, can_alloc); } -- 2.25.1