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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Z794IJ_oalhkw7RQ@kbusch-mbp>
Date: Wed, 26 Feb 2025 13:22:56 -0700
From: Keith Busch <kbusch@...nel.org>
To: Sean Christopherson <seanjc@...gle.com>
Cc: Keith Busch <kbusch@...a.com>, pbonzini@...hat.com, kvm@...r.kernel.org,
	x86@...nel.org, virtualization@...ts.linux.dev,
	linux-kernel@...r.kernel.org
Subject: Re: [RFC 2/2] kvm: retry nx_huge_page_recovery_thread creation

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ