Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp310393ybl; Thu, 29 Aug 2019 23:36:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZ5j+Nl/qJ9y0azB+xTeNOoIoYvVLlyXHWgqH65fmHGTF2PqEXCuo91HBFtOvbu16P26MG X-Received: by 2002:aa7:9735:: with SMTP id k21mr16072512pfg.116.1567146999143; Thu, 29 Aug 2019 23:36:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567146999; cv=none; d=google.com; s=arc-20160816; b=YCWSpu1VkwHO2E8WHf7UGctbenopu27t7lNmJ138sZqp13yPIiPTvZXWUAI4aKt55l KQzCfysmd9K0Kp8Vsf2WvDMrr1g4cjG2fvg+eKqBWUqD818MB8TDv4Ki4en02UaveinX aAWzHF61jDI6kqZZJ751Xevx6q7ea/tiUJlWgpwg5EME+ZMll18kw/mHOn+L1CTxuF6i qg39DmWrSrhPRsW/HvhBhgqA9ilwFtjyYAjY739C+z72UF6Nc3kEWIdt1etgifIMce7j 0SQ0HFJPCtpj9aDVnLAvnDP3DAq7OqtYG8pVKtiBKEf4EUPsbo+Mqh4XqlnyGWk5dY1a /D3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:in-reply-to:subject:cc:to:from :message-id:dkim-signature; bh=VNDjb7XNAUJpnNF57BH/DOSkfSBvm6Cn47vrZkZHhkw=; b=YJQd6ntwYoQ9okeo6XOjM4pTBZhD/y25nuVw5sqW1XlZfmAahjwu6i5TPp2FCxjzBr XrjcOOre06KyZJd7QTAUX1G0ep5Wd8ZniebQO2lGpHdUYvVjfYqAdENf+/iYAHR/vrts NpFY8CmkDIUJFLFHn9yHO/f7DqQChqcMjeyrpjmfuIDOoDRXBLBaO+uk+DWSmqToFDeD AJetIo/s6NBoD+8lxD9nZ5jZvl5xhAnOBw97689YF/Sy192JKisOy37Lq7O9vczBsnyW rX9FZmM92FC9YNzV7T9cKT8ibGlufUMz2qE1P766qqOyuYT22RRwlYnaaAmryJ08JDze Tm0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=orATMH27; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a15si4000222pgw.313.2019.08.29.23.36.23; Thu, 29 Aug 2019 23:36:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=orATMH27; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728042AbfH3GfR (ORCPT + 99 others); Fri, 30 Aug 2019 02:35:17 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:51052 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727023AbfH3GfQ (ORCPT ); Fri, 30 Aug 2019 02:35:16 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 46KV8b665GzB09Zr; Fri, 30 Aug 2019 08:35:11 +0200 (CEST) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=orATMH27; dkim-adsp=pass; dkim-atps=neutral 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 PlcR-YZRkOXv; Fri, 30 Aug 2019 08:35:11 +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 46KV8b4wh4zB09Zq; Fri, 30 Aug 2019 08:35:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1567146911; bh=VNDjb7XNAUJpnNF57BH/DOSkfSBvm6Cn47vrZkZHhkw=; h=From:To:Cc:Subject:In-Reply-To:Date:From; b=orATMH27meGQqzEjW6rZktasZZPfcKds3CNJBTx4K4XOa6AsiVfTyZsDPtWKWj/ip 0Zr88yjRrne1KOgVxSb6knUuH8pK8KP6fqu2krPwr1oZ5NhXv9RW8Rg5LvFG+LR6jF DwbnZidwbQ0UnKBbzWQjEnfQJ0srf3SXuHF/TpEs= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 9AA408B8E0; Fri, 30 Aug 2019 08:35: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 K6ZtuUL4-Grv; Fri, 30 Aug 2019 08:35:12 +0200 (CEST) Received: from pc16032vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.230.105]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 571BF8B8DD; Fri, 30 Aug 2019 08:35:12 +0200 (CEST) Received: by pc16032vm.idsi0.si.c-s.fr (Postfix, from userid 0) id E294869881; Fri, 30 Aug 2019 06:35:11 +0000 (UTC) Message-Id: <4d996b0a225ca5b7d287ae46825d7da4a1d6e509.1567146554.git.christophe.leroy@c-s.fr> From: Christophe Leroy To: linuxppc-dev@lists.ozlabs.org, Michal Suchanek Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Christophe Leroy , Nicholas Piggin , Hari Bathini , Joel Stanley , Andrew Donnellan , Firoz Khan , Breno Leitao , Russell Currey , Nicolai Stange , Michael Neuling , "Eric W. Biederman" , Thomas Gleixner , Arnd Bergmann , Geert Uytterhoeven , Heiko Carstens , Christian Brauner , David Howells , Greg Kroah-Hartman , Allison Randal , David Hildenbrand , linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 5/5] powerpc/perf: split callchain.c by bitness In-Reply-To: Date: Fri, 30 Aug 2019 06:35:11 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/29/2019 10:28 PM, Michal Suchanek wrote: > Building callchain.c with !COMPAT proved quite ugly with all the > defines. Splitting out the 32bit and 64bit parts looks better. > > Also rewrite current_is_64bit as common function. No other code change > intended. Nice result. Could look even better by merging both read_user_stack_32(), see below. Also a possible cosmetic change to Makefile. --- arch/powerpc/perf/Makefile | 7 ++--- arch/powerpc/perf/callchain_32.c | 65 ++++++++++++++++------------------------ 2 files changed, 29 insertions(+), 43 deletions(-) diff --git a/arch/powerpc/perf/Makefile b/arch/powerpc/perf/Makefile index e9f3202251d0..53d614e98537 100644 --- a/arch/powerpc/perf/Makefile +++ b/arch/powerpc/perf/Makefile @@ -1,9 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_PERF_EVENTS) += callchain.o perf_regs.o -ifdef CONFIG_PERF_EVENTS -obj-y += callchain_$(BITS).o -obj-$(CONFIG_COMPAT) += callchain_32.o +obj-$(CONFIG_PERF_EVENTS) += callchain.o callchain_$(BITS).o perf_regs.o +ifdef CONFIG_COMPAT +obj-$(CONFIG_PERF_EVENTS) += callchain_32.o endif obj-$(CONFIG_PPC_PERF_CTRS) += core-book3s.o bhrb.o diff --git a/arch/powerpc/perf/callchain_32.c b/arch/powerpc/perf/callchain_32.c index 0bd4484eddaa..17c43ae03084 100644 --- a/arch/powerpc/perf/callchain_32.c +++ b/arch/powerpc/perf/callchain_32.c @@ -15,50 +15,13 @@ #include #include #include -#ifdef CONFIG_PPC64 -#include "../kernel/ppc32.h" -#endif #include #include "callchain.h" #ifdef CONFIG_PPC64 -static int read_user_stack_32(unsigned int __user *ptr, unsigned int *ret) -{ - if ((unsigned long)ptr > TASK_SIZE - sizeof(unsigned int) || - ((unsigned long)ptr & 3)) - return -EFAULT; - - pagefault_disable(); - if (!__get_user_inatomic(*ret, ptr)) { - pagefault_enable(); - return 0; - } - pagefault_enable(); - - return read_user_stack_slow(ptr, ret, 4); -} -#else /* CONFIG_PPC64 */ -/* - * On 32-bit we just access the address and let hash_page create a - * HPTE if necessary, so there is no need to fall back to reading - * the page tables. Since this is called at interrupt level, - * do_page_fault() won't treat a DSI as a page fault. - */ -static int read_user_stack_32(unsigned int __user *ptr, unsigned int *ret) -{ - int rc; - - if ((unsigned long)ptr > TASK_SIZE - sizeof(unsigned int) || - ((unsigned long)ptr & 3)) - return -EFAULT; - - pagefault_disable(); - rc = __get_user_inatomic(*ret, ptr); - pagefault_enable(); - - return rc; -} +#include "../kernel/ppc32.h" +#else #define __SIGNAL_FRAMESIZE32 __SIGNAL_FRAMESIZE #define sigcontext32 sigcontext @@ -95,6 +58,30 @@ struct rt_signal_frame_32 { int abigap[56]; }; +/* + * On 32-bit we just access the address and let hash_page create a + * HPTE if necessary, so there is no need to fall back to reading + * the page tables. Since this is called at interrupt level, + * do_page_fault() won't treat a DSI as a page fault. + */ +static int read_user_stack_32(unsigned int __user *ptr, unsigned int *ret) +{ + int rc; + + if ((unsigned long)ptr > TASK_SIZE - sizeof(unsigned int) || + ((unsigned long)ptr & 3)) + return -EFAULT; + + pagefault_disable(); + rc = __get_user_inatomic(*ret, ptr); + pagefault_enable(); + + if (IS_ENABLED(CONFIG_PPC32) || !rc) + return rc; + + return read_user_stack_slow(ptr, ret, 4); +} + static int is_sigreturn_32_address(unsigned int nip, unsigned int fp) { if (nip == fp + offsetof(struct signal_frame_32, mctx.mc_pad)) -- 2.13.3