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 54EF9C54E58 for ; Mon, 25 Mar 2024 07:35:01 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HbF42RvTrixDCd3TkdDe2IJAYjO43ZsEJW3XE+D4l6Y=; b=D0SmPcSlofbaBL sAuFoj4uhL3aYZdIehoK9M6Ut35SVkyj1I9BZixZDLKRLW/abh7Muj7E8hYlCYTbTVYPFPER1HfVK rDLyYzLHX+ETB8BNVImAVw5TMuIy7Y6Q+iHgOIftnyv22KUD8QE987z5OE06Vn1rDp0ZH3Au/IMXx QbXfKLHMffYnODi8tfuMvIN+PAUAUM1KBpatwc4IKQLg1xRNJr1MfsxB9iCX10AkH+sFhKkGlg5Wr adGVsQJCnh1br8TYf6OSEl9t5vA/FpHOpaUWNV3wrhygfRG1CbzyBYCYnMZUFiXWzkRs39l835JM7 mrO+Jm4ZsAfn/nu9X9Kg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1roer1-0000000Fwag-3CFQ; Mon, 25 Mar 2024 07:34:47 +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 1roeqy-0000000FwYt-0Yhk for linux-arm-kernel@lists.infradead.org; Mon, 25 Mar 2024 07:34:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711352080; 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=6I4mGWtPnXl+rCWErFK37GiocqArlyDhDISrag+E6MY=; b=i1R2wcGTd+Y6Lm1ZGbeZRJxcbz5IFNUilNqnSvsQfwzLjoxRJJENXbZXGDNifelVVvW59g H7w29KRs+hd17UWlOyp3aUhpGbFrp48YHetepjmpKeGhKjI8YSKRx1ZxHy/Qz03Yhhk5vs P3JX6x41/Rq3gf97d1So4gccx34HqCI= Received: from mail-oa1-f69.google.com (mail-oa1-f69.google.com [209.85.160.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-54-h_Wt1HjRMuSM_qwKLf9lBw-1; Mon, 25 Mar 2024 03:34:38 -0400 X-MC-Unique: h_Wt1HjRMuSM_qwKLf9lBw-1 Received: by mail-oa1-f69.google.com with SMTP id 586e51a60fabf-229fd805944so1752283fac.3 for ; Mon, 25 Mar 2024 00:34:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711352077; x=1711956877; 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=6I4mGWtPnXl+rCWErFK37GiocqArlyDhDISrag+E6MY=; b=FoS2NOAG/FAy9JxGEvgpi1lLzMZJAzQEzEsXUsdOC2KtbxgpxNMF+gP0VLqafvN7ea fNdGAw2AryB31dpYSncR4AOCeud7YC0FVovsxyCGtWAWXzuBOAc3O1tv5W/EPBbkdESY WavMwNfSGyu8u/ALVZr/Fc+MudLXSlFb8WTr8BhwHvvVBQbbgRRlwVBplzuV3l+OyBTK aQCnyVHAbZZSuT3D1vivrRY9KK26EY0yCbtKHMzys2WZrqXIaI+2GSIODQaji17T3GSO b5R1PeOTgoguDojqcTm6rOv0xKV7EffkPUbHZhX5Zikhv/32OqfcGz49cApKQHn2kZ6N TLxw== X-Forwarded-Encrypted: i=1; AJvYcCWaCmHKWRBi/UmNhhLKUfZZRgKHeYUKxNqsYZI+YwJYpqE27wwdO+B78Rw3+DPk9aDJnF908uQioiLIWISQrgPhrm57lrw0mk/fHd/fvbYarXGAfpo= X-Gm-Message-State: AOJu0YwGAv99sg13zKK0m/0Al2vCkJDUfi2A4DsZKrO8Uaa8Y8c8uHov JhOmM3c7t+hqzSTkqKI4/n10eCXkrX0YEbaQontyCw0sz4z+RmB9Aq6lBOsrI1c2CMKc7wcq+u/ ZaBN6GifmGTDEaNP90xraSUtVVqFv7EU1nHgQNX6OWS38cbRXhIw22+mpbbxiWmS40k1eZiva X-Received: by 2002:a05:6871:288e:b0:22a:2446:353f with SMTP id bq14-20020a056871288e00b0022a2446353fmr3755167oac.11.1711352077659; Mon, 25 Mar 2024 00:34:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFKY6GYp1/XIaWHrTUl2r4qAWkWvRiG3Ehn1RpYbN3BtHiFYE6R3jh1TKiJs6ZlTqhiC8/SJA== X-Received: by 2002:a05:6871:288e:b0:22a:2446:353f with SMTP id bq14-20020a056871288e00b0022a2446353fmr3755157oac.11.1711352077282; Mon, 25 Mar 2024 00:34:37 -0700 (PDT) Received: from [192.168.68.51] ([43.252.115.31]) by smtp.gmail.com with ESMTPSA id c17-20020aa781d1000000b006e6bfff6085sm3766624pfn.143.2024.03.25.00.34.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 25 Mar 2024 00:34:36 -0700 (PDT) Message-ID: <1dcec730-ec26-46f4-ba4c-06101fcc599e@redhat.com> Date: Mon, 25 Mar 2024 17:34:29 +1000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] virtio_ring: Fix the stale index in available ring To: "Michael S. Tsirkin" 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 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> From: Gavin Shan In-Reply-To: <20240320030215-mutt-send-email-mst@kernel.org> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240325_003444_466838_CB007CDD X-CRM114-Status: GOOD ( 13.07 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. 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. 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 avail_head: 000 062 001 047 <-- : 015 112 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel