linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: wangyijing <wangyijing@huawei.com>
To: Guenter Roeck <linux@roeck-us.net>, Bjorn Helgaas <bhelgaas@google.com>
Cc: <linux-pci@vger.kernel.org>, <rajatja@google.com>, <rjw@rjwysocki.net>
Subject: Re: [PATCH v2 1/2] PCI: Use a local mutex instead of pci_bus_sem to avoid deadlock
Date: Fri, 24 Jul 2015 12:08:33 +0800	[thread overview]
Message-ID: <55B1BA41.4080700@huawei.com> (raw)
In-Reply-To: <55B1ABF3.9070201@roeck-us.net>



在 2015/7/24 11:07, Guenter Roeck 写道:
> On 07/17/2015 02:16 AM, Yijing Wang wrote:
>> Rajat Jain reported a deadlock when a hierarchical hot plug
>> thread and aer recovery thread both run.
>> https://lkml.org/lkml/2015/3/11/861
>>
>> thread 1:
>> pciehp_enable_slot()
>>     pciehp_configure_device()
>>         pci_bus_add_devices()
>>             device_attach(dev)
>>                 device_lock(dev) //acquire device mutex successfully
>>             ...
>>             pciehp_probe(dev)
>>                 __pci_hp_register()
>>                     pci_create_slot()
>>                         down_write(pci_bus_sem) //deadlock here
>>
>> thread 2:
>> aer_isr_one_error()
>>     aer_process_err_device()
>>         do_recovery()
>>             broadcast_error_message()
>>                 pci_walk_bus()
>>                     down_read(&pci_bus_sem) //acquire pci_bus_sem successfully
>>                         report_error_detected(dev)
>>                             device_lock(dev) // deadlock here
>>
>> We use down_write(&pci_bus_sem) to protect the bus->slots list, because the
>> bus->slots list is only accessed in drivers/pci/slot.c, we could introduce
>> a new local mutex to protect bus->slots, and use down_read(&pci_bus_sem)
>> instead of down_write(&pci_bus_sem) to protect the bus->devices list.
>>
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> 
> I applied both patches to our system and ran a number of tests.
> Works fine as far as I can see.
> 
> Tested-by: Guenter Roeck <linux@roeck-us.net>

Guenter, thanks very much!

Thanks!
Yijing.

> 
> 
> 


  reply	other threads:[~2015-07-24  4:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-17  9:16 [PATCH v2 0/2] Fix a deadlock for aer and pciehp driver Yijing Wang
2015-07-17  9:16 ` [PATCH v2 1/2] PCI: Use a local mutex instead of pci_bus_sem to avoid deadlock Yijing Wang
2015-07-24  3:07   ` Guenter Roeck
2015-07-24  4:08     ` wangyijing [this message]
2015-07-17  9:16 ` [PATCH v2 2/2] PCI: Lock pci_slot_mutex when traverse bus->slots Yijing Wang
2015-07-18  3:50 ` [PATCH v2 0/2] Fix a deadlock for aer and pciehp driver Guenter Roeck
2015-07-30 21:20 ` Bjorn Helgaas
2015-07-31  1:37   ` Guenter Roeck
2015-07-31 15:31     ` Bjorn Helgaas
2015-08-10 19:29 ` Bjorn Helgaas
2015-08-11  1:07   ` wangyijing

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=55B1BA41.4080700@huawei.com \
    --to=wangyijing@huawei.com \
    --cc=bhelgaas@google.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=rajatja@google.com \
    --cc=rjw@rjwysocki.net \
    /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;
as well as URLs for NNTP newsgroup(s).