Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1234928 > unrolled thread
| Started by | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| First post | 2015-09-29 11:50 +0200 |
| Last post | 2015-09-29 16:20 +0200 |
| Articles | 7 — 5 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[RFC][PATCH 02/11] sched: Create preempt_count invariant Peter Zijlstra <peterz@infradead.org> - 2015-09-29 11:50 +0200
[tip:sched/core] sched/core: Create preempt_count invariant tip-bot for Peter Zijlstra <tipbot@zytor.com> - 2015-09-29 12:40 +0200
Re: [RFC][PATCH 02/11] sched: Create preempt_count invariant Frederic Weisbecker <fweisbec@gmail.com> - 2015-09-29 15:00 +0200
Re: [RFC][PATCH 02/11] sched: Create preempt_count invariant Peter Zijlstra <peterz@infradead.org> - 2015-09-29 15:10 +0200
Re: [RFC][PATCH 02/11] sched: Create preempt_count invariant Steven Rostedt <rostedt@goodmis.org> - 2015-09-29 16:50 +0200
Re: [RFC][PATCH 02/11] sched: Create preempt_count invariant Thomas Gleixner <tglx@linutronix.de> - 2015-09-29 15:20 +0200
Re: [RFC][PATCH 02/11] sched: Create preempt_count invariant Peter Zijlstra <peterz@infradead.org> - 2015-09-29 16:20 +0200
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2015-09-29 11:50 +0200 |
| Subject | [RFC][PATCH 02/11] sched: Create preempt_count invariant |
| Message-ID | <qdZHS-2IS-41@gated-at.bofh.it> |
Ensure that upon scheduling preempt_count == 2; although currently an
additional PREEMPT_ACTIVE is still possible.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/x86/include/asm/preempt.h | 3 ++-
include/asm-generic/preempt.h | 2 +-
kernel/sched/core.c | 14 ++++++++++----
3 files changed, 13 insertions(+), 6 deletions(-)
--- a/arch/x86/include/asm/preempt.h
+++ b/arch/x86/include/asm/preempt.h
@@ -31,7 +31,8 @@ static __always_inline void preempt_coun
* must be macros to avoid header recursion hell
*/
#define init_task_preempt_count(p) do { \
- task_thread_info(p)->saved_preempt_count = PREEMPT_DISABLED; \
+ task_thread_info(p)->saved_preempt_count = \
+ 2*PREEMPT_DISABLE_OFFSET + PREEMPT_NEED_RESCHED; \
} while (0)
#define init_idle_preempt_count(p, cpu) do { \
--- a/include/asm-generic/preempt.h
+++ b/include/asm-generic/preempt.h
@@ -24,7 +24,7 @@ static __always_inline void preempt_coun
* must be macros to avoid header recursion hell
*/
#define init_task_preempt_count(p) do { \
- task_thread_info(p)->preempt_count = PREEMPT_DISABLED; \
+ task_thread_info(p)->preempt_count = 2*PREEMPT_DISABLED; \
} while (0)
#define init_idle_preempt_count(p, cpu) do { \
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2588,11 +2588,17 @@ asmlinkage __visible void schedule_tail(
{
struct rq *rq;
- /* finish_task_switch() drops rq->lock and enables preemtion */
- preempt_disable();
- rq = finish_task_switch(prev);
+ /*
+ * Still have preempt_count() == 2, from:
+ *
+ * schedule()
+ * preempt_disable(); // 1
+ * __schedule()
+ * raw_spin_lock_irq(&rq->lock) // 2
+ */
+ rq = finish_task_switch(prev); /* drops rq->lock, preempt_count() == 1 */
balance_callback(rq);
- preempt_enable();
+ preempt_enable(); /* preempt_count() == 0 */
if (current->set_child_tid)
put_user(task_pid_vnr(current), current->set_child_tid);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | tip-bot for Peter Zijlstra <tipbot@zytor.com> |
|---|---|
| Date | 2015-09-29 12:40 +0200 |
| Subject | [tip:sched/core] sched/core: Create preempt_count invariant |
| Message-ID | <qe0ud-3SL-11@gated-at.bofh.it> |
| In reply to | #1234928 |
Commit-ID: e26d555f695ac8a3aa38055dd04bd23c1334723b
Gitweb: http://git.kernel.org/tip/e26d555f695ac8a3aa38055dd04bd23c1334723b
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Tue, 29 Sep 2015 11:28:27 +0200
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 29 Sep 2015 12:27:40 +0200
sched/core: Create preempt_count invariant
Ensure that upon scheduling preempt_count == 2; although
currently an additional PREEMPT_ACTIVE is still possible.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: fweisbec@gmail.com
Cc: linux-kernel@vger.kernel.org
Cc: oleg@redhat.com
Cc: rostedt@goodmis.org
Cc: umgwanakikbuti@gmail.com
Link: http://lkml.kernel.org/r/20150929093519.817299442@infradead.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/include/asm/preempt.h | 3 ++-
include/asm-generic/preempt.h | 2 +-
kernel/sched/core.c | 14 ++++++++++----
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/arch/x86/include/asm/preempt.h b/arch/x86/include/asm/preempt.h
index b12f810..183d95c6 100644
--- a/arch/x86/include/asm/preempt.h
+++ b/arch/x86/include/asm/preempt.h
@@ -31,7 +31,8 @@ static __always_inline void preempt_count_set(int pc)
* must be macros to avoid header recursion hell
*/
#define init_task_preempt_count(p) do { \
- task_thread_info(p)->saved_preempt_count = PREEMPT_DISABLED; \
+ task_thread_info(p)->saved_preempt_count = \
+ 2*PREEMPT_DISABLE_OFFSET + PREEMPT_NEED_RESCHED; \
} while (0)
#define init_idle_preempt_count(p, cpu) do { \
diff --git a/include/asm-generic/preempt.h b/include/asm-generic/preempt.h
index 0bec580..1d6f104 100644
--- a/include/asm-generic/preempt.h
+++ b/include/asm-generic/preempt.h
@@ -24,7 +24,7 @@ static __always_inline void preempt_count_set(int pc)
* must be macros to avoid header recursion hell
*/
#define init_task_preempt_count(p) do { \
- task_thread_info(p)->preempt_count = PREEMPT_DISABLED; \
+ task_thread_info(p)->preempt_count = 2*PREEMPT_DISABLED; \
} while (0)
#define init_idle_preempt_count(p, cpu) do { \
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index a91df61..ecd585c 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2588,11 +2588,17 @@ asmlinkage __visible void schedule_tail(struct task_struct *prev)
{
struct rq *rq;
- /* finish_task_switch() drops rq->lock and enables preemtion */
- preempt_disable();
- rq = finish_task_switch(prev);
+ /*
+ * Still have preempt_count() == 2, from:
+ *
+ * schedule()
+ * preempt_disable(); // 1
+ * __schedule()
+ * raw_spin_lock_irq(&rq->lock) // 2
+ */
+ rq = finish_task_switch(prev); /* drops rq->lock, preempt_count() == 1 */
balance_callback(rq);
- preempt_enable();
+ preempt_enable(); /* preempt_count() == 0 */
if (current->set_child_tid)
put_user(task_pid_vnr(current), current->set_child_tid);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Frederic Weisbecker <fweisbec@gmail.com> |
|---|---|
| Date | 2015-09-29 15:00 +0200 |
| Message-ID | <qe2FJ-6Wy-19@gated-at.bofh.it> |
| In reply to | #1234928 |
On Tue, Sep 29, 2015 at 11:28:27AM +0200, Peter Zijlstra wrote:
> Ensure that upon scheduling preempt_count == 2; although currently an
> additional PREEMPT_ACTIVE is still possible.
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> arch/x86/include/asm/preempt.h | 3 ++-
> include/asm-generic/preempt.h | 2 +-
> kernel/sched/core.c | 14 ++++++++++----
> 3 files changed, 13 insertions(+), 6 deletions(-)
>
> --- a/arch/x86/include/asm/preempt.h
> +++ b/arch/x86/include/asm/preempt.h
> @@ -31,7 +31,8 @@ static __always_inline void preempt_coun
> * must be macros to avoid header recursion hell
> */
> #define init_task_preempt_count(p) do { \
> - task_thread_info(p)->saved_preempt_count = PREEMPT_DISABLED; \
> + task_thread_info(p)->saved_preempt_count = \
> + 2*PREEMPT_DISABLE_OFFSET + PREEMPT_NEED_RESCHED; \
> } while (0)
>
> #define init_idle_preempt_count(p, cpu) do { \
> --- a/include/asm-generic/preempt.h
> +++ b/include/asm-generic/preempt.h
> @@ -24,7 +24,7 @@ static __always_inline void preempt_coun
> * must be macros to avoid header recursion hell
> */
> #define init_task_preempt_count(p) do { \
> - task_thread_info(p)->preempt_count = PREEMPT_DISABLED; \
> + task_thread_info(p)->preempt_count = 2*PREEMPT_DISABLED; \
Since it's not quite obvious why we use this magic value without looking
at schedule_tail() details, maybe add a little comment? (Just "/* see schedule_tail() */").
> } while (0)
>
> #define init_idle_preempt_count(p, cpu) do { \
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -2588,11 +2588,17 @@ asmlinkage __visible void schedule_tail(
> {
> struct rq *rq;
>
> - /* finish_task_switch() drops rq->lock and enables preemtion */
> - preempt_disable();
> - rq = finish_task_switch(prev);
> + /*
> + * Still have preempt_count() == 2, from:
> + *
> + * schedule()
> + * preempt_disable(); // 1
> + * __schedule()
> + * raw_spin_lock_irq(&rq->lock) // 2
> + */
I found that a bit confusing first, because that's a preempt_count()
we actually emulate for a new task. Maybe something like:
+ /*
+ * New task is init with preempt_count() == 2 because prev task left
+ * us after:
+ *
+ * schedule()
+ * preempt_disable(); // 1
+ * __schedule()
+ * raw_spin_lock_irq(&rq->lock) // 2
+ */
> + rq = finish_task_switch(prev); /* drops rq->lock, preempt_count() == 1 */
> balance_callback(rq);
> - preempt_enable();
> + preempt_enable(); /* preempt_count() == 0 */
Thanks!
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2015-09-29 15:10 +0200 |
| Message-ID | <qe2Pn-7mR-3@gated-at.bofh.it> |
| In reply to | #1235036 |
On Tue, Sep 29, 2015 at 02:55:13PM +0200, Frederic Weisbecker wrote:
> On Tue, Sep 29, 2015 at 11:28:27AM +0200, Peter Zijlstra wrote:
> > #define init_task_preempt_count(p) do { \
> > - task_thread_info(p)->preempt_count = PREEMPT_DISABLED; \
> > + task_thread_info(p)->preempt_count = 2*PREEMPT_DISABLED; \
>
> Since it's not quite obvious why we use this magic value without looking
> at schedule_tail() details, maybe add a little comment? (Just "/* see schedule_tail() */").
Right, I fixed that in 12/11 v2. I'll change that around a bit.
> > + /*
> > + * Still have preempt_count() == 2, from:
> > + *
> > + * schedule()
> > + * preempt_disable(); // 1
> > + * __schedule()
> > + * raw_spin_lock_irq(&rq->lock) // 2
> > + */
>
> I found that a bit confusing first, because that's a preempt_count()
> we actually emulate for a new task. Maybe something like:
>
> + /*
> + * New task is init with preempt_count() == 2 because prev task left
> + * us after:
> + *
> + * schedule()
> + * preempt_disable(); // 1
> + * __schedule()
> + * raw_spin_lock_irq(&rq->lock) // 2
> + */
I think I'll move the comment to finish_task_switch(), but yes.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Steven Rostedt <rostedt@goodmis.org> |
|---|---|
| Date | 2015-09-29 16:50 +0200 |
| Message-ID | <qe4oa-ZN-33@gated-at.bofh.it> |
| In reply to | #1235038 |
On Tue, 29 Sep 2015 15:02:01 +0200
Peter Zijlstra <peterz@infradead.org> wrote:
> On Tue, Sep 29, 2015 at 02:55:13PM +0200, Frederic Weisbecker wrote:
> > On Tue, Sep 29, 2015 at 11:28:27AM +0200, Peter Zijlstra wrote:
> > > #define init_task_preempt_count(p) do { \
> > > - task_thread_info(p)->preempt_count = PREEMPT_DISABLED; \
> > > + task_thread_info(p)->preempt_count = 2*PREEMPT_DISABLED; \
> >
> > Since it's not quite obvious why we use this magic value without looking
> > at schedule_tail() details, maybe add a little comment? (Just "/* see schedule_tail() */").
>
> Right, I fixed that in 12/11 v2. I'll change that around a bit.
I'll wait for v2 because this confused me too.
-- Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2015-09-29 15:20 +0200 |
| Message-ID | <qe2Z4-7xW-7@gated-at.bofh.it> |
| In reply to | #1234928 |
On Tue, 29 Sep 2015, Peter Zijlstra wrote: > + /* > + * Still have preempt_count() == 2, from: > + * > + * schedule() > + * preempt_disable(); // 1 > + * __schedule() > + * raw_spin_lock_irq(&rq->lock) // 2 > + */ > + rq = finish_task_switch(prev); /* drops rq->lock, preempt_count() == 1 */ > balance_callback(rq); > - preempt_enable(); > + preempt_enable(); /* preempt_count() == 0 */ Bah. I so hate tail comments. What's wrong with + /* preempt_count() ==> 0 */ preempt_enable(); Hmm? tglx -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2015-09-29 16:20 +0200 |
| Message-ID | <qe3V9-rR-23@gated-at.bofh.it> |
| In reply to | #1235043 |
On Tue, Sep 29, 2015 at 03:11:56PM +0200, Thomas Gleixner wrote: > On Tue, 29 Sep 2015, Peter Zijlstra wrote: > > + /* > > + * Still have preempt_count() == 2, from: > > + * > > + * schedule() > > + * preempt_disable(); // 1 > > + * __schedule() > > + * raw_spin_lock_irq(&rq->lock) // 2 > > + */ > > + rq = finish_task_switch(prev); /* drops rq->lock, preempt_count() == 1 */ > > balance_callback(rq); > > - preempt_enable(); > > + preempt_enable(); /* preempt_count() == 0 */ > > Bah. I so hate tail comments. What's wrong with > > + /* preempt_count() ==> 0 */ > preempt_enable(); > > Hmm? I find the tail comments more readable in this case; clearly I don't share your hatred :-). But I can change them if you insist. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web