[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200319144642.GL25468@kitsune.suse.cz>
Date: Thu, 19 Mar 2020 15:46:42 +0100
From: Michal Suchánek <msuchanek@...e.de>
To: Christophe Leroy <christophe.leroy@....fr>
Cc: Andy Shevchenko <andy.shevchenko@...il.com>,
"open list:LINUX FOR POWERPC PA SEMI PWRFICIENT"
<linuxppc-dev@...ts.ozlabs.org>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Michael Ellerman <mpe@...erman.id.au>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...hat.com>,
Namhyung Kim <namhyung@...nel.org>,
Alexander Viro <viro@...iv.linux.org.uk>,
Mauro Carvalho Chehab <mchehab+huawei@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Rob Herring <robh@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Thomas Gleixner <tglx@...utronix.de>,
Arnd Bergmann <arnd@...db.de>,
Nayna Jain <nayna@...ux.ibm.com>,
Eric Richter <erichte@...ux.ibm.com>,
Claudio Carvalho <cclaudio@...ux.ibm.com>,
Nicholas Piggin <npiggin@...il.com>,
Hari Bathini <hbathini@...ux.ibm.com>,
Masahiro Yamada <masahiroy@...nel.org>,
Thiago Jung Bauermann <bauerman@...ux.ibm.com>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Valentin Schneider <valentin.schneider@....com>,
Jordan Niethe <jniethe5@...il.com>,
Michael Neuling <mikey@...ling.org>,
Gustavo Luiz Duarte <gustavold@...ux.ibm.com>,
Allison Randal <allison@...utok.net>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
"linux-fsdevel @ vger . kernel . org --in-reply-to="
<20200225173541.1549955-1-npiggin@...il.com>
Subject: Re: [PATCH v11 4/8] powerpc/perf: consolidate valid_user_sp
On Thu, Mar 19, 2020 at 03:16:03PM +0100, Christophe Leroy wrote:
>
>
> Le 19/03/2020 à 14:35, Andy Shevchenko a écrit :
> > On Thu, Mar 19, 2020 at 1:54 PM Michal Suchanek <msuchanek@...e.de> wrote:
> > >
> > > Merge the 32bit and 64bit version.
> > >
> > > Halve the check constants on 32bit.
> > >
> > > Use STACK_TOP since it is defined.
> > >
> > > Passing is_64 is now redundant since is_32bit_task() is used to
> > > determine which callchain variant should be used. Use STACK_TOP and
> > > is_32bit_task() directly.
> > >
> > > This removes a page from the valid 32bit area on 64bit:
> > > #define TASK_SIZE_USER32 (0x0000000100000000UL - (1 * PAGE_SIZE))
> > > #define STACK_TOP_USER32 TASK_SIZE_USER32
> >
> > ...
> >
> > > +static inline int valid_user_sp(unsigned long sp)
> > > +{
> > > + bool is_64 = !is_32bit_task();
> > > +
> > > + if (!sp || (sp & (is_64 ? 7 : 3)) || sp > STACK_TOP - (is_64 ? 32 : 16))
> > > + return 0;
> > > + return 1;
> > > +}
> >
> > Other possibility:
>
> I prefer this one.
>
> >
> > unsigned long align = is_32bit_task() ? 3 : 7;
>
> I would call it mask instead of align
>
> > unsigned long top = STACK_TOP - (is_32bit_task() ? 16 : 32);
> >
> > return !(!sp || (sp & align) || sp > top);
And we can avoid the inversion here as well as in !valid_user_sp(sp) by
changing to invalid_user_sp.
Thanks
Michal
Powered by blists - more mailing lists