From patchwork Fri Feb 7 16:20:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 13965419 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CAC561802DD for ; Fri, 7 Feb 2025 16:21:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738945282; cv=none; b=Hed4NbpEgUfPeDtoAWfiH0ML4Ab4v2OSllsqfe9at95E6ZbvTDE0G42JkdceQx0jP2XDsacC+cLR5RwgFLfJmGEwrGIcvMqUp/Nn3e/R7vWPmkIeNLSTFAdC3pEaKMkBO7s02NY4WPigWBjJ+Cmo5iazYzJq3SYrBYpuvWN6tQ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738945282; c=relaxed/simple; bh=9NJbIW8HF1iWtKwqaG6Q5rUnbJq8AVayNgTohN45mS4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MrNcodkHjKSP4OwNHLPDolijK//m24x7Yqxy1nR8TXckh0wJwHwTdDnk9ouS5lm96HBX6sUnn2HFg5e7Z/hppDzST/UqXm7s05+mAdEyjiipjB5DAD4mZ85zm8+BIt0ergYrlGFb/17wZCXSGF+AB40JPwKHzEU6Wled+cGtaIY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=UpjB75Eo; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UpjB75Eo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738945279; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dS3mG7q7Qhof/soXKvmjdSRvuo+ZNyeAZO9Cl/N//jo=; b=UpjB75EofS0Q+YdkAsHDZKj0F6SmommKxCE0ku5KJVCp9bxe2ERbw3y4ZffDWhWA/qsp/l 3Xq8zpHRF9k7+ICo7mKHZclygbcAbnVWTzhCa0lcbhQrcOk+zGKu7Fg+Rk7J+ZFnMOQF9C WQ1j7oJfsBGsD8kmZY41iZsGbJ3tiD0= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-53-oMh-emOuOZOhvvgumhecOA-1; Fri, 07 Feb 2025 11:21:18 -0500 X-MC-Unique: oMh-emOuOZOhvvgumhecOA-1 X-Mimecast-MFC-AGG-ID: oMh-emOuOZOhvvgumhecOA Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3713719560B5; Fri, 7 Feb 2025 16:21:17 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E602F18004A7; Fri, 7 Feb 2025 16:21:14 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , =?utf-8?q?Alex_Benn=C3=A9e?= , kvm@vger.kernel.org, peterx@redhat.com Subject: [PATCH v2 09/10] accel/kvm: Assert vCPU is created when calling kvm_dirty_ring_reap*() Date: Fri, 7 Feb 2025 17:20:47 +0100 Message-ID: <20250207162048.1890669-10-imammedo@redhat.com> In-Reply-To: <20250207162048.1890669-1-imammedo@redhat.com> References: <20250207162048.1890669-1-imammedo@redhat.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 From: Philippe Mathieu-Daudé Previous commits made sure vCPUs are realized before accelerators (such KVM) use them. Ensure that by asserting the vCPU is created, no need to return. For more context, see commit 56adee407fc ("kvm: dirty-ring: Fix race with vcpu creation"). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Signed-off-by: Igor Mammedov --- CC: kvm@vger.kernel.org CC: peterx@redhat.com --- accel/kvm/kvm-all.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index c65b790433..cb56d120a9 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -831,13 +831,11 @@ static uint32_t kvm_dirty_ring_reap_one(KVMState *s, CPUState *cpu) uint32_t count = 0, fetch = cpu->kvm_fetch_index; /* - * It's possible that we race with vcpu creation code where the vcpu is + * It's not possible that we race with vcpu creation code where the vcpu is * put onto the vcpus list but not yet initialized the dirty ring - * structures. If so, skip it. + * structures. */ - if (!cpu->created) { - return 0; - } + assert(cpu->created); assert(dirty_gfns && ring_size); trace_kvm_dirty_ring_reap_vcpu(cpu->cpu_index); From patchwork Fri Feb 7 16:20:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 13965420 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53AE110F1 for ; Fri, 7 Feb 2025 16:21:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738945288; cv=none; b=f13DdqrC6dXJ/d9cbjo/FncI1STu+x4vyEZdQMrAcL/SiAz6GYNzxcNlzQKv1KTYU6F/U4o29VB+a+eK1AKiQHavj1JFHzAP3sGrqeCtLOHVYyQp5O+zI/Cm0WxsLILLhiCwvuBbwTMKWjCWVOOK8TziC/qHot0vD50Cdoiqjsw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738945288; c=relaxed/simple; bh=o96xiAGGAf1VbfHWgHYbIYNVLqylg+O4B4Y//biT4pE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=a8BsV6idxw/cl5xHCcGFwkykcfJjLo5yWGEFICln3vuamwG9zmo4cDYzqOuetlUEjTk79j87k98siH6gmKUDDPs/pwugnUQGBMoc1U9HL4wtzQsZ1oYcYc4X45mz4R7zI2kBAyOXpVIbClg+Xz/GdFiyC6SDwNSnKJUjp1dFsSI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=DWVulNy8; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DWVulNy8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738945285; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3WVrexRlab32QyhpO6UTZhs06SRUtIvJ5qxTfzSBSSg=; b=DWVulNy8o6pjNdhFMmNcUontmIS8VGSfaPJF/UFpPCLqDxQlQedlTh+vHQ9iPiungbqK9S uUqaXMOKNrzXc8+lcKKY8hH+JZMTId04LzefugOtRhRXFULENnu+KqCXJNoe+S76YYbgOu QqDLjhsai7HjfgYAeNY5UtrK1c7Npw0= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-326--t9MizpNPHC3KSb7onlIuw-1; Fri, 07 Feb 2025 11:21:21 -0500 X-MC-Unique: -t9MizpNPHC3KSb7onlIuw-1 X-Mimecast-MFC-AGG-ID: -t9MizpNPHC3KSb7onlIuw Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6DC0219560AD; Fri, 7 Feb 2025 16:21:19 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9C870180087A; Fri, 7 Feb 2025 16:21:17 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , =?utf-8?q?Alex_Benn=C3=A9e?= , kvm@vger.kernel.org Subject: [PATCH v2 10/10] accel/kvm: Remove unreachable assertion in kvm_dirty_ring_reap*() Date: Fri, 7 Feb 2025 17:20:48 +0100 Message-ID: <20250207162048.1890669-11-imammedo@redhat.com> In-Reply-To: <20250207162048.1890669-1-imammedo@redhat.com> References: <20250207162048.1890669-1-imammedo@redhat.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 From: Philippe Mathieu-Daudé Previous commit passed all our CI tests, this assertion being never triggered. Remove it as dead code. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Signed-off-by: Igor Mammedov --- CC: kvm@vger.kernel.org --- accel/kvm/kvm-all.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index cb56d120a9..814b1a53eb 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -830,13 +830,6 @@ static uint32_t kvm_dirty_ring_reap_one(KVMState *s, CPUState *cpu) uint32_t ring_size = s->kvm_dirty_ring_size; uint32_t count = 0, fetch = cpu->kvm_fetch_index; - /* - * It's not possible that we race with vcpu creation code where the vcpu is - * put onto the vcpus list but not yet initialized the dirty ring - * structures. - */ - assert(cpu->created); - assert(dirty_gfns && ring_size); trace_kvm_dirty_ring_reap_vcpu(cpu->cpu_index);