All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Brownell <david-b@pacbell.net>
To: Greg KH <greg@kroah.com>, Samium Gromoff <_deepfire@mail.ru>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [2.4, 2.5, USB] locking issue
Date: Wed, 20 Nov 2002 07:40:48 -0800	[thread overview]
Message-ID: <3DDBAD00.3010500@pacbell.net> (raw)
In-Reply-To: 20021120084532.GD22936@kroah.com

Greg KH wrote:
> On Mon, Nov 18, 2002 at 05:34:20PM +0300, Samium Gromoff wrote:
> 
>>        The possible problem is encountered in ehci-q.c and ehci-sched.c
>>  in 2.4.19-pre9 and in one occurence in ehci-q.c of 2.5.47.

It's not a problem, see below.  The 2.5 code is better, since only one
body of code is managing the TD queues for async (control, bulk) and
interrupt queue heads.


>>        the offending pattern is the same in both files:
>>
>>        if (!list_empty (qtd_list)) {
>> -----------------------8<----------------------------------------------
>>                list_splice (qtd_list, &qh->qtd_list);
>>                qh_update (qh, list_entry (qtd_list->next, struct ehci_qtd, qtd_list));
>> -----------------------8<----------------------------------------------
>>        } else {
>>                qh->hw_qtd_next = qh->hw_alt_next = EHCI_LIST_END;
>>        }

Slightly different in 2.5.48 since it uses a dummy TD (so certain race
conditions can't happen), and it won't line-wrap that qh_update() call.


>>        since list_splice() the qtd_list is diposed of its belongings and
>>        immediately in the next line we rely on qtd_list->next to point
>>        at an existing list_head.
>>
>>        i haven`t noticed any locking out there, and i`m afraid of what
>>        could result from a preemption happening between these two lines.
> 
> 
> Um, David, any thoughts about this?

That code runs under a spinlock_irqsave(&ehci->lock,...), so no
other task can preempt.  And list_splice() doesn't modify qtd_list,
so the qtd_list->next pointer stays valid ... it's like list_del(),
not list_del_init(), read <linux/list.h> to see.

- Dave




      reply	other threads:[~2002-11-20 15:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-18 14:34 [2.4, 2.5, USB] locking issue Samium Gromoff
2002-11-20  8:45 ` Greg KH
2002-11-20 15:40   ` David Brownell [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=3DDBAD00.3010500@pacbell.net \
    --to=david-b@pacbell.net \
    --cc=_deepfire@mail.ru \
    --cc=greg@kroah.com \
    --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.