From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (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 C11121C4A37 for ; Thu, 21 Nov 2024 21:05:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732223134; cv=none; b=duxl7qtmYizeSK+hjhNJxyjXvqvgr1/kBa1dyPuisvd0llmD4LR1czXMiGikxOBhNYB6bPUO+iadDD9E3CfAWV6B4YRNfDm2/qH1T+xsu2ECTFHesnzuoCSpx+jYYAcZW0UEDd59cL9yq1mxAZQ+Fq8GO8u4pGud88hzZKB73lQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732223134; c=relaxed/simple; bh=vyjd2G/poPUNHJ7AgfmFwVQ4NgJflJ0Gzqnpxwe2gcQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=XWx1ptTphIPJZX2Pzh6IwbjvIZM5ljp+/Q07ot4Kp3v+ZegopwOt1szNNH/Sbhv2IZY2pmSVhboF1LUXaAfLw9A4j0ap9ee3/JuoASSnNEwmjvjteW133E0fS1PjUIKnWVHWaRqYN1GHOaRFk+uKzDVZNBLoVQuKYs1gh2ZD/6U= 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=x8/WOB1N; arc=none smtp.client-ip=209.85.210.201 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="x8/WOB1N" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-7203cdc239dso1529769b3a.3 for ; Thu, 21 Nov 2024 13:05:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1732223132; x=1732827932; 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=MVK84h+cRkKm7y5j10sbeKMXM6R17PysvQBrN7p5PNc=; b=x8/WOB1NHCZ7zRQUcb/LFI5nwstEWasp+R0mWXaFc39GvYOoAM4IS5+2If3oXMCALe bVj2zfZ5dsqLIh/XM/7xtHES8y60CmUerJxceDz3Oq+Op4x74gwu3+WxcND12xeRwTI4 lycW9J2wP4KD+Sql14qgZvEAoe29AOS0Wd2YfWCKJ4n7pBXdCHmh7vHQDgRIaVIY4JAP ivvbXPRx/r+F9daUhkYsG9PiDGHgKeuZx04AucxWyiO/G4tUpNTWbHqfx/goVxYTO886 3M43lPt4YkbDTqihzJkjviLTbBLnZX5ccRjqgIOatgPpzPEn4UTLaIFCgyUR0xqkkNpc fc+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732223132; x=1732827932; 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=MVK84h+cRkKm7y5j10sbeKMXM6R17PysvQBrN7p5PNc=; b=n8Nk/dOAXcgZg2t5J+idUBeScn8gLfGHGHxXD5AH8CQQZccesnM+PV+Q0k+jYUI3j/ vOLZ8rySiCR+xsPjBmVPEqUZZcFdcuH3Cd/xB/FtsyLJ2bbkEkVFRfKmIGIxzZIjr5ow BdCFhFhC0v6yfyBd6HEl7DH+AjWkjZlYl518VLwIrkbqCXoi5q02gYjvWDW1dcwZzT3m UeRQHAIOuWvBUdEtIV0nd1LGLd2RMO9/Fl8rFfi4ItQtAYKbDTc1RswPKHVWm8MPMG59 jFiTzy6G+3v+RfpU9M5B2aKroh+Cj90hWb2JQ5KneWHoTufdWItV+NIbattCEQexZvyZ MIKg== X-Forwarded-Encrypted: i=1; AJvYcCW2VeRV4R968O0d79J7cdX6ueJ+f85xzCOYb9QXWPDlma83AFOuqe6PISBFnaIYm39VLwv+crqGrtSkdFI=@vger.kernel.org X-Gm-Message-State: AOJu0YwyPSHanW/lv6DWCMx2dMIzcYT8pVfudEaBDTwbramE5keVpsfn HxsD8BfVtq9gXbTOYuqLH5bpP1MR85NJeZsMZYCau8CTYdMEUqROWa0l1kSHw7F8UQ2bBZdeHNe e+Q== X-Google-Smtp-Source: AGHT+IEZJHOQOby4QohXqqy90JcclwkUdaYqwtd1ld+r6QqFqDnTGy4TzDHLisEZ5MjJRibuGnXEc0/0VMc= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:9d:3983:ac13:c240]) (user=seanjc job=sendgmr) by 2002:a17:90a:cb0b:b0:2ea:1a5a:dacd with SMTP id 98e67ed59e1d1-2eb0e020087mr179a91.1.1732223131841; Thu, 21 Nov 2024 13:05:31 -0800 (PST) Date: Thu, 21 Nov 2024 13:05:30 -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: <20241118130403.23184-1-kalyazin@amazon.com> Message-ID: Subject: Re: [PATCH] KVM: x86: async_pf: check earlier if can deliver async pf From: Sean Christopherson To: Nikita Kalyazin Cc: pbonzini@redhat.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, david@redhat.com, peterx@redhat.com, oleg@redhat.com, vkuznets@redhat.com, gshan@redhat.com, graf@amazon.de, jgowans@amazon.com, roypat@amazon.co.uk, derekmn@amazon.com, nsaenz@amazon.es, xmarcalx@amazon.com Content-Type: text/plain; charset="us-ascii" On Thu, Nov 21, 2024, Nikita Kalyazin wrote: > On 19/11/2024 13:24, Sean Christopherson wrote: > > None of this justifies breaking host-side, non-paravirt async page faults. If a > > vCPU hits a missing page, KVM can schedule out the vCPU and let something else > > run on the pCPU, or enter idle and let the SMT sibling get more cycles, or maybe > > even enter a low enough sleep state to let other cores turbo a wee bit. > > > > I have no objection to disabling host async page faults, e.g. it's probably a net > > negative for 1:1 vCPU:pCPU pinned setups, but such disabling needs an opt-in from > > userspace. > > That's a good point, I didn't think about it. The async work would still > need to execute somewhere in that case (or sleep in GUP until the page is > available). The "async work" is often an I/O operation, e.g. to pull in the page from disk, or over the network from the source. The *CPU* doesn't need to actively do anything for those operations. The I/O is initiated, so the CPU can do something else, or go idle if there's no other work to be done. > If processing the fault synchronously, the vCPU thread can also sleep in the > same way freeing the pCPU for something else, If and only if the vCPU can handle a PV async #PF. E.g. if the guest kernel flat out doesn't support PV async #PF, or the fault happened while the guest was in an incompatible mode, etc. If KVM doesn't do async #PFs of any kind, the vCPU will spin on the fault until the I/O completes and the page is ready. > so the amount of work to be done looks equivalent (please correct me > otherwise). What's the net gain of moving that to an async work in the host > async fault case? "while allowing interrupt delivery into the guest." -- is > this the main advantage?