virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Keith Busch <kbusch@meta.com>
Cc: seanjc@google.com, pbonzini@redhat.com, kvm@vger.kernel.org,
	leiyang@redhat.com, virtualization@lists.linux.dev,
	x86@kernel.org, netdev@vger.kernel.org,
	Keith Busch <kbusch@kernel.org>
Subject: Re: [PATCHv3 2/2] kvm: retry nx_huge_page_recovery_thread creation
Date: Tue, 4 Mar 2025 15:59:22 +0000	[thread overview]
Message-ID: <20250304155922.GG3666230@kernel.org> (raw)
In-Reply-To: <20250227230631.303431-3-kbusch@meta.com>

On Thu, Feb 27, 2025 at 03:06:31PM -0800, Keith Busch wrote:
> From: Sean Christopherson <seanjc@google.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@kernel.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
> 
> 

  reply	other threads:[~2025-03-04 15:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-27 23:06 [PATCHv3 0/2] Keith Busch
2025-02-27 23:06 ` [PATCHv3 1/2] vhost: return task creation error instead of NULL Keith Busch
2025-02-28 18:34   ` Mike Christie
2025-02-27 23:06 ` [PATCHv3 2/2] kvm: retry nx_huge_page_recovery_thread creation Keith Busch
2025-03-04 15:59   ` Simon Horman [this message]
2025-03-04 16:07     ` Keith Busch
2025-05-01 15:12       ` Frederick Lawler
2025-02-28  8:07 ` [PATCHv3 0/2] Lei Yang
2025-02-28 14:15   ` Sean Christopherson
2025-02-28 14:32     ` Sean Christopherson
2025-02-28 14:58       ` Keith Busch
2025-02-28 15:29         ` Sean Christopherson
2025-02-28 15:36           ` Keith Busch
2025-02-28 16:43             ` Paolo Bonzini
2025-02-28 17:03               ` Sean Christopherson
2025-07-08 22:17               ` Keith Busch

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=20250304155922.GG3666230@kernel.org \
    --to=horms@kernel.org \
    --cc=kbusch@kernel.org \
    --cc=kbusch@meta.com \
    --cc=kvm@vger.kernel.org \
    --cc=leiyang@redhat.com \
    --cc=netdev@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;
as well as URLs for NNTP newsgroup(s).