Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1257913lqa; Mon, 29 Apr 2024 03:15:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV96EW8pLvcoxlgXzz9jON/uJVA5s9gnZ976EdohX2LiGsJkvBJTJfzeEamRnj696xfDSw6sVZknvhR+uekgQXUxfE+WjYO4Ss9biT0Wg== X-Google-Smtp-Source: AGHT+IHXNyGXgl9llECowbB27DxEBGVtQW5ZzoTqM72bU5OeodwbhGXAaSrJpNyfvWRA/r9b80ZF X-Received: by 2002:a17:906:4a93:b0:a58:e2eb:edd with SMTP id x19-20020a1709064a9300b00a58e2eb0eddmr5803416eju.57.1714385712172; Mon, 29 Apr 2024 03:15:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714385712; cv=pass; d=google.com; s=arc-20160816; b=flNwQ8OOxafSUtWz5jRzsX7vfBDHKct5c6R8F/SQ2itdtOLcJSAbGfn4bjwkVZU9rd nml42xWo0AvsHIDCAp+bBDtJzUsoUo4OqfHH38pMEojGN4M8+jAdCP9/4mYQSHAO+wmc 0F7bbuIHnJEbOkmxeH5BC4C/YJbhZax0oApWlnVdz3UJy7Jtv3NDGGEpxGhhnEgwXQ0U T+C112pghWzuPR8m8VWVHm1VDZevJM7GmLkduMowsB5SRdvPcOau+nKAhBzwldDbh0sk AiAmqojOy4ACOemUsaq4l20JLuUq0jOKWhTJIyPfWPIxFLHCUIosT9HTsmtJtXVSOlAc cPYA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=pQ+t0av/EOP1urgumrrp1t7Px6sEa+YzHYZfwcovyAc=; fh=J257D8fwb/+62Vcgdn9VfjMZXjRl80a3qN/eoi5IJQE=; b=mg+cKLcV7tuD4hZjgUHdZ8pU4iNhyixjvVsl/YhHo/z5DEA392dqsT/Tupevik0r4Y KBK8BVO4HdmALoBiPctX1H7gP8bk3aILEqw8kl5/ZnEBIoNg4H5UCcg1GaWusf5JFOU9 eTQ3nd8xbj1K0/BkIoCy9aY4FmNeOvAyJLPyj/oDXlq21yIH20RIyxqWYTIawGn0+66F A3PZtyX8otfqU7dBY9QNYMdKGr7JLISuz5VcGh+NQUUS10jlAlp8Zn2te5Nnz2YHDz9G dLe0b21RQEhJqw5sbAV31RbtUrzHUx/ZKJ35VDkAyEKauanLCYw+Q1FCJUUJPpZ94f1a srOg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VXqo3idc; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-162025-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162025-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id j1-20020a170906094100b00a51aaa75b95si13180897ejd.624.2024.04.29.03.15.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 03:15:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162025-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VXqo3idc; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-162025-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162025-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E334F1F22327 for ; Mon, 29 Apr 2024 10:15:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C5D702C6B9; Mon, 29 Apr 2024 10:14:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VXqo3idc" 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 AAF0C3B29A for ; Mon, 29 Apr 2024 10:14:24 +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=1714385667; cv=none; b=VVo536m0RlRRjbyc67js9E3GbzMhOSEVWjpY2wJmUED0G2LUp316RHdwPoipTubPPVTxAtk8ogtZ3+hdK4tW1il3hMr+ziDn+pEgthSoIaW76IwGQSfFHnWbKJIxdkLV4gBmwR4WTY8zjJe2ekynqO5qyhLqi3pDoRPCxMpFdB0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714385667; c=relaxed/simple; bh=wFFVcm/k79HiZBQXjR6hHvK8Eq3yzCmKghIT42hEDwQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gabo9m2p2wTOYAWHEU6lPKqwQCbhEY7mywNJTvbNVsM0F8vTzNaZn4jPBCClTF/Pu5pyIGpjakYKBezdKNxqXAZUFtdKuvbKb2piDcPZi6p27YubEiiHD8sVJeIg3tfSHZfgfJ+ERd3dBnHZq1RnPYbUhrV5htPjKbUp7iywuOM= 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=VXqo3idc; 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714385663; 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=pQ+t0av/EOP1urgumrrp1t7Px6sEa+YzHYZfwcovyAc=; b=VXqo3idcXUV5Q4coeNFgm/6h0cjL7DqJF6ECVI382pZAPIeh5gYX5St3gNHLQU1KzxhC7O 91zpblyH9UVgW6DVfNZACG33tZWCorZfu3giMTlbdv00fv4mHCnzz5Al2tN88g2dvdtyIP L0nt3kDRH6hrD4vFDkGDjsYzr4etiuU= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-59-IldMwNX_M8WvfhBrYQeNAw-1; Mon, 29 Apr 2024 06:14:19 -0400 X-MC-Unique: IldMwNX_M8WvfhBrYQeNAw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 210513C025D0; Mon, 29 Apr 2024 10:14:19 +0000 (UTC) Received: from gshan-thinkpadx1nanogen2.remote.csb (unknown [10.64.136.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E42A11C060D1; Mon, 29 Apr 2024 10:14:16 +0000 (UTC) From: Gavin Shan To: virtualization@lists.linux.dev Cc: linux-kernel@vger.kernel.org, mst@redhat.com, jasowang@redhat.com, shan.gavin@gmail.com Subject: [PATCH v2 2/4] vhost: Drop variable last_avail_idx in vhost_get_vq_desc() Date: Mon, 29 Apr 2024 20:13:58 +1000 Message-ID: <20240429101400.617007-3-gshan@redhat.com> In-Reply-To: <20240429101400.617007-1-gshan@redhat.com> References: <20240429101400.617007-1-gshan@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: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 The local variable @last_avail_idx is equivalent to vq->last_avail_idx. So the code can be simplified a bit by dropping the local variable @last_avail_idx. No functional change intended. Signed-off-by: Gavin Shan --- drivers/vhost/vhost.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 7aa623117aab..b278c0333a66 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -2524,7 +2524,6 @@ int vhost_get_vq_desc(struct vhost_virtqueue *vq, { struct vring_desc desc; unsigned int i, head, found = 0; - u16 last_avail_idx = vq->last_avail_idx; __virtio16 ring_head; int ret, access; @@ -2539,10 +2538,10 @@ int vhost_get_vq_desc(struct vhost_virtqueue *vq, /* Grab the next descriptor number they're advertising, and increment * the index we've seen. */ - if (unlikely(vhost_get_avail_head(vq, &ring_head, last_avail_idx))) { + if (unlikely(vhost_get_avail_head(vq, &ring_head, vq->last_avail_idx))) { vq_err(vq, "Failed to read head: idx %d address %p\n", - last_avail_idx, - &vq->avail->ring[last_avail_idx % vq->num]); + vq->last_avail_idx, + &vq->avail->ring[vq->last_avail_idx % vq->num]); return -EFAULT; } -- 2.44.0