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: <de07d4a9-0807-4ce9-a91f-1747239f5080@amd.com>
Date: Tue, 15 Apr 2025 16:44:28 +0530
From: K Prateek Nayak <kprateek.nayak@....com>
To: Jan Kiszka <jan.kiszka@...mens.com>, Aaron Lu <ziqianlu@...edance.com>,
	Florian Bezdeka <florian.bezdeka@...mens.com>
CC: Valentin Schneider <vschneid@...hat.com>, Ben Segall <bsegall@...gle.com>,
	Peter Zijlstra <peterz@...radead.org>, Josh Don <joshdon@...gle.com>, Ingo
 Molnar <mingo@...hat.com>, Vincent Guittot <vincent.guittot@...aro.org>, Xi
 Wang <xii@...gle.com>, <linux-kernel@...r.kernel.org>, Juri Lelli
	<juri.lelli@...hat.com>, Dietmar Eggemann <dietmar.eggemann@....com>, Steven
 Rostedt <rostedt@...dmis.org>, Mel Gorman <mgorman@...e.de>, Chengming Zhou
	<chengming.zhou@...ux.dev>, Chuyi Zhou <zhouchuyi@...edance.com>, "Sebastian
 Andrzej Siewior," <bigeasy@...utronix.de>
Subject: Re: [RFC PATCH v2 0/7] Defer throttle when task exits to user

Hello Jan,

On 4/15/2025 3:51 PM, Jan Kiszka wrote:
>> Is this in line with what you are seeing?
>>
> 
> Yes, and if you wait a bit longer for the second reporting round, you
> should get more task backtraces as well.

So looking at the backtrace [1], Aaron's patch should help with the
stalls you are seeing.

timerfd that queues a hrtimer also uses ep_poll_callback() to wakeup
the epoll waiter which queues ahead of the bandwidth timer and
requires the read lock but now since the writer tried to grab the
lock pushing readers on the slowpath. if epoll-stall-writer is now
throttled, it needs ktimer to replenish its bandwidth which cannot
happen without it grabbing the read lock first.

# epoll-stall-writer

ep_poll()
{
	...
	/*
	 * Does not disable IRQ / preemption on PREEMPT_RT; sends future readers on
	 * rwlock slowpath and they have to wait until epoll-stall-writer acquires
	 * and drops the write lock.
	 */
	write_lock_irq(&ep->lock);

	__set_current_state(TASK_INTERRUPTIBLE);

	/************** Preempted due to lack of bandwidth **************/

	...
	eavail = ep_events_available(ep);
	if (!eavail)
		__add_wait_queue_exclusive(&ep->wq, &wait);

	/* Never reaches here waiting for bandwidth */
	write_unlock_irq(&ep->lock);
}


# ktimers

ep_poll_callback(...)
{
	...

	/*
	 * Does not disable interrupts on PREEMPT_RT; ktimers needs the
	 * epoll-stall-writer to take the write lock and drop it to
	 * proceed but epoll-stall-writer requires ktimers to run the
	 * bandwidth timer to be runnable again. Deadlock!
  	 */
	read_lock_irqsave(&ep->lock, flags);

	...

	/* wakeup within read side critical section */
	if (sync)
		wake_up_sync(&ep->wq);
	else
		wake_up(&ep->wq);

	...

	read_unlock_irqrestore(&ep->lock, flags);
}

[1] https://lore.kernel.org/all/62304351-7fc0-48b6-883b-d346886dac8e@amd.com/

> 
> Jan
> 

-- 
Thanks and Regards,
Prateek


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ