Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp316827ybl; Thu, 29 Aug 2019 23:44:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxwXNBJcovFbtPzOPJIbl+4AEyJJxXrUtjOjry9zI6OhJ7rcZRuCnzSflaycv7m6MSYTd33 X-Received: by 2002:a62:8745:: with SMTP id i66mr16000064pfe.259.1567147448078; Thu, 29 Aug 2019 23:44:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567147448; cv=none; d=google.com; s=arc-20160816; b=fsbLZHWfzWP+v8eeytfFEiJZ2xHYg7yVlsS/SOQybdNIAgGN9//V0Xoh3ihykrnA8j ciy/dyKcKc8kUOQfXtLVqs5U5M/izpC/60mj84T+15wA5njX9nl9KrMzrBErrR+Fu+y9 U5s263WdjTzWe5KymMywxvpKQjOALJ83+hUe2kAXdtx2b5mDXb8otO28PGlch5HxpNXD rWCrWIbpCUYCARjXh/OUNMVn3lO8wMb1Mazadar6r/caPZA1NCduaWI2khhHlvFD6jl8 yj1Fy+nC104iICn9mwf7psGzcpHuy0Cbfk7wg/KEoF0q+Fm4sw5x4W9SfYepqR8A3NFq qAEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=rn2tl1njCxLoi6uBituC3AqMLr3etnHjZPnrofg+hCQ=; b=oQk50nibx6qFuySfV1cYKdT048aPSI6A1gMlrCDW2j+FJfdEXD7apuureT27LN8GCh hIYdTb3IjDOTTaVgw9vzLE1uykxo4cKdENmshsnJFRLAORVtdwGV4z9MtwqrKCo1GIG+ uelJ4btvoKoGF/hCK/gqZru7q24OpFLN4qYSiAgREsifvjD+giNiHlmSf8JjIJiGr+2+ 2M03O7N+1ZXzL635xVMZCcjaCNBB34PX7l5X2a4KNxCL82Uj+i/018af2oncxfLTdNNX 9v8ejEBsJGFJC/QJddQ9/4JMywrDJqSY00lNlQy1hqi7pFdWawx0Z37MmyWIeQmBtabr M14A== ARC-Authentication-Results: i=1; mx.google.com; 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 bg1si3919973plb.210.2019.08.29.23.43.51; Thu, 29 Aug 2019 23:44:08 -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; 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 S1727960AbfH3Gma (ORCPT + 99 others); Fri, 30 Aug 2019 02:42:30 -0400 Received: from mx2.suse.de ([195.135.220.15]:46754 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727156AbfH3Gma (ORCPT ); Fri, 30 Aug 2019 02:42:30 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 832E8ACC5; Fri, 30 Aug 2019 06:42:27 +0000 (UTC) Date: Fri, 30 Aug 2019 08:42:25 +0200 From: Michal =?UTF-8?B?U3VjaMOhbmVr?= To: Christophe Leroy Cc: linuxppc-dev@lists.ozlabs.org, Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , 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 Message-ID: <20190830084225.527f4265@naga> In-Reply-To: <4d996b0a225ca5b7d287ae46825d7da4a1d6e509.1567146554.git.christophe.leroy@c-s.fr> References: <4d996b0a225ca5b7d287ae46825d7da4a1d6e509.1567146554.git.christophe.leroy@c-s.fr> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 30 Aug 2019 06:35:11 +0000 (UTC) Christophe Leroy wrote: > 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 > That looks good. > 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)) I will leave consolidating this function to somebody who knows what the desired semantic is. With a short ifdef section at the top of the file it is a low-hanging fruit. Thanks Michal