From: Oleg Nesterov <oleg@tv-sign.ru>
To: akpm@linux-foundation.org
Cc: torvalds@linux-foundation.org, roland@redhat.com, mingo@elte.hu,
linux-kernel@vger.kernel.org
Subject: [PATCH] wait_task_inactive: don't consider task->nivcsw
Date: Sun, 27 Jul 2008 15:37:32 +0400 [thread overview]
Message-ID: <20080727113732.GA178@tv-sign.ru> (raw)
In-Reply-To: <200807260245.m6Q2jwB4012297@imap1.linux-foundation.org>
If wait_task_inactive() returns success the task was deactivated.
In that case schedule() always increments ->nvcsw which alone can
be used as a "generation counter".
If the next call returns the same number, we can be sure that the
task was unscheduled. Otherwise, because we know that .on_rq == 0
again, ->nvcsw should have been changed in between.
Q: perhaps it is better to do "ncsw = (p->nvcsw << 1) | 1" ? This
decreases the possibility of "was it unscheduled" false positive
when ->nvcsw == 0.
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
--- LINUS/kernel/sched.c~ 2008-07-27 14:46:03.000000000 +0400
+++ LINUS/kernel/sched.c 2008-07-27 14:55:12.000000000 +0400
@@ -1922,11 +1922,8 @@ unsigned long wait_task_inactive(struct
running = task_running(rq, p);
on_rq = p->se.on_rq;
ncsw = 0;
- if (!match_state || p->state == match_state) {
- ncsw = p->nivcsw + p->nvcsw;
- if (unlikely(!ncsw))
- ncsw = 1;
- }
+ if (!match_state || p->state == match_state)
+ ncsw = p->nvcsw ?: 1;
task_rq_unlock(rq, &flags);
/*
next parent reply other threads:[~2008-07-27 11:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200807260245.m6Q2jwB4012297@imap1.linux-foundation.org>
2008-07-27 11:37 ` Oleg Nesterov [this message]
2008-07-27 19:55 ` Roland McGrath
2008-07-27 12:15 ` Q: wait_task_inactive() and !CONFIG_SMP && CONFIG_PREEMPT Oleg Nesterov
2008-07-27 16:51 ` Linus Torvalds
2008-07-27 20:05 ` Roland McGrath
2008-07-28 12:57 ` Oleg Nesterov
2008-07-28 23:39 ` Roland McGrath
2008-07-29 12:21 ` Oleg Nesterov
2008-08-01 1:27 ` Roland McGrath
2008-08-01 11:49 ` Oleg Nesterov
2008-08-01 21:22 ` Roland McGrath
2008-07-27 12:42 ` [PATCH] kthread_bind: use wait_task_inactive(TASK_UNINTERRUPTIBLE) Oleg Nesterov
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=20080727113732.GA178@tv-sign.ru \
--to=oleg@tv-sign.ru \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=roland@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
all inboxes | Powered by JetHome®