From: Cheng Chao <cs.os.kernel@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>, Oleg Nesterov <oleg@redhat.com>
Cc: mingo@kernel.org, tj@kernel.org, akpm@linux-foundation.org,
chris@chris-wilson.co.uk, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] stop_machine: Make migration_cpu_stop() does useful works for CONFIG_PREEMPT_NONE
Date: Wed, 14 Sep 2016 10:07:14 +0800 [thread overview]
Message-ID: <8f78b328-7a44-8c9a-28bf-61ef91831e9b@gmail.com> (raw)
In-Reply-To: <20160913163729.GB5012@twins.programming.kicks-ass.net>
great, __schedule() doesn't need pay any attention to the TASK_DEAD now.
on 09/14/2016 12:37 AM, Peter Zijlstra wrote:
> On Tue, Sep 13, 2016 at 06:14:27PM +0200, Oleg Nesterov wrote:
>
>> Me too, and I failed to find something which could be broken... So
>> perhaps should make it nop and investigate the new bug reports after
>> that.
>
> Works for me :-)
>
>>
>> Hmm. And preempt_enable_no_resched_notrace() under TASK_DEAD in
>> __schedule() should be removed it seems, do_exit() can call __schedule()
>> directly.
>
>
> something like so?
>
> ---
>
> include/linux/kernel.h | 2 +-
> include/linux/sched.h | 2 ++
> kernel/exit.c | 11 ++---------
> kernel/sched/core.c | 23 ++++++++++++-----------
> 4 files changed, 17 insertions(+), 21 deletions(-)
>
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index d96a6118d26a..e5bd9cdd2e24 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -266,7 +266,7 @@ extern void oops_enter(void);
> extern void oops_exit(void);
> void print_oops_end_marker(void);
> extern int oops_may_print(void);
> -void do_exit(long error_code)
> +void __noreturn do_exit(long error_code)
> __noreturn;
> void complete_and_exit(struct completion *, long)
> __noreturn;
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index eb64fcd89e68..b0c818a05b2e 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -448,6 +448,8 @@ static inline void io_schedule(void)
> io_schedule_timeout(MAX_SCHEDULE_TIMEOUT);
> }
>
> +void __noreturn do_task_dead(void);
> +
> struct nsproxy;
> struct user_namespace;
>
> diff --git a/kernel/exit.c b/kernel/exit.c
> index 091a78be3b09..d4c12692f766 100644
> --- a/kernel/exit.c
> +++ b/kernel/exit.c
> @@ -725,7 +725,7 @@ static void check_stack_usage(void)
> static inline void check_stack_usage(void) {}
> #endif
>
> -void do_exit(long code)
> +void __noreturn do_exit(long code)
> {
> struct task_struct *tsk = current;
> int group_dead;
> @@ -897,14 +897,7 @@ void do_exit(long code)
> smp_mb();
> raw_spin_unlock_wait(&tsk->pi_lock);
>
> - /* causes final put_task_struct in finish_task_switch(). */
> - tsk->state = TASK_DEAD;
> - tsk->flags |= PF_NOFREEZE; /* tell freezer to ignore us */
> - schedule();
> - BUG();
> - /* Avoid "noreturn function does return". */
> - for (;;)
> - cpu_relax(); /* For when BUG is null */
> + do_task_dead();
> }
> EXPORT_SYMBOL_GPL(do_exit);
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index a0086a5fc008..6034f269000f 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -3327,17 +3327,6 @@ static void __sched notrace __schedule(bool preempt)
> rq = cpu_rq(cpu);
> prev = rq->curr;
>
> - /*
> - * do_exit() calls schedule() with preemption disabled as an exception;
> - * however we must fix that up, otherwise the next task will see an
> - * inconsistent (higher) preempt count.
> - *
> - * It also avoids the below schedule_debug() test from complaining
> - * about this.
> - */
> - if (unlikely(prev->state == TASK_DEAD))
> - preempt_enable_no_resched_notrace();
> -
> schedule_debug(prev);
>
> if (sched_feat(HRTICK))
> @@ -3404,6 +3393,18 @@ static void __sched notrace __schedule(bool preempt)
> balance_callback(rq);
> }
>
> +void __noreturn do_task_dead(void)
> +{
> + /* causes final put_task_struct in finish_task_switch(). */
> + __set_current_state(TASK_DEAD);
> + current->flags |= PF_NOFREEZE; /* tell freezer to ignore us */
> + __schedule(false);
> + BUG();
> + /* Avoid "noreturn function does return". */
> + for (;;)
> + cpu_relax(); /* For when BUG is null */
> +}
> +
> static inline void sched_submit_work(struct task_struct *tsk)
> {
> if (!tsk->state || tsk_is_pi_blocked(tsk))
>
next prev parent reply other threads:[~2016-09-14 2:07 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <OF73BCE1E4.D2224FEC-ON48258025.0022CFA7-48258025.0022E3DC@kedacom.com>
2016-09-09 8:13 ` [PATCH v2] stop_machine: Make migration_cpu_stop() does useful works for CONFIG_PREEMPT_NONE Cheng Chao
2016-09-09 8:19 ` chengchao
2016-09-09 13:14 ` Oleg Nesterov
2016-09-09 16:24 ` Peter Zijlstra
2016-09-10 8:52 ` [PATCH v3] " Cheng Chao
2016-09-10 9:51 ` Cheng Chao
2016-09-10 16:33 ` Peter Zijlstra
2016-09-12 11:03 ` Oleg Nesterov
2016-09-13 2:45 ` Cheng Chao
2016-09-12 11:37 ` Peter Zijlstra
2016-09-12 11:41 ` Peter Zijlstra
2016-09-12 13:05 ` Oleg Nesterov
2016-09-12 15:01 ` Peter Zijlstra
2016-09-13 16:14 ` Oleg Nesterov
2016-09-13 16:37 ` Peter Zijlstra
2016-09-14 2:07 ` Cheng Chao [this message]
2016-09-14 7:50 ` Peter Zijlstra
2016-09-14 15:45 ` Oleg Nesterov
2016-09-22 13:59 ` [tip:sched/core] sched/core: Optimize __schedule() tip-bot for Peter Zijlstra
2016-09-13 4:03 ` [PATCH v3] stop_machine: Make migration_cpu_stop() does useful works for CONFIG_PREEMPT_NONE Cheng Chao
2016-09-13 8:45 ` Peter Zijlstra
2016-09-14 2:01 ` [PATCH v4] stop_machine: Avoid a sleep and wakeup in the stop_one_cpu() Cheng Chao
2016-09-14 15:53 ` Oleg Nesterov
2016-09-18 2:07 ` Cheng Chao
2016-09-22 13:59 ` [tip:sched/core] stop_machine: Avoid a sleep and wakeup in stop_one_cpu() tip-bot for Cheng Chao
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=8f78b328-7a44-8c9a-28bf-61ef91831e9b@gmail.com \
--to=cs.os.kernel@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=chris@chris-wilson.co.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=tj@kernel.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;
as well as URLs for NNTP newsgroup(s).