From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D0E21C54E67 for ; Tue, 26 Mar 2024 07:49:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7Yd5z4hk2IYTBsYeHMpDytFt6uu8VSYWBpJoYUHZbBs=; b=pSc9UODlqhnwt2 y1/hggyYbYGCXPWKbSGVTc6yKh3HVk3V8LXiGIJR3O+V00dwMfGw+gZoBgqGnFTAAHYkjVrLNEdCH XuIM7q32P3jpj+nOvxp2CpaYD15mP0TqFswAGe37ZWn+GlCuAwawtmrc3lzTUSdyBXsLtnjgMPs3/ I0gsGxiVdiNwu3oWFuWNVaR5qCvorP4GvIERlAujDGtO/Q818OSrpiJ896Ek9bfKl0J3ZclLsODOS ejVNSqzKQVoNusyYZLeDSjY/YRZmBE3wrAv/cPDLXuaR5Ns0SNcTKYgFxGVzW3oKfywyr0vqUNUkK 9af5XM2HZvjU2stYv24g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rp1Yb-00000003Utc-0Cxp; Tue, 26 Mar 2024 07:49:17 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rp1YY-00000003Uso-2XYg for linux-arm-kernel@lists.infradead.org; Tue, 26 Mar 2024 07:49:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711439349; 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=S1Uq7z4YPDu1tfLjrShk+kcEkEswJznbeM6Yc8BuQDY=; b=EgmkFOMhPPgmvLV2A9yV3L7OvFtJ+6f7lzKZU0HzePl8trQLARNFg0TV3zGC43/lU+ruxZ gTeWwIA2Aw4x6GXO7cj7wUXc+1xCVkD9mxeCRL2D4OmlKE/uZRzv9yO9Q3FcCebiO9JGmQ k21guD1UczypzDNk3jiNeylQNU0cBuI= 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-656-88W9sJazPMGrtbM5HVUl2g-1; Tue, 26 Mar 2024 03:49:08 -0400 X-MC-Unique: 88W9sJazPMGrtbM5HVUl2g-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-33ec06aac83so3499824f8f.2 for ; Tue, 26 Mar 2024 00:49:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711439347; x=1712044147; 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=S1Uq7z4YPDu1tfLjrShk+kcEkEswJznbeM6Yc8BuQDY=; b=uzbpEOVYFsWkgwyHdHNLEg5XcVzPEz6PMD9claBmGoEEbtZMrua72QQI9tD0sPA1lw GCRrTLenHiScldozdP6QwD22H3nJuQdeNgJcf/x/jbCXCc5I4MvFsp7p+uH4U7SvfAXT cx5DOhV/AV3HRsEyRttZdE0iS3fHhjXMXTCx7JmwqbqC6M0YUG12ZcwNJS+u7vOUFU0z LL1jacG4+khZyysl8eY9F2TxNImDdYLqqYY+DcBgdyMEnr7Xd2Ln2CB/2HZvoaL4mvoN RVyOS7EzBqlFh+EGgU0o7FA3Zr1GSkfQgcD8ubGbodCyfod7Am3q9XliXK1muV363qx8 EkPg== X-Forwarded-Encrypted: i=1; AJvYcCUW7cMK4eI+WCUqiExWrWkKCWk1LhHa3UwRPdPopKtDUQl4xRIYFYdJ1oTyFeYxsw7FubSLJWcH4W63CFWgF4pr3VYK0mUsLiqVQVTDpfXaLflJ09c= X-Gm-Message-State: AOJu0YzcEGVPdkP/CLTu/a/UmmPQryk/mLzdNflc71vDOtMwezxxXOzF 9Q559gAOKth0CYiInOHLEFLxpfvKyD4GdxjoH+FzExg9MEGJqtMUEhHWOqGUCXA6L5V55cnQPOf 5t6jjgwadQ8NgTmHfbkDzLjigUnASwZXYAmtCWtAZGqNz0Sdzr8LtzkiifGkmQRtsQyUp2twpH7 3pbJCh X-Received: by 2002:a5d:6e01:0:b0:33c:deed:6745 with SMTP id h1-20020a5d6e01000000b0033cdeed6745mr7043782wrz.13.1711439346711; Tue, 26 Mar 2024 00:49:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEDZ76bKRqpYhB8UU97OH4GlDC/CvSpy1jx/iBj2k9Bsb4KVn/8tVO+C3bjtFRt0oGNKjWMFw== X-Received: by 2002:a5d:6e01:0:b0:33c:deed:6745 with SMTP id h1-20020a5d6e01000000b0033cdeed6745mr7043768wrz.13.1711439346203; Tue, 26 Mar 2024 00:49:06 -0700 (PDT) Received: from redhat.com ([2a06:c701:73e8:4f00:4a9d:49ee:c7ac:ea36]) by smtp.gmail.com with ESMTPSA id u13-20020a056000038d00b00341c934ae4asm6449808wrf.75.2024.03.26.00.49.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 00:49:05 -0700 (PDT) Date: Tue, 26 Mar 2024 03:49:02 -0400 From: "Michael S. Tsirkin" To: Gavin Shan Cc: Will Deacon , virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, jasowang@redhat.com, xuanzhuo@linux.alibaba.com, yihyu@redhat.com, shan.gavin@gmail.com, linux-arm-kernel@lists.infradead.org, Catalin Marinas , mochs@nvidia.com Subject: Re: [PATCH] virtio_ring: Fix the stale index in available ring Message-ID: <20240326033809-mutt-send-email-mst@kernel.org> References: <20240314074923.426688-1-gshan@redhat.com> <20240318165924.GA1824@willie-the-truck> <35a6bcef-27cf-4626-a41d-9ec0a338fe28@redhat.com> <20240319182251.GB3121@willie-the-truck> <9500adaf-0075-4ae9-92db-7e310b6598b0@redhat.com> <20240319203540-mutt-send-email-mst@kernel.org> <3a6c8b23-af9c-47a7-8c22-8e0a78154bd3@redhat.com> <20240320030215-mutt-send-email-mst@kernel.org> <1dcec730-ec26-46f4-ba4c-06101fcc599e@redhat.com> MIME-Version: 1.0 In-Reply-To: <1dcec730-ec26-46f4-ba4c-06101fcc599e@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240326_004914_748951_6DCF48E3 X-CRM114-Status: GOOD ( 25.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Mar 25, 2024 at 05:34:29PM +1000, Gavin Shan wrote: > > On 3/20/24 17:14, Michael S. Tsirkin wrote: > > On Wed, Mar 20, 2024 at 03:24:16PM +1000, Gavin Shan wrote: > > > On 3/20/24 10:49, Michael S. Tsirkin wrote:> > > > > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c > > > > index 6f7e5010a673..79456706d0bd 100644 > > > > --- a/drivers/virtio/virtio_ring.c > > > > +++ b/drivers/virtio/virtio_ring.c > > > > @@ -685,7 +685,8 @@ static inline int virtqueue_add_split(struct virtqueue *_vq, > > > > /* Put entry in available array (but don't update avail->idx until they > > > > * do sync). */ > > > > avail = vq->split.avail_idx_shadow & (vq->split.vring.num - 1); > > > > - vq->split.vring.avail->ring[avail] = cpu_to_virtio16(_vq->vdev, head); > > > > + u16 headwithflag = head | (q->split.avail_idx_shadow & ~(vq->split.vring.num - 1)); > > > > + vq->split.vring.avail->ring[avail] = cpu_to_virtio16(_vq->vdev, headwithflag); > > > > /* Descriptors and available array need to be set before we expose the > > > > * new available array entries. */ > > > > > > Ok, Michael. I continued with my debugging code. It still looks like a > hardware bug on NVidia's grace-hopper. I really think NVidia needs to be > involved for the discussion, as suggested by you. Do you have a support contact at Nvidia to report this? > Firstly, I bind the vhost process and vCPU thread to CPU#71 and CPU#70. > Note that I have only one vCPU in my configuration. Interesting but is guest built with CONFIG_SMP set? > Secondly, the debugging code is enhanced so that the available head for > (last_avail_idx - 1) is read for twice and recorded. It means the available > head for one specific available index is read for twice. I do see the > available heads are different from the consecutive reads. More details > are shared as below. > > From the guest side > =================== > > virtio_net virtio0: output.0:id 86 is not a head! > head to be released: 047 062 112 > > avail_idx: > 000 49665 > 001 49666 <-- > : > 015 49664 what are these #s 49665 and so on? and how large is the ring? I am guessing 49664 is the index ring size is 16 and 49664 % 16 == 0 > avail_head: is this the avail ring contents? > 000 062 > 001 047 <-- > : > 015 112 What are these arrows pointing at, btw? > From the host side > ================== > > avail_idx > 000 49663 > 001 49666 <--- > : > > avail_head > 000 062 (062) > 001 047 (047) <--- > : > 015 086 (112) // head 086 is returned from the first read, > // but head 112 is returned from the second read > > vhost_get_vq_desc: Inconsistent head in two read (86 -> 112) for avail_idx 49664 > > Thanks, > Gavin OK thanks so this proves it is actually the avail ring value. -- MST _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel