From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.182 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796305285; b=RGRUjfkEjj05bdFo4IwcNeHMOAYarUXXeEjyE42Y4d8o5zrVPlf/FM0O2hJBWMeb+Qat LVhjXuQs3nP4grB1w4hh4il0o9iMvDvD11eUVFFQ60ITCij2kMry6i0T+jTlRXa1VBj6j xwlx1H+pNbNT37Jbk9ru7CEarFDFZ8IL3SfSciYFJ4rRTGoUCHFS89yH7pv8bSMBQIoZP CvLdtVeYKyB20Os9CRvPcLwC8YQgopAKpyeA+AnUnyzjDxZTLucon+2DiFoDU3VlL2mgc tHe8Yz9vmlU5/ymY0+stdX2dd4SSulh7SV2FyTUyX88XRGi0B831dOhbWm4NhP91hrA== 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=yVdjtkmsRbTg3At7NqMYzV6+vBppfyDq+hxElXyKisoQHtztxh9Zlt1mv1TA7QPf/iaF JhB+GXz3DO/nXHHMhVx8cai37ywsUomdyI9TpivFgRXrNClv1lbAxN8rGjYVItDBf3qZt 62V5LUQdCuGeIKMQBQRAwERu2FT9r/+PvEva9FCdYVtRV+n2iXzJs4rFGqxhSAyl+vvZ7 QRF6vkb3L8Zhjb6mT1QWz1CHvuFerQfBUqcc1eeWTIsk7g2K6TCnOU7uriCqeKVsCPNuI uhxQLsj6VLnGPisseROoHGfoeVkrpV9o6GQe5wvL6yu7zl8P/hudusj5OqYISzjHh7Q== 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.182 Received: from mail-dy1-f182.google.com (mail-dy1-f182.google.com [74.125.82.182]) (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 93DF9606A68B for ; Thu, 3 Dec 2026 13:41:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 93DF9606A68B 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-f182.google.com with SMTP id 5a478bee46e88-3874cf36e63so160021eec.0 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=xgMENer3d4BstM0ba/U3RMD9e7ySzLYgiwLHQ1YylzRd47d+zpRNiizPJgQKGusNaI oT891tfXNfj/V9XoJcEr3svgtC2OGyE8naYr/M5yWXLY9/qzRm3x2YmTuZ/4bJ7gnNVI 4CZnSNGROJBKIeO2UkhgypsULlaPVGOjHjtJnFfUPmc3f5DuAQ8rCJ4oG16Grw4reBQ7 QAIL2LrerqqSd80k2rbXlsOIWzyACq1IZx4GjDS9xWzX+T/YiWNiGp+kmcXwNqpdZCsc KwDvVX7PPUE+qpTvj01VrnYCPyD4rCv9b5pOoTLTh+CzKaeERSpWZjlAhHG077QPS+Ih bk9A== X-Forwarded-Encrypted: i=1; AL+hErGtdaB84xuqd7MoECsHQQhWOVNhrUiXrU2E0o+7T+9wsDiw4IprYoRSqZ6gmqWcKF3COPG8D27zjVUIE3I=@vger.kernel.org X-Gm-Message-State: APuU4Z8QgitPHqzBA0R8DddiDpveFf48sQHOr/kGVJOnI8TcZ8WIIa4h Y6ia6UwjvTbgs9++XrykS5cEv7tjxiGzoyOv6RDAJ8w1UBTflgTOQzaK X-Gm-Gg: AZFdTZeC8M20EJN7Xmca0AUnxZgvKLWEFsdf+/XYtXAzTwX+GhpIa6rDkumGkTSOZJ+ eK8IwbM1OFawq8QBDr6Bvk6L4DYp45mGbegVEg0IxoHEbyTKQEKr+A+bK6AzQ2QH+fDmDTwI9im 1TI2Zplrm9QRlfm88K8vErJ3/NdHM6ofMPGVPwO37Uu6Nr/iecJLs7YKJT8Su667o6CmBGmMcxB cqSSpPFq7UFYVKLHsiny4AtXn793TwWi3c70z8LIusfN2oJzETDdszbOMVLMYS3UPpETaM0G4dD eR5oIsHMc/8aaUQKLj1jGIMAfBkMYkBdkFFCi3QhSNxF+kG6850PzEN6mfzKBn3AQ+HO9U77dzI AEff1iWVMJ/m7OXtuxT1XYvBtqFCtLfCizMtRYsWZZ7aVKZPmjAI3kXXIycLGA49OmzIBL48YBy hzTwYiUQSkC2Li3h1uK9rJbY13LPyWWoSx8Kmv9IPDwsJDX9ftAftPMaLecCKgXVXZAmofCi6PP nCHKx3USuC3MA8E9XL2eh2UW7jhjoqi5kTr4qIGWirAkiogGSt2lqP0OCv/XjeN6CzFD3dc7zNd D4HR+Uqd+AIjYpAIjkiWknQuLwTPGO9/ZP3FbrzJrWNh/8Mnw7jsNPKkm3xLGJqPj+wH0hEkpRx dI1nC6zjlrTUftwwN5L/kq/MGxXKOfYr+Es+71BQcsx09BuLzaQA= 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: linux-kernel@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ś