On Mon, Jan 27, 2025, Keith Busch wrote: > On Mon, Jan 27, 2025 at 08:48:03AM -0800, Sean Christopherson wrote: > > If vhost_task_create() fails, then the call_once() will "succeed" and mark the > > structure as ONCE_COMPLETED. The first KVM_RUN will fail with -ENOMEM, but any > > subsequent calls will succeed, including in-flight KVM_RUNs on other threads. > > The criteria for returning -ENOMEM for any KVM_RUN is if we have a NULL > nx_huge_page_recovery_thread vhost_task. So I think that part, at least, > is fine. > > The call_once is just needed to ensure that only the very first KVM_RUN > even tries to create it. If the vhost_task_create fails, then all the > KVM_RUN threads will see the NULL nx_huge_page_recovery_thread and > return -ENOMEM. Ah, duh, because the check is performed by the caller, outside of the "once" protection. > What you're suggesting here will allow a subsequent thread to attempt > creating the vhost task if the first one failed. Maybe you do want to > try again, but the current upstream code doesn't retry this, so I > thought it best to keep that behavior. No strong opinion. In practice, it's a moot point because the odds of a VM being able to make forward progress if task creation hits an OOM are basically nil. I'll defer to Paolo on what he thinks is best for the call_once() API.