From: Corey Minyard <minyard@acm.org>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] IPMI driver updates, part 1b
Date: Wed, 25 Feb 2004 15:12:14 -0600 [thread overview]
Message-ID: <403D0FAE.7090301@acm.org> (raw)
In-Reply-To: <20040225120551.32681515.akpm@osdl.org>
Andrew Morton wrote:
>Corey Minyard <minyard@acm.org> wrote:
>
>
>>>diff -puN net/ipmi/af_ipmi.c~af_ipmi-locking-fix net/ipmi/af_ipmi.c
>>>
>>>
>> >--- 25/net/ipmi/af_ipmi.c~af_ipmi-locking-fix Tue Feb 24 16:56:36 2004
>> >+++ 25-akpm/net/ipmi/af_ipmi.c Tue Feb 24 16:57:00 2004
>> >@@ -336,6 +336,7 @@ static int ipmi_recvmsg(struct kiocb *io
>> > }
>> >
>> > timeo = ipmi_wait_for_queue(i, timeo);
>> >+ spin_lock_irqsave(&i->lock, flags);
>> > }
>> >
>> > rcvmsg = list_entry(i->msg_list.next, struct ipmi_recv_msg, link);
>> >
>> >
>> > which may or may not be correct.
>> >
>> Actually, I believe the code is correct, and your change will break it.
>> This is in a "while (1)" loop, and the only way to get out of this loop
>> is to return with the lock not held or to break out of the loop with the
>> lock held (and later code will unlock it). Am I correct here?
>>
>>
>
>With a little more context:
>
>+ spin_unlock_irqrestore(&i->lock, flags);
>+ if (!timeo) {
>+ return -EAGAIN;
>+ } else if (signal_pending (current)) {
>+ dbg("Signal pending: %d", 1);
>+ return -EINTR;
>+ }
>+
>+ timeo = ipmi_wait_for_queue(i, timeo);
>+ }
>+
>+ rcvmsg = list_entry(i->msg_list.next, struct ipmi_recv_msg, link);
>+ list_del(&rcvmsg->link);
>+ spin_unlock_irqrestore(&i->lock, flags);
>
>See, there's a direct code path from one spin_unlock() to the other. And
>ipmi_wait_for_queue() does not retake the lock.
>
>
With even more context:
while (1) {
spin_lock_irqsave(&i->lock, flags);
if (!list_empty(&i->msg_list))
break;
spin_unlock_irqrestore(&i->lock, flags);
if (!timeo) {
return -EAGAIN;
} else if (signal_pending (current)) {
dbg("Signal pending: %d", 1);
return -EINTR;
}
timeo = ipmi_wait_for_queue(i, timeo);
}
rcvmsg = list_entry(i->msg_list.next, struct ipmi_recv_msg, link);
list_del(&rcvmsg->link);
spin_unlock_irqrestore(&i->lock, flags);
So it will always go back to the top of the while loop and claim the
lock again. It's kind of wierd looking, but I still believe it is
correct. It's ugly, true, I can work on rewriting this piece.
-Corey
next prev parent reply other threads:[~2004-02-25 22:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-24 13:55 [PATCH] IPMI driver updates, part 1b Corey Minyard
2004-02-24 23:51 ` Corey Minyard
2004-02-25 1:00 ` Andrew Morton
2004-02-25 15:59 ` Corey Minyard
2004-02-25 20:02 ` Andrew Morton
2004-02-25 16:15 ` Corey Minyard
2004-02-25 20:05 ` Andrew Morton
2004-02-25 21:12 ` Corey Minyard [this message]
2004-02-25 20:32 ` Andrew Morton
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=403D0FAE.7090301@acm.org \
--to=minyard@acm.org \
--cc=akpm@osdl.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.