linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@redhat.com>
To: Mikulas Patocka <mpatocka@redhat.com>
Cc: linux-raid@vger.kernel.org, NeilBrown <neilb@suse.de>,
	Jes Sorensen <Jes.Sorensen@redhat.com>,
	Jonathan Brassow <jbrassow@redhat.com>,
	rhkernel-list@redhat.com
Subject: Re: change '%' to condition
Date: Wed, 11 Sep 2013 19:37:16 -0400	[thread overview]
Message-ID: <20130911233716.GB23721@redhat.com> (raw)
In-Reply-To: <alpine.LRH.2.02.1307201112210.2761@file01.intranet.prod.int.rdu2.redhat.com>

On Wed, Sep 11 2013 at  7:18pm -0400,
Mikulas Patocka <mpatocka@redhat.com> wrote:

> Hi
> 
> I think you should revert the patch 
> 4c0ca26bd260dddf3b9781758cb5e2df3f74d4a3 that did this change:
> 
>                 for (f = 1; f < geo->far_copies; f++) {
>                         d += geo->near_copies;
> -                       if (d >= geo->raid_disks)
> -                               d -= geo->raid_disks;
> +                       d %= geo->raid_disks;
>                         s += geo->stride;
>                         r10bio->devs[slot].devnum = d;
>                         r10bio->devs[slot].addr = s;
> 
> 
> On most processors, the divide and modulo operations are slower than a 
> possibly misprediteced branch or conditional move instruction.
> 
> So, replacing a condition with modulo doesn't make sense.
> 
> A benchmark on AMD K10 shows that mispredicted branch is 8.7 times faster 
> than a divide operation:
> 
>         for (i = 0; i < 10000000; i++) {
>                 q++;
>                 if (q >= 8)
>                         q -= 8;
>         }
> - 11607us (it compiles to cmov and runs at a rate of 3 ticks per 
> iteration)
> 
>         for (i = 0; i < 10000000; i++) {
>                 q++;
>                 q %= max;
>         }
> - 101241us (26 ticks per iteration)

Patch 68 in this series goes on to introduce more use of %= (upstream
commit 9a3152ab024867100f2f50d124b998d05fb1c3f6).

But regardless Jes' original point still stands: if this should be
changed it needs to be done upstream first.

Mike

  reply	other threads:[~2013-09-11 23:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1373890837-3475-1-git-send-email-Jes.Sorensen@redhat.com>
     [not found] ` <1373890837-3475-67-git-send-email-Jes.Sorensen@redhat.com>
     [not found]   ` <alpine.LRH.2.02.1307151445220.23929@file01.intranet.prod.int.rdu2.redhat.com>
     [not found]     ` <wrfjfvvely2a.fsf@redhat.com>
2013-09-11 23:18       ` change '%' to condition Mikulas Patocka
2013-09-11 23:37         ` Mike Snitzer [this message]
2013-09-12  5:39         ` NeilBrown

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=20130911233716.GB23721@redhat.com \
    --to=snitzer@redhat.com \
    --cc=Jes.Sorensen@redhat.com \
    --cc=jbrassow@redhat.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=neilb@suse.de \
    --cc=rhkernel-list@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).