lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZxpzzExItrGMISp3@Boquns-Mac-mini.local>
Date: Thu, 24 Oct 2024 09:20:28 -0700
From: Boqun Feng <boqun.feng@...il.com>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: Dirk Behme <dirk.behme@...il.com>, Lyude Paul <lyude@...hat.com>,
	rust-for-linux@...r.kernel.org, Danilo Krummrich <dakr@...hat.com>,
	airlied@...hat.com, Ingo Molnar <mingo@...hat.com>, will@...nel.org,
	Waiman Long <longman@...hat.com>,
	Peter Zijlstra <peterz@...radead.org>, linux-kernel@...r.kernel.org,
	Miguel Ojeda <ojeda@...nel.org>,
	Alex Gaynor <alex.gaynor@...il.com>, wedsonaf@...il.com,
	Gary Guo <gary@...yguo.net>,
	Björn Roy Baron <bjorn3_gh@...tonmail.com>,
	Benno Lossin <benno.lossin@...ton.me>,
	Andreas Hindborg <a.hindborg@...sung.com>, aliceryhl@...gle.com,
	Trevor Gross <tmgross@...ch.edu>
Subject: Re: [POC 1/6] irq & spin_lock: Add counted interrupt
 disabling/enabling

On Thu, Oct 24, 2024 at 10:17:33AM +0200, Thomas Gleixner wrote:
> On Wed, Oct 23 2024 at 22:05, Boqun Feng wrote:
> > On Wed, Oct 23, 2024 at 09:34:27PM +0200, Thomas Gleixner wrote:
> >> local_interrupt_enable()
> >> {
> >>         if ((preempt_count() & LOCALIRQ_MASK) == LOCALIRQ_OFFSET) {
> >>         	local_irq_restore(this_cpu_read(...flags);
> >>                 preempt_count_sub_test_resched(LOCALIRQ_OFFSET);
> >>         } else {
> >>                 // Does not need a resched test because it's not going
> >>                 // to 0
> >>                 preempt_count_sub(LOCALIRQ_OFFSET);
> >>         }
> >> }
> >> 
> >
> > Yes, this looks nice, one tiny problem is that it requires
> > PREEMPT_COUNT=y ;-) Maybe we can do: if PREEMPT_COUNT=y, we use preempt
> > count, otherwise use a percpu?
> >
> > Hmm... but this will essentially be: we have a irq_disable_count() which
> > is always built-in, and we also uses it as preempt count if
> > PREEMPT_COUNT=y. This doesn't look too bad to me.
> 
> The preempt counter is always there even when PREEMPT_COUNT=n. It's
> required for tracking hard/soft interrupt and NMI context.
> 
> The only difference is that preempt_disable()/enable() are NOOPs. So in
> that case preempt_count_sub_test_resched() becomes a plain preempt_count_sub().
> 

Ah, good point!

> >> and then the lock thing becomes
> >> 
> >> spin_lock_irq_disable()
> >> {
> >>         local_interrupt_disable();
> >>         lock();
> >> }
> >> 
> >> spin_unlock_irq_enable()
> >> {
> >>         unlock();
> >>         local_interrupt_enable();
> >> }
> >> 
> >> instead having to do:
> >> 
> >> spin_unlock_irq_enable()
> >> {
> >>         unlock();
> >>         local_interrupt_enable();
> >>         preempt_enable();
> >> }
> >> 
> >> Which needs two distinct checks, one for the interrupt and one for the
> >
> > No? Because now since we fold the interrupt disable count into preempt
> > count, so we don't need to care about preempt count any more if we we
> > local_interrupt_{disable,enable}(). For example, in the above
> > local_interrupt_enable(), interrupts are checked at local_irq_restore()
> > and preemption is checked at preempt_count_sub_test_resched(). Right?
> 
> Correct. That's what I pointed out. By folding it into preempt count
> this becomes one operation, while in your POC it's two distinct checks
> and operations.
> 

Yes, I seemed to mis-read what you meant previously, much clear now, let
me put this into implementation for a POC v2.

Regards,
Boqun

> Thanks,
> 
>         tglx

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ