From mboxrd@z Thu Jan 1 00:00:00 1970 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 3177833123E for ; Tue, 6 Jan 2026 14:50:08 +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=1767711011; cv=none; b=oZElPKPRKUgZcX+UjTkN6yGOEOEW3F8LMaS3r2P6BJD8i+5TXT4XQyYLHhz30JQVinLntkuWgdjabz7eG+aBKCRfVU7eTPeoyfSMEEOXozbVndgA5JZpZARUIRd1EYmZp/uIiY6zTSrdXtK1GIulo65MSlbDw/v0XUiLyZBoW3w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767711011; c=relaxed/simple; bh=RqfJjI32FdZ7MpeaFMqvXp4bO7LyOB4RofYVb7BWxmE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BEuA4N7Fgl/qJfZp1vNNGm98QZU05uJn8yv+J+YuiKHc9O1VZeMSJm/lU+opVKtTvIirLpmGIj4IDIoGZkmWGR9fXH+cATJntE440ikjC20Np3Ih2+5Iywur73lcbQEAZrHZawMTIIjLWMdmg9Pr1k/FxOkg8HlGAdcnyiDuUgg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=Q6N9B7rq; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=aoAHoHrm; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Q6N9B7rq"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="aoAHoHrm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1767711008; 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=0jRp3cPG5jRtvX04esVBCT8Xv2J8JEx5kZGeR0bhCr4=; b=Q6N9B7rqBOy0edULfnPlNXw7pyLqnuaZ2kNeNi/0yvEpuUlPAM74/ALShcP0D8LK8pl7aE RyAIL7DkJq/N2Ik4ubtpFZ3y3dt9u5EJyLMNZ0u8EGrDZmXZAP3Y4N4X5EElvXoGhAjASm 9e+El8SlpopjnrZbBE0ZpFD7PJKDNUA= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-396-aPbzVlL3M7qG_iEnNhQfJQ-1; Tue, 06 Jan 2026 09:50:06 -0500 X-MC-Unique: aPbzVlL3M7qG_iEnNhQfJQ-1 X-Mimecast-MFC-AGG-ID: aPbzVlL3M7qG_iEnNhQfJQ_1767711006 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-477c49f273fso10752875e9.3 for ; Tue, 06 Jan 2026 06:50:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1767711005; x=1768315805; darn=vger.kernel.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=0jRp3cPG5jRtvX04esVBCT8Xv2J8JEx5kZGeR0bhCr4=; b=aoAHoHrmwMZxBs2Qp69OPcSFyaa1ig8teHOPJlTckRJ36lo6MAUEbtcC31JPG6FdXt r8wn0YoUmXby44f4lHbgR1uSQGC250mufP2o8GPX7n8jjsh3a/4d0o7zyVeYiY7or4wP 5fNAD2ypUG6iOfyMx50WuECY+vE25qV7VYCmDh2JcvSmkuCmk0jV6tgIRzf+JgvRWkZV /tyDnQ8+btDHVPo2V53lrmTUi6h1X5KXIFtPigLUhEhrf0OZfRoIPXQSNa8Sq6KPyslf ekrDkyLn4FoULpuMDI1pdSm/qjS0v7F1JRtZwgfRIfIsynaHmQ0FNYWqHLh8MavZgcjF OJNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767711005; x=1768315805; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0jRp3cPG5jRtvX04esVBCT8Xv2J8JEx5kZGeR0bhCr4=; b=HczsE/EDpv3uXkGZTykYwzzVgw+g8lp5hCCb9iBgftGoP2V1uoU8T0aqaJtZ6M368B 6iLpDIozV9+IkKVSZ6qbi7ufbjm+jaQu7A/VQ99zKn9JWqqcJqknHgw+BEMycYyunYZ8 5p8T9BtKv3hUYmFpJeasXfMuyLImYHgYcVENqL0NHMqM025lBb0QJf8QRGGMWkwKLXyM iqk72wFsdIw6kfcYIlQyRrn8QhkBSxKctlOGgqGUL86wwaZ1X3V64HNXbhamQ/7g5L6+ OREkSuRUsMdu6YpOxqxuDc3i0WLRMQCbQdOux0rbt1piOSIQaA6CR3mZMp8eoi2emKqW Esig== X-Gm-Message-State: AOJu0Ywn4ZMW5rrrdtDDMlZfLxCfW8P68h05tRk+ziYNPE5DSpjz1MLW KgF+ebitDkDIGfp/gsnLCcwIn1w3otTxAoJJMuQjC8URuldwD6I3YmSsXesRPK3wBntxajyGHgj 02fc3706dZ1tf03x0/RfDpIGYs6ib2TkvHZ9c05WJUsFPpAocDTao6SjVDZnlYedTJg== X-Gm-Gg: AY/fxX5/8kvc4A4w9LrjVPvRFfe0y94Ld8nGyZmf+jd1yWbpSatj2Z48Hdti+kQQ3X2 cAYHiWrg1R3VT/bdK/aD151oWsSycP/BllqYohGluyTQzDSiapy9Fq53djQ/R2/cQEBoJXia0ub /XVwBALMZGySddzXo+9xQsUiit8+03qfQQDbsPy02ECKxa0ay8hjCRz5ptI7Y5R6I+0ADPIXXyu mUtOnqXqnnjsHUXMyicuE6I7MC4ZYQ5ZwT2NXgu60q2el8EVOK3LLFbOo77fIsXh0QDDd6MHRam Ul+hae3nu7yooSCc3IoWUwIUomLy8iPrC4L9HQslb9NkwQyXbB7W17SGVrDiOZR3/LYXu9bjDgs L81jE49raCxMjLRhD+6Am4u4OvIX/M5xt2A== X-Received: by 2002:a05:600c:c0c5:b0:47d:6856:9bd9 with SMTP id 5b1f17b1804b1-47d8383d75cmr7820595e9.23.1767711005508; Tue, 06 Jan 2026 06:50:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFXHeGoEH1PxicAu3pvp2IKmLzneQBM5bSFfOKMFfLat4mQRdOWLJ6nIuVR4bStC0oG3LJdHw== X-Received: by 2002:a05:600c:c0c5:b0:47d:6856:9bd9 with SMTP id 5b1f17b1804b1-47d8383d75cmr7820345e9.23.1767711004990; Tue, 06 Jan 2026 06:50:04 -0800 (PST) Received: from redhat.com (IGLD-80-230-31-118.inter.net.il. [80.230.31.118]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d7f695956sm48129575e9.6.2026.01.06.06.50.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jan 2026 06:50:04 -0800 (PST) Date: Tue, 6 Jan 2026 09:50:00 -0500 From: "Michael S. Tsirkin" To: Stefan Hajnoczi Cc: linux-kernel@vger.kernel.org, Cong Wang , Jonathan Corbet , Olivia Mackall , Herbert Xu , Jason Wang , Paolo Bonzini , Eugenio =?iso-8859-1?Q?P=E9rez?= , "James E.J. Bottomley" , "Martin K. Petersen" , Gerd Hoffmann , Xuan Zhuo , Marek Szyprowski , Robin Murphy , Stefano Garzarella , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Petr Tesarik , Leon Romanovsky , Jason Gunthorpe , Bartosz Golaszewski , linux-doc@vger.kernel.org, linux-crypto@vger.kernel.org, virtualization@lists.linux.dev, linux-scsi@vger.kernel.org, iommu@lists.linux.dev, kvm@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH v2 10/15] virtio_scsi: fix DMA cacheline issues for events Message-ID: <20260106094824-mutt-send-email-mst@kernel.org> References: <8801aeef7576a155299f19b6887682dd3a272aba.1767601130.git.mst@redhat.com> <20260105181939.GA59391@fedora> 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: <20260105181939.GA59391@fedora> On Mon, Jan 05, 2026 at 01:19:39PM -0500, Stefan Hajnoczi wrote: > On Mon, Jan 05, 2026 at 03:23:29AM -0500, Michael S. Tsirkin wrote: > > @@ -61,7 +62,7 @@ struct virtio_scsi_cmd { > > > > struct virtio_scsi_event_node { > > struct virtio_scsi *vscsi; > > - struct virtio_scsi_event event; > > + struct virtio_scsi_event *event; > > struct work_struct work; > > }; > > > > @@ -89,6 +90,11 @@ struct virtio_scsi { > > > > struct virtio_scsi_vq ctrl_vq; > > struct virtio_scsi_vq event_vq; > > + > > + __dma_from_device_group_begin(); > > + struct virtio_scsi_event events[VIRTIO_SCSI_EVENT_LEN]; > > + __dma_from_device_group_end(); > > If the device emits two events in rapid succession, could the CPU see > stale data for the second event because it already holds the cache line > for reading the first event? No because virtio does unmap and syncs the cache line. In other words, CPU reads cause no issues. The issues are exclusively around CPU writes dirtying the cache and writeback overwriting DMA data. > In other words, it's not obvious to me that the DMA warnings are indeed > spurious and should be silenced here. > > It seems safer and simpler to align and pad the struct virtio_scsi_event > field in struct virtio_scsi_event_node rather than packing these structs > into a single array here they might share cache lines. > > Stefan