From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (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 6A7DE1FBBDA for ; Mon, 13 Jan 2025 15:48:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736783329; cv=none; b=RDQkd9xO0kyTidhg0mrVDWPiFygM7weDMdJD2ZtdnDvtZGmq5EG/J+Sx4WV9tkn60OcSIFan5sg28chpWIqNKWUBtC2qH3iXETktb0BwdK8lEBBvReZNpy+XX0WtAROYf33VkZS/CYEBXWWZBa959uT8Co7BKJJavuupxB0jHS0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736783329; c=relaxed/simple; bh=IYZOypcaQcSIoz0YrOnSpdYtmQ7rwZr8J3hfohT0pQw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=OpsZNnMNzEraA4EvqL2J2ojeERgkGds6V0bvqB+WZqOwQirRWns3hcETjYLHZS0C5PuChj9ul+XcyTwgHzVk9BXhMClwijfSMDvDjFA/o0CGUCbvLns4/hZkXH2ilJRhM+SOkNOSeJatJ8wBNxw+w6y2JzerSRZlcyjle6zMfY0= 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=jwChamly; arc=none smtp.client-ip=209.85.216.73 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="jwChamly" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-2ee9f66cb12so7929742a91.1 for ; Mon, 13 Jan 2025 07:48:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736783328; x=1737388128; 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=i9nzX7aXTGYmmOj2PtSq7Ss6UOn7GgH7UoDrTFdf5uc=; b=jwChamlyVOPgPyTfDzx3xVyO8+jGh84S7YG4oTnonPr+qJD9hWDTBduWsnj6YAk8l1 YHMBtzS6joxUS2F8qYthoAZJyBOpt5Ty2VowHEDNXIhmzbcv+srCDSFa1G1C352tgvl7 tpV5VvHy55F6bVWchBUKHuVM1+S/nlmfg4pYsaPB1lvSn8zTk8MSazlQJ4hsEVQ5cKIF 7FczpAL59EB98+d/nwZtH6GszvbvSwE+PyC0TrV5NF9D1kHVLFtcLr0BQpcaQCn56vYH a+7eKBgOAsjmEw7DMNiWuIWx2BlCI+tIUbIz7IIF4qBRK/JX+Yb7tq9NLQLX2D0wYaJ3 H3mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736783328; x=1737388128; 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=i9nzX7aXTGYmmOj2PtSq7Ss6UOn7GgH7UoDrTFdf5uc=; b=p61soNrJysHm8+L8vmHZ5ckvgVOyf4GENu/on59v9iMYuYxrnp9uJBfpAafy8CexcB ncM5+KEWe6SIsYA1V/V7ShHFA/Di1oe794AxXIx8f44U3cxwQxHBU2bJKrGl04kTBaTz o+m7JyF3naHm7KBCYYLVty8Wrl4yZbf70X+zvI2DH2ug3uMXHFOvogk6QPWASgND2KlQ RU+VZH3YYM1UBkjBsWsWTx2NcsCLpVfu/5E0QC4j1nA/Zmw45XXnkrHkEYyz8R5KnQ6v 04jZtOLVtCaFdpfqb2+ev8P0Krq2QXI+OUdnUXTA1QfY+4/Zd75K42Mm5nMNEixmTPn1 lsBg== X-Forwarded-Encrypted: i=1; AJvYcCUrudbq38wl2xWs0h8z4ZhQLOeysDQ8UEerMw+hGl2bKcAzcrYrXlFwORKlcOsHVb/l66ggoiCRctCfpuY=@vger.kernel.org X-Gm-Message-State: AOJu0Ywcw+9E9MQcqX5P3x2fZQJTSvy8PgoNjva9ip/dUdD2hIrndvz7 JxxujY5KVrDgk02y6fg/mklEKsjmcXPewsXYislSUJ3MhgKw0Sb/9+7KG+DbKETer7w9cjdS2OX /9g== X-Google-Smtp-Source: AGHT+IEnku9NNmAY4NKweblgpWHxNUkjYFq0KrtNH5xLtW+mmgVk7olQ8zzt2RYoUY6Srjz/ceKKLzr8p2w= X-Received: from pjqa2.prod.google.com ([2002:a17:90a:a502:b0:2f6:e47c:1747]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:520f:b0:2ee:db8a:29f0 with SMTP id 98e67ed59e1d1-2f548f1b7e6mr29175048a91.27.1736783327688; Mon, 13 Jan 2025 07:48:47 -0800 (PST) Date: Mon, 13 Jan 2025 07:48:46 -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: <20250111010409.1252942-1-seanjc@google.com> <20250111010409.1252942-3-seanjc@google.com> Message-ID: Subject: Re: [PATCH 2/5] KVM: Bail from the dirty ring reset flow if a signal is pending From: Sean Christopherson To: Yan Zhao Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Xu , Maxim Levitsky Content-Type: text/plain; charset="us-ascii" On Mon, Jan 13, 2025, Yan Zhao wrote: > On Fri, Jan 10, 2025 at 05:04:06PM -0800, Sean Christopherson wrote: > > Abort a dirty ring reset if the current task has a pending signal, as the > > hard limit of INT_MAX entries doesn't ensure KVM will respond to a signal > > in a timely fashion. > > > > Fixes: fb04a1eddb1a ("KVM: X86: Implement ring-based dirty memory tracking") > > Signed-off-by: Sean Christopherson > > --- > > virt/kvm/dirty_ring.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/virt/kvm/dirty_ring.c b/virt/kvm/dirty_ring.c > > index 2faf894dec5a..a81ad17d5eef 100644 > > --- a/virt/kvm/dirty_ring.c > > +++ b/virt/kvm/dirty_ring.c > > @@ -117,6 +117,9 @@ int kvm_dirty_ring_reset(struct kvm *kvm, struct kvm_dirty_ring *ring, > > cur_slot = cur_offset = mask = 0; > > > > while (likely((*nr_entries_reset) < INT_MAX)) { > > + if (signal_pending(current)) > > + return -EINTR; > Will it break the userspace when a signal is pending? e.g. QEMU might report an > error like > "kvm_dirty_ring_reap_locked: Assertion `ret == total' failed". Ugh. In theory, yes. In practice, I hope not? If it's a potential problem for QEMU, the only idea have is to only react to fatal signals by default, and then let userspace opt-in to reacting to non-fatal signals. > > > entry = &ring->dirty_gfns[ring->reset_index & (ring->size - 1)]; > > > > if (!kvm_dirty_gfn_harvested(entry)) > > -- > > 2.47.1.613.gc27f4b7a9f-goog > >