Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1674062 > unrolled thread
| Started by | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| First post | 2017-06-24 12:00 +0200 |
| Last post | 2017-06-28 23:10 +0200 |
| Articles | 12 — 6 participants |
Back to article view | Back to linux.kernel
PM / wakeirq: Convert to SRCU Thomas Gleixner <tglx@linutronix.de> - 2017-06-24 12:00 +0200
Re: PM / wakeirq: Convert to SRCU "Rafael J. Wysocki" <rafael@kernel.org> - 2017-06-24 14:10 +0200
Re: PM / wakeirq: Convert to SRCU Thomas Gleixner <tglx@linutronix.de> - 2017-06-24 14:20 +0200
Re: PM / wakeirq: Convert to SRCU "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2017-06-24 14:40 +0200
Re: PM / wakeirq: Convert to SRCU "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-24 16:00 +0200
Re: PM / wakeirq: Convert to SRCU Thomas Gleixner <tglx@linutronix.de> - 2017-06-25 11:20 +0200
Re: PM / wakeirq: Convert to SRCU "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-25 16:50 +0200
[PATCH v2] PM / wakeirq: Convert to SRCU Thomas Gleixner <tglx@linutronix.de> - 2017-06-25 19:40 +0200
Re: [PATCH v2] PM / wakeirq: Convert to SRCU "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-25 20:30 +0200
Re: [PATCH v2] PM / wakeirq: Convert to SRCU Tony Lindgren <tony@atomide.com> - 2017-06-26 12:20 +0200
Re: [PATCH v2] PM / wakeirq: Convert to SRCU Brian Norris <briannorris@chromium.org> - 2017-06-26 22:40 +0200
Re: [PATCH v2] PM / wakeirq: Convert to SRCU "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2017-06-28 23:10 +0200
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2017-06-24 12:00 +0200 |
| Subject | PM / wakeirq: Convert to SRCU |
| Message-ID | <tVQ1c-6d5-13@gated-at.bofh.it> |
The wakeirq infrastructure uses RCU to protect the list of wakeirqs. That
breaks the irq bus locking infrastructure, which allows sleeping functions
to be called so interrupt controllers behind slow busses, e.g. i2c, can be
handled.
The wakeirq functions hold rcu_read_lock and call into irq functions, which
in case of interrupts using the irq bus locking will trigger a
might_sleep() splat.
Convert the wakeirq infrastructure to Sleepable RCU and unbreak it.
Fixes: 4990d4fe327b ("PM / Wakeirq: Add automated device wake IRQ handling")
Reported-by: Brian Norris <briannorris@chromium.org>
Suggested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
---
drivers/base/power/wakeup.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -60,6 +60,8 @@ static LIST_HEAD(wakeup_sources);
static DECLARE_WAIT_QUEUE_HEAD(wakeup_count_wait_queue);
+static struct srcu_struct wakeup_srcu;
+
static struct wakeup_source deleted_ws = {
.name = "deleted",
.lock = __SPIN_LOCK_UNLOCKED(deleted_ws.lock),
@@ -198,7 +200,7 @@ void wakeup_source_remove(struct wakeup_
spin_lock_irqsave(&events_lock, flags);
list_del_rcu(&ws->entry);
spin_unlock_irqrestore(&events_lock, flags);
- synchronize_rcu();
+ synchronize_srcu(&wakeup_srcu);
}
EXPORT_SYMBOL_GPL(wakeup_source_remove);
@@ -804,10 +806,10 @@ EXPORT_SYMBOL_GPL(pm_wakeup_dev_event);
void pm_print_active_wakeup_sources(void)
{
struct wakeup_source *ws;
- int active = 0;
+ int srcuidx, active = 0;
struct wakeup_source *last_activity_ws = NULL;
- rcu_read_lock();
+ srcuidx = srcu_read_lock(&wakeup_srcu);
list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
if (ws->active) {
pr_debug("active wakeup source: %s\n", ws->name);
@@ -823,7 +825,7 @@ void pm_print_active_wakeup_sources(void
if (!active && last_activity_ws)
pr_debug("last active wakeup source: %s\n",
last_activity_ws->name);
- rcu_read_unlock();
+ srcu_read_unlock(&wakeup_srcu, srcuidx);
}
EXPORT_SYMBOL_GPL(pm_print_active_wakeup_sources);
@@ -950,8 +952,9 @@ void pm_wakep_autosleep_enabled(bool set
{
struct wakeup_source *ws;
ktime_t now = ktime_get();
+ int srcuidx;
- rcu_read_lock();
+ srcuidx = srcu_read_lock(&wakeup_srcu);
list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
spin_lock_irq(&ws->lock);
if (ws->autosleep_enabled != set) {
@@ -965,7 +968,7 @@ void pm_wakep_autosleep_enabled(bool set
}
spin_unlock_irq(&ws->lock);
}
- rcu_read_unlock();
+ srcu_read_unlock(&wakeup_srcu, srcuidx);
}
#endif /* CONFIG_PM_AUTOSLEEP */
@@ -1026,15 +1029,16 @@ static int print_wakeup_source_stats(str
static int wakeup_sources_stats_show(struct seq_file *m, void *unused)
{
struct wakeup_source *ws;
+ int srcuidx;
seq_puts(m, "name\t\tactive_count\tevent_count\twakeup_count\t"
"expire_count\tactive_since\ttotal_time\tmax_time\t"
"last_change\tprevent_suspend_time\n");
- rcu_read_lock();
+ srcuidx = srcu_read_lock(&wakeup_srcu);
list_for_each_entry_rcu(ws, &wakeup_sources, entry)
print_wakeup_source_stats(m, ws);
- rcu_read_unlock();
+ srcu_read_unlock(&wakeup_srcu, srcuidx);
print_wakeup_source_stats(m, &deleted_ws);
[toc] | [next] | [standalone]
| From | "Rafael J. Wysocki" <rafael@kernel.org> |
|---|---|
| Date | 2017-06-24 14:10 +0200 |
| Message-ID | <tVS2Z-7DX-11@gated-at.bofh.it> |
| In reply to | #1674062 |
On Sat, Jun 24, 2017 at 11:56 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
> The wakeirq infrastructure uses RCU to protect the list of wakeirqs. That
> breaks the irq bus locking infrastructure, which allows sleeping functions
> to be called so interrupt controllers behind slow busses, e.g. i2c, can be
> handled.
>
> The wakeirq functions hold rcu_read_lock and call into irq functions, which
> in case of interrupts using the irq bus locking will trigger a
> might_sleep() splat.
>
> Convert the wakeirq infrastructure to Sleepable RCU and unbreak it.
>
> Fixes: 4990d4fe327b ("PM / Wakeirq: Add automated device wake IRQ handling")
> Reported-by: Brian Norris <briannorris@chromium.org>
> Suggested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: stable@vger.kernel.org
OK
I guess it would be good to get this into 4.12?
Thanks,
Rafael
[toc] | [prev] | [next] | [standalone]
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2017-06-24 14:20 +0200 |
| Message-ID | <tVScF-7Ie-5@gated-at.bofh.it> |
| In reply to | #1674074 |
On Sat, 24 Jun 2017, Rafael J. Wysocki wrote:
> On Sat, Jun 24, 2017 at 11:56 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
> > The wakeirq infrastructure uses RCU to protect the list of wakeirqs. That
> > breaks the irq bus locking infrastructure, which allows sleeping functions
> > to be called so interrupt controllers behind slow busses, e.g. i2c, can be
> > handled.
> >
> > The wakeirq functions hold rcu_read_lock and call into irq functions, which
> > in case of interrupts using the irq bus locking will trigger a
> > might_sleep() splat.
> >
> > Convert the wakeirq infrastructure to Sleepable RCU and unbreak it.
> >
> > Fixes: 4990d4fe327b ("PM / Wakeirq: Add automated device wake IRQ handling")
> > Reported-by: Brian Norris <briannorris@chromium.org>
> > Suggested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> > Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> > Cc: stable@vger.kernel.org
>
> OK
>
> I guess it would be good to get this into 4.12?
I think so, but it probably wants some testing and breeding in next.
Thanks,
tglx
[toc] | [prev] | [next] | [standalone]
| From | "Rafael J. Wysocki" <rjw@rjwysocki.net> |
|---|---|
| Date | 2017-06-24 14:40 +0200 |
| Message-ID | <tVSw2-7Pk-17@gated-at.bofh.it> |
| In reply to | #1674075 |
On Saturday, June 24, 2017 02:13:35 PM Thomas Gleixner wrote:
> On Sat, 24 Jun 2017, Rafael J. Wysocki wrote:
> > On Sat, Jun 24, 2017 at 11:56 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
> > > The wakeirq infrastructure uses RCU to protect the list of wakeirqs. That
> > > breaks the irq bus locking infrastructure, which allows sleeping functions
> > > to be called so interrupt controllers behind slow busses, e.g. i2c, can be
> > > handled.
> > >
> > > The wakeirq functions hold rcu_read_lock and call into irq functions, which
> > > in case of interrupts using the irq bus locking will trigger a
> > > might_sleep() splat.
> > >
> > > Convert the wakeirq infrastructure to Sleepable RCU and unbreak it.
> > >
> > > Fixes: 4990d4fe327b ("PM / Wakeirq: Add automated device wake IRQ handling")
> > > Reported-by: Brian Norris <briannorris@chromium.org>
> > > Suggested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> > > Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> > > Cc: stable@vger.kernel.org
> >
> > OK
> >
> > I guess it would be good to get this into 4.12?
>
> I think so, but it probably wants some testing and breeding in next.
Right.
So here's a deal: if there is an -rc8, I can push this to Linus before the
final 4.12, but otherwise it will go into 4.13-rc during the merge window.
The -stable link will still be there, so that shouldn't be a big issue.
Thanks,
Rafael
[toc] | [prev] | [next] | [standalone]
| From | "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> |
|---|---|
| Date | 2017-06-24 16:00 +0200 |
| Message-ID | <tVTLs-8uO-21@gated-at.bofh.it> |
| In reply to | #1674062 |
On Sat, Jun 24, 2017 at 11:56:11AM +0200, Thomas Gleixner wrote:
> The wakeirq infrastructure uses RCU to protect the list of wakeirqs. That
> breaks the irq bus locking infrastructure, which allows sleeping functions
> to be called so interrupt controllers behind slow busses, e.g. i2c, can be
> handled.
>
> The wakeirq functions hold rcu_read_lock and call into irq functions, which
> in case of interrupts using the irq bus locking will trigger a
> might_sleep() splat.
>
> Convert the wakeirq infrastructure to Sleepable RCU and unbreak it.
>
> Fixes: 4990d4fe327b ("PM / Wakeirq: Add automated device wake IRQ handling")
> Reported-by: Brian Norris <briannorris@chromium.org>
> Suggested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: stable@vger.kernel.org
Looks plausible. One suggestion on initialization below, and a couple
of questions about uses of RCU that this patch does not convert to SRCU.
Thanx, Paul
> ---
> drivers/base/power/wakeup.c | 20 ++++++++++++--------
> 1 file changed, 12 insertions(+), 8 deletions(-)
>
> --- a/drivers/base/power/wakeup.c
> +++ b/drivers/base/power/wakeup.c
> @@ -60,6 +60,8 @@ static LIST_HEAD(wakeup_sources);
>
> static DECLARE_WAIT_QUEUE_HEAD(wakeup_count_wait_queue);
>
> +static struct srcu_struct wakeup_srcu;
I suggest this to avoid the need for boot-time init_srcu_struct():
DEFINE_STATIC_SRCU(wakeup_srcu);
> +
> static struct wakeup_source deleted_ws = {
> .name = "deleted",
> .lock = __SPIN_LOCK_UNLOCKED(deleted_ws.lock),
> @@ -198,7 +200,7 @@ void wakeup_source_remove(struct wakeup_
> spin_lock_irqsave(&events_lock, flags);
> list_del_rcu(&ws->entry);
> spin_unlock_irqrestore(&events_lock, flags);
> - synchronize_rcu();
> + synchronize_srcu(&wakeup_srcu);
> }
> EXPORT_SYMBOL_GPL(wakeup_source_remove);
The uses of RCU in device_wakeup_arm_wake_irqs() and
device_wakeup_disarm_wake_irqs() are unrelated and thus do not
need to be converted? Or am I looking at the wrong version of
the kernel? (Looking at f65013d655ac ("Merge branch 'for-linus' of
git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace")
in Linus's tree.)
If these two functions are making unrelated use of RCU and thus don't
need to be converted to SRCU, might be worth a comment somewhere.
> @@ -804,10 +806,10 @@ EXPORT_SYMBOL_GPL(pm_wakeup_dev_event);
> void pm_print_active_wakeup_sources(void)
> {
> struct wakeup_source *ws;
> - int active = 0;
> + int srcuidx, active = 0;
> struct wakeup_source *last_activity_ws = NULL;
>
> - rcu_read_lock();
> + srcuidx = srcu_read_lock(&wakeup_srcu);
> list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
> if (ws->active) {
> pr_debug("active wakeup source: %s\n", ws->name);
> @@ -823,7 +825,7 @@ void pm_print_active_wakeup_sources(void
> if (!active && last_activity_ws)
> pr_debug("last active wakeup source: %s\n",
> last_activity_ws->name);
> - rcu_read_unlock();
> + srcu_read_unlock(&wakeup_srcu, srcuidx);
> }
> EXPORT_SYMBOL_GPL(pm_print_active_wakeup_sources);
>
> @@ -950,8 +952,9 @@ void pm_wakep_autosleep_enabled(bool set
> {
> struct wakeup_source *ws;
> ktime_t now = ktime_get();
> + int srcuidx;
>
> - rcu_read_lock();
> + srcuidx = srcu_read_lock(&wakeup_srcu);
> list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
> spin_lock_irq(&ws->lock);
> if (ws->autosleep_enabled != set) {
> @@ -965,7 +968,7 @@ void pm_wakep_autosleep_enabled(bool set
> }
> spin_unlock_irq(&ws->lock);
> }
> - rcu_read_unlock();
> + srcu_read_unlock(&wakeup_srcu, srcuidx);
> }
> #endif /* CONFIG_PM_AUTOSLEEP */
Same question for pm_wakep_autosleep_enabled().
> @@ -1026,15 +1029,16 @@ static int print_wakeup_source_stats(str
> static int wakeup_sources_stats_show(struct seq_file *m, void *unused)
> {
> struct wakeup_source *ws;
> + int srcuidx;
>
> seq_puts(m, "name\t\tactive_count\tevent_count\twakeup_count\t"
> "expire_count\tactive_since\ttotal_time\tmax_time\t"
> "last_change\tprevent_suspend_time\n");
>
> - rcu_read_lock();
> + srcuidx = srcu_read_lock(&wakeup_srcu);
> list_for_each_entry_rcu(ws, &wakeup_sources, entry)
> print_wakeup_source_stats(m, ws);
> - rcu_read_unlock();
> + srcu_read_unlock(&wakeup_srcu, srcuidx);
>
> print_wakeup_source_stats(m, &deleted_ws);
>
>
[toc] | [prev] | [next] | [standalone]
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2017-06-25 11:20 +0200 |
| Message-ID | <tWbS1-3df-11@gated-at.bofh.it> |
| In reply to | #1674084 |
On Sat, 24 Jun 2017, Paul E. McKenney wrote:
> On Sat, Jun 24, 2017 at 11:56:11AM +0200, Thomas Gleixner wrote:
> > static DECLARE_WAIT_QUEUE_HEAD(wakeup_count_wait_queue);
> >
> > +static struct srcu_struct wakeup_srcu;
>
> I suggest this to avoid the need for boot-time init_srcu_struct():
>
> DEFINE_STATIC_SRCU(wakeup_srcu);
Now I know why I had this nagging feeling, that should stay away from
computers yesterday morning.....
> > static struct wakeup_source deleted_ws = {
> > .name = "deleted",
> > .lock = __SPIN_LOCK_UNLOCKED(deleted_ws.lock),
> > @@ -198,7 +200,7 @@ void wakeup_source_remove(struct wakeup_
> > spin_lock_irqsave(&events_lock, flags);
> > list_del_rcu(&ws->entry);
> > spin_unlock_irqrestore(&events_lock, flags);
> > - synchronize_rcu();
> > + synchronize_srcu(&wakeup_srcu);
> > }
> > EXPORT_SYMBOL_GPL(wakeup_source_remove);
>
> The uses of RCU in device_wakeup_arm_wake_irqs() and
> device_wakeup_disarm_wake_irqs() are unrelated and thus do not
> need to be converted? Or am I looking at the wrong version of
> the kernel? (Looking at f65013d655ac ("Merge branch 'for-linus' of
> git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace")
> in Linus's tree.)
No, you are looking at the result of heat induced brain melt. Will send a
proper one soon.
Thanks,
tglx
[toc] | [prev] | [next] | [standalone]
| From | "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> |
|---|---|
| Date | 2017-06-25 16:50 +0200 |
| Message-ID | <tWh1n-6hv-5@gated-at.bofh.it> |
| In reply to | #1674194 |
On Sun, Jun 25, 2017 at 11:11:57AM +0200, Thomas Gleixner wrote:
> On Sat, 24 Jun 2017, Paul E. McKenney wrote:
> > On Sat, Jun 24, 2017 at 11:56:11AM +0200, Thomas Gleixner wrote:
> > > static DECLARE_WAIT_QUEUE_HEAD(wakeup_count_wait_queue);
> > >
> > > +static struct srcu_struct wakeup_srcu;
> >
> > I suggest this to avoid the need for boot-time init_srcu_struct():
> >
> > DEFINE_STATIC_SRCU(wakeup_srcu);
>
> Now I know why I had this nagging feeling, that should stay away from
> computers yesterday morning.....
Believe me, I know that feeling well!
> > > static struct wakeup_source deleted_ws = {
> > > .name = "deleted",
> > > .lock = __SPIN_LOCK_UNLOCKED(deleted_ws.lock),
> > > @@ -198,7 +200,7 @@ void wakeup_source_remove(struct wakeup_
> > > spin_lock_irqsave(&events_lock, flags);
> > > list_del_rcu(&ws->entry);
> > > spin_unlock_irqrestore(&events_lock, flags);
> > > - synchronize_rcu();
> > > + synchronize_srcu(&wakeup_srcu);
> > > }
> > > EXPORT_SYMBOL_GPL(wakeup_source_remove);
> >
> > The uses of RCU in device_wakeup_arm_wake_irqs() and
> > device_wakeup_disarm_wake_irqs() are unrelated and thus do not
> > need to be converted? Or am I looking at the wrong version of
> > the kernel? (Looking at f65013d655ac ("Merge branch 'for-linus' of
> > git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace")
> > in Linus's tree.)
>
> No, you are looking at the result of heat induced brain melt. Will send a
> proper one soon.
And if anything, I know that feeling even better. Looking forward to
seeing the new patch.
Thanx, Paul
[toc] | [prev] | [next] | [standalone]
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2017-06-25 19:40 +0200 |
| Subject | [PATCH v2] PM / wakeirq: Convert to SRCU |
| Message-ID | <tWjFT-7Yc-7@gated-at.bofh.it> |
| In reply to | #1674230 |
The wakeirq infrastructure uses RCU to protect the list of wakeirqs. That
breaks the irq bus locking infrastructure, which is allows sleeping
functions to be called so interrupt controllers behind slow busses,
e.g. i2c, can be handled.
The wakeirq functions hold rcu_read_lock and call into irq functions, which
in case of interrupts using the irq bus locking will trigger a
might_sleep() splat.
Convert the wakeirq infrastructure to Sleepable RCU and unbreak it.
Fixes: 4990d4fe327b ("PM / Wakeirq: Add automated device wake IRQ handling")
Reported-by: Brian Norris <briannorris@chromium.org>
Suggested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
drivers/base/power/wakeup.c | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -60,6 +60,8 @@ static LIST_HEAD(wakeup_sources);
static DECLARE_WAIT_QUEUE_HEAD(wakeup_count_wait_queue);
+DEFINE_STATIC_SRCU(wakeup_srcu);
+
static struct wakeup_source deleted_ws = {
.name = "deleted",
.lock = __SPIN_LOCK_UNLOCKED(deleted_ws.lock),
@@ -198,7 +200,7 @@ void wakeup_source_remove(struct wakeup_
spin_lock_irqsave(&events_lock, flags);
list_del_rcu(&ws->entry);
spin_unlock_irqrestore(&events_lock, flags);
- synchronize_rcu();
+ synchronize_srcu(&wakeup_srcu);
}
EXPORT_SYMBOL_GPL(wakeup_source_remove);
@@ -332,12 +334,12 @@ void device_wakeup_detach_irq(struct dev
void device_wakeup_arm_wake_irqs(void)
{
struct wakeup_source *ws;
+ int srcuidx;
- rcu_read_lock();
+ srcuidx = srcu_read_lock(&wakeup_srcu);
list_for_each_entry_rcu(ws, &wakeup_sources, entry)
dev_pm_arm_wake_irq(ws->wakeirq);
-
- rcu_read_unlock();
+ srcu_read_unlock(&wakeup_srcu, srcuidx);
}
/**
@@ -348,12 +350,12 @@ void device_wakeup_arm_wake_irqs(void)
void device_wakeup_disarm_wake_irqs(void)
{
struct wakeup_source *ws;
+ int srcuidx;
- rcu_read_lock();
+ srcuidx = srcu_read_lock(&wakeup_srcu);
list_for_each_entry_rcu(ws, &wakeup_sources, entry)
dev_pm_disarm_wake_irq(ws->wakeirq);
-
- rcu_read_unlock();
+ srcu_read_unlock(&wakeup_srcu, srcuidx);
}
/**
@@ -804,10 +806,10 @@ EXPORT_SYMBOL_GPL(pm_wakeup_dev_event);
void pm_print_active_wakeup_sources(void)
{
struct wakeup_source *ws;
- int active = 0;
+ int srcuidx, active = 0;
struct wakeup_source *last_activity_ws = NULL;
- rcu_read_lock();
+ srcuidx = srcu_read_lock(&wakeup_srcu);
list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
if (ws->active) {
pr_debug("active wakeup source: %s\n", ws->name);
@@ -823,7 +825,7 @@ void pm_print_active_wakeup_sources(void
if (!active && last_activity_ws)
pr_debug("last active wakeup source: %s\n",
last_activity_ws->name);
- rcu_read_unlock();
+ srcu_read_unlock(&wakeup_srcu, srcuidx);
}
EXPORT_SYMBOL_GPL(pm_print_active_wakeup_sources);
@@ -950,8 +952,9 @@ void pm_wakep_autosleep_enabled(bool set
{
struct wakeup_source *ws;
ktime_t now = ktime_get();
+ int srcuidx;
- rcu_read_lock();
+ srcuidx = srcu_read_lock(&wakeup_srcu);
list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
spin_lock_irq(&ws->lock);
if (ws->autosleep_enabled != set) {
@@ -965,7 +968,7 @@ void pm_wakep_autosleep_enabled(bool set
}
spin_unlock_irq(&ws->lock);
}
- rcu_read_unlock();
+ srcu_read_unlock(&wakeup_srcu, srcuidx);
}
#endif /* CONFIG_PM_AUTOSLEEP */
@@ -1026,15 +1029,16 @@ static int print_wakeup_source_stats(str
static int wakeup_sources_stats_show(struct seq_file *m, void *unused)
{
struct wakeup_source *ws;
+ int srcuidx;
seq_puts(m, "name\t\tactive_count\tevent_count\twakeup_count\t"
"expire_count\tactive_since\ttotal_time\tmax_time\t"
"last_change\tprevent_suspend_time\n");
- rcu_read_lock();
+ srcuidx = srcu_read_lock(&wakeup_srcu);
list_for_each_entry_rcu(ws, &wakeup_sources, entry)
print_wakeup_source_stats(m, ws);
- rcu_read_unlock();
+ srcu_read_unlock(&wakeup_srcu, srcuidx);
print_wakeup_source_stats(m, &deleted_ws);
[toc] | [prev] | [next] | [standalone]
| From | "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> |
|---|---|
| Date | 2017-06-25 20:30 +0200 |
| Subject | Re: [PATCH v2] PM / wakeirq: Convert to SRCU |
| Message-ID | <tWksi-8vA-7@gated-at.bofh.it> |
| In reply to | #1674273 |
On Sun, Jun 25, 2017 at 07:31:13PM +0200, Thomas Gleixner wrote:
> The wakeirq infrastructure uses RCU to protect the list of wakeirqs. That
> breaks the irq bus locking infrastructure, which is allows sleeping
> functions to be called so interrupt controllers behind slow busses,
> e.g. i2c, can be handled.
>
> The wakeirq functions hold rcu_read_lock and call into irq functions, which
> in case of interrupts using the irq bus locking will trigger a
> might_sleep() splat.
>
> Convert the wakeirq infrastructure to Sleepable RCU and unbreak it.
>
> Fixes: 4990d4fe327b ("PM / Wakeirq: Add automated device wake IRQ handling")
> Reported-by: Brian Norris <briannorris@chromium.org>
> Suggested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Looks good to me!
Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> ---
> drivers/base/power/wakeup.c | 32 ++++++++++++++++++--------------
> 1 file changed, 18 insertions(+), 14 deletions(-)
>
> --- a/drivers/base/power/wakeup.c
> +++ b/drivers/base/power/wakeup.c
> @@ -60,6 +60,8 @@ static LIST_HEAD(wakeup_sources);
>
> static DECLARE_WAIT_QUEUE_HEAD(wakeup_count_wait_queue);
>
> +DEFINE_STATIC_SRCU(wakeup_srcu);
> +
> static struct wakeup_source deleted_ws = {
> .name = "deleted",
> .lock = __SPIN_LOCK_UNLOCKED(deleted_ws.lock),
> @@ -198,7 +200,7 @@ void wakeup_source_remove(struct wakeup_
> spin_lock_irqsave(&events_lock, flags);
> list_del_rcu(&ws->entry);
> spin_unlock_irqrestore(&events_lock, flags);
> - synchronize_rcu();
> + synchronize_srcu(&wakeup_srcu);
> }
> EXPORT_SYMBOL_GPL(wakeup_source_remove);
>
> @@ -332,12 +334,12 @@ void device_wakeup_detach_irq(struct dev
> void device_wakeup_arm_wake_irqs(void)
> {
> struct wakeup_source *ws;
> + int srcuidx;
>
> - rcu_read_lock();
> + srcuidx = srcu_read_lock(&wakeup_srcu);
> list_for_each_entry_rcu(ws, &wakeup_sources, entry)
> dev_pm_arm_wake_irq(ws->wakeirq);
> -
> - rcu_read_unlock();
> + srcu_read_unlock(&wakeup_srcu, srcuidx);
> }
>
> /**
> @@ -348,12 +350,12 @@ void device_wakeup_arm_wake_irqs(void)
> void device_wakeup_disarm_wake_irqs(void)
> {
> struct wakeup_source *ws;
> + int srcuidx;
>
> - rcu_read_lock();
> + srcuidx = srcu_read_lock(&wakeup_srcu);
> list_for_each_entry_rcu(ws, &wakeup_sources, entry)
> dev_pm_disarm_wake_irq(ws->wakeirq);
> -
> - rcu_read_unlock();
> + srcu_read_unlock(&wakeup_srcu, srcuidx);
> }
>
> /**
> @@ -804,10 +806,10 @@ EXPORT_SYMBOL_GPL(pm_wakeup_dev_event);
> void pm_print_active_wakeup_sources(void)
> {
> struct wakeup_source *ws;
> - int active = 0;
> + int srcuidx, active = 0;
> struct wakeup_source *last_activity_ws = NULL;
>
> - rcu_read_lock();
> + srcuidx = srcu_read_lock(&wakeup_srcu);
> list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
> if (ws->active) {
> pr_debug("active wakeup source: %s\n", ws->name);
> @@ -823,7 +825,7 @@ void pm_print_active_wakeup_sources(void
> if (!active && last_activity_ws)
> pr_debug("last active wakeup source: %s\n",
> last_activity_ws->name);
> - rcu_read_unlock();
> + srcu_read_unlock(&wakeup_srcu, srcuidx);
> }
> EXPORT_SYMBOL_GPL(pm_print_active_wakeup_sources);
>
> @@ -950,8 +952,9 @@ void pm_wakep_autosleep_enabled(bool set
> {
> struct wakeup_source *ws;
> ktime_t now = ktime_get();
> + int srcuidx;
>
> - rcu_read_lock();
> + srcuidx = srcu_read_lock(&wakeup_srcu);
> list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
> spin_lock_irq(&ws->lock);
> if (ws->autosleep_enabled != set) {
> @@ -965,7 +968,7 @@ void pm_wakep_autosleep_enabled(bool set
> }
> spin_unlock_irq(&ws->lock);
> }
> - rcu_read_unlock();
> + srcu_read_unlock(&wakeup_srcu, srcuidx);
> }
> #endif /* CONFIG_PM_AUTOSLEEP */
>
> @@ -1026,15 +1029,16 @@ static int print_wakeup_source_stats(str
> static int wakeup_sources_stats_show(struct seq_file *m, void *unused)
> {
> struct wakeup_source *ws;
> + int srcuidx;
>
> seq_puts(m, "name\t\tactive_count\tevent_count\twakeup_count\t"
> "expire_count\tactive_since\ttotal_time\tmax_time\t"
> "last_change\tprevent_suspend_time\n");
>
> - rcu_read_lock();
> + srcuidx = srcu_read_lock(&wakeup_srcu);
> list_for_each_entry_rcu(ws, &wakeup_sources, entry)
> print_wakeup_source_stats(m, ws);
> - rcu_read_unlock();
> + srcu_read_unlock(&wakeup_srcu, srcuidx);
>
> print_wakeup_source_stats(m, &deleted_ws);
>
>
[toc] | [prev] | [next] | [standalone]
| From | Tony Lindgren <tony@atomide.com> |
|---|---|
| Date | 2017-06-26 12:20 +0200 |
| Subject | Re: [PATCH v2] PM / wakeirq: Convert to SRCU |
| Message-ID | <tWzhE-13H-9@gated-at.bofh.it> |
| In reply to | #1674277 |
* Paul E. McKenney <paulmck@linux.vnet.ibm.com> [170625 11:29]:
> On Sun, Jun 25, 2017 at 07:31:13PM +0200, Thomas Gleixner wrote:
> > The wakeirq infrastructure uses RCU to protect the list of wakeirqs. That
> > breaks the irq bus locking infrastructure, which is allows sleeping
> > functions to be called so interrupt controllers behind slow busses,
> > e.g. i2c, can be handled.
> >
> > The wakeirq functions hold rcu_read_lock and call into irq functions, which
> > in case of interrupts using the irq bus locking will trigger a
> > might_sleep() splat.
> >
> > Convert the wakeirq infrastructure to Sleepable RCU and unbreak it.
> >
> > Fixes: 4990d4fe327b ("PM / Wakeirq: Add automated device wake IRQ handling")
> > Reported-by: Brian Norris <briannorris@chromium.org>
> > Suggested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> > Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
>
> Looks good to me!
>
> Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
And still works for me!
Tested-by: Tony Lindgren <tony@atomide.com>
[toc] | [prev] | [next] | [standalone]
| From | Brian Norris <briannorris@chromium.org> |
|---|---|
| Date | 2017-06-26 22:40 +0200 |
| Subject | Re: [PATCH v2] PM / wakeirq: Convert to SRCU |
| Message-ID | <tWIXD-72s-9@gated-at.bofh.it> |
| In reply to | #1674273 |
On Sun, Jun 25, 2017 at 07:31:13PM +0200, Thomas Gleixner wrote:
> The wakeirq infrastructure uses RCU to protect the list of wakeirqs. That
> breaks the irq bus locking infrastructure, which is allows sleeping
> functions to be called so interrupt controllers behind slow busses,
> e.g. i2c, can be handled.
>
> The wakeirq functions hold rcu_read_lock and call into irq functions, which
> in case of interrupts using the irq bus locking will trigger a
> might_sleep() splat.
>
> Convert the wakeirq infrastructure to Sleepable RCU and unbreak it.
>
> Fixes: 4990d4fe327b ("PM / Wakeirq: Add automated device wake IRQ handling")
> Reported-by: Brian Norris <briannorris@chromium.org>
> Suggested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---
> drivers/base/power/wakeup.c | 32 ++++++++++++++++++--------------
> 1 file changed, 18 insertions(+), 14 deletions(-)
This resolves the warnings I've seen, for sure. And I don't seem to have
any new suspend/resume problems, so:
Tested-by: Brian Norris <briannorris@chromium.org>
[toc] | [prev] | [next] | [standalone]
| From | "Rafael J. Wysocki" <rjw@rjwysocki.net> |
|---|---|
| Date | 2017-06-28 23:10 +0200 |
| Subject | Re: [PATCH v2] PM / wakeirq: Convert to SRCU |
| Message-ID | <tXsnM-2zA-9@gated-at.bofh.it> |
| In reply to | #1675089 |
On Monday, June 26, 2017 01:37:11 PM Brian Norris wrote:
> On Sun, Jun 25, 2017 at 07:31:13PM +0200, Thomas Gleixner wrote:
> > The wakeirq infrastructure uses RCU to protect the list of wakeirqs. That
> > breaks the irq bus locking infrastructure, which is allows sleeping
> > functions to be called so interrupt controllers behind slow busses,
> > e.g. i2c, can be handled.
> >
> > The wakeirq functions hold rcu_read_lock and call into irq functions, which
> > in case of interrupts using the irq bus locking will trigger a
> > might_sleep() splat.
> >
> > Convert the wakeirq infrastructure to Sleepable RCU and unbreak it.
> >
> > Fixes: 4990d4fe327b ("PM / Wakeirq: Add automated device wake IRQ handling")
> > Reported-by: Brian Norris <briannorris@chromium.org>
> > Suggested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> > Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> > ---
> > drivers/base/power/wakeup.c | 32 ++++++++++++++++++--------------
> > 1 file changed, 18 insertions(+), 14 deletions(-)
>
> This resolves the warnings I've seen, for sure. And I don't seem to have
> any new suspend/resume problems, so:
>
> Tested-by: Brian Norris <briannorris@chromium.org>
Applied with all tags, thanks!
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web