From: "Darren Jenkins\\" <darrenrjenkins@gmail.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: [KJ] Fwd: libata janitor project
Date: Sat, 11 Feb 2006 05:13:52 +0000 [thread overview]
Message-ID: <1139634833.7781.68.camel@localhost.localdomain> (raw)
In-Reply-To: <20060210132138.GA11586@mipter.zuzino.mipt.ru>
[-- Attachment #1: Type: text/plain, Size: 2317 bytes --]
On Fri, 2006-02-10 at 14:49 +0100, Eric Sesterhenn wrote:
> @@ -2510,11 +2510,11 @@ static void ata_sg_clean(struct ata_queu
> int dir = qc->dma_dir;
> void *pad_buf = NULL;
>
> - assert(qc->flags & ATA_QCFLAG_DMAMAP);
> - assert(sg != NULL);
> + WARN_ON(!(qc->flags & ATA_QCFLAG_DMAMAP));
> + WARN_ON(sg == NULL);
>
> if (qc->flags & ATA_QCFLAG_SINGLE)
> - assert(qc->n_elem == 1);
> + WARN_ON(qc->n_elem != 1);
>
> VPRINTK("unmapping %u sg elements\n", qc->n_elem);
>
Ok now I have had some sleep I have been thinking about this bit some
more. The last bit expands to.
example 1
if (qc->flags & ATA_QCFLAG_SINGLE)
if (unlikely((qc->n_elem != 1)!=0) {
printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
dump_stack();
}
which has two if() tests.
where if you wrote
WARN_ON((qc->flags & ATA_QCFLAG_SINGLE) && qc->n_elem != 1)
it will expand to
example 2
if (unlikely(((qc->flags & ATA_QCFLAG_SINGLE) && qc->n_elem != 1) != 0 ) {
printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
dump_stack();
}
which has one if () with unlikely wrapped around the result.
I assume in the case of unlikely(test1 && test2) GCC will bail out if
test1 is not true (no I have not checked yet)
before testing test2.
So we should have three cases:
1 test1 is false
2 test1 is true test2 is false
3 test1 is true test2 is false
in case 1 both code examples should be relatively similar.
in case 2 the second code example will evaluate both tests then fail the
if (unlikely ()) so probably no branching
the first code example will evaluate test1 as true and probably branch
to the second test which will fail. So we have an extra branch in the
first code example.
in case 3 the second code example will pass the if (unlikely()) test and
branch to the debug code then jump back.
The first code example will pass the first test and branch to the second
test then pass the second and branch again to the debug code, before
jumping back. So again we have an extra branch in the first code
example.
However;
This all assumes GCC is not smart enough to see what is happening and
optimise the tests itself. I don't know, I am not very familiar with
GCC.
Also the code as it stands might be more readable, as it probably
explains the situation better.
Darren J.
[-- Attachment #2: Type: text/plain, Size: 168 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
next prev parent reply other threads:[~2006-02-11 5:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-10 13:21 [KJ] Fwd: libata janitor project Alexey Dobriyan
2006-02-10 13:49 ` Eric Sesterhenn
2006-02-11 5:13 ` Darren Jenkins\ [this message]
2006-02-11 9:56 ` Jaco Kroon
2006-02-11 22:54 ` Jeff Garzik
2006-02-12 21:13 ` Håkon Løvdal
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=1139634833.7781.68.camel@localhost.localdomain \
--to=darrenrjenkins@gmail.com \
--cc=kernel-janitors@vger.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.