From: Keith Busch <kbusch@kernel.org>
To: Sean Christopherson <seanjc@google.com>
Cc: Keith Busch <kbusch@meta.com>,
pbonzini@redhat.com, kvm@vger.kernel.org, x86@kernel.org,
virtualization@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [RFC 2/2] kvm: retry nx_huge_page_recovery_thread creation
Date: Wed, 26 Feb 2025 13:22:56 -0700 [thread overview]
Message-ID: <Z794IJ_oalhkw7RQ@kbusch-mbp> (raw)
In-Reply-To: <Z7919lMgDtbcl1CX@google.com>
On Wed, Feb 26, 2025 at 12:13:42PM -0800, Sean Christopherson wrote:
> I much prefer my (misguided in the original context[*]) approach of marking the
> call_once() COMPLETED if and only if it succeeds.
I have a new appreciation for this approach given our recent
discoveries. I was mistaken in assuming there were no retryable errors
here.
Thanks for the suggestion, I'll merge your propsal with the kvm side and
give it a test.
> diff --git a/include/linux/call_once.h b/include/linux/call_once.h
> index 6261aa0b3fb0..9d47ed50139b 100644
> --- a/include/linux/call_once.h
> +++ b/include/linux/call_once.h
> @@ -26,20 +26,28 @@ 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;
>
> atomic_set(&once->state, ONCE_RUNNING);
> - cb(once);
> + r = cb(once);
> + if (r) {
> + atomic_set(&once->state, ONCE_NOT_STARTED);
> + return r;
> + }
> +
> atomic_set_release(&once->state, ONCE_COMPLETED);
> + return 0;
> }
>
> #endif /* _LINUX_CALL_ONCE_H */
prev parent reply other threads:[~2025-02-26 20:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-26 2:43 [RFC 2/2] kvm: retry nx_huge_page_recovery_thread creation Keith Busch
2025-02-26 20:13 ` Sean Christopherson
2025-02-26 20:22 ` Keith Busch [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z794IJ_oalhkw7RQ@kbusch-mbp \
--to=kbusch@kernel.org \
--cc=kbusch@meta.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=virtualization@lists.linux.dev \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox