[{"id":3679866,"web_url":"http://patchwork.ozlabs.org/comment/3679866/","msgid":"<20260421124800.GC2707369@p1gen4-pw042f0m>","list_archive_url":null,"date":"2026-04-21T12:48:00","subject":"Re: [PATCH v13 1/2] PCI/IOV: Make pci_lock_rescan_remove() reentrant\n and protect sriov_add_vfs/sriov_del_vfs","submitter":{"id":91674,"url":"http://patchwork.ozlabs.org/api/people/91674/","name":"Benjamin Block","email":"bblock@linux.ibm.com"},"content":"On Tue, Apr 21, 2026 at 10:34:20AM +0300, Ionut Nechita (Wind River) wrote:\n> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c\n> index b63cd0c310bc..0e62081bc5e5 100644\n> --- a/drivers/pci/probe.c\n> +++ b/drivers/pci/probe.c\n> @@ -3513,16 +3513,30 @@ EXPORT_SYMBOL_GPL(pci_rescan_bus);\n>   * routines should always be executed under this mutex.\n>   */\n>  DEFINE_MUTEX(pci_rescan_remove_lock);\n> +static struct task_struct *pci_rescan_remove_owner;\n\nYou could make this variable `const`:\n\n    static const struct task_struct *pci_rescan_remove_owner;\n\nso it is clear that this pointer is not meant to be used to modify the\ntask_struct in any way - just for these comparisons.\n\n> +static unsigned int pci_rescan_remove_depth;\n>  \n>  void pci_lock_rescan_remove(void)\n>  {\n> -\tmutex_lock(&pci_rescan_remove_lock);\n> +\tif (pci_rescan_remove_owner == current) {\n> +\t\tpci_rescan_remove_depth++;\n> +\t} else {\n> +\t\tmutex_lock(&pci_rescan_remove_lock);\n> +\t\tpci_rescan_remove_owner = current;\n> +\t\tpci_rescan_remove_depth = 1;\n> +\t}\n>  }\n>  EXPORT_SYMBOL_GPL(pci_lock_rescan_remove);\n>  \n>  void pci_unlock_rescan_remove(void)\n>  {\n> -\tmutex_unlock(&pci_rescan_remove_lock);\n> +\tif (WARN_ON(pci_rescan_remove_owner != current))\n> +\t\treturn;\n> +\n> +\tif (--pci_rescan_remove_depth == 0) {\n> +\t\tpci_rescan_remove_owner = NULL;\n> +\t\tmutex_unlock(&pci_rescan_remove_lock);\n> +\t}\n>  }\n>  EXPORT_SYMBOL_GPL(pci_unlock_rescan_remove);\n\n\nBut anyway, with, or without this change, this looks good to me. I hadn't run\ninto any linker issues, but I only ever used our debug config.\nAlso holds up with my tests on my s390 rig.\n\n\nReviewed-by: Benjamin Block <bblock@linux.ibm.com>\nTested-by: Benjamin Block <bblock@linux.ibm.com>","headers":{"Return-Path":"\n <linux-pci+bounces-52833-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256\n header.s=pp1 header.b=TWIG9w6n;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.232.135.74; helo=sto.lore.kernel.org;\n envelope-from=linux-pci+bounces-52833-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com\n header.b=\"TWIG9w6n\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=148.163.156.1","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=linux.ibm.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=linux.ibm.com"],"Received":["from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g0Mbt0mLvz1yGt\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 22:48:42 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id D73CE301649F\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 12:48:38 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 549103D6474;\n\tTue, 21 Apr 2026 12:48:35 +0000 (UTC)","from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com\n [148.163.156.1])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id D88323D6473;\n\tTue, 21 Apr 2026 12:48:31 +0000 (UTC)","from pps.filterd (m0360083.ppops.net [127.0.0.1])\n\tby mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 63LCYaeP1926131;\n\tTue, 21 Apr 2026 12:48:11 GMT","from ppma22.wdc07v.mail.ibm.com\n (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92])\n\tby mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4dm2nf4afc-1\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n\tTue, 21 Apr 2026 12:48:09 +0000 (GMT)","from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1])\n\tby ppma22.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id\n 63LCZHqP017802;\n\tTue, 21 Apr 2026 12:48:08 GMT","from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229])\n\tby ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4dmmnvrtuy-1\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n\tTue, 21 Apr 2026 12:48:08 +0000 (GMT)","from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com\n [10.20.54.102])\n\tby smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n 63LCm19Z50397526\n\t(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n\tTue, 21 Apr 2026 12:48:02 GMT","from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id 0D5882005A;\n\tTue, 21 Apr 2026 12:48:01 +0000 (GMT)","from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id ECFB320040;\n\tTue, 21 Apr 2026 12:48:00 +0000 (GMT)","from p1gen4-pw042f0m (unknown [9.52.223.163])\n\tby smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTPS;\n\tTue, 21 Apr 2026 12:48:00 +0000 (GMT)","from bblock by p1gen4-pw042f0m with local (Exim 4.99.1)\n\t(envelope-from <bblock@linux.ibm.com>)\n\tid 1wFAWG-00000008gcr-2uSw;\n\tTue, 21 Apr 2026 14:48:00 +0200"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776775714; cv=none;\n b=iCZTlC63ZuSknMoccn40KNCILY1k5rC/SKGwUyqSphFXdV0rwrmh6/YFTGmpD4D5sZPMckQ0epVBIjnqpdgIH/q+bjhUs7NxkeXLrpBc3CM9DK8130uCaI2geFdR01Jzyq0qp2MMoOrtdQLQydGG9n2LT5pMOP6V4RbT9weGeKE=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776775714; c=relaxed/simple;\n\tbh=DqkUUpZt+hpjmPvXz874JmbMRCHrWto+MnCeLhZXaTM=;\n\th=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:\n\t Content-Type:Content-Disposition:In-Reply-To;\n b=VK2x/jQDOn312nYzGE8xYjPQINd6KwvdcQKgLDjx+N6kFjKHsR0TK9YOAgdQBp4QkLL/PTfS+BvJbIcx30Cj7JySywRg6LuTzGNbO1OuUi+M5G/uLCph5vGGUEHyD191EiQLN+nQj1DrhTSbhzi+6Sv5rgjMZ9sn7F0B2WyBMMQ=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=linux.ibm.com;\n spf=pass smtp.mailfrom=linux.ibm.com;\n dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com\n header.b=TWIG9w6n; arc=none smtp.client-ip=148.163.156.1","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc\n\t:content-transfer-encoding:content-type:date:from:in-reply-to\n\t:message-id:mime-version:references:sender:subject:to; s=pp1;\n\t bh=M79HhCpXrEJibLCm0ot7+Qrs+NU6rdb9PIvmAG0wnZI=; b=TWIG9w6nErxf\n\tSXoy89Ivu/SGbjMR8Skso48WhgB85VrsY3DHXFOlpODlGugqAc/lkeYgG+gfc8OT\n\tPVq18Vs1EIAUeTc8nFt9a7pjAMBpI/yGg2ECHERdNixadBajvGq2U2PEN56JdFAR\n\tG7dpKnbf1VsoGAHfpFRWf5/YPKXqdetwsCfgA6MkASocy7vWyn0fmsIMBZLVL61n\n\tNvUlKFYkTwfSyJsMUWu+eqaAlWaPJXAEqbODK4vs13GXBODf7NAztw8qHmR5PMa4\n\tbaGicRpWWzTmJaFj71AaLB1dckYWzyT2IB5n3hLfZ34TWTkgOnrb4FZLxxE1kD3i\n\toqvnhWQTwg==","Date":"Tue, 21 Apr 2026 14:48:00 +0200","From":"Benjamin Block <bblock@linux.ibm.com>","To":"\"Ionut Nechita (Wind River)\" <ionut.nechita@windriver.com>","Cc":"linux-pci@vger.kernel.org, bhelgaas@google.com, helgaas@kernel.org,\n        sebott@linux.ibm.com, schnelle@linux.ibm.com, linux@roeck-us.net,\n        lukas@wunner.de, stable@vger.kernel.org, linux-kernel@vger.kernel.org,\n        intel-xe@lists.freedesktop.org, matthew.brost@intel.com,\n        michal.wajdeczko@intel.com, piotr.piorkowski@intel.com,\n        dtatulea@nvidia.com, mani@kernel.org, kbusch@kernel.org,\n        lkml@mageta.org, alifm@linux.ibm.com, julianr@linux.ibm.com,\n        ionut_n2001@yahoo.com, sunlightlinux@gmail.com","Subject":"Re: [PATCH v13 1/2] PCI/IOV: Make pci_lock_rescan_remove() reentrant\n and protect sriov_add_vfs/sriov_del_vfs","Message-ID":"<20260421124800.GC2707369@p1gen4-pw042f0m>","References":"<cover.1776756380.git.ionut.nechita@windriver.com>\n <288517e50996200c368cfe172de86ceb02bbd342.1776756380.git.ionut.nechita@windriver.com>","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"\n <288517e50996200c368cfe172de86ceb02bbd342.1776756380.git.ionut.nechita@windriver.com>","Sender":"Benjamin Block <bblock@linux.ibm.com>","X-TM-AS-GCONF":"00","X-Proofpoint-Reinject":"loops=2 maxloops=12","X-Proofpoint-ORIG-GUID":"_T_YS1t-0kR617j0Vc0usA0NLymckQlx","X-Proofpoint-Spam-Details-Enc":"AW1haW4tMjYwNDIxMDEyNyBTYWx0ZWRfXzv2wYY+WCjIe\n KBgiHPcxBLxGsTuee1IKtW8ise3WgABts9BprOSl012ZwwNKw35SyWA6syU2817r/qmDSM0toLU\n 7NP/hWT2zhQBXxGJRAHnoGaVZrBt98wlMN/5suML0AT9fNSk1RsMy/Xb6gWKDivB/3y1JLDtjKF\n FLqiDAOuMmOG8DiCtZZm8SVWXI9teaFw0iWZHZuwfOKNYklNhJOsDeIl7+uOClDYABfMYlx6iCe\n jxZaJ6ZHEMTyWeTZCGoynVgpwkF2IwAVObNVBiAfEviFjX18X9MTALOPt2Zp4sLAPqTDDbLt0Y6\n lROPWBdCPDBzx4MlcUJ8wmWHpDBBZMfgYAfpm5F7AxAawDYCizIBxDfIJRpl+pHuWeWBxKniMVB\n BLhsmciMRJBJkXgLfBt455APvm6c0rhiitA4wrK7lu8tvPmCF1KWHLbBSMu/yB/wQzPhBIbWMiE\n biMGOASBmX55wQ4MtwQ==","X-Proofpoint-GUID":"JO6cXdAwmXMtH6EKkilw8ZwQUwRUzAXu","X-Authority-Analysis":"v=2.4 cv=B7iJFutM c=1 sm=1 tr=0 ts=69e7720a cx=c_pps\n a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17\n a=8nJEP1OIZ-IA:10 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22\n a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8\n a=fGqJzq9b8BsJZAzwzYEA:9 a=3ZKOabzyN94A:10 a=wPNLvfGTeEIA:10","X-Proofpoint-Virus-Version":"vendor=baseguard\n engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49\n definitions=2026-04-21_02,2026-04-20_02,2025-10-01_01","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n malwarescore=0 priorityscore=1501 spamscore=0 impostorscore=0 adultscore=0\n bulkscore=0 phishscore=0 suspectscore=0 lowpriorityscore=0 clxscore=1015\n classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0\n reason=mlx scancount=1 engine=8.22.0-2604070000 definitions=main-2604210127"}}]