All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcin Slusarz <marcin.slusarz@gmail.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Akinobu Mita <akinobu.mita@gmail.com>,
	linux-kernel@vger.kernel.org,
	Christoph Lameter <cl@linux-foundation.org>,
	Pekka Enberg <penberg@kernel.org>, Matt Mackall <mpm@selenic.com>,
	linux-mm@kvack.org
Subject: Re: [PATCH] slub: fix check_bytes() for slub debugging
Date: Tue, 9 Aug 2011 23:46:46 +0200	[thread overview]
Message-ID: <20110809214646.GA3719@joi.lan> (raw)
In-Reply-To: <1312883169.2371.16.camel@edumazet-HP-Compaq-6005-Pro-SFF-PC>

On Tue, Aug 09, 2011 at 11:46:09AM +0200, Eric Dumazet wrote:
> Le mardi 09 août 2011 à 18:38 +0900, Akinobu Mita a écrit :
> > 2011/8/9 Eric Dumazet <eric.dumazet@gmail.com>:
> > 
> > >> > diff --git a/mm/slub.c b/mm/slub.c
> > >> > index eb5a8f9..5695f92 100644
> > >> > --- a/mm/slub.c
> > >> > +++ b/mm/slub.c
> > >> > @@ -701,7 +701,7 @@ static u8 *check_bytes(u8 *start, u8 value, unsigned int bytes)
> > >> >             return check_bytes8(start, value, bytes);
> > >> >
> > >> >     value64 = value | value << 8 | value << 16 | value << 24;
> > >> > -   value64 = value64 | value64 << 32;
> > >> > +   value64 = (value64 & 0xffffffff) | value64 << 32;
> > >> >     prefix = 8 - ((unsigned long)start) % 8;
> > >> >
> > >> >     if (prefix) {
> > >>
> > >> Still buggy I am afraid. Could we use the following ?
> > >>
> > >>
> > >>       value64 = value;
> > >>       value64 |= value64 << 8;
> > >>       value64 |= value64 << 16;
> > >>       value64 |= value64 << 32;
> > >>
> > >>
> > >
> > > Well, 'buggy' was not well chosen.
> > >
> > > Another possibility would be to use a multiply if arch has a fast
> > > multiplier...
> > >
> > >
> > >        value64 = value;
> > > #if defined(ARCH_HAS_FAST_MULTIPLIER) && BITS_PER_LONG == 64
> > >        value64 *= 0x0101010101010101;
> > > #elif defined(ARCH_HAS_FAST_MULTIPLIER)
> > >        value64 *= 0x01010101;
> > >        value64 |= value64 << 32;
> > > #else
> > >        value64 |= value64 << 8;
> > >        value64 |= value64 << 16;
> > >        value64 |= value64 << 32;
> > > #endif
> > 
> > I don't really care about which one should be used.  So tell me if I need
> > to resend it with this improvement.
> 
> It would be nice to fix all bugs while we review this code.
> 
> Lets push your patch and I'll submit a patch for next kernel.
> 
> For example, following code is suboptimal :
> 
>         prefix = 8 - ((unsigned long)start) % 8;
> 
>         if (prefix) {
>                 u8 *r = check_bytes8(start, value, prefix);
>                 if (r)
>                         return r;
>                 start += prefix;
>                 bytes -= prefix;
>         }
> 
> 
> Since we always have prefix = 8 if 'start' is longword aligned, so we
> call check_bytes8() at least once with 8 bytes to compare...

Yeah. 
 
> Also, 32bit arches should be taken into account properly.

At least on x86_32 reading 8 bytes is faster than 4 (I benchmarked it - IIRC
reading 8 bytes speeds up by a factor of ~5 and reading 4 only by ~3.5) 


Marcin


WARNING: multiple messages have this Message-ID (diff)
From: Marcin Slusarz <marcin.slusarz@gmail.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Akinobu Mita <akinobu.mita@gmail.com>,
	linux-kernel@vger.kernel.org,
	Christoph Lameter <cl@linux-foundation.org>,
	Pekka Enberg <penberg@kernel.org>, Matt Mackall <mpm@selenic.com>,
	linux-mm@kvack.org
Subject: Re: [PATCH] slub: fix check_bytes() for slub debugging
Date: Tue, 9 Aug 2011 23:46:46 +0200	[thread overview]
Message-ID: <20110809214646.GA3719@joi.lan> (raw)
In-Reply-To: <1312883169.2371.16.camel@edumazet-HP-Compaq-6005-Pro-SFF-PC>

On Tue, Aug 09, 2011 at 11:46:09AM +0200, Eric Dumazet wrote:
> Le mardi 09 aoA>>t 2011 A  18:38 +0900, Akinobu Mita a A(C)crit :
> > 2011/8/9 Eric Dumazet <eric.dumazet@gmail.com>:
> > 
> > >> > diff --git a/mm/slub.c b/mm/slub.c
> > >> > index eb5a8f9..5695f92 100644
> > >> > --- a/mm/slub.c
> > >> > +++ b/mm/slub.c
> > >> > @@ -701,7 +701,7 @@ static u8 *check_bytes(u8 *start, u8 value, unsigned int bytes)
> > >> >             return check_bytes8(start, value, bytes);
> > >> >
> > >> >     value64 = value | value << 8 | value << 16 | value << 24;
> > >> > -   value64 = value64 | value64 << 32;
> > >> > +   value64 = (value64 & 0xffffffff) | value64 << 32;
> > >> >     prefix = 8 - ((unsigned long)start) % 8;
> > >> >
> > >> >     if (prefix) {
> > >>
> > >> Still buggy I am afraid. Could we use the following ?
> > >>
> > >>
> > >>       value64 = value;
> > >>       value64 |= value64 << 8;
> > >>       value64 |= value64 << 16;
> > >>       value64 |= value64 << 32;
> > >>
> > >>
> > >
> > > Well, 'buggy' was not well chosen.
> > >
> > > Another possibility would be to use a multiply if arch has a fast
> > > multiplier...
> > >
> > >
> > >        value64 = value;
> > > #if defined(ARCH_HAS_FAST_MULTIPLIER) && BITS_PER_LONG == 64
> > >        value64 *= 0x0101010101010101;
> > > #elif defined(ARCH_HAS_FAST_MULTIPLIER)
> > >        value64 *= 0x01010101;
> > >        value64 |= value64 << 32;
> > > #else
> > >        value64 |= value64 << 8;
> > >        value64 |= value64 << 16;
> > >        value64 |= value64 << 32;
> > > #endif
> > 
> > I don't really care about which one should be used.  So tell me if I need
> > to resend it with this improvement.
> 
> It would be nice to fix all bugs while we review this code.
> 
> Lets push your patch and I'll submit a patch for next kernel.
> 
> For example, following code is suboptimal :
> 
>         prefix = 8 - ((unsigned long)start) % 8;
> 
>         if (prefix) {
>                 u8 *r = check_bytes8(start, value, prefix);
>                 if (r)
>                         return r;
>                 start += prefix;
>                 bytes -= prefix;
>         }
> 
> 
> Since we always have prefix = 8 if 'start' is longword aligned, so we
> call check_bytes8() at least once with 8 bytes to compare...

Yeah. 
 
> Also, 32bit arches should be taken into account properly.

At least on x86_32 reading 8 bytes is faster than 4 (I benchmarked it - IIRC
reading 8 bytes speeds up by a factor of ~5 and reading 4 only by ~3.5) 


Marcin

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2011-08-09 21:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-07  9:30 [PATCH] slub: fix check_bytes() for slub debugging Akinobu Mita
2011-08-07  9:30 ` Akinobu Mita
2011-08-08 21:24 ` Marcin Slusarz
2011-08-08 21:24   ` Marcin Slusarz
2011-08-09  1:08   ` Akinobu Mita
2011-08-09  1:08     ` Akinobu Mita
2011-08-09  3:10 ` Eric Dumazet
2011-08-09  3:10   ` Eric Dumazet
2011-08-09  3:33   ` Eric Dumazet
2011-08-09  3:33     ` Eric Dumazet
2011-08-09  9:38     ` Akinobu Mita
2011-08-09  9:38       ` Akinobu Mita
2011-08-09  9:43       ` Pekka Enberg
2011-08-09  9:43         ` Pekka Enberg
2011-08-09  9:54         ` Eric Dumazet
2011-08-09  9:54           ` Eric Dumazet
2011-08-09  9:46       ` Eric Dumazet
2011-08-09  9:46         ` Eric Dumazet
2011-08-09 21:46         ` Marcin Slusarz [this message]
2011-08-09 21:46           ` Marcin Slusarz

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=20110809214646.GA3719@joi.lan \
    --to=marcin.slusarz@gmail.com \
    --cc=akinobu.mita@gmail.com \
    --cc=cl@linux-foundation.org \
    --cc=eric.dumazet@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mpm@selenic.com \
    --cc=penberg@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.