linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Pingfan Liu <piliu@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Pingfan Liu <kernelfans@gmail.com>,
	linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Wang Qing <wangqing@vivo.com>,
	Santosh Sivaraj <santosh@fossix.org>,
	Sumit Garg <sumit.garg@linaro.org>, Will Deacon <will@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>
Subject: Re: [PATCH 2/5] kernel/watchdog_hld: clarify the condition in hardlockup_detector_event_create()
Date: Thu, 16 Sep 2021 10:02:27 +0200	[thread overview]
Message-ID: <YUL6E1Psg1xCrIxo@alley> (raw)
In-Reply-To: <YULAuEeSSeLTcBM9@piliu.users.ipa.redhat.com>

On Thu 2021-09-16 11:57:44, Pingfan Liu wrote:
> On Wed, Sep 15, 2021 at 03:45:06PM +0200, Peter Zijlstra wrote:
> > On Wed, Sep 15, 2021 at 11:51:00AM +0800, Pingfan Liu wrote:
> > > hardlockup_detector_event_create() indirectly calls
> > > kmem_cache_alloc_node(), which is blockable.
> > > 
> > > So here, the really planned context is is_percpu_thread().
> > > 
> > > Signed-off-by: Pingfan Liu <kernelfans@gmail.com>
> > > Cc: Petr Mladek <pmladek@suse.com>
> > > Cc: Andrew Morton <akpm@linux-foundation.org>
> > > Cc: Wang Qing <wangqing@vivo.com>
> > > Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
> > > Cc: Santosh Sivaraj <santosh@fossix.org>
> > > Cc: Sumit Garg <sumit.garg@linaro.org>
> > > Cc: Will Deacon <will@kernel.org>
> > > Cc: Mark Rutland <mark.rutland@arm.com>
> > > To: linux-kernel@vger.kernel.org
> > > ---
> > >  kernel/watchdog_hld.c | 5 ++++-
> > >  1 file changed, 4 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/kernel/watchdog_hld.c b/kernel/watchdog_hld.c
> > > index 247bf0b1582c..6876e796dbf5 100644
> > > --- a/kernel/watchdog_hld.c
> > > +++ b/kernel/watchdog_hld.c
> > > @@ -165,10 +165,13 @@ static void watchdog_overflow_callback(struct perf_event *event,
> > >  
> > >  static int hardlockup_detector_event_create(void)
> > >  {
> > > -	unsigned int cpu = smp_processor_id();
> > > +	unsigned int cpu;
> > >  	struct perf_event_attr *wd_attr;
> > >  	struct perf_event *evt;
> > >  
> > > +	/* This function plans to execute in cpu bound kthread */
> > > +	BUG_ON(!is_percpu_thread());
> > > +	cpu = raw_smp_processor_id();
> > >  	wd_attr = &wd_hw_attr;
> > >  	wd_attr->sample_period = hw_nmi_get_sample_period(watchdog_thresh);
> > 
> > This patch makes no sense.
> 
> This patch aims to disable any attempt such as using get_cpu()/put_cpu() to
> shut up the check_preemption_disabled().

I have to say that the description of the problem is really cryptic.
Please, provide more context, code paths, sample code, next time.

Well, I probably got it. The code might sleep. But it should run on the
same CPU even after waking up. You try to achieve this by running
the code in a process that is bound to a single CPU.

IMHO, this is not reliable. Anyone could change the affinity
of the process in the meantime.

I see two solutions. Either avoid the sleep or making sure
that the code access per-CPU variables on the same CPU
all the time.

For example, you might use

	*per_cpu_ptr(watchdog_ev, cpu) = evt;

instead of

	this_cpu_write(watchdog_ev, evt);

Best Regards,
Petr

  reply	other threads:[~2021-09-16  8:09 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-15  3:50 [PATCH 0/5] watchdog_hld cleanup and async model for arm64 Pingfan Liu
2021-09-15  3:50 ` [PATCH 1/5] kernel/watchdog: remove useless WATCHDOG_DEFAULT Pingfan Liu
2021-09-15  3:51 ` [PATCH 2/5] kernel/watchdog_hld: clarify the condition in hardlockup_detector_event_create() Pingfan Liu
2021-09-15  4:06   ` Andrew Morton
2021-09-16  3:47     ` Pingfan Liu
2021-09-15 13:45   ` Peter Zijlstra
2021-09-16  3:57     ` Pingfan Liu
2021-09-16  8:02       ` Petr Mladek [this message]
2021-09-17 15:08         ` Pingfan Liu
2021-09-15  3:51 ` [PATCH 3/5] kernel/watchdog: adapt the watchdog_hld interface for async model Pingfan Liu
2021-09-15 14:02   ` Peter Zijlstra
2021-09-16  3:07     ` Pingfan Liu
2021-09-16  8:29   ` Petr Mladek
2021-09-16  8:36     ` Petr Mladek
2021-09-17 15:41       ` Pingfan Liu
2021-09-20  8:20         ` Petr Mladek
2021-09-22  4:26           ` Pingfan Liu
2021-09-17 14:43     ` Pingfan Liu
2021-09-15  3:51 ` [PATCH 4/5] kernel/watchdog_hld: simplify the detecting of hld watchdog Pingfan Liu
2021-09-15  3:51 ` [PATCH 5/5] arm64/watchdog_hld: enable hard lockup on arm64 platform Pingfan Liu
2021-09-17 15:11   ` Pingfan Liu

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=YUL6E1Psg1xCrIxo@alley \
    --to=pmladek@suse.com \
    --cc=akpm@linux-foundation.org \
    --cc=kernelfans@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=peterz@infradead.org \
    --cc=piliu@redhat.com \
    --cc=santosh@fossix.org \
    --cc=sumit.garg@linaro.org \
    --cc=wangqing@vivo.com \
    --cc=will@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).