Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3257687pxa; Tue, 18 Aug 2020 10:24:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxK+wspJ2XBSxXbk+6iBKc4ixkIUpFWjkbbdYC/eizmV/zxidTmgE1IXYDjJvuAD0Xvv0d6 X-Received: by 2002:a05:6402:1758:: with SMTP id v24mr21140140edx.274.1597771443628; Tue, 18 Aug 2020 10:24:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597771443; cv=none; d=google.com; s=arc-20160816; b=tui2hvSj8gNXGeFqky08Q1RyF6nLyMSvCTQzAcVuVEdVNGoSE3HjZMurR/ABJtnBOT nEmWVUrOlBkaoUPleffVJb459JFiZ0iahxkdi+TorGxlwtDPT3yvwr0xiA0h1fJWSPsT rMH2lZd2zfnjYxosPicND5Bjv2sleTYKBciO2kdotdQNFxEADvgSm9u8tpnfG9pQjlBa 5XukpA0p/hooi2wwWDadTAg+0jzlZx9Wp08IoObCtakWi4/mhtDdwbWKsEKSXQ0QbvOC XUAh1PeyNn05Ef368DNikj/QsAM7iAs+YqErL9eFpIjXmfke+0pfBUmmdNYEPGOC6cIF 6Djg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:message-id; bh=dIvK1MpM6C7NkqR4TCtEOzyMaejaJaJYDJXmT3C3A1E=; b=bW+0lc9BQJdpjKzKwvalXmC0PWuKzh+BjXYIWSa0MKR807zefWNLD1dsIJ3aUEI8so 9QcRdqkHqzMUyRNw/0bkMaMcu+HX2EvKyT/xbEIMqCVsUeL8m31QBqfBxeYuKsdzEuR+ 2Ty0JFxRZ0mUc/Agqwr7BPr2no5JZEE2C3yrkdnIU0gYn8pjvEEL4xry4I1WupiDv7eS KGWbVkdxYD/P8fVUMQymULPPb+VkjELGleWJrE7dFUg198NP4C43ktLQZr9iSyNYG2L5 2qIiEYWuEiwj1p73OpZLPRf3WSG4YxOxLz4XS1Rnqak4K3o9jM5C1DhW8PY2WbXWfCAR aSxw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a23si13561769edx.271.2020.08.18.10.23.39; Tue, 18 Aug 2020 10:24:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728561AbgHRRTW (ORCPT + 99 others); Tue, 18 Aug 2020 13:19:22 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:53262 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728375AbgHRRTQ (ORCPT ); Tue, 18 Aug 2020 13:19:16 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4BWHhG6lDGz9vCxl; Tue, 18 Aug 2020 19:19:10 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id KmAtwbC2ajWH; Tue, 18 Aug 2020 19:19:10 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4BWHhG5hQJz9vCxg; Tue, 18 Aug 2020 19:19:10 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 904248B7EC; Tue, 18 Aug 2020 19:19:12 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id foYwuDOQMRXv; Tue, 18 Aug 2020 19:19:12 +0200 (CEST) Received: from po17688vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 4C5D08B7D7; Tue, 18 Aug 2020 19:19:12 +0200 (CEST) Received: by po17688vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 0F0C965CF4; Tue, 18 Aug 2020 17:19:11 +0000 (UTC) Message-Id: From: Christophe Leroy Subject: [PATCH v2 00/25] powerpc: Switch signal 32 to using unsafe_put_user() and friends To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Tue, 18 Aug 2020 17:19:11 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This series leads to a reduction from 2.55s to 1.73s of the system CPU time with the following microbench app on an mpc832x with KUAP (approx 32%) This series replaces copies to users by unsafe_put_user() and friends with user_write_access_begin() dance in signal32. The advantages are: - No KUAP unlock/lock at every copy - More readable code. - Better generated code. Without KUAP, the difference is in the noise. void sigusr1(int sig) { } int main(int argc, char **argv) { int i = 100000; signal(SIGUSR1, sigusr1); for (;i--;) raise(SIGUSR1); exit(0); } An additional 0.10s reduction is achieved by removing CONFIG_PPC_FPU, as the mpc832x has no FPU. A bit less spectacular on an 8xx as KUAP is less heavy, prior to the series (with KUAP) it ran in 8.10 ms. Once applies the removal of FPU regs handling, we get 7.05s. With the full series, we get 6.9s. If artificially re-activating FPU regs handling with the full series, we get 7.6s. So for the 8xx, the removal of the FPU regs copy is what makes the difference, but the rework of handle_signal also have a benefit. Same as above, without KUAP the difference is in the noise. Difference since v1(RFC): - Almost copies to user are now replaced by unsafe_ alternative. - Reworked a bit the FPU registers handling following feedback from Michael. - Fixed a few build failures reported by Mr Robot on the RFC. Christophe Leroy (25): powerpc/signal: Move inline functions in signal.h powerpc/ptrace: Move declaration of ptrace_get_reg() and ptrace_set_reg() powerpc/ptrace: Consolidate reg index calculation powerpc/ptrace: Create ptrace_get_fpr() and ptrace_put_fpr() powerpc/signal: Don't manage floating point regs when no FPU powerpc/32s: Allow deselecting CONFIG_PPC_FPU on mpc832x powerpc/signal: Remove BUG_ON() in handler_signal functions powerpc/signal: Move access_ok() out of get_sigframe() powerpc/signal: Remove get_clean_sp() powerpc/signal: Call get_tm_stackpointer() from get_sigframe() powerpc/signal: Refactor bad frame logging powerpc/signal32: Simplify logging in handle_rt_signal32() powerpc/signal32: Move handle_signal32() close to handle_rt_signal32() powerpc/signal32: Rename local pointers in handle_rt_signal32() powerpc/signal32: Misc changes to make handle_[rt_]_signal32() more similar powerpc/signal32: Move signal trampoline setup to handle_[rt_]signal32 powerpc/signal32: Switch handle_signal32() to user_access_begin() logic powerpc/signal32: Switch handle_rt_signal32() to user_access_begin() logic powerpc/signal32: Remove ifdefery in middle of if/else signal: Add unsafe_put_compat_sigset() powerpc/signal32: Add and use unsafe_put_sigset_t() powerpc/signal32: Switch swap_context() to user_access_begin() logic powerpc/signal: Create 'unsafe' versions of copy_[ck][fpr/vsx]_to_user() powerpc/signal32: Isolate non-copy actions in save_user_regs() and save_tm_user_regs() powerpc/signal32: Transform save_user_regs() and save_tm_user_regs() in 'unsafe' version arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/processor.h | 16 +- arch/powerpc/include/asm/ptrace.h | 6 - arch/powerpc/kernel/asm-offsets.c | 2 + arch/powerpc/kernel/head_32.S | 4 + arch/powerpc/kernel/process.c | 4 + arch/powerpc/kernel/ptrace/Makefile | 3 +- arch/powerpc/kernel/ptrace/ptrace-decl.h | 21 + arch/powerpc/kernel/ptrace/ptrace-fpu.c | 40 ++ arch/powerpc/kernel/ptrace/ptrace-view.c | 2 + arch/powerpc/kernel/ptrace/ptrace.c | 54 +- arch/powerpc/kernel/ptrace/ptrace32.c | 2 + arch/powerpc/kernel/signal.c | 59 +-- arch/powerpc/kernel/signal.h | 115 ++++- arch/powerpc/kernel/signal_32.c | 598 +++++++++++------------ arch/powerpc/kernel/signal_64.c | 21 +- arch/powerpc/kernel/traps.c | 2 + arch/powerpc/platforms/Kconfig.cputype | 15 +- include/linux/compat.h | 32 ++ 19 files changed, 566 insertions(+), 431 deletions(-) create mode 100644 arch/powerpc/kernel/ptrace/ptrace-fpu.c -- 2.25.0