From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795603579; b=UUVpFU7zTLvpDov16uCQpdnbxogD6JrHTeBhzI/as+zs7k9WNPvNQZ3jUneQBJmBu3Q7 t+EwNYqYW7u/H/Bcb7mlDFQJe4/Eaod/0/ifp9x/bDQJRew4FNEw8qo3ec9VvbXml5lTl cmCqIo09Jz0UOPzufC8tn+BrimvLiAffneQvPkBv5Zm3cSxvVq7VMfE6ji1alF+OdvIyZ OubR/LYyj7C3PtUpoC9ggNjHbssMTYJP76NsA3oHfXQlsSb66XvptPlGEQtE6ckWyprU3 B0RIFxcOpnHddj4xBIBd9V2UV9fTgAEgiCEmo6eL6WIGNkKkomLazvoPS5J/lEDfnwg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795603579; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received: X-Received:Received:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=J0xbpu1QOArMZW7hFhhmtZ4gk401vyBEZ/yHioUPp3Q=; b=cwKlPUPYK4Y5tuJCtx2xzFQsKGfl2QPInCMdm/CsLUrGi3xjzRAln7QRM1TypKCgERIP EmdtWNaZNwbRrvmYf+svvLLrHUN2Jq9W0GZcSaESuiwnWa5iDdWk2VAE3WUe0yqGmf0HR K1AyOSbyA7CwzOx5o0ojeWBnitUPVFNQE9/3CfIhmpDWOV48V+FLEhIJx0qFFMKHt4Gsf PSMUj2SIvWePRsBK+B1Yn3oORHLkEschx1V9gOhwkVbg5T4nNdlWXGBiA3KLZXmyph9Fo X4kOeTUdig6SQxkL0lF+T7/MTj/h45/jOgSfxpuioEXwksYsEX3c+oYzkEcHBXXWHpA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=iM4wN1pU; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=ZlpO7Bhb; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0F3A606A32A for ; Wed, 25 Nov 2026 10:46:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A0F3A606A32A 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.a=rsa-sha256 header.s=mimecast20190719 header.b=iM4wN1pU; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=ZlpO7Bhb DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795603577; 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=J0xbpu1QOArMZW7hFhhmtZ4gk401vyBEZ/yHioUPp3Q=; b=iM4wN1pU4ZiBlnCjaZtTZAkW15geOZqs5zI9rL182bhz+3mimqhQ1B+maFH80OzZrk07QB hsUUKyrLSML/qiXAMV/mPjyDacvMqP6xpg7GBLzMOjZ4VeNw3WkgRLONbPXF8dFH5IPsgc ICcd6i6A6/VgFi4E3JuA/hATkBf594U= 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-26-beM2cx0sMuCHE16aQymz1g-1; Wed, 25 Nov 2026 10:46:15 +0000 X-MC-Unique: beM2cx0sMuCHE16aQymz1g-1 X-Mimecast-MFC-AGG-ID: beM2cx0sMuCHE16aQymz1g_1795603574 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4994d67d0e3so34727935e9.2 for ; Wed, 25 Nov 2026 02:46:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1795603574; x=1796208374; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=J0xbpu1QOArMZW7hFhhmtZ4gk401vyBEZ/yHioUPp3Q=; b=ZlpO7BhbwPAv9gb+oImo+4CAgE2L5fCiTPULVGvm2wfhNA3C5VKP19CX7rhV8COaf7 kpQu9lCvKOhDUkdd4kAdpSsaPTjU9N7HVOR4NDypQYvHuji8w+0Cox32cuqFQMsSm/Wa 7sDSX7iVr/mIDr/dFQaJHJkvdrQ8W9HfGx1nhKMgwaQh7UdEUg60cW4r96ZZOqI5S59y hMAyKm1U3xSnH4+xocPIWTInnlz/NwZsyr5imOkjd/DVutk8knpnIBUZE99OZfICNK4D AnNyHm27HS3Wo8aEQPnsi/CvhEkkqSOKY1kOUyqLI2QdLQ/TTwk348Ue3h6gXytZIk8q KNMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795603574; x=1796208374; h=in-reply-to:content-disposition:content-type: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 :content-type; bh=J0xbpu1QOArMZW7hFhhmtZ4gk401vyBEZ/yHioUPp3Q=; b=qBmo+QITu6PNZdjR3Hqhc1fD9q0llEg6rXJGStMnKYTq1ZCpA7fjl/BsKP/ILAuB9s IOlMTI8DgywiwPgH3pocYkxDBTT43WTksXoKY8e45iJAquWs6CvxQ/670x4EQ8+G7opk 8/o05m9uBmkEaqkf6v7EgW5xUsIsX9KQjEgtJ2sKTdhKRHrUral+RtgHdwWsmznbc6nS 4xIlKMS7plp6K/I9qpIQ/8xiHjbeZhDDxpEIIiRWmN7rwqXBmBlDdyAKi02F9ztMSGG3 nSzExxpQQW33N3GtqIqv4I7JrUZxkgNe1FVPUdvjwykSwMgOV0kGbDEnzKREC0tvtZeA vsIg== X-Forwarded-Encrypted: i=1; AL+hErFja1TdqWN3bTcePUrqmFS7DXreOC/hTDVsrSKoYuG26Zvq3KaCpqhcuW/V42MIAFcyt+q9vSM3G2WZD1Kq@vger.kernel.org X-Gm-Message-State: APuU4Z9/npqWbKJ06voFsYaG44rsgfvSfG8x29We6o546aZnVfVFCFAr /bIfhEcmNk3m3vOk3G49H9D526UHff4sRP1BVcj/KLv0hJ49s4Iu2b/AIUn+BdEvIGC7Nvqh4aF ikI08UT6K9FqW0/QiDlQJ3p3rDaeH95z5npaOEpedCOziczEV4z5GgsYPc8DK+x7JlJU= X-Gm-Gg: AZFdTZfexg+BGqbJlSWNpqJaur/DW6ADMbEnztaeUsPfq84FFcdEiBMsfLB51Oq/O1y 706A0eeXmcuTgvKxTLN9VGzMUuuLINi/04WDfsTKFatONUzZAX57iE+n/nD7NDgCJyolHL+ZLpr ej9/cHrodL21+ptlEFaWm6tD3u1B1iqlyMLNLJrK9Vu/fbmk3aehF1dA9hF6ZX2MNuapOqmemwu ExBK8nOqqMtcLRbd7IOVpvbOfX3u/MswUiQTAj458UZ+fHM1viyTAMxqv2aTOgK3LY6/3np1H8A 1y88/hSRqW1rrLhh69ix2jsfqdRu5WshoNuk9Y+fWZRYKgfG/CNe4ZgQwLEpb+uz3qo24Rka6io EfT+KjuZu2vXW5mXklmT+LGiJBWvfV5xLlgc99WZrHpY= X-Received: by 2002:a05:600c:5246:b0:4a7:9006:b176 with SMTP id 5b1f17b1804b1-4bb887fe892mr375982895e9.7.1795603573928; Wed, 25 Nov 2026 02:46:13 -0800 (PST) X-Received: by 2002:a05:600c:5246:b0:4a7:9006:b176 with SMTP id 5b1f17b1804b1-4bb887fe892mr375982235e9.7.1795603573317; Wed, 25 Nov 2026 02:46:13 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:1529:2e00:86ec:bef7:c309:ba1f]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb853a9687sm568878595e9.10.2026.11.25.02.46.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2026 02:46:12 -0800 (PST) Date: Wed, 25 Nov 2026 05:46:09 -0500 From: "Michael S. Tsirkin" To: Li Wang Cc: Miklos Szeredi , German Maglione , Vivek Goyal , Stefan Hajnoczi , Eugenio =?iso-8859-1?Q?P=E9rez?= , fuse-devel@lists.linux.dev, virtualization@lists.linux.dev, linux-fsdevel@vger.kernel.org, virtio-fs@lists.linux.dev, stable@vger.kernel.org, Sashiko Subject: Re: [PATCH] virtiofs: fix lost reply due to unaligned cache line sharing Message-ID: <20261125053116-mutt-send-email-mst@kernel.org> References: <20261125093908.48619-1-liwang@kylinos.cn> X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261125093908.48619-1-liwang@kylinos.cn> Thanks for the patch! yet something to improve: On Wed, Nov 25, 2026 at 05:39:08PM +0800, Li Wang wrote: > virtio_fs_enqueue_req() maps fuse_req::out.h for DMA_FROM_DEVICE in > place. fuse_req comes from the "fuse_request" slab with no DMA-granule > alignment, so out.h shares a CPU cache line with the waitq field. > request_wait_answer() updates waitq while the DMA is active. > > Note: Sashiko correctly identified the bug, but the resulting behavior > is not as described. Sashiko reported that unmap invalidates this shared > cache line and drops the waitq updates made by request_wait_answer(), > so wake_up() walks a damaged list, the waiter never runs, and a later > wait-queue operation can panic. That is not what current arm64 does for > this buffer. fuse_out_header is 16 bytes and does not cover a whole cache > line. dcache_inval_poc() uses dc civac on that partial line: a dirty line > is written back and then invalidated. The waitq update is kept, but the > out.h written by the device is lost and reverts to its initial all-zero > values. virtio_fs_verify_response() rejects that header, because > its unique and length do not match, and the request finishes with -EIO. > > Place out.h on its own DMA granule and start waitq on the following > one. Allocate the slab at __alignof__(struct fuse_req) so those > offsets are granule-aligned in memory. Coherent architectures keep > ARCH_DMA_MINALIGN at the natural alignment, so fuse_req does not grow > there. The padding is compiled in only when virtiofs is enabled. Is this not all completely theoretical for when virtio fs device is on a real hardware chip as opposed to running on a cache coherent cpu? With LLMs hallucinating real life impact? But anyway, this is not how one should write commit logs. Should be, for example: Currently .... as a result, when ... then ... but ... so we can not ... . To fix ... as a result .... Tested by ... > Fixes: a62a8ef9d97d ("virtio-fs: add virtiofs filesystem") theoretical cleanups, as I suspect this one is, do not need a fixes tag. > Cc: stable@vger.kernel.org and accordingly it is not appropriate for stable. > Reported-by: Sashiko > Closes: https://sashiko.dev/#/bug/linux-41eaaf0f-0eb9-4809-99cf-5f83439eb848 > Signed-off-by: Li Wang > --- > fs/fuse/dev.c | 3 ++- > fs/fuse/fuse_dev_i.h | 18 ++++++++++++++++-- > 2 files changed, 18 insertions(+), 3 deletions(-) > > diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c > index b198cc729cba..00e637d5e552 100644 > --- a/fs/fuse/dev.c > +++ b/fs/fuse/dev.c > @@ -2342,7 +2342,8 @@ int __init fuse_dev_init(void) > int err = -ENOMEM; > fuse_req_cachep = kmem_cache_create("fuse_request", > sizeof(struct fuse_req), > - 0, 0, NULL); > + __alignof__(struct fuse_req), > + 0, NULL); > if (!fuse_req_cachep) > goto out; > > diff --git a/fs/fuse/fuse_dev_i.h b/fs/fuse/fuse_dev_i.h > index a8eba46a3e51..e42f3dc30d3b 100644 > --- a/fs/fuse/fuse_dev_i.h > +++ b/fs/fuse/fuse_dev_i.h > @@ -12,6 +12,18 @@ > #include > #include > #include > +#include > + > +/* > + * virtiofs DMA-maps fuse_req::out.h for DMA_FROM_DEVICE in place. > + * Put @out on its own granule and start @waitq on the next one. > + * fuse_dev_init() allocates the slab at this alignment. > + */ > +#if IS_ENABLED(CONFIG_VIRTIO_FS) > +#define FUSE_REQ_DMA_ALIGN __aligned(ARCH_DMA_MINALIGN) > +#else > +#define FUSE_REQ_DMA_ALIGN > +#endif virtio fs specific code in fuse headers. not good. > > /* Ordinary requests have even IDs, while interrupts IDs are odd */ > #define FUSE_INT_REQ_BIT (1ULL << 0) > @@ -94,10 +106,10 @@ struct fuse_req { > struct { > /** @out.h: The request output header */ > struct fuse_out_header h; > - } out; > + } out FUSE_REQ_DMA_ALIGN; Ugh. You want __dma_from_device_group_begin/end Maybe. If it even is ok to dma here directly. > > /** @waitq: Used to wake up the task waiting for completion of request */ > - wait_queue_head_t waitq; > + wait_queue_head_t waitq FUSE_REQ_DMA_ALIGN; > > #if IS_ENABLED(CONFIG_VIRTIO_FS) > /** > @@ -118,6 +130,8 @@ struct fuse_req { > unsigned long create_time; > }; > > +#undef FUSE_REQ_DMA_ALIGN > + > /* One forget request */ > struct fuse_forget_link { > struct fuse_forget_one forget_one; > -- > 2.34.1