Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-31 Thread Ming Lei
On Wed, Oct 31, 2012 at 11:41 PM, Alan Stern wrote: > > Sorry, I misread your message. You are setting the device's flag, not > the thread's flag. Never mind. > > This still doesn't help in this case where CONFIG_PM_RUNTIME is > disabled. I think it will be simpler to set the noio flag during

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-31 Thread Alan Stern
On Wed, 31 Oct 2012, Alan Stern wrote: > On Wed, 31 Oct 2012, Ming Lei wrote: > > > The below idea may help the problem which 'memalloc_noio' flag isn't set > > during > > usb_reset_device(). > > > > - for usb mass storage device, call pm_runtime_set_memalloc_noio(true) > > inside

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-31 Thread Alan Stern
On Wed, 31 Oct 2012, Ming Lei wrote: > The below idea may help the problem which 'memalloc_noio' flag isn't set > during > usb_reset_device(). > > - for usb mass storage device, call pm_runtime_set_memalloc_noio(true) > inside usb_stor_probe2() and uas_probe(), and call >

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-31 Thread Oliver Neukum
On Wednesday 31 October 2012 11:05:33 Ming Lei wrote: > On Wed, Oct 31, 2012 at 10:08 AM, Ming Lei wrote: > >> I am afraid it is, because a disk may just have been probed as the > >> deviceis being reset. > > > > Yes, it is probable, and sounds like similar with 'root_wait' problem, see > >

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-31 Thread Oliver Neukum
On Wednesday 31 October 2012 11:05:33 Ming Lei wrote: On Wed, Oct 31, 2012 at 10:08 AM, Ming Lei ming@canonical.com wrote: I am afraid it is, because a disk may just have been probed as the deviceis being reset. Yes, it is probable, and sounds like similar with 'root_wait' problem,

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-31 Thread Alan Stern
On Wed, 31 Oct 2012, Ming Lei wrote: The below idea may help the problem which 'memalloc_noio' flag isn't set during usb_reset_device(). - for usb mass storage device, call pm_runtime_set_memalloc_noio(true) inside usb_stor_probe2() and uas_probe(), and call

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-31 Thread Alan Stern
On Wed, 31 Oct 2012, Alan Stern wrote: On Wed, 31 Oct 2012, Ming Lei wrote: The below idea may help the problem which 'memalloc_noio' flag isn't set during usb_reset_device(). - for usb mass storage device, call pm_runtime_set_memalloc_noio(true) inside usb_stor_probe2() and

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-31 Thread Ming Lei
On Wed, Oct 31, 2012 at 11:41 PM, Alan Stern st...@rowland.harvard.edu wrote: Sorry, I misread your message. You are setting the device's flag, not the thread's flag. Never mind. This still doesn't help in this case where CONFIG_PM_RUNTIME is disabled. I think it will be simpler to set

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-30 Thread Ming Lei
On Wed, Oct 31, 2012 at 10:08 AM, Ming Lei wrote: >> I am afraid it is, because a disk may just have been probed as the deviceis >> being reset. > > Yes, it is probable, and sounds like similar with 'root_wait' problem, see > prepare_namespace(): init/do_mounts.c, so looks no good solution > for

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-30 Thread Ming Lei
On Wed, Oct 31, 2012 at 12:30 AM, Oliver Neukum wrote: >> If the USB mass-storage device is being reseted, the flag should be set >> already generally. If the flag is still unset, that means the disk/network >> device isn't added into system(or removed just now), so memory allocation >> with

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-30 Thread Alan Stern
On Wed, 31 Oct 2012, Ming Lei wrote: > On Tue, Oct 30, 2012 at 11:38 PM, Alan Stern > wrote: > > > > > Okay, I see your point. But acquiring the lock here doesn't solve the > > problem. Suppose a thread is about to reset a USB mass-storage device. > > It acquires the lock and sees that the

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-30 Thread Oliver Neukum
On Wednesday 31 October 2012 00:00:56 Ming Lei wrote: > On Tue, Oct 30, 2012 at 11:38 PM, Alan Stern > wrote: > > > > > Okay, I see your point. But acquiring the lock here doesn't solve the > > problem. Suppose a thread is about to reset a USB mass-storage device. > > It acquires the lock and

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-30 Thread Ming Lei
On Wed, Oct 31, 2012 at 12:00 AM, Ming Lei wrote: > > Looks the simplest approach is to handle the noio flag thing at the start and > end of rpm_resume. Sorry, that doesn't work, runtime_suspend need that too because memory allocation with block I/O might deadlock when doing I/O on the same

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-30 Thread Ming Lei
On Tue, Oct 30, 2012 at 11:38 PM, Alan Stern wrote: > > Okay, I see your point. But acquiring the lock here doesn't solve the > problem. Suppose a thread is about to reset a USB mass-storage device. > It acquires the lock and sees that the noio flag is clear. But before > it can issue the

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-30 Thread Alan Stern
On Tue, 30 Oct 2012, Ming Lei wrote: > >> +bool pm_runtime_get_memalloc_noio(struct device *dev) > >> +{ > >> + bool ret; > >> + spin_lock_irq(>power.lock); > >> + ret = dev->power.memalloc_noio_resume; > >> + spin_unlock_irq(>power.lock); > >> + return ret; > >> +} > > > >

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-30 Thread Ming Lei
Hi, On Tue, Oct 30, 2012 at 6:57 PM, Oliver Neukum wrote: > how is this to work with power management domains? Could you explain it in a bit detail? Why is PM domain involved? Suppose PM domain is involved, its domain runtime_resume callback is still run in the context with PF_MEMALLOC_NOIO

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-30 Thread Oliver Neukum
On Tuesday 30 October 2012 11:21:33 Ming Lei wrote: > On Mon, Oct 29, 2012 at 11:41 PM, Alan Stern > wrote: > > On Mon, 29 Oct 2012, Ming Lei wrote: > > > >> The patch introduces the flag of memalloc_noio_resume in > >> 'struct dev_pm_info' to help PM core to teach mm not allocating > >> memory

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-30 Thread Oliver Neukum
On Tuesday 30 October 2012 11:21:33 Ming Lei wrote: On Mon, Oct 29, 2012 at 11:41 PM, Alan Stern st...@rowland.harvard.edu wrote: On Mon, 29 Oct 2012, Ming Lei wrote: The patch introduces the flag of memalloc_noio_resume in 'struct dev_pm_info' to help PM core to teach mm not allocating

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-30 Thread Ming Lei
Hi, On Tue, Oct 30, 2012 at 6:57 PM, Oliver Neukum oneu...@suse.de wrote: how is this to work with power management domains? Could you explain it in a bit detail? Why is PM domain involved? Suppose PM domain is involved, its domain runtime_resume callback is still run in the context with

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-30 Thread Alan Stern
On Tue, 30 Oct 2012, Ming Lei wrote: +bool pm_runtime_get_memalloc_noio(struct device *dev) +{ + bool ret; + spin_lock_irq(dev-power.lock); + ret = dev-power.memalloc_noio_resume; + spin_unlock_irq(dev-power.lock); + return ret; +} You don't need to acquire

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-30 Thread Ming Lei
On Tue, Oct 30, 2012 at 11:38 PM, Alan Stern st...@rowland.harvard.edu wrote: Okay, I see your point. But acquiring the lock here doesn't solve the problem. Suppose a thread is about to reset a USB mass-storage device. It acquires the lock and sees that the noio flag is clear. But before

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-30 Thread Ming Lei
On Wed, Oct 31, 2012 at 12:00 AM, Ming Lei ming@canonical.com wrote: Looks the simplest approach is to handle the noio flag thing at the start and end of rpm_resume. Sorry, that doesn't work, runtime_suspend need that too because memory allocation with block I/O might deadlock when doing

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-30 Thread Oliver Neukum
On Wednesday 31 October 2012 00:00:56 Ming Lei wrote: On Tue, Oct 30, 2012 at 11:38 PM, Alan Stern st...@rowland.harvard.edu wrote: Okay, I see your point. But acquiring the lock here doesn't solve the problem. Suppose a thread is about to reset a USB mass-storage device. It

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-30 Thread Alan Stern
On Wed, 31 Oct 2012, Ming Lei wrote: On Tue, Oct 30, 2012 at 11:38 PM, Alan Stern st...@rowland.harvard.edu wrote: Okay, I see your point. But acquiring the lock here doesn't solve the problem. Suppose a thread is about to reset a USB mass-storage device. It acquires the lock and

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-30 Thread Ming Lei
On Wed, Oct 31, 2012 at 12:30 AM, Oliver Neukum oneu...@suse.de wrote: If the USB mass-storage device is being reseted, the flag should be set already generally. If the flag is still unset, that means the disk/network device isn't added into system(or removed just now), so memory allocation

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-30 Thread Ming Lei
On Wed, Oct 31, 2012 at 10:08 AM, Ming Lei ming@canonical.com wrote: I am afraid it is, because a disk may just have been probed as the deviceis being reset. Yes, it is probable, and sounds like similar with 'root_wait' problem, see prepare_namespace(): init/do_mounts.c, so looks no good

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-29 Thread Ming Lei
On Mon, Oct 29, 2012 at 11:41 PM, Alan Stern wrote: > On Mon, 29 Oct 2012, Ming Lei wrote: > >> The patch introduces the flag of memalloc_noio_resume in >> 'struct dev_pm_info' to help PM core to teach mm not allocating >> memory with GFP_KERNEL flag for avoiding probable deadlock >> problem. >>

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-29 Thread Alan Stern
On Mon, 29 Oct 2012, Ming Lei wrote: > The patch introduces the flag of memalloc_noio_resume in > 'struct dev_pm_info' to help PM core to teach mm not allocating > memory with GFP_KERNEL flag for avoiding probable deadlock > problem. > > As explained in the comment, any GFP_KERNEL allocation

[PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-29 Thread Ming Lei
The patch introduces the flag of memalloc_noio_resume in 'struct dev_pm_info' to help PM core to teach mm not allocating memory with GFP_KERNEL flag for avoiding probable deadlock problem. As explained in the comment, any GFP_KERNEL allocation inside runtime_resume on any one of device in the

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-29 Thread Ming Lei
On Mon, Oct 29, 2012 at 11:41 PM, Alan Stern st...@rowland.harvard.edu wrote: On Mon, 29 Oct 2012, Ming Lei wrote: The patch introduces the flag of memalloc_noio_resume in 'struct dev_pm_info' to help PM core to teach mm not allocating memory with GFP_KERNEL flag for avoiding probable

[PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-29 Thread Ming Lei
The patch introduces the flag of memalloc_noio_resume in 'struct dev_pm_info' to help PM core to teach mm not allocating memory with GFP_KERNEL flag for avoiding probable deadlock problem. As explained in the comment, any GFP_KERNEL allocation inside runtime_resume on any one of device in the

Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()

2012-10-29 Thread Alan Stern
On Mon, 29 Oct 2012, Ming Lei wrote: The patch introduces the flag of memalloc_noio_resume in 'struct dev_pm_info' to help PM core to teach mm not allocating memory with GFP_KERNEL flag for avoiding probable deadlock problem. As explained in the comment, any GFP_KERNEL allocation inside