From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f202.google.com (mail-oi1-f202.google.com [209.85.167.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FC31157493 for ; Mon, 27 Jan 2025 17:19:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737998355; cv=none; b=dnnHGsy6ypJpcfpgKxAMGBwWmc3FSb4rXzSdyhdc2mx5splAU1R+3Qp4cKeYvgokUJhfsUiB9nh0BBEwQOLYcAM4PWLFt76CY9wfxrB8UiHI0mZTOqx+dUcqe+O0vmkQ2HdwydczveGQ7EOuk7pGkshM4asl1y0t9fRwsPxOtWM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737998355; c=relaxed/simple; bh=iBnURTqPXW2aHXWRytiUQwc3RleQ1CdQYvgVqtnNdGE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=QnIDTaFaLwyilj3CrxaTOgGXu2aps5Mg0oilWiBnatUhlHhQj7olVD0H+P/9q4R+ktoqUZy/2eoU+Fytwhk0YzBgYBhcfvq2zDTwwoWCwGe/c92Zzn3Hv76Xb3byzxWw2mbUvuuADDZX4VGcoAZXSzU0hk7d7poh7OLwngVuFHU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=LktCMKX+; arc=none smtp.client-ip=209.85.167.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="LktCMKX+" Received: by mail-oi1-f202.google.com with SMTP id 5614622812f47-3eb9757e579so3675317b6e.3 for ; Mon, 27 Jan 2025 09:19:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1737998352; x=1738603152; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=k6ZFPH8+E5WrW09Nv346BS0Z+fTVST94HMISpos/8LA=; b=LktCMKX+x+gMHGf4yRYp6sgTS58jwjTIG+VZbla/k0JpZjDlhW+1tNdPOike04CnJ0 WJGxcgLLprx+36tny9oXFgSlasxLbVyBfNz7xorLJyQ2g+8P3NdbUovbUdTSfJExb9RJ KZetbEQX8Di+XliZ/4GSnTmMNNCGvcWlKkeKkCXl5Fl/bHLqiQnPnXGzM+YivlNcrWKf jHK+XdZ5BDS1mbdVRk8w6dqfy41kK0BgfEb/BmMouqcG94z6DAYYi4NNgmKHJ6TuAYla DKt+jHh564qSDKzUtDr7Mp+wXGWC2vwtMrio68PIDMvnooJH8k/9svhRGBn+7sHbhGF3 de1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737998352; x=1738603152; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=k6ZFPH8+E5WrW09Nv346BS0Z+fTVST94HMISpos/8LA=; b=bLDrfewVUC/K3nLOA97hMhRcyYCtcosUTWf0m+zR06PKTiSSEgUI+KAIR+PNgHMoOq qAYf22YwZ+qMVJ5OlzRxtWXNep1gofqql4LNFzK2owydMw29GQBj0qoEmozPTXjx7J4q yfthbeSTSeo4lPK5mz6sICpIfVygBIVrXRWGuVQp7BD40MN37NE9nd6igs8efdxnvLzZ shPlB8jREzeGIj55YxviAHGifUEqC/M6XWFgySzGmhL8z+2huFuqkFAYOTkbJEbhS3Y5 btc3lpZYD9GaxSV5h51KVZNEAh696IFMjCKedtxb7To0jB2WGPbSphEBbl0R/2WP5EiI EvKQ== X-Forwarded-Encrypted: i=1; AJvYcCVe8L/6zmlAWegn46fmZ2gBFP0MaaUGEo94+zVKhORxUZ1np2goxW1IC2F+Q75fb2csnf9NKta5FRpHi48=@vger.kernel.org X-Gm-Message-State: AOJu0YxKbWz35u1DuABXHDmTCNLP58+AFXTccCnDZFxwAQ419MmvAwgw hM1XF64qCrB2KUiLe5irOwYQqJelLNhPP1oweW3e29L8DHHX+BKr0E4NdDRpe7d0maA4aJfH2fT xjg== X-Google-Smtp-Source: AGHT+IGRUszYJFAK7joMtRXqZLbVy1IE+a02qW5WNJPmkf4KHnpufiJpDLdSbCWXxcMpFRmG2nQMUgnxee4= X-Received: from pgbcf12.prod.google.com ([2002:a05:6a02:84c:b0:801:d724:5abd]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:1d1:b0:216:668d:690c with SMTP id d9443c01a7336-21c3558171emr693519375ad.28.1737998342288; Mon, 27 Jan 2025 09:19:02 -0800 (PST) Date: Mon, 27 Jan 2025 09:19:01 -0800 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250124234623.3609069-1-seanjc@google.com> Message-ID: Subject: Re: [PATCH] KVM: x86/mmu: Ensure NX huge page recovery thread is alive before waking From: Sean Christopherson To: Keith Busch Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" 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.