From patchwork Wed Dec 20 22:58:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Harris X-Patchwork-Id: 18391 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp71984dyi; Wed, 20 Dec 2023 15:28:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IEvKRA20dHW5ZMCiOPVzo9BftnFuiPbJMSqcxxdLmNACtHRAwuxqGpylM3p3QlZ+Fv1vu/b X-Received: by 2002:a05:6e02:1e0b:b0:35f:cf31:bc25 with SMTP id g11-20020a056e021e0b00b0035fcf31bc25mr1386361ila.53.1703114892757; Wed, 20 Dec 2023 15:28:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703114892; cv=none; d=google.com; s=arc-20160816; b=wR5KrjkAx/MEcElDlZDoz1lZOArl15MYiz7eORH6Lg9PP2vfgcYmWac5RQS8y6QlsJ TpKPTlBemdhnDxL8QISa9e7pxCFC1TC/VWmFqWmn93HnwEpS+bqSoU0GWzE9bCDIIl7L YqYSOtn4PL/tJNORZmD6zIHImg7d2XVWYjtJg/SoLtRqJGosqio8CJ1c4TF0sgPLxTYD PQpIbNttqe3LaaljlriWlLa+1vAt4YKK4M8EwNdNRcRk9JpXnf+WXNCza6PvNcJU90+n cXRBEaUOdBzVgiMl76duqDXr+rO1ntYa5rBP2LIl3e9eo4GCky9pUiGy5+t/boDall9l pRoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:cms-type:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:content-transfer-encoding:content-id :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:to:from:dkim-signature:dkim-filter; bh=vHjHVuNeMvsYn/jGlYOwAfeBkkG04z0tW8qpz0yXs/Q=; fh=OtPxTFaFpOC/i6a2eMxR19Qv834xIhrDak+9qqew0ho=; b=QCnowNLCnMnfwpiYzEsqKkULn0V5tGGtqfvQ6ToV6PmctAEok/YqvO8aRxQPkexx9s m2KbRMXTWGGt7bBWBDxM5sWu1Wzn39rHV7pXXvBycCKvb3F+S8xgnbWcs4SHT4OG7O3q Zsx5LGC5X5tY+RgbcOiSBQ30VPFUrdPFNwXxI5LpzkmoWZISsGEX5gR8yUXSbrumTwnh Rt2ixPRLnnN/h9l6gnSGrhIYUptw4lIbdaIMzlNUrHXRPY5auelXElbN5yS+qfrYctPq 2dU2kjMpHA/eQzT50wdpITfbV4Y2QLZOE3xp44iAe/7jo1C03RmJcuoM0PUoS81i1ynD NgUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="FyZ+W7Y/"; spf=pass (google.com: domain of linux-kernel+bounces-7620-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7620-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id x126-20020a636384000000b00577616e3ad9si473937pgb.871.2023.12.20.15.28.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 15:28:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7620-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="FyZ+W7Y/"; spf=pass (google.com: domain of linux-kernel+bounces-7620-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7620-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B64E8B20AF0 for ; Wed, 20 Dec 2023 23:14:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0672251002; Wed, 20 Dec 2023 23:05:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="FyZ+W7Y/" X-Original-To: linux-kernel@vger.kernel.org Received: from mailout1.w2.samsung.com (mailout1.w2.samsung.com [211.189.100.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67EF150264; Wed, 20 Dec 2023 23:05:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from uscas1p2.samsung.com (unknown [182.198.245.207]) by mailout1.w2.samsung.com (KnoxPortal) with ESMTP id 20231220225813usoutp01a69809fd1697b5b3d6bf63c8bdf8d1a8~irFXKeojt1790817908usoutp01k; Wed, 20 Dec 2023 22:58:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w2.samsung.com 20231220225813usoutp01a69809fd1697b5b3d6bf63c8bdf8d1a8~irFXKeojt1790817908usoutp01k DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1703113093; bh=vHjHVuNeMvsYn/jGlYOwAfeBkkG04z0tW8qpz0yXs/Q=; h=From:To:Subject:Date:References:From; b=FyZ+W7Y/VhbLPiZsAXd51gGWEz9YXuY2oZIV21iTyB70lF4BxrP+5ZJExlU64bUGW KH+gx0+9RicXHf+azd8lZ9GDYU6FWSy9BX14XHNvTFM1umu+YPFEZ4XfCie6llGLO1 Rvjm06yzpIHjQvxELv35qHnZufkE4ljP9Qdmq4tE= Received: from ussmges1new.samsung.com (u109.gpu85.samsung.co.kr [203.254.195.109]) by uscas1p2.samsung.com (KnoxPortal) with ESMTP id 20231220225813uscas1p20ef1e841a3f4350729c33fac0b286679~irFXB_21L2500725007uscas1p2-; Wed, 20 Dec 2023 22:58:13 +0000 (GMT) Received: from uscas1p2.samsung.com ( [182.198.245.207]) by ussmges1new.samsung.com (USCPEMTA) with SMTP id 5A.12.09678.58173856; Wed, 20 Dec 2023 17:58:13 -0500 (EST) Received: from ussmgxs1new.samsung.com (u89.gpu85.samsung.co.kr [203.254.195.89]) by uscas1p1.samsung.com (KnoxPortal) with ESMTP id 20231220225813uscas1p15c950a58c7de44d32199a63a13f1bb31~irFWtWa1u0648706487uscas1p1Y; Wed, 20 Dec 2023 22:58:13 +0000 (GMT) X-AuditID: cbfec36d-acdff700000025ce-ea-658371852dd0 Received: from SSI-EX2.ssi.samsung.com ( [105.128.3.67]) by ussmgxs1new.samsung.com (USCPEXMTA) with SMTP id 17.DE.09930.48173856; Wed, 20 Dec 2023 17:58:12 -0500 (EST) Received: from SSI-EX2.ssi.samsung.com (105.128.2.227) by SSI-EX2.ssi.samsung.com (105.128.2.227) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.2375.24; Wed, 20 Dec 2023 14:58:12 -0800 Received: from SSI-EX2.ssi.samsung.com ([105.128.2.227]) by SSI-EX2.ssi.samsung.com ([105.128.2.227]) with mapi id 15.01.2375.024; Wed, 20 Dec 2023 14:58:12 -0800 From: Jim Harris To: Bjorn Helgaas , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Leon Romanovsky , "Jason Gunthorpe" , Alex Williamson Subject: [PATCH 0/2] pci/iov: avoid device_lock() when reading sriov_numvfs Thread-Topic: [PATCH 0/2] pci/iov: avoid device_lock() when reading sriov_numvfs Thread-Index: AQHaM5gBfWDt8KjT2UOEaPDLPlceog== Date: Wed, 20 Dec 2023 22:58:12 +0000 Message-ID: <170311143880.2826.17853753430536108145.stgit@bgt-140510-bm01.eng.stellus.in> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJKsWRmVeSWpSXmKPExsWy7djX87qthc2pBncnCFt8+9/DZrGkKcPi yr89jBabNjxhsbi8aw6bxdl5x9kc2DwWbCr16G1+x+bxft9VNo/Pm+QCWKK4bFJSczLLUov0 7RK4MuY+bGIq2MRdsfXaU+YGxh7uLkZODgkBE4kpHbsYuxi5OIQEVjJKdL+dzALhtDJJ3On4 xgpTterlInaIxBpGiV+T5zNBOJ8YJbbOmQ/VsoxRoulZMxtIC5uApsSvK2uYQGwRgTlMEjMu eHYxcnAIC3hLHOiugggHSRycf5oVwtaT+NXykwWkhEVAVeLsznqQMK9ApMTFS4fYQWxGATGJ 76cgJjILiEvcejKfCeI4QYlFs/cwQ9hiEv92PWSDsBUl7n9/yQ4ykhnomvW79CFMO4m++VIQ UxQlpnQ/ZIfYJChxcuYTFohOSYmDK26APSUhMJdD4s22rVCrXCRezj/GDmFLS1y9PhVqbbbE yvUdTCDzJQQKJBqOBEGErSUW/lkPdTGfxN9fjxghSnglOtqEJjAqzULyyyyEO2ch3DkLyZ2z kNy5gJF1FaN4aXFxbnpqsWFearlecWJucWleul5yfu4mRmDqOf3vcO4Oxh23PuodYmTiYDzE KMHBrCTCu7ezKVWINyWxsiq1KD++qDQntfgQozQHi5I4r6HtyWQhgfTEktTs1NSC1CKYLBMH p1QD09RVEy1Fyo8wrOAqCdOfx9nhWbnt0mRWxq0K02/JRMu0yDm7SllvvTt7ywWJH+lM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6/P6OomfdNS2FSulFdsfqh49sXTme7afU8eG56/ycMxXTZj6Wqj/y+6 r1y2+Dc9893e1WuTLGd0PFCN1tg6/X7X5QmHvnjXTqxut2JekPxGfrrmhTDDX/fnBdsWxd7N lU+72Lot6SD77wADmUKvzeUbbuV/XVndsjkxjXNmVrNG6uob7e/u/+U9uWpmfeUDKf1ZJ65m ygoIZtUEB+nqql8vFD1wZGmDfeo9JZbijERDLeai4kQAe1AuXycDAAA= X-CMS-MailID: 20231220225813uscas1p15c950a58c7de44d32199a63a13f1bb31 CMS-TYPE: 301P X-CMS-RootMailID: 20231220225813uscas1p15c950a58c7de44d32199a63a13f1bb31 References: X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785845401326646079 X-GMAIL-MSGID: 1785845401326646079 If SR-IOV enabled device is held by vfio, and device is removed, vfio will hold device lock and notify userspace of the removal. If userspace reads sriov_numvfs sysfs entry, that thread will be blocked since sriov_numvfs_show() also tries to acquire the device lock. If that same thread is responsible for releasing the device to vfio, it results in a deadlock. One patch was proposed to add a separate mutex, specifically for struct pci_sriov, to synchronize access to sriov_numvfs in the sysfs paths (replacing use of the device_lock()). Leon instead suggested just reverting the commit 35ff867b765 which introduced device_lock() in the store path. This also led to a small fix around ordering on the kobject_uevent() when sriov_numvfs is updated. Ref: https://lore.kernel.org/linux-pci/ZXJI5+f8bUelVXqu@ubuntu/ --- Jim Harris (2): Revert "PCI/IOV: Serialize sysfs sriov_numvfs reads vs writes" pci/iov: fix kobject_uevent() ordering in sriov_enable() drivers/pci/iov.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) --