[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200421083043.GP20730@hirez.programming.kicks-ass.net>
Date: Tue, 21 Apr 2020 10:30:43 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Zhenyu Ye <yezhenyu2@...wei.com>, mark.rutland@....com,
will@...nel.org, catalin.marinas@....com,
aneesh.kumar@...ux.ibm.com, akpm@...ux-foundation.org,
npiggin@...il.com, arnd@...db.de, maz@...nel.org,
suzuki.poulose@....com, tglx@...utronix.de, yuzhao@...gle.com,
Dave.Martin@....com, steven.price@....com, broonie@...nel.org,
guohanjun@...wei.com, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org, linux-arch@...r.kernel.org,
linux-mm@...ck.org, arm@...nel.org, xiexiangyou@...wei.com,
prime.zeng@...ilicon.com, zhangshaokun@...ilicon.com,
kuhn.chenqun@...wei.com
Subject: Re: [PATCH v1 6/6] arm64: tlb: Set the TTL field in flush_tlb_range
On Mon, Apr 20, 2020 at 08:06:16PM -0400, Steven Rostedt wrote:
> Peter Zijlstra <peterz@...radead.org> wrote:
> > On Fri, Apr 03, 2020 at 05:00:48PM +0800, Zhenyu Ye wrote:
> > > +static inline int tlb_get_level(struct mmu_gather *tlb)
> > > +{
> > > + int sum = tlb->cleared_ptes + tlb->cleared_pmds +
> > > + tlb->cleared_puds + tlb->cleared_p4ds;
> > > +
> > > + if (sum != 1)
> > > + return 0;
> > > + else if (tlb->cleared_ptes)
> > > + return 3;
> > > + else if (tlb->cleared_pmds)
> > > + return 2;
> > > + else if (tlb->cleared_puds)
> > > + return 1;
> > > +
> > > + return 0;
> > > +}
> >
> > That's some mighty wonky code. Please look at the generated asm.
>
> Without even looking at the generated asm, if a condition returns,
> there's no reason to add an else for that condition.
Not really the point; he wants to guarantee he only returns >0 when
there's a single bit set. But the thing is, cleared_* is a bitfield, and
I'm afraid that the above will result in some terrible code-gen.
Maybe something like:
if (tlb->cleared_ptes && !(tlb->cleared_pmds ||
tlb->cleared_puds ||
tlb->cleared_p4ds))
return 3;
if (tlb->cleared_pmds && !(tlb->cleared_ptes ||
tlb->cleared_puds ||
tlb->cleared_p4ds))
return 2;
if (tlb->cleared_puds && !(tlb->cleared_ptes ||
tlb->cleared_pmds ||
tlb->cleared_p4ds))
return 1;
return 0;
Which I admit is far too much typing, but I suspect it generates far
saner code (just a few masks and branches).
But maybe the compiler surprises us, what do I konw.
Powered by blists - more mailing lists