Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1558166lqa; Mon, 29 Apr 2024 11:50:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUomoPyv3vE+Yb1+4jkme16qQYWXmY9XaN+mXj4t1TtoWqGd6GQJlFPE6hTmC3/lT+KRxPEeuXcEHUHxg0vietaMFKFCC5FEHYS4ocmAQ== X-Google-Smtp-Source: AGHT+IFfoJUXCc9eD1o18VHgh8WbWIb4TS3fBlK53I/EEV0xn3PIfE1j6mFRVP+9Z2QQwhtIw3r1 X-Received: by 2002:ae9:f114:0:b0:790:b15f:ae0d with SMTP id k20-20020ae9f114000000b00790b15fae0dmr9089825qkg.51.1714416641150; Mon, 29 Apr 2024 11:50:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714416641; cv=pass; d=google.com; s=arc-20160816; b=V2baTR4haRKlRluX4HvaTa+N+0Z6OWpS0kumv2e2rKJAVN+IgDp3xBC8oXXcGYeCgs pJ7MYTCL4vU4fnvnSeWcIa7gPE08tFPO0oSQSmgEGwHnvrsj+JjoDh5fiK29pRB9aCic wH2NTH5dQvXLCOJaKgDkewgH0CkKn1y75nuwZHKFiIEW1suI0W18ajv1aGkaJFgNCyHB 3DEUanU6qMEYO3lI5AQ9E3LKrZTI6LmW0B5wqLych6OnKxTpCUeHNL8XufJRrAlZViXG N9SNwN3PzJ5jLbsxt6bfmNyRib9xwwSMjT2VEVZ30Q7u9i38GszKSDFX8We11w7KXCpW 2a7A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=/isLP1aYjVL55Cg0kF6I/0JVsi7H8eKx3IvIq+SH1r4=; fh=c6lb8RE1MxZdnCWMK39lLfHsMW49o28MGLDNR7bgZxs=; b=hFWeIBn5oZNTzy2qYOLLEM+8Hy0KsM0iIkkdwSA2soIbOFOlc6r2aNqVp9lARzzp4Q 5Hgf0VTrShclJtGBn+QnWsC1P7zTU+1MRHibNMCGbs+Z4kO60zgdqkYoLpA9YI18nYHc P40OPqY2EN6dcYj04Quvr0VLERUClL3fv/csbCv1JpZcAsFMwPYZtGA6OLZIxrumGiey IClVKo+GvPZwlCxfLcujhVLudOKH9pJRTpHJdaOUGLUc+04+t9uMPNw4mi65M8iEFEs6 cA6UmOh6YSn6xvd40L8fVuNS9lnLOcl/SurBZH9fO7cHu0Cnn2ONFoWBKb9JXBG8t7xc YIuA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cRKRu19V; 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-162859-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162859-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id vu20-20020a05620a561400b0078d6f24ddeasi25927613qkn.638.2024.04.29.11.50.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 11:50:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162859-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cRKRu19V; 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-162859-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162859-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id DD1351C2083B for ; Mon, 29 Apr 2024 18:50:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0BDD913AA3B; Mon, 29 Apr 2024 18:50:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="cRKRu19V" 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 3B3B2127E20 for ; Mon, 29 Apr 2024 18:50:31 +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=1714416634; cv=none; b=gb1cvfjxdwRAtuKM8Xkf+y8L8IxMZCuBxdysGMvbtaAzUcAOxcRKMjnHDF8Thhq0D35HzTKbm1uAwsZGZrqCG26cnUpdt/uHfteZZki9nnaSJtvAepL8IOdjgFDckWEZCTFpb3ddbwihjh5rOcq086JGTgm2wif8GPw3vcnDGMU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714416634; c=relaxed/simple; bh=4BM15V5T8ZCJlfeNEJbWlVWcJsEzsXEXtP5ugGZF6aQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DT9S2G1akUaN8Z821coUGjyPa7PWtOtOtQXyBQueV0UvNYlRDJdxbB/YvY0w/wDylsE5E9dpurb3oyv4QtCvvifi7YMqrLe/iMw8T5Sdo6uu+eRxQl14R3c2iBeAELoSu+FmvpBoFW/gzbZX5m59J9vOk8qa6HtHhm3nQn1S6lQ= 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=cRKRu19V; 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714416631; 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: in-reply-to:in-reply-to:references:references; bh=/isLP1aYjVL55Cg0kF6I/0JVsi7H8eKx3IvIq+SH1r4=; b=cRKRu19VbqSMm5ae7cxlxcFu4h3uJdv5eZrmPeuOzvWKDItmvwUwKQPEgI6yMeDgNYOwOB 4wa81Hek45lbV4SHIp6f4QSxYe5kUqhOBDQRpKiTOWJMu0WdFyX3++yNV2wTDJWQxHRTC8 6uVkTi+VisbPGAE/n4RnVjjfJYr7w7c= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-392-xcDcqx9qPByo8W4q8nWSbg-1; Mon, 29 Apr 2024 14:50:29 -0400 X-MC-Unique: xcDcqx9qPByo8W4q8nWSbg-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-34d1089a3feso710312f8f.2 for ; Mon, 29 Apr 2024 11:50:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714416628; x=1715021428; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/isLP1aYjVL55Cg0kF6I/0JVsi7H8eKx3IvIq+SH1r4=; b=S5lKQMa3BwVy6cNeTVht5ww8YByC7yaBHP/nwZCAOqlWSgjnZchhxkgi/y7Iy1QkqD YM0w+CYa5sEzVdZ6BpRN78J1AoqQZgl06LonJO57Kgct+XeLrVkNrs+JdDrclrpLlCLX ewDzGYCTbfmK17oAf6g9Wsjtbxbtx1wD7kVWFvUfHAflSLP7MNVcGNmsXp5rb2oLHKiL A7FdcYxLWpnivxR7fMJKAILx58la8MHNcPlZQNw9hmuSe5dlWNPozzQAk6EgxmZMHPow kiMplmsZ8k/pdk/j0LUOBQDKA379KJ1vTtsymYxeIRtOLdVx0rI57dr7GbZsCNK6BMU5 MjWA== X-Forwarded-Encrypted: i=1; AJvYcCUKiJ12Q4+O/iyvCAuxyARUFw2Mbq8JBbHlSfCvf8FGeNqK7BQl/HcKC9THO9mWiFG2+jITHjCfKK9WmE7ANmkh4WUVHVZkvuz+uQEH X-Gm-Message-State: AOJu0YwfH4IILuT14EhskenY/KY1uZdHRycEKgaRaPmpDIIzUvvRtvD0 /xBBxVM1t39SHmd/pw1KXh2+B9FCWVyvsi4YYijbA8ZuhyfhSV/YoN4kxmo1DbdaKfIOHngdEVg /C2P26lOq8Y2nRaMhcUfGcGVwMq2J9qrdyGWnZrQilvaFqundTOFCcDKA5W/3mQ== X-Received: by 2002:a5d:47c1:0:b0:34d:1d09:f06d with SMTP id o1-20020a5d47c1000000b0034d1d09f06dmr3471558wrc.13.1714416628182; Mon, 29 Apr 2024 11:50:28 -0700 (PDT) X-Received: by 2002:a5d:47c1:0:b0:34d:1d09:f06d with SMTP id o1-20020a5d47c1000000b0034d1d09f06dmr3471538wrc.13.1714416627641; Mon, 29 Apr 2024 11:50:27 -0700 (PDT) Received: from redhat.com ([2a02:14f:174:67cc:7d0:12ee:4f8f:484f]) by smtp.gmail.com with ESMTPSA id s11-20020adf978b000000b0034d0a64ed0bsm3592659wrb.77.2024.04.29.11.50.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 11:50:27 -0700 (PDT) Date: Mon, 29 Apr 2024 14:50:23 -0400 From: "Michael S. Tsirkin" To: Gavin Shan Cc: virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, jasowang@redhat.com, shan.gavin@gmail.com Subject: Re: [PATCH v2 0/4] vhost: Cleanup Message-ID: <20240429144955-mutt-send-email-mst@kernel.org> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240429101400.617007-1-gshan@redhat.com> On Mon, Apr 29, 2024 at 08:13:56PM +1000, Gavin Shan wrote: > This is suggested by Michael S. Tsirkin according to [1] and the goal > is to apply smp_rmb() inside vhost_get_avail_idx() if needed. With it, > the caller of the function needn't to worry about memory barriers. Since > we're here, other cleanups are also applied. > > [1] https://lore.kernel.org/virtualization/20240327155750-mutt-send-email-mst@kernel.org/ Patch 1 makes some sense, gave some comments. Rest I think we should just drop. > PATCH[1] improves vhost_get_avail_idx() so that smp_rmb() is applied if > needed. Besides, the sanity checks on the retrieved available > queue index are also squeezed to vhost_get_avail_idx() > PATCH[2] drops the local variable @last_avail_idx since it's equivalent > to vq->last_avail_idx > PATCH[3] improves vhost_get_avail_head(), similar to what we're doing > for vhost_get_avail_idx(), so that the relevant sanity checks > on the head are squeezed to vhost_get_avail_head() > PATCH[4] Reformat vhost_{get, put}_user() by using tab instead of space > as the terminator for each line > > Gavin Shan (3): > vhost: Drop variable last_avail_idx in vhost_get_vq_desc() > vhost: Improve vhost_get_avail_head() > vhost: Reformat vhost_{get, put}_user() > > Michael S. Tsirkin (1): > vhost: Improve vhost_get_avail_idx() with smp_rmb() > > drivers/vhost/vhost.c | 215 +++++++++++++++++++----------------------- > 1 file changed, 97 insertions(+), 118 deletions(-) > > Changelog > ========= > v2: > * Improve vhost_get_avail_idx() as Michael suggested in [1] > as above (Michael) > * Correct @head's type from 'unsigned int' to 'int' (ltp@intel.com) > > -- > 2.44.0