From: lizhe.67@bytedance.com
To: akpm@linux-foundation.org
Cc: dianders@chromium.org, kernelfans@gmail.com,
lecopzer.chen@mediatek.com, linux-kernel@vger.kernel.org,
lizefan.x@bytedance.com, pmladek@suse.com,
lizhe.67@bytedance.com
Subject: Re: [PATCH v2] softlockup: serialized softlockup's log
Date: Thu, 23 Nov 2023 16:23:28 +0800 [thread overview]
Message-ID: <20231123082328.7671-1-lizhe.67@bytedance.com> (raw)
In-Reply-To: <20231122140521.85c66b789625e8d270722b3c@linux-foundation.org>
On Wed, 22 Nov 2023 14:05:21 -0800 akpm@linux-foundation.org wrote:
>> From: Li Zhe <lizhe.67@bytedance.com>
>>
>> If multiple CPUs trigger softlockup at the same time with
>> 'softlockup_all_cpu_backtrace=0', the softlockup's logs will appear
>> staggeredly in dmesg, which will affect the viewing of the logs for
>> developer. Since the code path for outputting softlockup logs is not
>> a kernel hotspot and the performance requirements for the code are
>> not strict, locks are used to serialize the softlockup log output to
>> improve the readability of the logs.
>
>Seems reasonable, but...
>
>> --- a/kernel/watchdog.c
>> +++ b/kernel/watchdog.c
>> @@ -28,6 +28,8 @@
>> #include <linux/kvm_para.h>
>>
>> static DEFINE_MUTEX(watchdog_mutex);
>> +/* This lock is used to prevent concurrent actions of softlockup output logs */
>> +static DEFINE_SPINLOCK(watchdog_output_lock);
>
>It would be a little neater to reduce the scope of this - move the
>definition into that little code block in watchdog_timer_fn() where it
>is actually used.
Yes. For this patch, it is more appropriate to put the definition in
watchdog_timer_fn(). It can be moved out in subsequent patches if
necessary. I will send a v3 patch to move it in watchdog_timer_fn().
Thanks for your advice.
>> #if defined(CONFIG_HARDLOCKUP_DETECTOR) || defined(CONFIG_HARDLOCKUP_DETECTOR_SPARC64)
>> # define WATCHDOG_HARDLOCKUP_DEFAULT 1
>> @@ -514,6 +516,7 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
>> /* Start period for the next softlockup warning. */
>> update_report_ts();
>>
>> + spin_lock(&watchdog_output_lock);
>
>The hrtimer callout function is called from [soft]irq context, yes?
Yes.
>Doesn't lockdep get upset when we take a spinlock in such a context?
My test results are the same as Doug Anderson's, things seemed OK.
>
>> pr_emerg("BUG: soft lockup - CPU#%d stuck for %us! [%s:%d]\n",
>> smp_processor_id(), duration,
>> current->comm, task_pid_nr(current));
>> @@ -523,6 +526,7 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
>> show_regs(regs);
>> else
>> dump_stack();
>> + spin_unlock(&watchdog_output_lock);
>>
>> if (softlockup_all_cpu_backtrace) {
>> trigger_allbutcpu_cpu_backtrace(smp_processor_id());
prev parent reply other threads:[~2023-11-23 8:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-22 10:02 lizhe.67
2023-11-22 16:03 ` Doug Anderson
2023-11-22 22:05 ` Andrew Morton
2023-11-22 23:22 ` Doug Anderson
2023-11-23 8:25 ` lizhe.67
2023-11-23 8:23 ` lizhe.67 [this message]
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=20231123082328.7671-1-lizhe.67@bytedance.com \
--to=lizhe.67@bytedance.com \
--cc=akpm@linux-foundation.org \
--cc=dianders@chromium.org \
--cc=kernelfans@gmail.com \
--cc=lecopzer.chen@mediatek.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan.x@bytedance.com \
--cc=pmladek@suse.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 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®