Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2692999lqt; Mon, 22 Apr 2024 20:37:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUt7argZhlfZgZwyZxs3tplLbYA2/ffTr20ADdKy61eUADBdpLQhhunS+w9Vl/zunuHTwb9Nf55xj1mgpWQB6DaG/ueJTw4IaJOzqLM6w== X-Google-Smtp-Source: AGHT+IHTCqO69k9Pss+jcrjYCjqqTDA+Gmy1RY3G18z9hCZ2rZm0arS/gqkxPHqkzA4FSUulZo0Q X-Received: by 2002:a50:aad8:0:b0:570:c8f:1a35 with SMTP id r24-20020a50aad8000000b005700c8f1a35mr6578427edc.8.1713843422085; Mon, 22 Apr 2024 20:37:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713843422; cv=pass; d=google.com; s=arc-20160816; b=zx9ZHJpKMzHdcOV8W+6r0Z8tFF4sI4fDVs6LEtZe8c3UnDV9h+28yF5xQumvu1GLOH p6QH8JCXKi+CaP4XvhbRMB7DV8nlNKVK0I2DcYfMzwrzkgORqZSkmA8djtTobj8xVGTR FN/pNGqIngLRiuiBmMHR1YgRPm+uHTM//Ka1G323FGO/EoNZIklgQVzW7v94mGlUmL5a eSSKqYdnK43NsdIdYU72K3t7Aek1iOoGB5P2K0BzpKP75RzCJAKeFeFgRVSn8459NRYI pcarEGE8EEhzEaw31CTJD1WvZVZhiJJZzVfyrCAcX/xWHxZTfCTd2g/wrPDx2QTaCqf1 fenw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=AgcL8WISfu/qXNDjCu04c4243W33DII37P9yj0gbDx8=; fh=wzKinT0wRj4oorHsnGyJkLgCvq9jO9f1+/NCalAkokg=; b=RrWvzzLeeTmHiwmmQ5RH+ORAZng7Qa1FAuTnhAM4fLqpV34x848JDu8rR0qWlNemqP AZJ0bcWX9ZencyywV5KMdh0AnEwwbOyW5odFYRSCPNVgn+EMlBBsCKtp+YO+hEfzB1Ie cuvv/Gc5rGeKHX6wQCRuXD3zVtHLoF8/mZwrr3PL0HSw9HfQ0mHwDv3PTZWmKvXC7BXw Yw7K0Vlq3PSwsuX2ZJXAKQy5pozE9f64XANw4dGrgNf+rHgw/qp5xkDjTNZ5fYVacXYf AiAn5Sf63xtB4/JPnugdXyLLtWpM/Xmh4pW6Yp1x3lFjMGPD5hcw813JK3qnlKRUit+q snhQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aBVqJB88; 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-154460-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154460-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. [147.75.80.249]) by mx.google.com with ESMTPS id h11-20020a056402280b00b00572004f4edesi2999838ede.542.2024.04.22.20.37.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 20:37:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154460-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aBVqJB88; 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-154460-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154460-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 7DD561F21030 for ; Tue, 23 Apr 2024 03:36:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2EBA51C68C; Tue, 23 Apr 2024 03:36:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="aBVqJB88" 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 EF9FA18E1D for ; Tue, 23 Apr 2024 03:36:39 +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=1713843401; cv=none; b=hJW4pZ/pWMvMoNh4ganu0o7eXgio1x2iOkoBx2Vk/97exHU5dP0GcNtmU0eOZjB4I76os8M5jCXwirCvi1vocJeFrG932La3EC9BbQVygZtTrQdB7yhtJWCmxv5XIzzm+nvmhBCLKC0VCGqeIVavfiiwkwn34UGE4WjyXhTk6fc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713843401; c=relaxed/simple; bh=5vWsoypMS8KW9AyNG2fX2xop6xfTDebSOf8rMvu+fP0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=eiHzpaS54VeP2vm3R/2f8vSZIQPY22qg7uWTSwEst9yJqCk8D5VVklLSf/M0JUYRbgjjQGNEQFc9KGRChT772s18UQjQao3t8s+cOOxC9JhmV4dxtsgdbIVSlx1oDBwTmnEMWIL6+k3vUM5i3dltgPl5QfvRzCLwOZqDpnW6Gyw= 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=aBVqJB88; 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=1713843398; 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=AgcL8WISfu/qXNDjCu04c4243W33DII37P9yj0gbDx8=; b=aBVqJB88wTqrzlhJgYwE+XXgJw4wQ0wDUvXWa+97KkCkJMcrHugC9YcfupsFEt8BtYn0wB J78Pwzv5lQRkVO/wn86OD7zRCsuyZtsBDpmMsmZtrHo0GcuHCj9N+JDRPsUvelreEW2cqH KF98fjy4t2htsT6G+BJimDbTyoJeruQ= Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-477-1FrMKfsGNPKm6FkfsLNgNw-1; Mon, 22 Apr 2024 23:36:36 -0400 X-MC-Unique: 1FrMKfsGNPKm6FkfsLNgNw-1 Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-2ae9176aad8so528394a91.2 for ; Mon, 22 Apr 2024 20:36:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713843395; x=1714448195; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=AgcL8WISfu/qXNDjCu04c4243W33DII37P9yj0gbDx8=; b=CscCeAnQx/H7dzgC4g9ZBiP6+KNt3gua2WKQreCJ0LtkvDmto4o6hD6mQBoqO4bNOK 0JkWvzgGtBF7OBtoDet+w2xC7zbYuXONpJdRpfCYsjVvFPtkLXWlMmkQzsclfvVrZhug 18ciPYeSGUwDm0eEN+3tMAUih/W7DYP8QQxQxKSrvCWQUw8MQo+V6DTaxK5jdrDTgJQS 7vDdv4VHK5VRX2GUYL7pQNQ57Z/r3GgM9BCkrDUZ9UlSpWBO2iQDR7JnS6a/Mf5DcluZ HzxPe5vK9ea5BvtrlmUvny07hiOLgkRSZfw0sToZq5BSFUgItfnuKORgGfWPvKdxjbDO 9xPQ== X-Forwarded-Encrypted: i=1; AJvYcCUBPuhA1g0QWXSElR/MxG9bZ/EBmd9C4HkwHI3/MqFFSxXc4BLZ1ZmJlKtrUhcmtKizvc+DJKNwAmUD+Mbf/V0y6sde8aK9eqBDvHO1 X-Gm-Message-State: AOJu0Yw/lOV0na6oUhYFLeJOdBiro5XJRKpM/eAOqBPpsC6DPePaEqOX uQOJgCwWWnBiXgcx7NGgeUZ4QTRvLp8UUxaIoCoH8hzWhC1C1ayazCenL4hQl9zQUyUmSaQZYRO M4bdOSgkRft9dd+p7bjYlP6J35f9OFVBsHqs+dYRx3KuNgug07LgZQj5+SoyiAA== X-Received: by 2002:a17:903:11ce:b0:1e5:8175:4968 with SMTP id q14-20020a17090311ce00b001e581754968mr13010968plh.9.1713843395474; Mon, 22 Apr 2024 20:36:35 -0700 (PDT) X-Received: by 2002:a17:903:11ce:b0:1e5:8175:4968 with SMTP id q14-20020a17090311ce00b001e581754968mr13010950plh.9.1713843395116; Mon, 22 Apr 2024 20:36:35 -0700 (PDT) Received: from [192.168.68.51] ([43.252.115.31]) by smtp.gmail.com with ESMTPSA id l9-20020a170903120900b001e3e0aa9776sm8877634plh.27.2024.04.22.20.36.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Apr 2024 20:36:34 -0700 (PDT) Message-ID: Date: Tue, 23 Apr 2024 13:36:28 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 3/3] vhost: Improve vhost_get_avail_idx() with smp_rmb() Content-Language: en-US To: "Michael S. Tsirkin" Cc: virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, jasowang@redhat.com, will@kernel.org, davem@davemloft.net, stefanha@redhat.com, sgarzare@redhat.com, keirf@google.com, yihyu@redhat.com, shan.gavin@gmail.com References: <20240328002149.1141302-1-gshan@redhat.com> <20240328002149.1141302-4-gshan@redhat.com> <20240328052814-mutt-send-email-mst@kernel.org> <8faa07aa-d330-4e3f-95b7-26437d448beb@redhat.com> <20240422164613-mutt-send-email-mst@kernel.org> From: Gavin Shan In-Reply-To: <20240422164613-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/23/24 06:46, Michael S. Tsirkin wrote: > On Mon, Apr 08, 2024 at 02:15:24PM +1000, Gavin Shan wrote: >> On 3/30/24 19:02, Gavin Shan wrote: >>> On 3/28/24 19:31, Michael S. Tsirkin wrote: >>>> On Thu, Mar 28, 2024 at 10:21:49AM +1000, Gavin Shan wrote: >>>>> All the callers of vhost_get_avail_idx() are concerned to the memory >>>>> barrier, imposed by smp_rmb() to ensure the order of the available >>>>> ring entry read and avail_idx read. >>>>> >>>>> Improve vhost_get_avail_idx() so that smp_rmb() is executed when >>>>> the avail_idx is advanced. With it, the callers needn't to worry >>>>> about the memory barrier. >>>>> >>>>> Suggested-by: Michael S. Tsirkin >>>>> Signed-off-by: Gavin Shan >>>> >>>> Previous patches are ok. This one I feel needs more work - >>>> first more code such as sanity checking should go into >>>> this function, second there's actually a difference >>>> between comparing to last_avail_idx and just comparing >>>> to the previous value of avail_idx. >>>> I will pick patches 1-2 and post a cleanup on top so you can >>>> take a look, ok? >>>> >>> >>> Thanks, Michael. It's fine to me. >>> >> >> A kindly ping. >> >> If it's ok to you, could you please merge PATCH[1-2]? Our downstream >> 9.4 need the fixes, especially for NVidia's grace-hopper and grace-grace >> platforms. >> >> For PATCH[3], I also can help with the improvement if you don't have time >> for it. Please let me know. >> > > 1-2 are upstream go ahead and post the cleanup. > Michael, a cleanup series has been sent for review. https://lore.kernel.org/virtualization/20240423032407.262329-1-gshan@redhat.com/T/#t Thanks, Gavin