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 X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDF6DC433DF for ; Thu, 15 Oct 2020 15:22:54 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D06102225A for ; Thu, 15 Oct 2020 15:22:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D06102225A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codefail.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4CBtMH00L3zDqGG for ; Fri, 16 Oct 2020 02:22:51 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=codefail.de (client-ip=198.54.127.69; helo=se14-2.privateemail.com; envelope-from=cmr@codefail.de; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=codefail.de X-Greylist: delayed 1286 seconds by postgrey-1.36 at bilbo; Fri, 16 Oct 2020 02:20:26 AEDT Received: from se14-2.privateemail.com (se14-2.privateemail.com [198.54.127.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4CBtJV0D8JzDqF3 for ; Fri, 16 Oct 2020 02:20:25 +1100 (AEDT) Received: from new-01-3.privateemail.com ([198.54.122.47]) by se14.registrar-servers.com with esmtpsa (TLSv1.2:AES128-GCM-SHA256:128) (Exim 4.92) (envelope-from ) id 1kT4iT-0005PL-Nz for linuxppc-dev@lists.ozlabs.org; Thu, 15 Oct 2020 07:59:01 -0700 Received: from MTA-11.privateemail.com (unknown [10.20.147.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by NEW-01-3.privateemail.com (Postfix) with ESMTPS id B02B1A6F for ; Thu, 15 Oct 2020 14:58:52 +0000 (UTC) Received: from mta-11.privateemail.com (localhost [127.0.0.1]) by mta-11.privateemail.com (Postfix) with ESMTP id 9350580046 for ; Thu, 15 Oct 2020 10:58:52 -0400 (EDT) Received: from geist.attlocal.net (unknown [10.20.151.235]) by mta-11.privateemail.com (Postfix) with ESMTPA id 6541A80041 for ; Thu, 15 Oct 2020 14:58:52 +0000 (UTC) From: "Christopher M. Riedl" To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 0/8] Improve signal performance on PPC64 with KUAP Date: Thu, 15 Oct 2020 10:01:51 -0500 Message-Id: <20201015150159.28933-1-cmr@codefail.de> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV using ClamSMTP X-Originating-IP: 198.54.122.47 X-SpamExperts-Domain: o3.privateemail.com X-SpamExperts-Username: out-03 Authentication-Results: registrar-servers.com; auth=pass (plain) smtp.auth=out-03@o3.privateemail.com X-SpamExperts-Outgoing-Class: ham X-SpamExperts-Outgoing-Evidence: Combined (0.05) X-Recommended-Action: accept X-Filter-ID: Mvzo4OR0dZXEDF/gcnlw0ZXzIHSbE2lF8iY6Od2jmSypSDasLI4S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dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" As reported by Anton, there is a large penalty to signal handling performance on radix systems using KUAP. The signal handling code performs many user access operations, each of which needs to switch the KUAP permissions bit to open and then close user access. This involves a costly 'mtspr' operation [0]. There is existing work done on x86 and by Christopher Leroy for PPC32 to instead open up user access in "blocks" using user_*_access_{begin,end}. We can do the same in PPC64 to bring performance back up on KUAP-enabled radix systems. This series applies on top of Christophe Leroy's work for PPC32 [1] (I'm sure patchwork won't be too happy about that). The first two patches add some needed 'unsafe' versions of copy-from functions. While these do not make use of asm-goto they still allow for avoiding the repeated uaccess switches. The third patch adds 'notrace' to any functions expected to be called in a uaccess block context. Normally functions called in such a context should be inlined, but this is not feasible everywhere. Marking them 'notrace' should provide _some_ protection against leaving the user access window open. The next three patches rewrite some of the signal64 helper functions to be 'unsafe'. Finally, the last two patches update the main signal handling functions to make use of the new 'unsafe' helpers and eliminate some additional uaccess switching. I used the will-it-scale signal1 benchmark to measure and compare performance [2]. The below results are from a P9 Blackbird system. Note that currently hash does not support KUAP and is therefore used as the "baseline" comparison. Bigger numbers are better: signal1_threads -t1 -s10 | | hash | radix | | --------------- | ------ | ------ | | linuxppc/next | 289014 | 158408 | | unsafe-signal64 | 298506 | 253053 | [0]: https://github.com/linuxppc/issues/issues/277 [1]: https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=196278 [2]: https://github.com/antonblanchard/will-it-scale/blob/master/tests/signal1.c Christopher M. Riedl (5): powerpc/uaccess: Add unsafe_copy_from_user powerpc/signal: Add unsafe_copy_{vsx,fpr}_from_user() powerpc: Mark functions called inside uaccess blocks w/ 'notrace' powerpc/signal64: Replace setup_sigcontext() w/ unsafe_setup_sigcontext() powerpc/signal64: Replace restore_sigcontext() w/ unsafe_restore_sigcontext() Daniel Axtens (3): powerpc/signal64: Replace setup_trampoline() w/ unsafe_setup_trampoline() powerpc/signal64: Rewrite handle_rt_signal64() to minimise uaccess switches powerpc/signal64: Rewrite rt_sigreturn() to minimise uaccess switches arch/powerpc/include/asm/uaccess.h | 28 ++-- arch/powerpc/kernel/process.c | 20 +-- arch/powerpc/kernel/signal.h | 33 +++++ arch/powerpc/kernel/signal_64.c | 216 +++++++++++++++++------------ arch/powerpc/mm/mem.c | 4 +- 5 files changed, 194 insertions(+), 107 deletions(-) -- 2.28.0