public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Joel Fernandes <joelagnelf@nvidia.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Lyude Paul <lyude@redhat.com>,
	rust-for-linux@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Boqun Feng <boqun.feng@gmail.com>,
	linux-kernel@vger.kernel.org,
	Daniel Almeida <daniel.almeida@collabora.com>,
	Danilo Krummrich <dakr@kernel.org>,
	Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
	Vlastimil Babka <vbabka@suse.cz>,
	"Liam R. Howlett" <Liam.Howlett@oracle.com>,
	Uladzislau Rezki <urezki@gmail.com>,
	Miguel Ojeda <ojeda@kernel.org>,
	Alex Gaynor <alex.gaynor@gmail.com>, Gary Guo <gary@garyguo.net>,
	Bj??rn Roy Baron <bjorn3_gh@protonmail.com>,
	Benno Lossin <lossin@kernel.org>,
	Andreas Hindborg <a.hindborg@kernel.org>,
	Alice Ryhl <aliceryhl@google.com>,
	Trevor Gross <tmgross@umich.edu>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>,
	Ryo Takakura <ryotkkr98@gmail.com>,
	K Prateek Nayak <kprateek.nayak@amd.com>,
	"open list:CPU FREQUENCY SCALING FRAMEWORK"
	<linux-pm@vger.kernel.org>
Subject: Re: [PATCH v13 01/17] preempt: Track NMI nesting to separate per-CPU counter
Date: Tue, 14 Oct 2025 13:59:00 -0400	[thread overview]
Message-ID: <c58d01f7-2589-465b-b10e-ba39e01deee1@nvidia.com> (raw)
In-Reply-To: <20251014082506.GO3245006@noisy.programming.kicks-ass.net>



On 10/14/2025 4:25 AM, Peter Zijlstra wrote:
> On Mon, Oct 13, 2025 at 05:27:32PM -0400, Joel Fernandes wrote:
>>
>>
>> On 10/13/2025 4:00 PM, Peter Zijlstra wrote:
>>> On Mon, Oct 13, 2025 at 11:48:03AM -0400, Lyude Paul wrote:
>>>> From: Joel Fernandes <joelagnelf@nvidia.com>
>>>>
>>>> Move NMI nesting tracking from the preempt_count bits to a separate per-CPU
>>>> counter (nmi_nesting). This is to free up the NMI bits in the preempt_count,
>>>> allowing those bits to be repurposed for other uses.  This also has the benefit
>>>> of tracking more than 16-levels deep if there is ever a need.
>>>>
>>>> Suggested-by: Boqun Feng <boqun.feng@gmail.com>
>>>> Signed-off-by: Joel Fernandes <joelaf@google.com>
>>>> Signed-off-by: Lyude Paul <lyude@redhat.com>
>>>> ---
>>>>  include/linux/hardirq.h   | 17 +++++++++++++----
>>>>  kernel/softirq.c          |  2 ++
>>>>  rust/kernel/alloc/kvec.rs |  5 +----
>>>>  rust/kernel/cpufreq.rs    |  3 +--
>>>>  4 files changed, 17 insertions(+), 10 deletions(-)
>>>>
>>>> diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
>>>> index d57cab4d4c06f..177eed1de35cc 100644
>>>> --- a/include/linux/hardirq.h
>>>> +++ b/include/linux/hardirq.h
>>>> @@ -10,6 +10,8 @@
>>>>  #include <linux/vtime.h>
>>>>  #include <asm/hardirq.h>
>>>>  
>>>> +DECLARE_PER_CPU(unsigned int, nmi_nesting);
>>>
>>> Urgh, and it isn't even in the same cacheline as the preempt_count :/
>>
>> Great point. I will move this to DECLARE_PER_CPU_CACHE_HOT()
>> so it's co-located with preempt_count and run some tests. Let me know if that
>> works for you, thanks!
> 
> Well, I hate how on entry we then end up incrementing both. How terrible
> would it be to make __preempt_count u64 instead?

Would that break 32-bit x86? I have to research this more. This was what I
initially thought of doing but ISTR some challenges. I'd like to think that was
my imagination, but I will revisit it and see what it takes.

Thanks!

 - Joel



  reply	other threads:[~2025-10-14 17:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20251013155205.2004838-1-lyude@redhat.com>
2025-10-13 15:48 ` [PATCH v13 01/17] preempt: Track NMI nesting to separate per-CPU counter Lyude Paul
2025-10-13 16:19   ` Lyude Paul
2025-10-13 16:32     ` Miguel Ojeda
2025-10-13 20:00   ` Peter Zijlstra
2025-10-13 21:27     ` Joel Fernandes
2025-10-14  8:25       ` Peter Zijlstra
2025-10-14 17:59         ` Joel Fernandes [this message]
2025-10-14 19:37           ` Peter Zijlstra
2025-10-14 10:48   ` Peter Zijlstra
2025-10-14 17:55     ` Joel Fernandes
2025-10-14 19:43       ` Peter Zijlstra
2025-10-14 22:05         ` Joel Fernandes
2025-10-20 20:44         ` Joel Fernandes
2025-10-30 22:56           ` Joel Fernandes

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=c58d01f7-2589-465b-b10e-ba39e01deee1@nvidia.com \
    --to=joelagnelf@nvidia.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=bigeasy@linutronix.de \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=gary@garyguo.net \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=lossin@kernel.org \
    --cc=lyude@redhat.com \
    --cc=mingo@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=ryotkkr98@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=tmgross@umich.edu \
    --cc=urezki@gmail.com \
    --cc=vbabka@suse.cz \
    --cc=viresh.kumar@linaro.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