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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <145ddb99-025b-4ed0-bee6-e1e2c70ff0bf@amd.com>
Date: Thu, 3 Apr 2025 00:10:16 +0530
From: K Prateek Nayak <kprateek.nayak@....com>
To: Sean Christopherson <seanjc@...gle.com>
CC: <kvm@...r.kernel.org>, Paolo Bonzini <pbonzini@...hat.com>, Albert Ou
	<aou@...s.berkeley.edu>, Palmer Dabbelt <palmer@...belt.com>, Paul Walmsley
	<paul.walmsley@...ive.com>, Oliver Upton <oliver.upton@...ux.dev>, Marc
 Zyngier <maz@...nel.org>, Juri Lelli <juri.lelli@...hat.com>, Peter Zijlstra
	<peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
	<linux-kernel@...r.kernel.org>, <linux-arm-kernel@...ts.infradead.org>,
	<kvmarm@...ts.linux.dev>, <linux-riscv@...ts.infradead.org>, David Matlack
	<dmatlack@...gle.com>, Juergen Gross <jgross@...e.com>, Stefano Stabellini
	<sstabellini@...nel.org>, Oleksandr Tyshchenko
	<oleksandr_tyshchenko@...m.com>, Vincent Guittot <vincent.guittot@...aro.org>
Subject: Re: [PATCH 06/12] sched/wait: Add a waitqueue helper for fully
 exclusive priority waiters

Hello Sean,

On 4/2/2025 2:14 AM, Sean Christopherson wrote:
[..snip..]
> diff --git a/kernel/sched/wait.c b/kernel/sched/wait.c
> index 51e38f5f4701..80d90d1dc24d 100644
> --- a/kernel/sched/wait.c
> +++ b/kernel/sched/wait.c
> @@ -47,6 +47,26 @@ void add_wait_queue_priority(struct wait_queue_head *wq_head, struct wait_queue_
>   }
>   EXPORT_SYMBOL_GPL(add_wait_queue_priority);
>   
> +int add_wait_queue_priority_exclusive(struct wait_queue_head *wq_head,
> +				      struct wait_queue_entry *wq_entry)
> +{
> +	struct list_head *head = &wq_head->head;
> +	unsigned long flags;
> +	int r = 0;
> +
> +	wq_entry->flags |= WQ_FLAG_EXCLUSIVE | WQ_FLAG_PRIORITY;
> +	spin_lock_irqsave(&wq_head->lock, flags);

nit.

Using "guard(spinlock_irqsave)(&wq_head->lock)" can help you get rid of
both "flags" and "r".

> +	if (!list_empty(head) &&
> +	    (list_first_entry(head, typeof(*wq_entry), entry)->flags & WQ_FLAG_PRIORITY))
> +		r = -EBUSY;
> +	else
> +		list_add(&wq_entry->entry, head);
> +	spin_unlock_irqrestore(&wq_head->lock, flags);
> +
> +	return r;
> +}
> +EXPORT_SYMBOL(add_wait_queue_priority_exclusive);
> +
>   void remove_wait_queue(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry)
>   {
>   	unsigned long flags;

-- 
Thanks and Regards,
Prateek


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ