From: Song Liu <songliubraving@meta.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <song@kernel.org>, LKML <linux-kernel@vger.kernel.org>,
Kernel Team <kernel-team@meta.com>,
Andrew Morton <akpm@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] watchdog: Prefer use "ref-cycles" for NMI watchdog
Date: Mon, 15 May 2023 20:33:37 +0000 [thread overview]
Message-ID: <06AB5C73-9E63-442A-834C-532553DAC025@fb.com> (raw)
In-Reply-To: <20230515103316.GG83892@hirez.programming.kicks-ass.net>
> On May 15, 2023, at 3:33 AM, Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Fri, May 12, 2023 at 09:43:48AM -0700, Song Liu wrote:
>> On Fri, May 12, 2023 at 5:47 AM Peter Zijlstra <peterz@infradead.org> wrote:
>>>
>>> On Tue, May 09, 2023 at 03:17:00PM -0700, Song Liu wrote:
>>>> NMI watchdog permanently consumes one hardware counters per CPU on the
>>>> system. For systems that use many hardware counters, this causes more
>>>> aggressive time multiplexing of perf events.
>>>>
>>>> OTOH, some CPUs (mostly Intel) support "ref-cycles" event, which is rarely
>>>> used. Try use "ref-cycles" for the watchdog. If the CPU supports it, so
>>>> that one more hardware counter is available to the user. If the CPU doesn't
>>>> support "ref-cycles", fall back to "cycles".
>>>>
>>>> The downside of this change is that users of "ref-cycles" need to disable
>>>> nmi_watchdog.
>>>
>>> Urgh..
>>>
>>> how about something like so instead; then you can use whatever event you
>>> like...
>>
>> Configuring this at boot time is not ideal for our use case. Currently, we have
>> some systems support ref-cycles and some don't. So this is one more kernel
>> argument we need to make sure to get correctly. This also means we cannot
>> change this setting without reboot.
>
> You can still add the fallback (with a suitable pr_warn() that the
> requested config is not valid or so).
>
>> Another idea I have is to use sysctl kernel.nmi_watchdog, so we can change
>> the event after boot. Would this work?
>
> Yeah, I suppose you can also extend the thing to allow runtime changes
> to the values, provided the NMI watchdog is disabled at the time or
> somesuch.
How about something like:
sysctl kernel.nmi_watchdog=0 => no nmi watchdog
sysctl kernel.nmi_watchdog=1 => use "cycles" nmi watchdog
sysctl kernel.nmi_watchdog=2 => use "ref-cycles" nmi watchdog
I know the values are arbitrary. But using raw code encoding seems an
overkill (for command line or sysctl).
By the way, current code for "sysctl kernel.nmi_watchdog" doesn't
report the error properly. For example, on an Intel host, with:
sysctl kernel.nmi_watchdog=0
perf stat -e cycles:D,cycles:D,cycles:D,cycles:D,cycles:D -a &
sysctl kernel.nmi_watchdog=1
kill $(pidof perf)
At this point, the watchdog is effectively disabled, because the perf
events failed to enable. But sysctl still show:
kernel.nmi_watchdog = 1
How about we use current version (plus error reporting fix suggested
by Andrew)? If this causes any user visible issues, we can add the
option to configure it via sysctl (and fix sysctl reporting at the
same time).
Thanks,
Song
next prev parent reply other threads:[~2023-05-15 20:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-09 22:17 Song Liu
2023-05-12 12:46 ` Peter Zijlstra
2023-05-12 16:43 ` Song Liu
2023-05-15 10:33 ` Peter Zijlstra
2023-05-15 20:33 ` Song Liu [this message]
2023-05-12 23:40 ` Andrew Morton
2023-05-13 0:03 ` Song 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=06AB5C73-9E63-442A-834C-532553DAC025@fb.com \
--to=songliubraving@meta.com \
--cc=akpm@linux-foundation.org \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=song@kernel.org \
--cc=tglx@linutronix.de \
/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®