Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1230901
| From | Joakim Tjernlund <joakim.tjernlund@transmode.se> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2 22/25] powerpc32: move xxxxx_dcache_range() functions inline |
| Date | 2015-09-22 22:00 +0200 |
| Message-ID | <qbBTl-6Qf-41@gated-at.bofh.it> (permalink) |
| References | (1 earlier) <qbz58-2KT-17@gated-at.bofh.it> <qbAkA-4J7-73@gated-at.bofh.it> <qbAXh-5tC-41@gated-at.bofh.it> <qbBzY-6tc-13@gated-at.bofh.it> <qbBTl-6Qf-43@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Tue, 2015-09-22 at 14:42 -0500, Scott Wood wrote:
> On Tue, 2015-09-22 at 19:34 +0000, Joakim Tjernlund wrote:
> > On Tue, 2015-09-22 at 13:58 -0500, Scott Wood wrote:
> > > On Tue, 2015-09-22 at 18:12 +0000, Joakim Tjernlund wrote:
> > > > On Tue, 2015-09-22 at 18:51 +0200, Christophe Leroy wrote:
> > > > > flush/clean/invalidate _dcache_range() functions are all very
> > > > > similar and are quite short. They are mainly used in __dma_sync()
> > > > > perf_event locate them in the top 3 consumming functions during
> > > > > heavy ethernet activity
> > > > >
> > > > > They are good candidate for inlining, as __dma_sync() does
> > > > > almost nothing but calling them
> > > > >
> > > > > Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> > > > > ---
> > > > > New in v2
> > > > >
> > > > > arch/powerpc/include/asm/cacheflush.h | 55
> > > > > +++++++++++++++++++++++++++--
> > > > > arch/powerpc/kernel/misc_32.S | 65 --------------------------
> > > > > ----
> > > > > -----
> > > > > arch/powerpc/kernel/ppc_ksyms.c | 2 ++
> > > > > 3 files changed, 54 insertions(+), 68 deletions(-)
> > > > >
> > > > > diff --git a/arch/powerpc/include/asm/cacheflush.h
> > > > > b/arch/powerpc/include/asm/cacheflush.h
> > > > > index 6229e6b..6169604 100644
> > > > > --- a/arch/powerpc/include/asm/cacheflush.h
> > > > > +++ b/arch/powerpc/include/asm/cacheflush.h
> > > > > @@ -47,12 +47,61 @@ static inline void
> > > > > __flush_dcache_icache_phys(unsigned long physaddr)
> > > > > }
> > > > > #endif
> > > > >
> > > > > -extern void flush_dcache_range(unsigned long start, unsigned long
> > > > > stop);
> > > > > #ifdef CONFIG_PPC32
> > > > > -extern void clean_dcache_range(unsigned long start, unsigned long
> > > > > stop);
> > > > > -extern void invalidate_dcache_range(unsigned long start, unsigned
> > > > > long
> > > > > stop);
> > > > > +/*
> > > > > + * Write any modified data cache blocks out to memory and invalidate
> > > > > them.
> > > > > + * Does not invalidate the corresponding instruction cache blocks.
> > > > > + */
> > > > > +static inline void flush_dcache_range(unsigned long start, unsigned
> > > > > long
> > > > > stop)
> > > > > +{
> > > > > + void *addr = (void *)(start & ~(L1_CACHE_BYTES - 1));
> > > > > + unsigned int size = stop - (unsigned long)addr + (L1_CACHE_BYTES -
> > > > > 1);
> > > > > + unsigned int i;
> > > > > +
> > > > > + for (i = 0; i < size >> L1_CACHE_SHIFT; i++, addr +=
> > > > > L1_CACHE_BYTES)
> > > > > + dcbf(addr);
> > > > > + if (i)
> > > > > + mb(); /* sync */
> > > > > +}
> > > >
> > > > This feels optimized for the uncommon case when there is no
> > > > invalidation.
> > >
> > > If you mean the "if (i)", yes, that looks odd.
> >
> > Yes.
> >
> > >
> > > > I THINK it would be better to bail early
> > >
> > > Bail under what conditions?
> >
> > test for "i = 0" and return.
>
> Why bother?
I usally find it better to dela with special cases upfront så the rest doesn't need to
bother. i=0 is a NOP and it is clearer to show that upfront.
>
> >
> > >
> > > > and use do { .. } while(--i); instead.
> > >
> > > GCC knows how to optimize loops. Please don't make them less readable.
> >
> > Been a while since I checked but it used to be bad att transforming post
> > inc to pre inc/dec
> > I remain unconvinced until I have seen it.
>
> I would expect it to use bdnz for this loop, as the loop variable isn't
> referenced in the loop body.
>
> And generally the one proposing uglification-for-optimization should provide
> the evidence. :-)
When it comes to gcc, past history is my evidence until proven otherwise :)
Maybe I will check again ...--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 22/25] powerpc32: move xxxxx_dcache_range() functions inline Christophe Leroy <christophe.leroy@c-s.fr> - 2015-09-22 19:00 +0200
Re: [PATCH v2 22/25] powerpc32: move xxxxx_dcache_range() functions inline Joakim Tjernlund <joakim.tjernlund@transmode.se> - 2015-09-22 20:20 +0200
Re: [PATCH v2 22/25] powerpc32: move xxxxx_dcache_range() functions inline Scott Wood <scottwood@freescale.com> - 2015-09-22 21:00 +0200
Re: [PATCH v2 22/25] powerpc32: move xxxxx_dcache_range() functions inline Joakim Tjernlund <joakim.tjernlund@transmode.se> - 2015-09-22 21:40 +0200
Re: [PATCH v2 22/25] powerpc32: move xxxxx_dcache_range() functions inline Joakim Tjernlund <joakim.tjernlund@transmode.se> - 2015-09-22 22:00 +0200
Re: [PATCH v2 22/25] powerpc32: move xxxxx_dcache_range() functions inline Joakim Tjernlund <joakim.tjernlund@transmode.se> - 2015-09-22 22:10 +0200
Re: [PATCH v2 22/25] powerpc32: move xxxxx_dcache_range() functions inline Joakim Tjernlund <joakim.tjernlund@transmode.se> - 2015-09-22 22:40 +0200
Re: [PATCH v2 22/25] powerpc32: move xxxxx_dcache_range() functions inline Christophe Leroy <christophe.leroy@c-s.fr> - 2015-09-22 23:00 +0200
Re: [PATCH v2 22/25] powerpc32: move xxxxx_dcache_range() functions inline Christophe Leroy <christophe.leroy@c-s.fr> - 2015-09-23 00:50 +0200
Re: [PATCH v2 22/25] powerpc32: move xxxxx_dcache_range() functions inline Joakim Tjernlund <joakim.tjernlund@transmode.se> - 2015-09-22 22:40 +0200
Re: [PATCH v2 22/25] powerpc32: move xxxxx_dcache_range() functions inline Scott Wood <scottwood@freescale.com> - 2015-09-29 02:30 +0200
csiph-web