* [PATCH v2] sched/wait: use freezable_schedule when possible
@ 2019-02-07 20:03 Hugo Lefeuvre
2019-02-08 0:12 ` Joel Fernandes
2019-02-11 10:53 ` [tip:sched/core] sched/wait: Use freezable_schedule() " tip-bot for Hugo Lefeuvre
0 siblings, 2 replies; 3+ messages in thread
From: Hugo Lefeuvre @ 2019-02-07 20:03 UTC (permalink / raw)
To: Joel Fernandes
Cc: Ingo Molnar, Peter Zijlstra, linux-kernel, Rafael J. Wysocki
Replace schedule(); try_to_freeze() by freezable_schedule().
Tasks calling freezable_schedule() set the PF_FREEZER_SKIP flag
before calling schedule(). Unlike tasks calling schedule();
try_to_freeze() tasks calling freezable_schedule() are not awaken by
try_to_freeze_tasks(). Instead they call try_to_freeze() when they
wake up if the freeze is still underway.
It is not a problem since sleeping tasks can't do anything which isn't
allowed for a frozen task while sleeping.
The result is a potential performance gain during freeze, since less
tasks have to be awaken.
For instance on a bare Debian vm running a 4.19 stable kernel, the
number of tasks skipped in freeze_task() went up from 12 without the
patch to 32 with the patch (out of 448), an increase of > x2.5.
Signed-off-by: Hugo Lefeuvre <hle@owl.eu.com>
---
Changes in v2:
- Add test results to commit message.
- Split from initial patch set[0] since this patch can go in separately
[0] https://lkml.org/lkml/2019/2/1/19
include/linux/wait.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/linux/wait.h b/include/linux/wait.h
index ed7c122cb31f..5f3efabc36f4 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -308,7 +308,7 @@ do { \
#define __wait_event_freezable(wq_head, condition) \
___wait_event(wq_head, condition, TASK_INTERRUPTIBLE, 0, 0, \
- schedule(); try_to_freeze())
+ freezable_schedule())
/**
* wait_event_freezable - sleep (or freeze) until a condition gets true
@@ -367,7 +367,7 @@ do { \
#define __wait_event_freezable_timeout(wq_head, condition, timeout) \
___wait_event(wq_head, ___wait_cond_timeout(condition), \
TASK_INTERRUPTIBLE, 0, timeout, \
- __ret = schedule_timeout(__ret); try_to_freeze())
+ __ret = freezable_schedule_timeout(__ret))
/*
* like wait_event_timeout() -- except it uses TASK_INTERRUPTIBLE to avoid
@@ -588,7 +588,7 @@ do { \
#define __wait_event_freezable_exclusive(wq, condition) \
___wait_event(wq, condition, TASK_INTERRUPTIBLE, 1, 0, \
- schedule(); try_to_freeze())
+ freezable_schedule())
#define wait_event_freezable_exclusive(wq, condition) \
({ \
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] sched/wait: use freezable_schedule when possible
2019-02-07 20:03 [PATCH v2] sched/wait: use freezable_schedule when possible Hugo Lefeuvre
@ 2019-02-08 0:12 ` Joel Fernandes
2019-02-11 10:53 ` [tip:sched/core] sched/wait: Use freezable_schedule() " tip-bot for Hugo Lefeuvre
1 sibling, 0 replies; 3+ messages in thread
From: Joel Fernandes @ 2019-02-08 0:12 UTC (permalink / raw)
To: Hugo Lefeuvre
Cc: Ingo Molnar, Peter Zijlstra, linux-kernel, Rafael J. Wysocki
On Thu, Feb 07, 2019 at 09:03:52PM +0100, Hugo Lefeuvre wrote:
> Replace schedule(); try_to_freeze() by freezable_schedule().
>
> Tasks calling freezable_schedule() set the PF_FREEZER_SKIP flag
> before calling schedule(). Unlike tasks calling schedule();
> try_to_freeze() tasks calling freezable_schedule() are not awaken by
> try_to_freeze_tasks(). Instead they call try_to_freeze() when they
> wake up if the freeze is still underway.
>
> It is not a problem since sleeping tasks can't do anything which isn't
> allowed for a frozen task while sleeping.
>
> The result is a potential performance gain during freeze, since less
> tasks have to be awaken.
>
> For instance on a bare Debian vm running a 4.19 stable kernel, the
> number of tasks skipped in freeze_task() went up from 12 without the
> patch to 32 with the patch (out of 448), an increase of > x2.5.
>
Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> Signed-off-by: Hugo Lefeuvre <hle@owl.eu.com>
> ---
> Changes in v2:
> - Add test results to commit message.
> - Split from initial patch set[0] since this patch can go in separately
> [0] https://lkml.org/lkml/2019/2/1/19
>
> include/linux/wait.h | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/wait.h b/include/linux/wait.h
> index ed7c122cb31f..5f3efabc36f4 100644
> --- a/include/linux/wait.h
> +++ b/include/linux/wait.h
> @@ -308,7 +308,7 @@ do { \
>
> #define __wait_event_freezable(wq_head, condition) \
> ___wait_event(wq_head, condition, TASK_INTERRUPTIBLE, 0, 0, \
> - schedule(); try_to_freeze())
> + freezable_schedule())
>
> /**
> * wait_event_freezable - sleep (or freeze) until a condition gets true
> @@ -367,7 +367,7 @@ do { \
> #define __wait_event_freezable_timeout(wq_head, condition, timeout) \
> ___wait_event(wq_head, ___wait_cond_timeout(condition), \
> TASK_INTERRUPTIBLE, 0, timeout, \
> - __ret = schedule_timeout(__ret); try_to_freeze())
> + __ret = freezable_schedule_timeout(__ret))
>
> /*
> * like wait_event_timeout() -- except it uses TASK_INTERRUPTIBLE to avoid
> @@ -588,7 +588,7 @@ do { \
>
> #define __wait_event_freezable_exclusive(wq, condition) \
> ___wait_event(wq, condition, TASK_INTERRUPTIBLE, 1, 0, \
> - schedule(); try_to_freeze())
> + freezable_schedule())
>
> #define wait_event_freezable_exclusive(wq, condition) \
> ({ \
> --
> 2.20.1
^ permalink raw reply [flat|nested] 3+ messages in thread* [tip:sched/core] sched/wait: Use freezable_schedule() when possible
2019-02-07 20:03 [PATCH v2] sched/wait: use freezable_schedule when possible Hugo Lefeuvre
2019-02-08 0:12 ` Joel Fernandes
@ 2019-02-11 10:53 ` tip-bot for Hugo Lefeuvre
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Hugo Lefeuvre @ 2019-02-11 10:53 UTC (permalink / raw)
To: linux-tip-commits
Cc: torvalds, hpa, linux-kernel, tglx, joel, hle, rjw, peterz, mingo
Commit-ID: 2b9c2a4859ad5ac7b5a28e9db28c3e618760fe8c
Gitweb: https://git.kernel.org/tip/2b9c2a4859ad5ac7b5a28e9db28c3e618760fe8c
Author: Hugo Lefeuvre <hle@owl.eu.com>
AuthorDate: Thu, 7 Feb 2019 21:03:52 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 11 Feb 2019 08:34:04 +0100
sched/wait: Use freezable_schedule() when possible
Replace 'schedule(); try_to_freeze();' with a call to freezable_schedule().
Tasks calling freezable_schedule() set the PF_FREEZER_SKIP flag
before calling schedule(). Unlike tasks calling schedule();
try_to_freeze() tasks calling freezable_schedule() are not awaken by
try_to_freeze_tasks(). Instead they call try_to_freeze() when they
wake up if the freeze is still underway.
It is not a problem since sleeping tasks can't do anything which isn't
allowed for a frozen task while sleeping.
The result is a potential performance gain during freeze, since less
tasks have to be awaken.
For instance on a bare Debian vm running a 4.19 stable kernel, the
number of tasks skipped in freeze_task() went up from 12 without the
patch to 32 with the patch (out of 448), an increase of > x2.5.
Signed-off-by: Hugo Lefeuvre <hle@owl.eu.com>
Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Cc: Joel Fernandes <joel@joelfernandes.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20190207200352.GA27859@behemoth.owl.eu.com.local
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
include/linux/wait.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/linux/wait.h b/include/linux/wait.h
index ed7c122cb31f..5f3efabc36f4 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -308,7 +308,7 @@ do { \
#define __wait_event_freezable(wq_head, condition) \
___wait_event(wq_head, condition, TASK_INTERRUPTIBLE, 0, 0, \
- schedule(); try_to_freeze())
+ freezable_schedule())
/**
* wait_event_freezable - sleep (or freeze) until a condition gets true
@@ -367,7 +367,7 @@ do { \
#define __wait_event_freezable_timeout(wq_head, condition, timeout) \
___wait_event(wq_head, ___wait_cond_timeout(condition), \
TASK_INTERRUPTIBLE, 0, timeout, \
- __ret = schedule_timeout(__ret); try_to_freeze())
+ __ret = freezable_schedule_timeout(__ret))
/*
* like wait_event_timeout() -- except it uses TASK_INTERRUPTIBLE to avoid
@@ -588,7 +588,7 @@ do { \
#define __wait_event_freezable_exclusive(wq, condition) \
___wait_event(wq, condition, TASK_INTERRUPTIBLE, 1, 0, \
- schedule(); try_to_freeze())
+ freezable_schedule())
#define wait_event_freezable_exclusive(wq, condition) \
({ \
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-02-11 10:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-07 20:03 [PATCH v2] sched/wait: use freezable_schedule when possible Hugo Lefeuvre
2019-02-08 0:12 ` Joel Fernandes
2019-02-11 10:53 ` [tip:sched/core] sched/wait: Use freezable_schedule() " tip-bot for Hugo Lefeuvre
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.