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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E1AEC46467 for ; Thu, 14 Apr 2022 14:56:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348339AbiDNOwd (ORCPT ); Thu, 14 Apr 2022 10:52:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344857AbiDNNoo (ORCPT ); Thu, 14 Apr 2022 09:44:44 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F1CBF38BCD for ; Thu, 14 Apr 2022 06:40:26 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7E8F9139F; Thu, 14 Apr 2022 06:40:26 -0700 (PDT) Received: from lakrids (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2CA933F70D; Thu, 14 Apr 2022 06:40:24 -0700 (PDT) Date: Thu, 14 Apr 2022 14:40:21 +0100 From: Mark Rutland To: andrey.konovalov@linux.dev Cc: Marco Elver , Alexander Potapenko , 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: Re: [PATCH v3 0/3] kasan, arm64, scs: collect stack traces from Shadow Call Stack Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 14, 2022 at 01:36:59PM +0100, Mark Rutland wrote: > As I suspected, you're hitting a known performance oddity with QEMU TCG > mode where pointer authentication is *incredibly* slow when using the > architected QARMA5 algorithm (enabled by default with `-cpu max`). > This overhead has nothing to do with the *nature* of the unwinder, and > is an artifact of the *platform* and the *structure* of the code. > There's plenty that can be done to avoid that overhead FWIW, from a quick look, disabling KASAN instrumentation for the stacktrace object alone (with no other changes) has a significant impact (compounded by the TCG QARMA5 slowdown), and I note that x86 doesn't both instrumenting its stacktrace code anyway, so we could consider doing likewise. Atop that, replacing set_bit() with __set_bit() brings the regular unwinder *really* close to the earlier SCS unwinder figures. I know that the on_accessible_stack() calculations and checks could be ammortized with some refactoring (which I'd planned to do anyway), so I think it's plausible that with some changes to the existing unwinder we can bring the difference into the noise. > generic kasan w/ `-cpu max` > --------------------------- > > master-no-stack-traces: 12.66 > master: 18.39 (+45.2%) > master-no-stack-depot: 17.85 (+40.1%) > up-scs-stacks-v3: 13.54 (+7.0%) master-noasan: 15.67 (+23.8%) master-noasan-__set_bit: 14.61 (+15.5%) > Generic KASAN w/ `-cpu max,pauth-impdef=true` > --------------------------------------------- > > master-no-stack-traces: 2.69 > master: 3.35 (+24.5%) > master-no-stack-depot: 3.54 (+31.5%) > up-scs-stacks-v3: 2.80 (+4.1%) master-noasan: 3.05 (+13.0%) master-noasan-__set_bit: 2.96 (+10.0%) > Generic KASAN w/ `-cpu max,pauth=false` > --------------------------------------- > > master-no-stack-traces: 1.92 > master: 2.27 (+18.2%) > master-no-stack-depot: 2.22 (+15.6%) > up-scs-stacks-v3: 2.06 (+7.3%) master-noasan: 2.14 (+11.4%) master-noasan-__set_bit: 2.10 (+9.4%) Thanks, Mark. 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A33C0C433F5 for ; Thu, 14 Apr 2022 13:41:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2e0lAHLULfugPdV9s65HXUeolnUXTVBRZc/cV9TVowY=; b=W+dgumURHgfEOB 7wZy+5GJLCQaNvE6XJ+sH4/5WZ8z0JLUYSYduUxS9nhh4F34jvsUXXuIkjDtYnAMHFpVHEFxHGPpz Y4TMBEhke6ud3orzM/ExTmyV/RrtkFy3WekHZa5QRh/HTZQajP1ZIqI99UGovMVAAjn+u5O3M5esj kFosqb8EJxI7Z1sfWSsP6vZfXNA8G92bKq+AyyOxs+SEBvzlg+/TQf6sM1lFASnKaw5sfVp4butqj fN55hGy9fRTJ/Po6PVcINrOiDN729QpzzxXkj4eG/k9sI+zSTT2jCm7ahyPd8/vDqvuYuqkvcHsH9 +5AjKb2eyI2n4i1VURNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nezi9-005q9x-KG; Thu, 14 Apr 2022 13:40:37 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nezi2-005q6E-Rv for linux-arm-kernel@lists.infradead.org; Thu, 14 Apr 2022 13:40:33 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7E8F9139F; Thu, 14 Apr 2022 06:40:26 -0700 (PDT) Received: from lakrids (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2CA933F70D; Thu, 14 Apr 2022 06:40:24 -0700 (PDT) Date: Thu, 14 Apr 2022 14:40:21 +0100 From: Mark Rutland To: andrey.konovalov@linux.dev Cc: Marco Elver , Alexander Potapenko , 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: Re: [PATCH v3 0/3] kasan, arm64, scs: collect stack traces from Shadow Call Stack Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220414_064030_996820_17860FA1 X-CRM114-Status: GOOD ( 12.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Apr 14, 2022 at 01:36:59PM +0100, Mark Rutland wrote: > As I suspected, you're hitting a known performance oddity with QEMU TCG > mode where pointer authentication is *incredibly* slow when using the > architected QARMA5 algorithm (enabled by default with `-cpu max`). > This overhead has nothing to do with the *nature* of the unwinder, and > is an artifact of the *platform* and the *structure* of the code. > There's plenty that can be done to avoid that overhead FWIW, from a quick look, disabling KASAN instrumentation for the stacktrace object alone (with no other changes) has a significant impact (compounded by the TCG QARMA5 slowdown), and I note that x86 doesn't both instrumenting its stacktrace code anyway, so we could consider doing likewise. Atop that, replacing set_bit() with __set_bit() brings the regular unwinder *really* close to the earlier SCS unwinder figures. I know that the on_accessible_stack() calculations and checks could be ammortized with some refactoring (which I'd planned to do anyway), so I think it's plausible that with some changes to the existing unwinder we can bring the difference into the noise. > generic kasan w/ `-cpu max` > --------------------------- > > master-no-stack-traces: 12.66 > master: 18.39 (+45.2%) > master-no-stack-depot: 17.85 (+40.1%) > up-scs-stacks-v3: 13.54 (+7.0%) master-noasan: 15.67 (+23.8%) master-noasan-__set_bit: 14.61 (+15.5%) > Generic KASAN w/ `-cpu max,pauth-impdef=true` > --------------------------------------------- > > master-no-stack-traces: 2.69 > master: 3.35 (+24.5%) > master-no-stack-depot: 3.54 (+31.5%) > up-scs-stacks-v3: 2.80 (+4.1%) master-noasan: 3.05 (+13.0%) master-noasan-__set_bit: 2.96 (+10.0%) > Generic KASAN w/ `-cpu max,pauth=false` > --------------------------------------- > > master-no-stack-traces: 1.92 > master: 2.27 (+18.2%) > master-no-stack-depot: 2.22 (+15.6%) > up-scs-stacks-v3: 2.06 (+7.3%) master-noasan: 2.14 (+11.4%) master-noasan-__set_bit: 2.10 (+9.4%) Thanks, Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel