From: Steven Rostedt <srostedt@redhat.com>
To: Keir Fraser <Keir.Fraser@cl.cam.ac.uk>
Cc: xen-devel@lists.xensource.com, quintela@redhat.com
Subject: Re: [PATCH] wrong accounting in direct_remap_pfn_range
Date: Wed, 30 Aug 2006 21:35:31 -0400 [thread overview]
Message-ID: <44F63CE3.8090803@redhat.com> (raw)
In-Reply-To: <C11BF47E.1939%Keir.Fraser@cl.cam.ac.uk>
Keir Fraser wrote:
>
>
> On 31/8/06 2:03 am, "Steven Rostedt" <srostedt@redhat.com> wrote:
>
>>> It's not really missing. We could have a size==0 check *or* we can have the
>>> v!=u check. We don't need both and I think the latter is more obviously
>>> correct, as the test is closer to the code that it 'protects'. Also it's a
>>> fairly idiomatic way of generating and flushing batches of work.
>>>
>> So what is really wrong with this code? Or is the flushes need even on
>> size == 0?
>
> This patch is fine. But it's no more correct than the current version of the
> code because there is no bug. I don't think your version is particularly
> clearer.
>
You're right that the original version was not a bug, which I admittedly
thought it was.
As for clarity, I'll argue that my version is clearer. Just because it
shows exactly that nothing needs to be done when size is zero, instead
having a check for (v != u) that is only true when we have a zero size.
Usually, when I have a condition of that sort that comes after a loop
incrementing v and lets v return back to u, I have that condition need
to be done if a) the loop wasn't entered (as in this case), or b) the
condition in the loop wasn't done at the end (which isn't the case here).
Hence, the reason that I thought it was a bug. Nowhere is there a
comment that says /* don't do anything if size was 0 */.
Now enough about clarity. By the off chance that size would be zero
(which I still don't know when that would be), we waste time with
flushing caches and the TLB, not to mention wasted time getting a memory
page and freeing it.
But this is all moot anyway, since there is no bug being fixed. But as
for submitting to mainline, I've submitted enough patches to know that
Andrew Morton actually cares about readability and optimizations (even
on the not so often path if it doesn't hurt anything else). And I have
a tough time seeing Andrew (or others) think that
v = u;
for (i=0; i < size; ...) {
if (v - u/ ...) {
...
v = u;
...
}
...
v++;
...
}
if (v != u) { ... }
is more readable and clearer than
if (!size) return 0;
for (...) {
...
}
/* no if needed */
....
But that's just my opinion. Take it for what it's worth.
-- Steve
prev parent reply other threads:[~2006-08-31 1:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-29 16:25 [PATCH] wrong accounting in direct_remap_pfn_range Steven Rostedt
2006-08-29 18:22 ` Steven Rostedt
2006-08-30 21:29 ` Keir Fraser
2006-08-31 0:17 ` Steven Rostedt
2006-08-31 0:37 ` Steven Rostedt
2006-08-31 0:42 ` Keir Fraser
2006-08-31 0:47 ` Steven Rostedt
2006-08-31 1:03 ` Steven Rostedt
2006-08-31 1:05 ` Keir Fraser
2006-08-31 1:35 ` Steven Rostedt [this message]
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=44F63CE3.8090803@redhat.com \
--to=srostedt@redhat.com \
--cc=Keir.Fraser@cl.cam.ac.uk \
--cc=quintela@redhat.com \
--cc=xen-devel@lists.xensource.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 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.