From mboxrd@z Thu Jan 1 00:00:00 1970 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 4BE5324468B for ; Wed, 28 May 2025 06:43:58 +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=1748414639; cv=none; b=rdK9qBzrnXrNwr37OudfhmtmECbRnlqCs6NCafbtxgWmgDWa58ASpBacCjiA187tiuGAEVWJzw4l97zXwYkeuanScEbrZLOKDdKx/i2ZHGAA/yKVKo5uiJ1LXOdyjy8zxErDeQ8N9RFAnCUAyAD73wcPUZYp6GvtUkG85Sbqq0A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748414639; c=relaxed/simple; bh=ee0hLlMssI0+f8fw+vaSrOCMZwnEvTPiqql7oONLOuk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ckko3FhEvhwkXzcBPGqVNserahH3w5Q+3Y+3RuXsvrOtoYFBHbZgwsePgDwhgV3K3Otu8APDyPGXVPm9avO6M5HJAyV6v2ySplYtDkeFd/CuvEBofxUpNUG4v8/WJ5fXPIP6pmDJgSQRypXmfbgkVJVapSCKEPPcY7DQsigeNJU= 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=M0JKCVXX; arc=none smtp.client-ip=170.10.129.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="M0JKCVXX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748414637; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qZeV9IaGwfczmG903KPOWASPjcuUkTqKJ1zdHNkiWCc=; b=M0JKCVXXxiIwpt+rIDiutspL1QzX1Vw1M9eeYQ2nd7asan0xJaU41ZSDOMa6yRJP7aNWIP +EfP9DkhBrBr7wsK9ND6C+os8AiFTONt6yekXHg+05a8cBjG9mpiT40obiloIS3fAGcuEj poXHnfY2Y8tUp1M1htilfYkCEIgD3HA= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-31-emazegylPCGFD4Z-GxVvoA-1; Wed, 28 May 2025 02:43:55 -0400 X-MC-Unique: emazegylPCGFD4Z-GxVvoA-1 X-Mimecast-MFC-AGG-ID: emazegylPCGFD4Z-GxVvoA_1748414634 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CE5A6180036D; Wed, 28 May 2025 06:43:54 +0000 (UTC) Received: from localhost.localdomain (unknown [10.72.112.248]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 901BA1956095; Wed, 28 May 2025 06:43:51 +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 V2 18/19] virtio_ring: factor out split detaching logic Date: Wed, 28 May 2025 14:42:33 +0800 Message-ID: <20250528064234.12228-19-jasowang@redhat.com> In-Reply-To: <20250528064234.12228-1-jasowang@redhat.com> References: <20250528064234.12228-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-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 This patch factors out the split core detaching logic that could be reused by in order feature into a dedicated function. 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 259380797ec4..27a9459a0555 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -804,8 +804,9 @@ static void detach_indirect_split(struct vring_virtqueue *vq, vq->split.desc_state[head].indir_desc = NULL; } -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; @@ -826,8 +827,6 @@ static void detach_buf_split(struct vring_virtqueue *vq, unsigned int head, } vring_unmap_one_split(vq, &extra[i]); - vq->split.desc_extra[i].next = vq->free_head; - vq->free_head = head; /* Plus final descriptor */ vq->vq.num_free++; @@ -836,6 +835,17 @@ static void detach_buf_split(struct vring_virtqueue *vq, unsigned int head, detach_indirect_split(vq, head); else if (ctx) *ctx = 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 = detach_buf_split_in_order(vq, head, ctx); + + vq->split.desc_extra[i].next = vq->free_head; + vq->free_head = head; } static bool virtqueue_poll_split(const struct vring_virtqueue *vq, -- 2.31.1