[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250304155922.GG3666230@kernel.org>
Date: Tue, 4 Mar 2025 15:59:22 +0000
From: Simon Horman <horms@...nel.org>
To: Keith Busch <kbusch@...a.com>
Cc: seanjc@...gle.com, pbonzini@...hat.com, kvm@...r.kernel.org,
leiyang@...hat.com, virtualization@...ts.linux.dev, x86@...nel.org,
netdev@...r.kernel.org, Keith Busch <kbusch@...nel.org>
Subject: Re: [PATCHv3 2/2] kvm: retry nx_huge_page_recovery_thread creation
On Thu, Feb 27, 2025 at 03:06:31PM -0800, Keith Busch wrote:
> From: Sean Christopherson <seanjc@...gle.com>
>
> A VMM may send a signal to its threads while they've entered KVM_RUN. If
> that thread happens to be trying to make the huge page recovery vhost
> task, then it fails with -ERESTARTNOINTR. We need to retry if that
> happens, so call_once needs to be retryable. Make call_once complete
> only if what it called was successful.
>
> [implemented the kvm user side]
> Signed-off-by: Keith Busch <kbusch@...nel.org>
...
> diff --git a/include/linux/call_once.h b/include/linux/call_once.h
> index 6261aa0b3fb00..ddcfd91493eaa 100644
> --- a/include/linux/call_once.h
> +++ b/include/linux/call_once.h
> @@ -26,20 +26,26 @@ do { \
> __once_init((once), #once, &__key); \
> } while (0)
>
> -static inline void call_once(struct once *once, void (*cb)(struct once *))
> +static inline int call_once(struct once *once, int (*cb)(struct once *))
> {
> + int r;
> +
> /* Pairs with atomic_set_release() below. */
> if (atomic_read_acquire(&once->state) == ONCE_COMPLETED)
> - return;
> + return 0;
>
> guard(mutex)(&once->lock);
> WARN_ON(atomic_read(&once->state) == ONCE_RUNNING);
> if (atomic_read(&once->state) != ONCE_NOT_STARTED)
> - return;
> + return -EINVAL;
Hi Keith,
A minor nit from my side:
As you are changing this line, and it seems like there will be another
revision of this series anyway, please consider updating the indentation to
use tabs.
>
> atomic_set(&once->state, ONCE_RUNNING);
> - cb(once);
> - atomic_set_release(&once->state, ONCE_COMPLETED);
> + r = cb(once);
> + if (r)
> + atomic_set(&once->state, ONCE_NOT_STARTED);
> + else
> + atomic_set_release(&once->state, ONCE_COMPLETED);
> + return r;
> }
>
> #endif /* _LINUX_CALL_ONCE_H */
> --
> 2.43.5
>
>
Powered by blists - more mailing lists