From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 90D83C4708E for ; Fri, 6 Jan 2023 01:03:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1761610E81C; Fri, 6 Jan 2023 01:03:44 +0000 (UTC) X-Greylist: delayed 2811 seconds by postgrey-1.36 at gabe; Fri, 06 Jan 2023 01:03:41 UTC Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 46EFB10E2A5; Fri, 6 Jan 2023 01:03:41 +0000 (UTC) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3060xRJs027071; Fri, 6 Jan 2023 01:03:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=H3o6tON5owMSXwvuPyf2voj0PCtiOis55aqH7xs9h+Q=; b=qGD9nV9Wwn5xkJP5ZW8DYBQZnIPjLy37H/l+TB+mrQv2bvMvFOyVFoC/BcUSUuVjbMRH 8pSV2BNyTAus8E+Z608QE70pROq/AZDvpRo34zwiy5fLvzCl+TfWBJPa2C+pJ7NFeKmN wYMeCxy6rgh94KDdHK4lqrH0UrhjXkSGpVLf3YZsdbAH/rhW+3caQXGulz61ifux6UDS 9XgS4Up5n7mgDGyEMyXl0QFN4/D+iGp7vC5shDMCwelaY4KLmSEQpf9u2igWrba0ODte m5dQu28/42T7OjJSOHw1xomfFfZiw6GZdd1B9wQ/4C4ftt83YMTfvqoUwRXyxyC2lyb5 cg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3mx9k983hu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 06 Jan 2023 01:03:37 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 30610808030362; Fri, 6 Jan 2023 01:03:37 GMT Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3mx9k983hb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 06 Jan 2023 01:03:36 +0000 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 305NmnaV020198; Fri, 6 Jan 2023 01:03:35 GMT Received: from smtprelay02.dal12v.mail.ibm.com ([9.208.130.97]) by ppma02dal.us.ibm.com (PPS) with ESMTPS id 3mtcq80w9w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 06 Jan 2023 01:03:35 +0000 Received: from smtpav03.dal12v.mail.ibm.com (smtpav03.dal12v.mail.ibm.com [10.241.53.102]) by smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30613Y4K46334654 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 6 Jan 2023 01:03:34 GMT Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 54CC858064; Fri, 6 Jan 2023 01:03:34 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 77CA458056; Fri, 6 Jan 2023 01:03:32 +0000 (GMT) Received: from [9.160.126.91] (unknown [9.160.126.91]) by smtpav03.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 6 Jan 2023 01:03:32 +0000 (GMT) Message-ID: Date: Thu, 5 Jan 2023 20:03:32 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Content-Language: en-US To: Jason Gunthorpe References: <20220519183311.582380-1-mjrosato@linux.ibm.com> <20220519183311.582380-2-mjrosato@linux.ibm.com> <20230105150930.6ee65182.alex.williamson@redhat.com> <5e17a35d-2a94-f482-c466-521afcab80b8@linux.ibm.com> From: Matthew Rosato In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: qSA-WQm0cN_f2KPomMfKGbg7bJ0EykJW X-Proofpoint-ORIG-GUID: K0or9jUZQNxgyJRFdIz7eHqAFs_WqRdN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-05_14,2023-01-05_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxlogscore=999 spamscore=0 suspectscore=0 adultscore=0 mlxscore=0 phishscore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301060006 Subject: Re: [Intel-gfx] [PATCH v3 1/1] vfio: remove VFIO_GROUP_NOTIFY_SET_KVM X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jjherne@linux.ibm.com, akrowiak@linux.ibm.com, kvm@vger.kernel.org, hch@infradead.org, linux-s390@vger.kernel.org, intel-gfx@lists.freedesktop.org, cohuck@redhat.com, linux-kernel@vger.kernel.org, pasic@linux.ibm.com, borntraeger@linux.ibm.com, intel-gvt-dev@lists.freedesktop.org, Christoph Hellwig Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On 1/5/23 7:32 PM, Jason Gunthorpe wrote: > On Thu, Jan 05, 2023 at 07:16:37PM -0500, Matthew Rosato wrote: > >> Yeah, this is also what I was thinking, replace the direct >> kvm_put_kvm calls with, say, schedule_delayed_work in each driver, >> where the delayed task just does the kvm_put_kvm (along with a brief >> comment explaining why we handle the put asynchronously). > > Don't put that in every driver, do something like mmput_async() where > the core code has all of this. > If the core vfio code were to add logic to invoke kvm_put_kvm and kvm_get_kvm, won't this introduce a vfio dependency on kvm? If I recall, we have the drivers handling the kvm reference today in order to avoid that.. >> Other than that.. The goal of this patch originally was to get the >> kvm reference at first open_device and release it with the very last >> close_device, so the only other option I could think of would be to >> take the responsibility back from the vfio drivers and do the >> kvm_get_kvm and kvm_put_kvm directly in vfio_main after dropping the >> (but that would result in some ugly symbol linkage and would acquire >> kvm references that a driver maybe does not care about so I don't >> really like that idea) > > And we still have the deadlock problem anyhow.. Looks like I never finished my sentence here -- I meant call kvm_put_kvm directly in vfio_main after dropping the group lock (e.g. when we set device->kvm = NULL;). But I think we'd still have the kvm dependency issue