Re: [RFC 2/2] kvm: retry nx_huge_page_recovery_thread creation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 */




[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux