All of lore.kernel.org
 help / color / mirror / Atom feed
From: anish singh <anish198519851985@gmail.com>
To: Frederic Weisbecker <fweisbec@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	"Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Ingo Molnar <mingo@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Borislav Petkov <bp@alien8.de>,
	Li Zhong <zhong@linux.vnet.ibm.com>,
	Don Zickus <dzickus@redhat.com>
Subject: Re: [RFC PATCH 6/8] kthread: Enable parking requests from setup() and unpark() callbacks
Date: Tue, 21 May 2013 11:04:31 +0530	[thread overview]
Message-ID: <CAK7N6voNjWrDJNzAaVAndt8cGWR+AAERs_C-oCWe0rRO=XuutQ@mail.gmail.com> (raw)
In-Reply-To: <1369065716-22801-7-git-send-email-fweisbec@gmail.com>

On Mon, May 20, 2013 at 9:31 PM, Frederic Weisbecker <fweisbec@gmail.com> wrote:
> When the watchdog code is boot-disabled by the user, for example
> through the 'nmi_watchdog=0' boot option, the setup() callback of
> the watchdog kthread requests to park the task, and that until the
> user later re-enables the watchdog through sysctl or procfs.
>
> However the parking request is not well handled when done from
> the setup() callback. After ->setup() is called, the generic smpboot
> kthread loop directly tries to call the thread function or wait
> for some event if ->thread_should_run() is false.
>
> In the case of the watchdog kthread, ->thread_should_run() returns
> false and the kthread goes to sleep and wait for the watchdog timer
> to wake it up. But the timer is not enabled since the user requested
> to disable the watchdog. We want the kthread to park instead of waiting
> for events that can't happen.
>
> As a result, later unpark requests after sysctl write through
> 'sysctl -w kernel.watchdog=1' won't wake up/unpark the task as
> expected, since it's not parked anyway, leaving the value modified
> without triggering any action.
Out of curiosity, this can happen only for short period of time right?After
some time this will work right as the thread get back in action
after the schedule call.Then sysctl and procfs will work I think.
>
> We could workaround some solution in the watchdog code like forcing
> one pass to the thread function and immediately return to park.
>
> But supporting parking requests from ->setup() or ->unpark()
> callbacks look like proper way to implement cancellation in
> general. So let's fix it that way.
>
> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Li Zhong <zhong@linux.vnet.ibm.com>
> Cc: Don Zickus <dzickus@redhat.com>
> ---
>  kernel/smpboot.c |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)
>
> diff --git a/kernel/smpboot.c b/kernel/smpboot.c
> index 02fc5c9..3394ed0 100644
> --- a/kernel/smpboot.c
> +++ b/kernel/smpboot.c
> @@ -151,6 +151,12 @@ static int smpboot_thread_fn(void *data)
>                         break;
>                 }
>
> +               /* Check if setup or unpark actually want us to park */
> +               if (kthread_should_stop() || kthread_should_park()) {
> +                       preempt_enable();
> +                       continue;
> +               }
> +
>                 if (!ht->thread_should_run(td->cpu)) {
>                         preempt_enable();
>                         schedule();
> --
> 1.7.5.4
>
> --
> 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/

  reply	other threads:[~2013-05-21  5:34 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-20 16:01 [PATCH 0/8] nohz: Random fixes Frederic Weisbecker
2013-05-20 16:01 ` [PATCH 1/8] nohz: Warn if the machine can not perform nohz_full Frederic Weisbecker
2013-05-20 16:01 ` [PATCH 2/8] vtime: Use consistent clocks among nohz accounting Frederic Weisbecker
2013-06-03  9:47   ` Stefan Seyfried
2013-06-03 13:48     ` Steven Rostedt
2013-06-03 19:48     ` Frederic Weisbecker
2013-06-03 19:51       ` Stefan Seyfried
2013-06-03 20:12         ` Frederic Weisbecker
2013-05-20 16:01 ` [PATCH 3/8] watchdog: Boot-disable by default on full dynticks Frederic Weisbecker
2013-05-20 17:52   ` Don Zickus
2013-05-20 18:14     ` Frederic Weisbecker
2013-05-20 16:01 ` [PATCH 4/8] kvm: Move guest entry/exit APIs to context_tracking Frederic Weisbecker
2013-05-20 16:01 ` [PATCH 5/8] nohz: Fix notifier return val that enforce timekeeping Frederic Weisbecker
2013-05-20 16:01 ` [RFC PATCH 6/8] kthread: Enable parking requests from setup() and unpark() callbacks Frederic Weisbecker
2013-05-21  5:34   ` anish singh [this message]
2013-05-21  7:49     ` Srivatsa S. Bhat
2013-05-21  8:58       ` anish singh
2013-05-21  9:07         ` Srivatsa S. Bhat
2013-05-22 15:18         ` Frederic Weisbecker
2013-05-21  6:59   ` Srivatsa S. Bhat
2013-06-05 16:33     ` Frederic Weisbecker
2013-05-20 16:01 ` [RFC PATCH 7/8] watchdog: Rename confusing state variable Frederic Weisbecker
2013-05-20 17:53   ` Don Zickus
2013-05-20 16:01 ` [RFC PATCH 8/8] watchdog: Fix internal state with boot user disabled watchdog Frederic Weisbecker
2013-05-20 17:54   ` Don Zickus

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='CAK7N6voNjWrDJNzAaVAndt8cGWR+AAERs_C-oCWe0rRO=XuutQ@mail.gmail.com' \
    --to=anish198519851985@gmail.com \
    --cc=bp@alien8.de \
    --cc=dzickus@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=srivatsa.bhat@linux.vnet.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=zhong@linux.vnet.ibm.com \
    /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 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.