From: Matthew Wilcox <willy@infradead.org>
To: Joe Perches <joe@perches.com>
Cc: Donglin Peng <dolinux.peng@gmail.com>,
viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] seq_file: remove redundant assignment of index to m->index
Date: Sat, 10 Feb 2018 17:02:01 -0800 [thread overview]
Message-ID: <20180211010201.GA14719@bombadil.infradead.org> (raw)
In-Reply-To: <1518285863.16865.17.camel@perches.com>
On Sat, Feb 10, 2018 at 10:04:23AM -0800, Joe Perches wrote:
> > @@ -120,14 +120,12 @@ static int traverse(struct seq_file *m, loff_t offset)
> > if (pos + m->count > offset) {
> > m->from = offset - pos;
> > m->count -= m->from;
> > - m->index = index;
> > break;
> > }
> > pos += m->count;
> > m->count = 0;
> > if (pos == offset) {
> > index++;
> > - m->index = index;
> > break;
> > }
> > p = m->op->next(m, p, &index);
>
> Of course this looks correct, but how
> are you _absolutely sure_ about this?
>
> Perhaps the m->op->stop(m, p) call below
> the break, which takes m as an argument,
> needs an updated m->index.
Not only that, but ->next might also look at m->index.
This is not performance critical; don't try to optimise it.
Programmers waste enormous amounts of time thinking about, or worrying
about, the speed of noncritical parts of their programs, and these
attempts at efficiency actually have a strong negative impact when
debugging and maintenance are considered. We should forget about small
efficiencies, say about 97% of the time: premature optimization is the
root of all evil. Yet we should not pass up our opportunities in that
critical 3%. -- Donald Knuth
next prev parent reply other threads:[~2018-02-11 2:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-10 15:59 Donglin Peng
2018-02-10 18:04 ` Joe Perches
2018-02-11 1:02 ` Matthew Wilcox [this message]
2018-02-11 5:46 ` Donglin Peng
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=20180211010201.GA14719@bombadil.infradead.org \
--to=willy@infradead.org \
--cc=dolinux.peng@gmail.com \
--cc=joe@perches.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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
all inboxes | Powered by JetHome®