Re: Memory allocation in PCI's ->suspend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tuesday 20 January 2009, Matthew Wilcox wrote:
> On Mon, Jan 19, 2009 at 10:45:18AM +0100, Rafael J. Wysocki wrote:
> > On Monday 19 January 2009, Matthew Wilcox wrote:
> > > 
> > > It seems that the PCI code goes out of its way to avoid doing any memory
> > > allocation during the suspend path.  For example, there's
> > > pci_allocate_cap_save_buffers() which is called (indirectly) from
> > > pci_device_add().
> > > 
> > > This is a bit of a problem for MSI.  I can get the per-interrupt
> > > overhead down to 4 bytes (ie the unsigned int that is the Linux
> > > interrupt number), but if I can't allocate memory during suspend, that
> > > bloats up to 16 bytes per interrupt.  The maximum number of interrupts
> > > allocated per devfn is 2048, so that's an extra 24k of ram that either
> > > needs to be allocated all the time, or at suspend time (and then
> > > released at resume time).
> > > 
> > > Matthew Garrett tells me there's no reason to avoid memory allocation at
> > > suspend time, indeed it's run twice, once with interrupts on and once
> > > with them off, precisely to permit memory allocations.  So why does PCI
> > > try so hard?  Is it just an accident of history?
> > 
> > AFAICS, it is done so we don't have to allocate memory with interrupts
> > disabled, because that would have to be done with GFP_ATOMIC.
> > pci_allocate_cap_save_buffers() is there exactly for this reason.
> 
> You recently wrote:
> 
> > > > Nope.  pci_prepare_to_sleep() is called during suspend, from
> > > > pci_pm_default_suspend(), with interrupts on.
> 
> Why can't we allocate memory in pci_prepare_to_sleep()?

Hm, in fact we can.

When I added pci_allocate_cap_save_buffers() the idea was that we
would call pci_save_state() with interrupts off, but it's better to call it
earlier.  Also, pci_allocate_cap_save_buffers() replaced code that allocated
memory during the first run of pci_save_state() for given device and kept it
reserved afterwards, so I thought we might allocate it upfront just as well.

Thanks,
Rafael
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux