From: "Michal Suchánek" <msuchanek@suse.de>
To: Christophe Leroy <christophe.leroy@c-s.fr>
Cc: linuxppc-dev@lists.ozlabs.org,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
Hari Bathini <hbathini@linux.ibm.com>,
Joel Stanley <joel@jms.id.au>,
Andrew Donnellan <andrew.donnellan@au1.ibm.com>,
Firoz Khan <firoz.khan@linaro.org>,
Breno Leitao <leitao@debian.org>,
Russell Currey <ruscur@russell.cc>,
Nicolai Stange <nstange@suse.de>,
Michael Neuling <mikey@neuling.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Thomas Gleixner <tglx@linutronix.de>,
Arnd Bergmann <arnd@arndb.de>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Heiko Carstens <heiko.carstens@de.ibm.com>,
Christian Brauner <christian@brauner.io>,
David Howells <dhowells@redhat.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Allison Randal <allison@lohutok.net>,
David Hildenbrand <david@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 5/5] powerpc/perf: split callchain.c by bitness
Date: Fri, 30 Aug 2019 08:42:25 +0200 [thread overview]
Message-ID: <20190830084225.527f4265@naga> (raw)
In-Reply-To: <4d996b0a225ca5b7d287ae46825d7da4a1d6e509.1567146554.git.christophe.leroy@c-s.fr>
On Fri, 30 Aug 2019 06:35:11 +0000 (UTC)
Christophe Leroy <christophe.leroy@c-s.fr> 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 <asm/sigcontext.h>
> #include <asm/ucontext.h>
> #include <asm/vdso.h>
> -#ifdef CONFIG_PPC64
> -#include "../kernel/ppc32.h"
> -#endif
> #include <asm/pte-walk.h>
>
> #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
next prev parent reply other threads:[~2019-08-30 6:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-29 22:28 [PATCH v5 0/5] Disable compat cruft on ppc64le v5 Michal Suchanek
2019-08-29 22:28 ` [PATCH v5 1/5] powerpc: make llseek 32bit-only Michal Suchanek
2019-08-29 22:28 ` [PATCH v5 2/5] powerpc: move common register copy functions from signal_32.c to signal.c Michal Suchanek
2019-08-29 22:28 ` [PATCH v5 3/5] powerpc/64: make buildable without CONFIG_COMPAT Michal Suchanek
2019-08-30 6:35 ` Christophe Leroy
2019-08-30 7:54 ` Michal Suchánek
2019-08-30 8:01 ` Christophe Leroy
2019-08-29 22:28 ` [PATCH v5 4/5] powerpc/64: Make COMPAT user-selectable disabled on littleendian by default Michal Suchanek
2019-08-29 22:28 ` [PATCH v5 5/5] powerpc/perf: split callchain.c by bitness Michal Suchanek
2019-08-30 6:35 ` Christophe Leroy
2019-08-30 6:42 ` Michal Suchánek [this message]
2019-08-30 7:12 ` Michal Suchánek
2019-08-30 7:15 ` Christophe Leroy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190830084225.527f4265@naga \
--to=msuchanek@suse.de \
--cc=allison@lohutok.net \
--cc=andrew.donnellan@au1.ibm.com \
--cc=arnd@arndb.de \
--cc=benh@kernel.crashing.org \
--cc=christian@brauner.io \
--cc=christophe.leroy@c-s.fr \
--cc=david@redhat.com \
--cc=dhowells@redhat.com \
--cc=ebiederm@xmission.com \
--cc=firoz.khan@linaro.org \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=hbathini@linux.ibm.com \
--cc=heiko.carstens@de.ibm.com \
--cc=joel@jms.id.au \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mikey@neuling.org \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=nstange@suse.de \
--cc=paulus@samba.org \
--cc=ruscur@russell.cc \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox