From nobody Mon Feb 9 13:36:35 2026 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 393812FFFB5 for ; Tue, 30 Dec 2025 06:48:09 +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=1767077291; cv=none; b=CqAIFOV+N78f7VPFg/QIjdBUgqQ62q1AZS04OYLP7q8/t+fdkXV206tPJD4nKhEeu0rvYDAf9nPXdE+de0YL6FH+W001gjwNwhzgx+aEIPscTJgw3X57nJJvgpVkTL5k+K6AKvM6+uny8Jc8HzCRvXZHFHwP1dOYzxKwMWyt2C8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767077291; c=relaxed/simple; bh=7VfrefuV0RyveHZDmWeVM/KBolm41k0Ra+JCI+z6+JI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jxIAv6Mgc0RmAmw4OuL90WlnznM3TwLYh0oD/Rxy9rcB/Ez6yDwBSDPccAFn39yDygbyFg227B29Q0h7xh4N1tJd6U3K1WoUHjPLMCenocHl3KOKupdI6AeW/nobvsuP5/sjoLI806APCZePheJIjyeUN5hoIDtBAbDmuMe/bNs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=iLAttjBE; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="iLAttjBE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1767077288; 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=Qsn3F2c//WA9V2xo8nKXDIJfNbf92PNIzZ1cj0+dpjM=; b=iLAttjBEBo/xFaQ7Mwp2v2l+oAhwquM8xZNF8D2SAp/I+85f1Ox1koos8hwk+W/C95KmNs reqoLEiG3QIGg14XPx0XZMCn/FxlKIZH9omSfyLEXiwVM3xkvBWjTYFbcfQj5o89M84bLr mwvq1ZLq7hXymF1a5LnxS/MBDtNZ6tE= Received: from mx-prod-mc-01.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-390-fOxDKlIgNja0RMsTMq6IiA-1; Tue, 30 Dec 2025 01:48:05 -0500 X-MC-Unique: fOxDKlIgNja0RMsTMq6IiA-1 X-Mimecast-MFC-AGG-ID: fOxDKlIgNja0RMsTMq6IiA_1767077284 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 560621956050; Tue, 30 Dec 2025 06:48:04 +0000 (UTC) Received: from localhost.localdomain (unknown [10.72.112.134]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5A04819560AB; Tue, 30 Dec 2025 06:48:00 +0000 (UTC) From: Jason Wang To: mst@redhat.com, jasowang@redhat.com Cc: xuanzhuo@linux.alibaba.com, eperezma@redhat.com, virtualization@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH V11 18/19] virtio_ring: factor out split detaching logic Date: Tue, 30 Dec 2025 14:46:48 +0800 Message-ID: <20251230064649.55597-19-jasowang@redhat.com> In-Reply-To: <20251230064649.55597-1-jasowang@redhat.com> References: <20251230064649.55597-1-jasowang@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 This patch factors out the split core detaching logic that could be reused by in order feature into a dedicated function. Acked-by: Eugenio P=C3=A9rez Reviewed-by: Xuan Zhuo Signed-off-by: Jason Wang --- drivers/virtio/virtio_ring.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 3d0263a10f6f..f0b5511a2651 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -805,8 +805,9 @@ static void detach_indirect_split(struct vring_virtqueu= e *vq, vq->split.desc_state[head].indir_desc =3D NULL; } =20 -static void detach_buf_split(struct vring_virtqueue *vq, unsigned int head, - void **ctx) +static unsigned detach_buf_split_in_order(struct vring_virtqueue *vq, + unsigned int head, + void **ctx) { struct vring_desc_extra *extra; unsigned int i; @@ -827,8 +828,6 @@ static void detach_buf_split(struct vring_virtqueue *vq= , unsigned int head, } =20 vring_unmap_one_split(vq, &extra[i]); - vq->split.desc_extra[i].next =3D vq->free_head; - vq->free_head =3D head; =20 /* Plus final descriptor */ vq->vq.num_free++; @@ -837,6 +836,17 @@ static void detach_buf_split(struct vring_virtqueue *v= q, unsigned int head, detach_indirect_split(vq, head); else if (ctx) *ctx =3D vq->split.desc_state[head].indir_desc; + + return i; +} + +static void detach_buf_split(struct vring_virtqueue *vq, unsigned int head, + void **ctx) +{ + unsigned int i =3D detach_buf_split_in_order(vq, head, ctx); + + vq->split.desc_extra[i].next =3D vq->free_head; + vq->free_head =3D head; } =20 static bool virtqueue_poll_split(const struct vring_virtqueue *vq, --=20 2.31.1