All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Cong Wang <amwang@redhat.com>
Cc: Christoph Lameter <cl@linux-foundation.org>,
	linux-kernel@vger.kernel.org, akpm@linux-foundation.org
Subject: Re: [PATCH] percpu: explain quick paths in pcpu_[de]populate_chunk()
Date: Tue, 01 Dec 2009 14:09:50 +0900	[thread overview]
Message-ID: <4B14A51E.2090702@kernel.org> (raw)
In-Reply-To: <4B14A2E6.1070603@kernel.org>

On 12/01/2009 02:00 PM, Tejun Heo wrote:
> I thought about that but didn't want to open code the special and
> fairly complex loop construct used there.  To me, it seemed using the
> same loop construct would be much less error-prone than open coding
> the loop mostly because those two special cases are the only place
> where that is necessary.  Maybe we can add pcpu_first_[un]pop_region()
> macros and use them there but is the first iteration check that bad
> even with sufficient explanations?

So, something like the following.

#define pcpu_first_unpop_region(chunk, rs, re, start, end)	do {	\
	(rs) = (start);							\
	pcpu_next_unpop((chunk), &(rs), &(re), (end));			\
} while (0)

#define pcpu_for_each_unpop_region(chunk, rs, re, start, end)		\
	for (pcpu_first_unpop_region(chunk, rs, re, start, end);	\
	     (rs) < (re);						\
	     (rs) = (re) + 1, pcpu_next_unpop((chunk), &(rs), &(re), (end)))

#define pcpu_first_pop_region(chunk, rs, re, start, end)	do {	\
	(rs) = (start);							\
	pcpu_next_pop((chunk), &(rs), &(re), (end));			\
} while (0)

#define pcpu_for_each_pop_region(chunk, rs, re, start, end)		\
	for (pcpu_first_pop_region(chunk, rs, re, start, end);		\
	     (rs) < (re);						\
	     (rs) = (re) + 1, pcpu_next_pop((chunk), &(rs), &(re), (end)))

It might be better to make these proper functions which take pointers
but that makes the only two interfaces for region iterators disagree
about how they take parameters.

So, I don't know.  The first iteration only loop looks a bit unusual
for sure but it isn't something conceptually convoluted.

Thanks.

-- 
tejun

  reply	other threads:[~2009-12-01  5:10 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-30  9:12 [Patch] percpu: remove two suspicious break statements Amerigo Wang
2009-11-30 11:09 ` Tejun Heo
2009-11-30 19:01   ` Christoph Lameter
2009-12-01  0:01     ` [PATCH] percpu: explain quick paths in pcpu_[de]populate_chunk() Tejun Heo
2009-12-01  2:02       ` Cong Wang
2009-12-01  5:00         ` Tejun Heo
2009-12-01  5:09           ` Tejun Heo [this message]
2009-12-01  5:40             ` Cong Wang
2009-12-01  5:47               ` Tejun Heo
2009-12-01  6:35                 ` Cong Wang
2009-12-01  6:59                   ` Tejun Heo
2009-12-01  7:13                     ` [PATCH] percpu: refactor the code " Cong Wang
2009-12-01 14:31                       ` Tejun Heo

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=4B14A51E.2090702@kernel.org \
    --to=tj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=amwang@redhat.com \
    --cc=cl@linux-foundation.org \
    --cc=linux-kernel@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.