From: Peter Zijlstra <peterz@infradead.org>
To: Julian Anastasov <ja@ssi.bg>
Cc: Ingo Molnar <mingo@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Oleg Nesterov <oleg@redhat.com>,
linux-kernel@vger.kernel.org, neilb@suse.de
Subject: Re: [PATCH] sched: Introduce TASK_NOLOAD and TASK_IDLE
Date: Mon, 11 May 2015 16:22:47 +0200 [thread overview]
Message-ID: <20150511142247.GT27504@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <alpine.LFD.2.11.1505090910060.1671@ja.home.ssi.bg>
On Sat, May 09, 2015 at 11:49:01AM +0300, Julian Anastasov wrote:
> After checking our code in net/netfilter/ipvs/ip_vs_sync.c,
> sync_thread_master(), we may also need some wrappers:
>
> - schedule_timeout_idle (instead of schedule_timeout call):
> __set_current_state(TASK_IDLE);
> return schedule_timeout(timeout);
>
> - we here are really idle, so "N" looks ok
So I don't get the point of the schedule_timeout_*() stubs. What are
they for? Why would one use an unconditional schedule_timeout() call?
Isn't that what msleep() is for?
> - pair of __wait_event_idle(wq, condition) and
> wait_event_idle(wq, condition) macros
>
> - we here are write-blocked for socket, not sure
> if this blocked vs idle difference is useful to
> represent, in new bit for this blocked state "B"=2048,
> with 2 TASK_NOLOAD variants: N(idle) and B(blocked,
> 2|1024|2048, eg. for read-blocked or write-blocked).
> It will need additional argument 'state'/'blocked' for
> *wait_event_idle().
Completely untested.
---
include/linux/wait.h | 41 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 39 insertions(+), 2 deletions(-)
diff --git a/include/linux/wait.h b/include/linux/wait.h
index 2db83349865b..b9ef6bacf633 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -307,6 +307,26 @@ do { \
__ret; \
})
+#define __wait_event_idle(wq, condition) \
+ (void)___wait_event(wq, condition, TASK_IDLE, 0, 0, \
+ schedule())
+
+
+/**
+ * wait_event_idle - sleep until a condition get true; do not contribute to the loadavg
+ * @wq: the waitqueue to wait on
+ * @condition: a C expression for the event to wait for
+ *
+ * See wait_event()
+ */
+#define wait_event_idle(wq, condition) \
+do { \
+ might_sleep(); \
+ if (condition) \
+ break; \
+ __wait_event_idle(wq, condition); \
+} while (0)
+
#define __wait_event_timeout(wq, condition, timeout) \
___wait_event(wq, ___wait_cond_timeout(condition), \
TASK_UNINTERRUPTIBLE, 0, timeout, \
@@ -346,8 +366,8 @@ do { \
__ret = schedule_timeout(__ret); try_to_freeze())
/*
- * like wait_event_timeout() -- except it uses TASK_INTERRUPTIBLE to avoid
- * increasing load and is freezable.
+ * like wait_event_timeout() -- except it uses TASK_INTERRUPTIBLE
+ * and is freezable.
*/
#define wait_event_freezable_timeout(wq, condition, timeout) \
({ \
@@ -358,6 +378,23 @@ do { \
__ret; \
})
+#define __wait_event_idle_timeout(wq, condition, timeout) \
+ ___wait_event(wq, ___wait_cond_timeout(condition), \
+ TASK_IDLE, 0, timeout, \
+ __ret = schedule_timeout(__ret))
+
+/*
+ * like wait_event_timeout() -- except it uses TASK_IDLE to avoid loadavg
+ */
+#define wait_event_idle_timeout(wq, condition, timeout) \
+({ \
+ long __ret = timeout; \
+ might_sleep(); \
+ if (!___wait_cond_timeout(condition)) \
+ ret = __wait_event_idle_timeout(wq, condition, timeout);\
+ __ret; \
+})
+
#define __wait_event_cmd(wq, condition, cmd1, cmd2) \
(void)___wait_event(wq, condition, TASK_UNINTERRUPTIBLE, 0, 0, \
cmd1; schedule(); cmd2)
next prev parent reply other threads:[~2015-05-11 14:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-08 12:47 Peter Zijlstra
2015-05-09 8:49 ` Julian Anastasov
2015-05-11 7:11 ` NeilBrown
2015-05-11 14:22 ` Peter Zijlstra [this message]
2015-05-11 19:34 ` Julian Anastasov
2015-05-12 12:25 ` Peter Zijlstra
2015-05-13 7:22 ` Julian Anastasov
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=20150511142247.GT27504@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=ja@ssi.bg \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=neilb@suse.de \
--cc=oleg@redhat.com \
--cc=torvalds@linux-foundation.org \
/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
Powered by JetHome