From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796238912; b=GqlBbJ58KZnIy1+2JKp1tX/6aKJQmumh2vUWUEmtU3azoTZ9fxMcGR+EUYq/6qPRtUT5 Od7y0/3Zz88Jymewr/+ERAYqX1IMrwoVrUywgqxJBUMkRlyelnx1ebtxd1aR7K+9wBBSV W6DijJxHDetIuYpyeQb/SvE9HeqqeYuAT6qJbZP1IA+vcZH3AZZye7Lj4UFiSRnNiPvhU p/IDsVO4G9qQhsz3POHS859P+0SM0Ozkj7j29bLNgh/vdLLz4vHPTXHJbGoCxF3/FmHAz mq1JnDZhFGt99LCcr51RMazutTVHKi/E/dnCjCSQsJE3LEiPL6iPubQip4XW47gnBsg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796238912; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=zJSH952Y21Yokh8iKognuVqtcLs5VF8EFPapuO0uk7E=; b=42G6OazSmnTHDbwWzCQnf7Xq8pUajPQMWGASfoKazPkiJA5LEb3y+tewjXvvEwWSL2Fj E+tXz7TZdeePSxKdwZDFNNLW7yCmVbcWM5rCJqq7ipZyDI0aCk8TshKJ/OyGjEWWItJsn fc7CpcpbXjEcRrBbFfed5+sQi3BRq8EkO2DilSwjdr6qY08i2f34HPQZWnp4I3nbsqqDP 1QbF4xRCFEsHp5HNTxxdpjlPZ7IyFtebXrfbmui1grigHc550rvKfTcMgs+AVGMe5/xm4 4n6wVZCk+9LIm8qmOsblS0Qx9aOkDuUbOtEnSfmriwUstUUoS+PK08BtsPPwA5sCSwQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Pr7pMprb; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 738E8606A330 for ; Wed, 2 Dec 2026 19:15:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Pr7pMprb Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B3A01F00896; Wed, 2 Dec 2026 19:15:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796238911; bh=zJSH952Y21Yokh8iKognuVqtcLs5VF8EFPapuO0uk7E=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Pr7pMprb7z2J2aSMJkNqmgMxTAuTKuuhI7yX7F++imGdllwdMQlTH2BMX5tMeEJ9v 6d7TZU6FYV5NWjK67kNjzR3VOy2JW9rnWA1i/5BVKCnxU+O6qADHcI91oAwLMftJRZ xPWrmvz1lJofS07s1CoEoB2c+egGgMjxEpeUkkY1yIuT5oeZFGLaRtHPbKYQyKWh6r /Tzy3DwhgdkpMLhsx1q1q6hHFakfyDXQlFdSggYB9aA4u+nyvgyvunR3U2jveYibcS pLMD0T9N2UkhuWA1PYgvvQxaHsJF0uWYTFl4pOqnFDqGO8bmo/44XQSRwe4Am2Yapn GuTPglWXvALJA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH RESEND v4 2/2] PCI: Call local_pci_probe() directly in pci_call_probe() if affined to the right node Reply-To: sashiko-reviews@lists.linux.dev To: "Waiman Long" Cc: linux-pci@vger.kernel.org In-Reply-To: <20261202190007.1852337-3-longman@redhat.com> References: <20261202190007.1852337-1-longman@redhat.com> <20261202190007.1852337-3-longman@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 19:15:11 +0000 X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] PCI: cpumask_subset() in pci_call_probe() misses unbound async_wq workers - [Medium] PCI: affine_to_node check in pci_call_probe() bypasses HK_TYPE_DOMAIN - [Low] PCI: pci_call_probe() checks node state and affinity before disabling hotplug -- commit 9f7bc4a2d73c970ab760b19214b180be397319cb Author: Waiman Long PCI: Call local_pci_probe() directly in pci_call_probe() if affined to the = right node This commit modifies pci_call_probe() to invoke local_pci_probe() directly instead of queueing work when current->cpus_ptr is a subset of the target NUMA node's cpumask. > diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c > index 57c52dd292ea6..13f4312e74f7d 100644 > --- a/drivers/pci/pci-driver.c > +++ b/drivers/pci/pci-driver.c > @@ -398,6 +398,8 @@ static int pci_call_probe(struct pci_driver *drv, str= uct pci_dev *dev, > { > int error, node, cpu; > struct drv_dev_and_id ddi =3D { drv, dev, id }; > + bool node_invalid, affine_to_node; > + const struct cpumask *node_cpus; > =20 > /* > * Execute driver initialization on node where the device is > @@ -406,14 +408,24 @@ static int pci_call_probe(struct pci_driver *drv, s= truct pci_dev *dev, > */ > node =3D dev_to_node(&dev->dev); > dev->is_probed =3D 1; > + node_invalid =3D node < 0 || node >=3D MAX_NUMNODES || !node_online(nod= e); > + > + if (node_invalid) { > + node_cpus =3D cpu_online_mask; > + affine_to_node =3D false; > + } else { > + node_cpus =3D cpumask_of_node(node); > + /* Check if the current task is affined to the right node */ > + affine_to_node =3D cpumask_subset(current->cpus_ptr, node_cpus); > + } [Severity: Medium] Does cpumask_subset(current->cpus_ptr, node_cpus) ever match workers from async_schedule_dev() on multi-node NUMA systems? async_schedule_dev() queues work onto async_wq, which is allocated with WQ_UNBOUND and default non-strict affinity (affn_strict =3D=3D false): kernel/workqueue.c:pool_allowed_cpus() { if (!is_percpu_pool(pool) && pool->attrs->affn_strict) return pool->attrs->__pod_cpumask; else return pool->attrs->cpumask; } create_worker() binds unbound workers to pool_allowed_cpus(pool), so an async_wq worker's current->cpus_ptr spans wq_unbound_cpumask across all NUMA nodes rather than a single node. On multi-node systems, affine_to_node is always false for async_wq workers, so they still allocate a dynamic lockdep key and serialize probing via queue_work_on() on pci_probe_wq. > =20 > cpu_hotplug_disable(); [Severity: Low] Can evaluating node_online(node), cpumask_of_node(node), and cpumask_subset(current->cpus_ptr, node_cpus) before cpu_hotplug_disable() race with CPU hotplug? If the CPUs in current->cpus_ptr are taken offline before cpu_hotplug_disable() is reached, current's affinity is broken and the task is migrated to another node, while pci_call_probe() proceeds with the stale affine_to_node =3D=3D true result and runs local_pci_probe() on the wrong N= UMA node. > /* > - * Prevent nesting work_on_cpu() for the case where a Virtual Function > - * device is probed from work_on_cpu() of the Physical device. > + * Prevent nesting queue_work_on() for the case where a Virtual Function > + * device is probed from queue_work_on() of the Physical function or > + * when the current task is affined to the right node. > */ > - if (node < 0 || node >=3D MAX_NUMNODES || !node_online(node) || > - pci_physfn_is_probed(dev)) { > + if (node_invalid || affine_to_node || pci_physfn_is_probed(dev)) { > error =3D local_pci_probe(&ddi); > } else { [Severity: Medium] Can the affine_to_node fast path run local_pci_probe() on domain-isolated CPUs and bypass housekeeping_update() synchronization? node_cpus is cpumask_of_node(node), which includes isolated CPUs excluded from housekeeping_cpumask(HK_TYPE_DOMAIN). When current->cpus_ptr is a subset of cpumask_of_node(node) (for example, a task with default affinity on a single-node system or a task affined to a node that contains isolated CPUs), affine_to_node is true even if current->cpus_ptr includes isolated CPUs. Calling local_pci_probe() directly here skips the RCU-protected housekeeping_cpumask(HK_TYPE_DOMAIN) check and pci_probe_wq execution that 608fedd2f303 ("PCI: Prepare to protect against concurrent isolated cpuset change") and 29b306c44eb5 ("PCI: Flush PCI probe workqueue on cpuset isolated partition change") rely on when flushing in-flight probes during cpuset isolation updates. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202190007.1852= 337-1-longman@redhat.com?part=3D2