Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1179593lqe; Mon, 8 Apr 2024 00:33:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVhwZc77tLxRg7q01DpbUtrhRbRsynHh+bTW64nBoJKGv4j6p0zYz8jKEvuEtEa85XkhTw3EXKK00V0Uyr9VHxvG/FCumE57zH54PNMtQ== X-Google-Smtp-Source: AGHT+IGRhD6wJ9qhCLbvT3Fe0ltBDhxQKpuxjHB7ow6B7Td0MH+TVwxT1cyLb1L92gBJl226NQ37 X-Received: by 2002:a05:6a20:9686:b0:1a7:57d9:9358 with SMTP id hp6-20020a056a20968600b001a757d99358mr2512337pzc.16.1712561616021; Mon, 08 Apr 2024 00:33:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712561616; cv=pass; d=google.com; s=arc-20160816; b=T9Kqg3sJaYiq9mnLySa35iofgFQiFvIt/dVqtjaVuIDMJwnHlYVbQ4EPnlnNONiVJu pqVVSi+3LJ6UgCos+I9+/njGsmSyJWL1w36FWORAf9BblQP5hGLZC0VbF16esbL/E/ol V1vOLgJEx5NyuySzEiTlaELjsYsNCgAtJx56hNvbF8Xnv3egaiMNgOmL/J+uxMS+/dfM S0jTLTGcZPrPuMxcfndJ7+bDQ2rR08YvyWcfbuszq72GtxuiyTsEdBAY4Prahekks5vU o7EhPEd9AbFGwz8Lrw9mB/WQL10nclGo/KDpwMI0IAQbeQDY0ji3zgdU6EkXGv9h8SQj 1s0A== 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=T1ekjaOH/ZVs1uSejqLbBkJhchKKbAwLuZOoQubtwZA=; fh=b4aQP8LZS+nj7Ms1s8U133MXz1KS2Kalc8omIfPcseg=; b=sDZ+dJrJqdGQg3hJBcWdj7sAO0i/NPYQy0z9dTSCC5fmIT6RV82iENJu6Ug0wfE5Vr KdSbje6WF8rhTvjnHkQxX0kHX/oKqnmfa+x03iNzyB1aFWqgorTN7+8O6LnhZtAiOnVf h/Le+9HIvGsvPt2Pg6tM+2X7g5zW4dBCDe3b5C1kC/g7BMUMcmzV1/BBirSqTthLrvIj yOizLiJX32jPYlpTro+wLer3A4NCNH6klApCoiQa+1A6Ehoh6uwbm8ozzVTeO1Fq4DXJ 8zf1J8TfgLl72yaPVk7HmIQAAtLEQZXbdNkU/PIiwEUf5ypJtNi+d3n/XVgLkZ6FwcY/ upjQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=H0U7uAH9; 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-134904-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134904-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d12-20020a170903230c00b001e3cd8839ddsi4787150plh.273.2024.04.08.00.33.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 00:33:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-134904-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=H0U7uAH9; 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-134904-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134904-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id ACD0A283C12 for ; Mon, 8 Apr 2024 07:33:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8AA0428DD1; Mon, 8 Apr 2024 07:33:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="H0U7uAH9" 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 1323F219F0 for ; Mon, 8 Apr 2024 07:33:26 +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=1712561608; cv=none; b=IXzG9OoiZvP+x8oQ1JHM/WkMbvQju/SlMykdtZMy2LHJwwC1hCJZJ3E3WtNmnJr9NcrJy7c3DXuL+pNv2EMu8/Zg3qJh/ucxrpdWpypBrofr6s1tJoWYBzaYiqqr+U+8Virzxvk88MdGslnYdefPaSBQ5r6kox0cgs1TFJvG3ac= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712561608; c=relaxed/simple; bh=Ni7HvNm5U0I3Dy8ia12IlwiVKh7s5+qpbpTyHOdBxQQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Vc7RN2KfEXP3VT6himGKCJUdRJrX1qBA3QwmorM4W5tEGgvBcOeQLipYaicQqyy4N21RHTZwgIRFgJizdRmRSvJ+nNhzZNnYYCxZDKVnCQmPscinbR+scViO/v7IgrCRL1Zfp9yXN7Gzto+CXG812ldSkDcRr7qWHTr9psnNomE= 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=H0U7uAH9; 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=1712561605; 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=T1ekjaOH/ZVs1uSejqLbBkJhchKKbAwLuZOoQubtwZA=; b=H0U7uAH9gUwv6vCAM88dYFHoAsbNKqFHDLyjhCppSD1gvfjlSMU/DdTYpGneCEDCW3nW/G 1ZEVT1no5FUo4eWQ15m6f9H69OKvCjR/tc/iRp+KrBHbA9uO2VxhGaA1QVC/qfsgfPJmy2 XfpQxP5j40cXuHEebrlWnLuQDl/4YhE= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-394-aDGwmsp_Pt-GwRrMRYWCYg-1; Mon, 08 Apr 2024 03:33:24 -0400 X-MC-Unique: aDGwmsp_Pt-GwRrMRYWCYg-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-41663c713b7so3657955e9.0 for ; Mon, 08 Apr 2024 00:33:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712561603; x=1713166403; 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=T1ekjaOH/ZVs1uSejqLbBkJhchKKbAwLuZOoQubtwZA=; b=FvENA3GXM7gmYxU5/RKYB/0X+RmFLZReYdI256zlAqwH5W7oKxnt3wgw/anX1EliBA Z1+YVjgGqapcRI6e2HeRgaUpenI5DyN4gM1s5pJt2xwp8eg9vLSwkpxfPnzRtBeSiLaN Wgp2gFFJh0wQ7jkrQIyafOnVuLPZ8/vaoP+qQ68RcJ7axrqVsHD4dN0whyMwTTqXu0HB KGrPtWkjW/NhXhiO6XYWt4UM0DkhAzxzxhHa+yUt4juDt3FYr0qSovUcSZbvCC+dxaoV S+/LUksjgNwiQTJzYd7ZQxJXczhKIg+75Ju1f8SF6xD98opzl4S7w0tDQZ3/Meg+4Ae0 4WBQ== X-Forwarded-Encrypted: i=1; AJvYcCW7GcCdimuLuWlH/G+wWZ9/AtVLj5ekjo0rLcuwAln9ypkZ6ut7WrngXaaMVO4OKYUkhxcmfsF/UUQ6wChoyU3pXqpVApxWueyPwkEj X-Gm-Message-State: AOJu0YxhzKO/0VZDqpZ+ZarJRhlP/q6DhwvERMtLwNk/Gxh++8FgsYy8 c4CyPk87C+TCH6+jEj43Vp+zElCPYbGD/WVF8u78ywIfKrWSKCuCaesps2ZGs6vnacnQnwf/+8B bY12m9zypJYzc79RVgXsGqGKkk4kijPyOdZ6Ypl5Zk/aIA1bmzGRaGpL97hLGlg== X-Received: by 2002:a05:600c:450d:b0:416:389d:a4b6 with SMTP id t13-20020a05600c450d00b00416389da4b6mr5091677wmo.12.1712561603390; Mon, 08 Apr 2024 00:33:23 -0700 (PDT) X-Received: by 2002:a05:600c:450d:b0:416:389d:a4b6 with SMTP id t13-20020a05600c450d00b00416389da4b6mr5091642wmo.12.1712561602800; Mon, 08 Apr 2024 00:33:22 -0700 (PDT) Received: from redhat.com ([2.52.152.188]) by smtp.gmail.com with ESMTPSA id r19-20020a05600c35d300b004163345d2b4sm9448357wmq.36.2024.04.08.00.33.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 00:33:22 -0700 (PDT) Date: Mon, 8 Apr 2024 03:33:19 -0400 From: "Michael S. Tsirkin" To: Gavin Shan 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 Subject: Re: [PATCH v3 3/3] vhost: Improve vhost_get_avail_idx() with smp_rmb() Message-ID: <20240408033143-mutt-send-email-mst@kernel.org> 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> 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: On Mon, Apr 08, 2024 at 02:15:24PM +1000, Gavin Shan wrote: > Hi Michael, > > 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. > > Thanks, > Gavin The thing to do is basically diff with the patch I wrote :) We can also do a bit more cleanups on top of *that*, like unifying error handling. -- MST