Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1325774rdb; Fri, 9 Feb 2024 19:20:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IGDYxSV73d3Weju5IkDI3iHSbTBRrkmUNCYmIIkuN/T3iXBwQ1pxZjSPjN3y02glgNd2lL+ X-Received: by 2002:a2e:88c6:0:b0:2d0:898f:b78e with SMTP id a6-20020a2e88c6000000b002d0898fb78emr458892ljk.17.1707535239279; Fri, 09 Feb 2024 19:20:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707535239; cv=pass; d=google.com; s=arc-20160816; b=Lrh2amTzlrrayuiwxviWE3pKMXZMh2QMjYvqVC9jdkLWSBbxPglvlfhLgGRD2rQ9RX 28dwLMtAjWIm/lIqmE6rVN0tbjmBY38ftWKju25KJU2jN5DGI5Xa/Nqs0MZ3fNwpkZ6D uxIws2oYMFh7VJd0dEkvXMhQo0Zuwy5oETKM3PEcsQU1CfipO91OnCWLZDpCw6fs9PYg MwXG4nPo6RY8tKIN785UzPZLZbFH7BH11t8JHGZrj/W+2lFiagDmF/366sg4vJ4nMKaq paO3oeSApl824ObH46m0muYHF+2cD9iGYrysEnDmkVrWlBcalljbqFk1u72vC58KwAxK 3BJw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=AfYns0OVrMk6P+8x5YR4f6n27GL9vpZpbRczROQmzHU=; fh=ve4Wi+oyWvVOegnnoNdjpo9cSruKy6iY2hKHtTrcs4A=; b=DcVhnyXe5t+e67je7OY1jCh3BW/PkotGRkKAjVkpfs+hYAG37DnDTmYZZi5xmdfamN V/IASJ6raXVjcVEAjo2r+Oh3G0KUQCpkE3iihPlfhV6M/NFVuKDtYAmdmCmWoOCILmR1 XKCeduqvxovvVe2wf/tfwffernlYPvHQ/UXTPLBk05lRLP53RLDK8rZS5nkXmL0Ki5yp Mk1Aze3CFzT3EkNrZMtoPKMY7L9C05lhnLbT1QlJIDmHZnqSnTzzKX/FiFLEBqi8WoPJ csMTsR8494J9CaQX1YjEnMlCckoTiOE9UDfDNXJI3I0gdhcYzqGiDANygIh3DkuuERFE GGZA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QMq6HdU2; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-60270-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60270-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCUBl9tq2fJEZbP/DPZp0s1fH3VvRTSel49SzgX586PXjEe7YHU7mRReTMK8+MpObUV6EHTSIetxS0nZ39OGQtE8gHWA6bAGUv/5Kn0Brg== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id z12-20020aa7cf8c000000b0055f46b71142si417703edx.20.2024.02.09.19.20.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 19:20:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60270-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QMq6HdU2; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-60270-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60270-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0BD821F24C35 for ; Sat, 10 Feb 2024 03:20:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 82980566B; Sat, 10 Feb 2024 03:20:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="QMq6HdU2" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 CD2FE1370; Sat, 10 Feb 2024 03:20:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707535231; cv=none; b=NT6puFOzNsTAxjH3pXbKf6WvnIRkPKX+yhsuRWRGERTKhCnOzzHNrud71iKQ3AY6r8pfe1DxYeI4BXR6sBAreVzUQ7t5s0tICTZ43NhFlcMpfIh2Mmkgg6ewHsmCE2qLUhNm9sLiFkDKJIuPdXWTk66TF9NBDNPDK3c5McuV4JE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707535231; c=relaxed/simple; bh=inh8wpC7E3QmfuR6VOWyQAlRN6uFRdc+6r3sM41j+P0=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=KStXAnuueXugwXZF5ZxHzVi/kHbrSZBA0a6JJQcZeMnnSSMS6XcTBMmZ4AoFxtcLw4X07a5w/+JMM6UlSQfRyfW0RnyXW9U7Wm6TLW3W+Zi8CXhgKSUltMtraMaRJuevyFUB6Fom4/Yw5Vh0qAaDSxqd1i6Hu3JfFpHRY9g7nvI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=QMq6HdU2; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707535230; x=1739071230; h=message-id:date:mime-version:subject:to:references:from: in-reply-to:content-transfer-encoding; bh=inh8wpC7E3QmfuR6VOWyQAlRN6uFRdc+6r3sM41j+P0=; b=QMq6HdU2BBq/a/boN1Q8yBUT9uWjvL36VVBiYqUJ589QON3PRM1wXEvB dUx2JX2fexGFWWA/JCfLlI7hvyZxrursoJ5bBchOtdIUH2N98PbPipY2z RvWvtbkEZziokL4gzBg2U7dNKeXlfeVpyH0YuQ5+rsXdo+fOkq2AHz324 Wu52t77EgpKmJDlKX8Y8NtQysP/WOpjc9eGNkURzwP7FT/d7WGk3xYpfE +jY16BzPwj4DSQYR0/TGYDxdENklKLnozWgb5IF3nHpK9JpwEL7NZwoOF BV7Zoei2f/OKlKP7QgCE85Zh72LQ5jsJ752LRWiddRn3IOQ5mg0JTqxaP w==; X-IronPort-AV: E=McAfee;i="6600,9927,10979"; a="1671197" X-IronPort-AV: E=Sophos;i="6.05,258,1701158400"; d="scan'208";a="1671197" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2024 19:20:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,258,1701158400"; d="scan'208";a="2086323" Received: from ticela-or-295.amr.corp.intel.com (HELO [10.209.25.188]) ([10.209.25.188]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2024 19:20:28 -0800 Message-ID: <10d63412-583b-4647-bb5c-4113a466324e@linux.intel.com> Date: Fri, 9 Feb 2024 19:20:28 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/2] PCI/IOV: Revert "PCI/IOV: Serialize sysfs sriov_numvfs reads vs writes" Content-Language: en-US To: Jim Harris , Bjorn Helgaas , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Leon Romanovsky , Jason Gunthorpe , Alex Williamson , "pierre.cregut@orange.com" References: <170752254154.1693615.9176696143128338408.stgit@bgt-140510-bm01.eng.stellus.in> <170752273224.1693615.11371097645648272257.stgit@bgt-140510-bm01.eng.stellus.in> From: Kuppuswamy Sathyanarayanan In-Reply-To: <170752273224.1693615.11371097645648272257.stgit@bgt-140510-bm01.eng.stellus.in> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2/9/24 3:52 PM, Jim Harris wrote: > If an SR-IOV enabled device is held by vfio, and the device is removed, > vfio will hold device lock and notify userspace of the removal. If > userspace reads the 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. > > The proper way to detect a change to the num_VFs value is to listen for a > sysfs event, not to add a device_lock() on the attribute _show() in the > kernel. Since you are reverting a commit that synchronizes SysFS read /write, please add some comments about why it is not an issue anymore. > > This reverts commit 35ff867b76576e32f34c698ccd11343f7d616204. > Revert had a small conflict, the sprintf() is now changed to sysfs_emit(). > > Link: https://lore.kernel.org/linux-pci/ZXJI5+f8bUelVXqu@ubuntu/ > Suggested-by: Leon Romanovsky > Reviewed-by: Leon Romanovsky > Signed-off-by: Jim Harris > --- > drivers/pci/iov.c | 8 +------- > 1 file changed, 1 insertion(+), 7 deletions(-) > > diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c > index aaa33e8dc4c9..0ca20cd518d5 100644 > --- a/drivers/pci/iov.c > +++ b/drivers/pci/iov.c > @@ -395,14 +395,8 @@ static ssize_t sriov_numvfs_show(struct device *dev, > char *buf) > { > struct pci_dev *pdev = to_pci_dev(dev); > - u16 num_vfs; > - > - /* Serialize vs sriov_numvfs_store() so readers see valid num_VFs */ > - device_lock(&pdev->dev); > - num_vfs = pdev->sriov->num_VFs; > - device_unlock(&pdev->dev); > > - return sysfs_emit(buf, "%u\n", num_vfs); > + return sysfs_emit(buf, "%u\n", pdev->sriov->num_VFs); > } > > /* > -- Sathyanarayanan Kuppuswamy Linux Kernel Developer