Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.179 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796305285; b=xCcsJF48Kx8llwh0/1st9XZsW439mb2s3HAI6uafVgow2R1y4aGxj889/r1LHs2vGo1/ NekbIHVGk2bB0nC3X2ZiHllHsbH40hyTQBtZkNkdQwsb8rSGrhp91jfk76ZyhS+ovVyE4 62IFhngFgVLt0kS75feoLqKTNZBz7gAG8F8eSG6q3CLzuTXUD0pLA2hwUhuFAr8Bs2+vv D2ze1DS5xVy2FAUWx+HfaTTh/LXGvQ7oBbxh5ltvGmoXynWGJ9W4Gn286XOqQtkEmKNIl zswYLJNESeFG8Ipi+tX/wfg5BPkKwhrBW0v16n9RRdhLv1WYdZAlpamtuIzroW4YohA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796305285; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:Content-Transfer-Encoding:MIME-Version; bh=hm8MWCZFYBj3BJqp6PN49dq5QWddoiG9eoCDC5px6M0=; b=FP9Ej0YbhGS/Q5E5Pew0YrrILCDn7UtvgZtWNV+XC0iU4Ib/PAgJ65vkoJ/qV/tjqObE oU6n9XED+Wrc1R9LbQh3i9cBhRj1Pi6KOEBmiz99bWfcbfn7sXqFX7PGKox7eInKpLBX4 tpw0LiYTC4ZMf88pqU1K559dNJuAGj97E1nt+W4EQz77RXOvJDnlxT1bzki+4jTUJvbN2 RsPAww2A5qTZ3vNZy1syw7TuSiW0OQwxOMZDVQrRlGWsA5aEgT7ggjhyy2Q/L25AQN26n HFhz63rjc45rat9Zk1PobJ1kN4RqEkf1rykIHJ43mvMfsm3eHSNAVCym6nD5xnVG+mw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=WBx8dnZ9; arc=none smtp.remote-ip=74.125.82.179 Received: from mail-dy1-f179.google.com (mail-dy1-f179.google.com [74.125.82.179]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 90268606A68A for ; Thu, 3 Dec 2026 13:41:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 90268606A68A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=WBx8dnZ9 Received: by mail-dy1-f179.google.com with SMTP id 5a478bee46e88-38699cf08dfso19948445eec.1 for ; Thu, 03 Dec 2026 05:41:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796305285; x=1796910085; darn=vger.kernel.org; h=mime-version:content-transfer-encoding:content-type:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=hm8MWCZFYBj3BJqp6PN49dq5QWddoiG9eoCDC5px6M0=; b=WBx8dnZ9JB4m79ArElxTIutGREwxW4UAkcxhcwd2UcZHK85BjL9tfXNWCEBH3ZRoOD UOGn50pfZ540buhqq9CnieuAIUodce6tKjlD5OmVgk2E7XOkibPmbj/frAMYkuQ9+J46 Kwy4FwaX00tQXPz5tfhMNVaaeYw885mr6EBgL7CZtlWoq9XzAUInbkoR6zQTSHBNGDO5 fpkOkXNLtztg4YR54LTCNAbDigJ0PQpE/nKY5rxC0TmYlH2uW5mfD6GMzzMHSlilt8Lr LZ15FzoueU9SVTC+Q02wsxKodAWQQ83e8qIp/gXdIxk3HWpB5WEGM2Ie4Vg/TRBCz1wp BbyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796305285; x=1796910085; h=mime-version:content-transfer-encoding:content-type:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=hm8MWCZFYBj3BJqp6PN49dq5QWddoiG9eoCDC5px6M0=; b=gdLvSULwojdwQrXv+HXoDFVj8Aba/WpUD+2XwRgnp8dyNBBthm5JAMoKcOJwM+DSH7 wSZrjrlWriUNHiKT6eQPVbJdwGDfiN327VWZ4YVY1X24w8YeKR6a5HouEHRoUvDm+M1i SxM4Xmt1Oy0ZnPhSeQWUpipo6LYscKKFOdJsjmU8AJnFkYmZDclRovLM93xftJND7wgX /oT+EdCa7qU9Y8C8ZOowdlr5MImNRSaCqz6zpjXntqatl07TWn48H6C3zZiV3tHk8H5J tG74DAe06muZCcXbzwVe9PaH+3VdK5vM2QVgLYcNKzvp4pHzeHETlG3W1Rg+O1ok16zL i8eg== X-Forwarded-Encrypted: i=1; AL+hErEFZMh1D/i3RvW7f7q3Y/+5v7JazBzRrYC79k3QxHtN+3rgeFdDUu8dxEMJnHTVAPG+tO4=@vger.kernel.org X-Gm-Message-State: APuU4Z+M2HOr/dn5d1CYPzW7d5mlrKufLEW7BsQMOePOPjHVHy0SDaO1 p43272+nqKTLsGGEpxFDjvW7Yp7nVe/b35cCjyieCpCLbyQ+q1/7ePEB X-Gm-Gg: AZFdTZfoccbl84qbyC3RpMzWtx5M/xCwkGvagPfL0mmcEwnChDbTD8z9DfGlnUqGSs9 63i3tvsUkqsBI6VTZGF1nFRE6FU1HFqI/f6mq7ler3D3i9I0pZHsbWleB4JohQjcdj/Rjjg7WNb 9YweDGRR5FQQ2+SqfkW9/S2h7q7iZ0awG3/Op5i77gsrzuknE0zfy2MiklUZQy8kUykJQsQQi4R 8+Pd/o2qig3Fdi2t8MrOei1XMFrz8bNgZ2L7L3wJOWAFt1C9f9XBXUn000oRpjVuoabyNTSL5Y1 Uk0oX1TItq6XrDBW5uG2LCcdeMcXKh56X6I8Y2hdV3mTivVpFJ/Y+GlnXmMMCck9Fcoi0CZ7HEn 9u3TXUWv4W3PSmCVUwmB5GwdaQCfpXYmeUaznY83qUClsjEfNar9SVVzgolrDzOYVksHV8i00Fi spdTzbgcZC3IP1RVmjNe99zDL2VVU9xQfUVZHzmUi1Z5prWcWt2HsggE2XK0spVrWFvFzsrhyb4 6FPuvHMhia3NFaZRI9CtsgY1vJxp4XvfDFZGU92+uRKvb4RJ9jiQU4qvCDEJG5AWGucj82pz4jD vbtyGLVbWRoj6qMiqv2mW93PDYbM4HhBiALSLgKrLHX8NbHGRnnJjUf6RULfn5eqaSgpqZ77WKP K2ZAy7Erkywq4qQChAxuD9MaW5U/bk9YkNuGm0nNWcf2WMYdC6HY= X-Received: by 2002:a05:7301:5f14:b0:387:403e:860b with SMTP id 5a478bee46e88-387403e8e3amr3297236eec.36.1796305284565; Thu, 03 Dec 2026 05:41:24 -0800 (PST) Received: from [127.0.1.1] (M106072044160.v4.enabler.ne.jp. [106.72.44.160]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-386aa203267sm89309842eec.0.2026.12.03.05.41.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 05:41:23 -0800 (PST) From: Krzysztof =?utf-8?q?Wo=C5=9B?= To: Stefano Garzarella Cc: Stefan Hajnoczi , Michael S. Tsirkin , Bobby Eshleman , Jason Wang , Eugenio =?utf-8?q?P=C3=A9rez?= , virtualization@lists.linux.dev, netdev@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] vhost/vsock: wait for RCU grace period before rehashing guest_cid Date: Thu, 03 Dec 2026 12:13:52 +0000 Message-ID: <179630003262.439139.12879743486189024236@gmail.com> In-Reply-To: References: <179627895906.335073.17960904565008606745@gmail.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 On Thu, Dec 03, 2026 at 11:43:29AM +0100, Stefano Garzarella wrote: > 1 commit for all of those fixes? > > BTW it seems your LLMs are founding the same issue in the last weeks, > so, please, before posting a patch, can you check if there are patches > fixing the same issue? > > Please test those patches already posted, and comment on them if you > think they are not complete. Hi Stefano, My sincere apologies for the duplicate submission and for bundling multiple changes into a single commit. This is one of my first kernel submissions: I checked torvalds/linux HEAD (d06ce6f1eb5e) without checking net-next and lore.kernel.org/netdev first, and I should also have split distinct changes into separate commits. Going forward I will always check net-next and lore/Patchwork before posting. Please drop/ignore this patch in Patchwork in favor of Nguyen Dinh Phi's merged net-next commit c68d8b4cb2e7 ("vhost/vsock: annotate lockless accesses to guest_cid") and Bilal Hashim's v2 thread (179614298864.2872.3567081270371906851@126.com). Looking through Bilal's v2 and Michael's hlist_nulls follow-up there, two small notes in case they help that discussion: 1. On Michael's question whether synchronize_rcu() runs on every VM boot: on initial VM boot vsock->guest_cid is 0 (kzalloc'd in vhost_vsock_dev_open()), so synchronize_rcu() is skipped and only triggers if user space calls VHOST_VSOCK_SET_GUEST_CID again to reassign an already-configured fd. Still, holding global vhost_vsock_mutex across synchronize_rcu() blocks unrelated VMs' vhost_vsock_dev_release() and SET_GUEST_CID calls during that grace period, and leaving vsock->guest_cid non-zero across synchronize_rcu() lets vhost_vsock_handle_tx_kick() keep accepting TX packets with the unlinked CID until guest_cid is updated. 2. On Michael's hlist_nulls sketch: get_nulls_value(node) != bucket catches cross-bucket moves at end-of-chain, without needing synchronize_rcu(), if other == vsock returns early. One subtlety is same-bucket CID reassignment (e.g. CID 3 -> 259, both hashing to the same 8-bit bucket): if two instances in the same bucket are repeatedly re-added at head via hlist_nulls_add_head_rcu() without a grace period, a concurrent RCU reader positioned on them can bounce between the two nodes without reaching the nulls marker. Also, hlist_nulls_add_head_rcu() updates n->next via WRITE_ONCE() before publishing head->first, so rehashing an existing live node (unlike a freshly allocated SLAB_TYPESAFE_BY_RCU node) needs smp_wmb() between updating guest_cid and overwriting n->next. Thanks, and sorry again for the noise, Krzysztof Woś