mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Nikola Pajkovsky <npajkovs@redhat.com>
Cc: Stanislav Kinsbursky <skinsbursky@parallels.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Peter Hurley <peter@hurleysoftware.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ipc: use list_for_each_entry for list traversing
Date: Tue, 9 Apr 2013 13:36:47 -0700	[thread overview]
Message-ID: <20130409133647.fdb9cd6414ae6da83170fee6@linux-foundation.org> (raw)
In-Reply-To: <m3wqsc3ux0.fsf@redhat.com>

On Tue, 09 Apr 2013 11:39:07 +0200 Nikola Pajkovsky <npajkovs@redhat.com> wrote:

> Andrew Morton <akpm@linux-foundation.org> writes:
> 
> > urgh, that code is sick.  What's it doing poking around in the
> > list_head internals?
> 
> No idea, it there from beginning of first kernel importation into
> git. Where is history before git?

The old bitkeeper repo is at
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/old-2.6-bkcvs.git
and goes back to the 2.4->2.5 split iirc.  But this code predates that
- my trusty CVS tree goes back to linux-2.4.2-pre2 (November 2000) and
the list.next hackery is in there.

> >> @@ -253,14 +248,9 @@ static void ss_wakeup(struct list_head *h, int kill)
> >>  
> >>  static void expunge_all(struct msg_queue *msq, int res)
> >>  {
> >> -	struct list_head *tmp;
> >> -
> >> -	tmp = msq->q_receivers.next;
> >> -	while (tmp != &msq->q_receivers) {
> >> -		struct msg_receiver *msr;
> >> +	struct msg_receiver *msr, *t;
> >>  
> >> -		msr = list_entry(tmp, struct msg_receiver, r_list);
> >> -		tmp = tmp->next;
> >> +	list_for_each_entry_safe(msr, t, &msq->q_receivers, r_list) {
> >>  		msr->r_msg = NULL;
> >>  		wake_up_process(msr->r_tsk);
> >>  		smp_mb();
> >
> > I think list_for_each_entry() would suffice here.
> 
> I don't know, I found wake_up_sem_queue_do in sem.c and it looks almost same
> except preempt stuff. I'll be dancing around ipc/

wake_up_sem_queue_do() is wrong ;)



      reply	other threads:[~2013-04-09 20:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-05 13:42 Nikola Pajkovsky
2013-04-08 22:38 ` Andrew Morton
2013-04-09  9:39   ` Nikola Pajkovsky
2013-04-09 20:36     ` Andrew Morton [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=20130409133647.fdb9cd6414ae6da83170fee6@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=npajkovs@redhat.com \
    --cc=peter@hurleysoftware.com \
    --cc=skinsbursky@parallels.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

all inboxes | Powered by JetHome®