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 36C6CC6FD1F for ; Tue, 26 Mar 2024 09:39:25 +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=lAAj252qMj41xRWzD1yCPFm1g0U+tijFkxqh6MolEn4=; b=Y4sf4K5DZUaXJ+ ypKs3MDwsplKYBL9tzdzapprmy1ySaVafJxNzh7u/Cs53PNGbABACbfmZrFSM5r/AJpNWtk/ciQOu gWr5ctOjoC4ylJTwK+m2GwIu/Se2TXndEZnPESHUoHQIuCDlpnmNQbyC+KX7YHooAp/Cl3k7sr4SI dZoJyrZ/PA3vX6vKbm8kL7Y0MDG28LQV5dAhxwY9W76KCF1jnCdZtccWgIdmruucaBw1FJBvjTfnB 8kMtovYhssjfcxLlgm2svcs0uMKzBAXdKJcX+PH++5s3ipiUASPpwK57nSbQnysIdiHau1xDFJsud MLUsIUZYFN3Anoz2hdbA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rp3Gv-00000003rBA-0Y2N; Tue, 26 Mar 2024 09:39:11 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rp3Gq-00000003r9K-28oY for linux-arm-kernel@lists.infradead.org; Tue, 26 Mar 2024 09:39:05 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4148c09ec6bso49365e9.1 for ; Tue, 26 Mar 2024 02:39:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1711445941; x=1712050741; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=MBfa7bD+DHZlqzDRNnmeC7FlWZiV7yjPXXmtlDzPpsM=; b=fh9N512z93G9le28B5ivYWgh9NfadolfwkrLRcbsUSdjF1AMLMSjVV39hP6kYR3DbN mQLw0XYrNVgjSyLr0xO7NcoHICaITfGNlJqimKVjx31I74a6lTsZlAGVfMTqZKnuXgGK TLiPJRioyz1+bjQ4dK29tQJMdGOzsz8DL+SMIREkCu/q5m/Ki+ixgvN9y4z8AjolKtS9 t5940XEOYY/I7jcTrcw9lUTWgnI5fLdlqwRYlXIlxEYLsUYhL/Ex7OPYAuTYAwkDG4/R 4SGGU2qrM/L9/hBHwNakzKPVOKzDJoL3QhA5s6MgFq56tOB4sYnC82q+Sedm6kE1fHvR IoKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711445941; x=1712050741; 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=MBfa7bD+DHZlqzDRNnmeC7FlWZiV7yjPXXmtlDzPpsM=; b=gVJR0uOZODua88x5As4SyeMh5o+4MqGjzgW1WE5HWNNWHdDR+IpgpobfG5nrIsc+/7 +N+45rI7Uz3w1s7pejFS0fr/2sekOVfhAgiDOZvkvYHIpcRddVAH+ZH8Qp/Tc2wQlx8x Re9VuAGciYkEAUFWaYWglgOGYOwn8ZGDqF/dRbqezfI9W3hvy5ydwX+5g7RDl0Q5Xlud KyEj1L38fbDxzuws2TRnojKN9pnY/Zg9boUtsAbaRkcQ7rPqp/l8kbwzxvlt2wfqBGmM HnEG5m68Ilp/VWT8kvsOCtuxdd28Hv5b1bY5TE3TDeS9Q3pwhzdMw6TWK7KE/KypAqkz zOWQ== X-Forwarded-Encrypted: i=1; AJvYcCVz+RFZq0hOIB9WmHj/FNqFiiB/8p3jPV5H/ZrB7Fa1CVVuo1KQbCvD2eCvxgQ7yUnpByylO3m37Htc2gMygxL5bKrESwHdyA2XZFCqoyQjql6Ui6s= X-Gm-Message-State: AOJu0YzvB9/mcKINrZUAyBWmNw40jNNJ3TCOOh0JeZnQfPT2ReCI7rHF XqzJfi0lGCNPM7v+ox4WrAzUimPNqLBzNBT/cIgfF2u6muEpew94JlWP6ybaTQ== X-Google-Smtp-Source: AGHT+IE+q/VP+Y5OuAlcSHXpSI2sdtUwAKOteOf+H3BRkrfJpESuCtSgjAvRcoND0mJ6ryAOmNSbIQ== X-Received: by 2002:a05:600c:6cf:b0:414:908c:460d with SMTP id b15-20020a05600c06cf00b00414908c460dmr19791wmn.7.1711445940511; Tue, 26 Mar 2024 02:39:00 -0700 (PDT) Received: from google.com (105.93.155.104.bc.googleusercontent.com. [104.155.93.105]) by smtp.gmail.com with ESMTPSA id g23-20020a19e057000000b00513d244005asm1491791lfj.199.2024.03.26.02.38.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 02:39:00 -0700 (PDT) Date: Tue, 26 Mar 2024 09:38:55 +0000 From: Keir Fraser To: "Michael S. Tsirkin" Cc: Gavin Shan , 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: 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> <20240326033809-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240326033809-mutt-send-email-mst@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240326_023904_580279_D5D188B4 X-CRM114-Status: GOOD ( 32.37 ) 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 Tue, Mar 26, 2024 at 03:49:02AM -0400, Michael S. Tsirkin wrote: > 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? arm64 is always built CONFIG_SMP. > > 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 More than that, 49664 % 256 == 0 So again there seems to be an error in the vicinity of roll-over of the idx low byte, as I observed in the earlier log. Surely this is more than coincidence? -- Keir > > 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