From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.180 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796305286; b=HtMG4YnZCCDtaGbFxC5wXbTigFNDF7Mt8r3rP5NEdcJO+h1o1/VCqUp1opEMW4NoE4GX Xp2HPe3DN2oWwOii+iEiLN6gFeDNZWmXZFAW91o+mAWbL3IHFS5TmHppcM8Zgd5gT00gs hlXr5cormcTKMf4F7zFZtXpB3Xkd8mqAqejaT5jHB+m0BN5ynn6gX5YuPG22a8h0aTDCV FqBoCKfOtdm8QGAPk48d0E1CAiJirRCLO4a5aAzcLdb6wElxujx7YTZsgbeULWjitQlUB MNPUM257KqXuTQfS1ZrGtwvF+XNtx9JEWKwlYaI0TSo588OjYGlu7x6aUmookAvRbDA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796305286; 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=ktdNMz5L6W5wjlpkJAapYdde6akxzjmnJpqJqg+kUffgqo2oOTpi1LCFMQ55n8/U3/wc JvtRZDrKxHhGlXF0r05uZvjx0NyTqPCrsyipJbzbsK0S30MajlWxj/CRyQbnGY0rrj+0F zytXaM4YhsG2MCVk4Gv+fRMGHvYbpmBAbz7wr5aJtiJsrCi6tE2EGwM5SMSheVDHlVXyC H2mTubw7Yly/2Ag6VnO4pCSl19SGD60krvTVVhx19A4rVjFPLUcK6I5RHTKkXQp2Fzcal x6bb0/uXJzaTkQqlTCjsfKkCmHb9xPm+hN7I1Rkc/4qNQmykFkaUxQktMDCkgd9qbwQ== 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.180 Received: from mail-dy1-f180.google.com (mail-dy1-f180.google.com [74.125.82.180]) (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 9831F606A68C for ; Thu, 3 Dec 2026 13:41:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9831F606A68C 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-f180.google.com with SMTP id 5a478bee46e88-38699cf08dfso19948444eec.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=oNW4BND4LSqrjR4LmtYpEAhZKMzVIRTBqXkOPPeHoJRllu5nlreOZdtSNs1iDbIPZ3 XpSnkbhySawgiQOUBozM3+tcx7+MG531I3ysaK0zrIgrDS2YRo6Zo2sAl8DBGZfSMQ5u EhU17DmZkEt5ICdNy1qA74afCgtdomVK66oRmvfAA5YNusnzTW9BYxZuple8oXIbt1Ox 2DcbBhOz6/yFcuza+NIGpn+Pk+ytX//4DkchcTx3ulWdTOpHz3dd2+KyJVYZQsnnHki7 xHGR9Ay2hlAZ52fblUedG9CLGLrQ7XhOgZXrMPiF9Vwyuf0juJzroN7Qzyp1Y9Bq4D/c eG0g== X-Forwarded-Encrypted: i=1; AL+hErGMOPFHkjqAmlG+ANSY6NwvGouBVG5X7jz+DvYhvoypGK/ATAOXKFq+ZChmwL1GSPSaKycsjhQ=@vger.kernel.org X-Gm-Message-State: APuU4Z9IsOkyuoeelhqybTlow8sC06MsGYOclLHXrVkFKEzONArqjYcx zap+JbtWmfymZFYvfN2eJwGG7DZAva6IF4X7JcadNb4HRWY3ZNUk0Xiv X-Gm-Gg: AZFdTZdRoMQNb4sfxIcYqmhRXCG31lXTNCVD7KgO1/lLLQxtpdCCsp673c+BG59Rf9B vdaemkbypeelGieT0/Wzc5RjaHBTyINMLNkNOMk0SGTzWbvS7dRXiazCfwIs0s6ByaH/NHANhpG /J82tgUhXGvrv9WkraKPEEbNcDiCq+9hJ4kIo3Mzltx8UjJKQTKWxTss9kXKs1QzMFj9T9C/lhM Cb1ZdkercENnMFM+UFyerABORAWE7BqI6jOe47Lobn3Mi95ScL9pxJleshSLUD4o5PM/+aj9QY8 kfr+xsyODpk1Y+Ax9QsiU0eUzCGPkrYMznOCxKn2Khohsm0Aoavb5fP5rIIkTuMqHp794LWf2rh l0V4goIqxe1DGFn/Nqy8MQpOmBGJ+W4EqGZvVpEFRjltk79UIaV66wXw83gDXyxtkbQglla7+2R bX6b0vB3LwWHeM9bJP5ks1fCU5vcN/YA6hHVDy2Dbjv6PEa0UAD+QtaXiRqh84cJUPvZENrksdG 6uChpiz/IDSX2A8wsCjpa8zHZfq+zsYYTh2R3XP0Bd6+RDvs4+0JaswL9M1D2kxJs3BZ8urH2SY PSoCqtWbWhI9U1unUJeqEcIs72n5ebUCYXs/0ygiWcWONt0gppZRHQGGGdW912zCySp0fqq9nfM vlPmn6Ir/6YdXnmmE7Py3nk5RVy/3vPnTfUldDGG4Uz6EzcgdVKg= 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: netdev@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ś