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: <aFF84rW5fNXrnwC8@Mac.home>
Date: Tue, 17 Jun 2025 07:34:10 -0700
From: Boqun Feng <boqun.feng@...il.com>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Lyude Paul <lyude@...hat.com>, rust-for-linux@...r.kernel.org,
	Thomas Gleixner <tglx@...utronix.de>, linux-kernel@...r.kernel.org,
	Daniel Almeida <daniel.almeida@...labora.com>,
	Ingo Molnar <mingo@...hat.com>,	Peter Zijlstra <peterz@...radead.org>,
	Juri Lelli <juri.lelli@...hat.com>,
	Vincent Guittot <vincent.guittot@...aro.org>,
	Dietmar Eggemann <dietmar.eggemann@....com>,
	Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
	Valentin Schneider <vschneid@...hat.com>,	Will Deacon <will@...nel.org>,
 Waiman Long <longman@...hat.com>,	Miguel Ojeda <ojeda@...nel.org>,
	Alex Gaynor <alex.gaynor@...il.com>, Gary Guo <gary@...yguo.net>,
	Björn Roy Baron <bjorn3_gh@...tonmail.com>,
	Benno Lossin <lossin@...nel.org>,
	Andreas Hindborg <a.hindborg@...nel.org>,
	Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
	Danilo Krummrich <dakr@...nel.org>,	David Woodhouse <dwmw@...zon.co.uk>,
 Jens Axboe <axboe@...nel.dk>,
	Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
	NeilBrown <neilb@...e.de>,	Caleb Sander Mateos <csander@...estorage.com>,
	Ryo Takakura <ryotkkr98@...il.com>,
	K Prateek Nayak <kprateek.nayak@....com>
Subject: Re: [RFC RESEND v10 03/14] irq & spin_lock: Add counted interrupt
 disabling/enabling

On Tue, Jun 17, 2025 at 10:11:20AM -0400, Steven Rostedt wrote:
> On Tue, 27 May 2025 18:21:44 -0400
> Lyude Paul <lyude@...hat.com> wrote:
> 
> > +static inline void local_interrupt_enable(void)
> > +{
> > +	int new_count;
> > +
> > +	new_count = hardirq_disable_exit();
> > +
> > +	if ((new_count & HARDIRQ_DISABLE_MASK) == 0) {
> > +		unsigned long flags;
> > +
> > +		flags = raw_cpu_read(local_interrupt_disable_state.flags);
> > +		local_irq_restore(flags);
> > +		/*
> > +		 * TODO: re-read preempt count can be avoided, but it needs
> > +		 * should_resched() taking another parameter as the current
> > +		 * preempt count
> > +		 */
> > +#ifdef PREEMPTION
> > +		if (should_resched(0))
> > +			__preempt_schedule();
> > +#endif
> > +	}
> > +}
> 
> I'm confused to why the should_resched() is needed? We are handling
> interrupts right? The hardirq_disable_exit() will set preempt_count to zero
> before we enable interrupts. When the local_irq_restore() enables interrupts
> again, if there's an interrupt pending it will trigger then. If the
> interrupt sets NEED_RESCHED, when it returns from the interrupt handler, it
> will see preempt_count as zero, right?
> 

Because the new local_interrupt_{disable, enable}() participate the
preempt count game as well, for example, __raw_spin_lock_irq_disable()
doesn't call an additional preempt_disable() and
__raw_spin_unlock_irq_enable() doesn't call preempt_enable(). And the
following can happen:

	spin_lock(a);
	// preemption is disabled.
	<interrupted and set need_resched>

	spin_lock_irq_disable(b);

	spin_unlock(a);
	spin_unlock_irq_enable(b):
	  local_interrupt_enable():
	  // need to check should_resched, otherwise preemption won't
	  // happen.

Regards,
Boqun

> If it does, then it will call schedule before it gets back to this code.
> 
> -- Steve

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ