Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1760138imm; Tue, 22 May 2018 08:54:45 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpwrNP7hPfBq/LbC5Y8T+a0qWzqE+jz8tfRvc1jDpGRBsnOsmWLpOKymWNrXQzDMG3Towh8 X-Received: by 2002:a63:b007:: with SMTP id h7-v6mr19572306pgf.448.1527004485298; Tue, 22 May 2018 08:54:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527004485; cv=none; d=google.com; s=arc-20160816; b=zmxhwY/W8v+iAvWqpIfCPGm3//2d105fPCPJhlPIYexpym0VDJoBIBGVXynvQqkrrL c0BnbUxmn8h0yYSIf/7t6b5bhTORw4OEuDErizb1mF01FuVXkT+tTK14qZtyjBx3phbb 79ZBFJ/x2LVUtafANnFmVUb0piTEzQlO9t1pFoMZffIUulN+F0oARNKo9bc975HuhRxg CTzcuguexrTZzSrgJgt2Mis3mRDlF9MGh8kLNAKlvMRuD1nrn83d7FyTENyUrHnGnUGK gOVgXyD+PCQWrS8vuoV32BMuLDXgez4rEM59FxlnKCSoDK7AV0b6mVwfYycMlaZVnZ6e pF+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=y1FPCTrU32eKrwVTkTgfXH7Dj1W1mz5bQRYlV1xGlAM=; b=aQ7A7akYO8mbvGPSioff5RdlnwrHOw8qF/yZrzL+wIKUy0IRIDyH5+AYMsuQEuT0KY FP+bw7nvy0HNvpLxw3taxBMGf8UrcgAPmHri0G2YcF95v5goSiWEBZdX3lOLw4gu4/uW 7XPMdOcnBK8THTJqJx8qN4ZUD8VWwDeyIRIkTNSIZ66jdHEY7Mp4VUOhfiNnaDX9otxA n5z9JDcXYhtarv4T/4vgl8ttNlNgFvaIPVVRhHIgv3n6Hhc9HmO2wX1mMjEs7kfBGkhs nHhkLV+yWk5+Uj0j/lt4sEHNN+RJsC3Ys8lAuQq81tqqKOtIgefRby/dns2nWqHAwQ8O jE/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a71-v6si13001411pge.159.2018.05.22.08.54.30; Tue, 22 May 2018 08:54:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752100AbeEVPxo (ORCPT + 99 others); Tue, 22 May 2018 11:53:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54375 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751892AbeEVPxj (ORCPT ); Tue, 22 May 2018 11:53:39 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EB2B07CBB1; Tue, 22 May 2018 15:53:38 +0000 (UTC) Received: from w520.home (ovpn-116-135.phx2.redhat.com [10.3.116.135]) by smtp.corp.redhat.com (Postfix) with ESMTP id 294F0608F6; Tue, 22 May 2018 15:53:38 +0000 (UTC) Date: Tue, 22 May 2018 09:53:37 -0600 From: Alex Williamson To: Cornelia Huck Cc: kwankhede@nvidia.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, pasic@linux.ibm.com, zhenyuw@linux.intel.com, zhenyuw@linux.intel.com, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Subject: Re: [PATCH v4 1/2] vfio/mdev: Check globally for duplicate devices Message-ID: <20180522095337.1a3043e6@w520.home> In-Reply-To: <20180522101346.3442e1af.cohuck@redhat.com> References: <20180518190145.3187.7620.stgit@gimli.home> <20180518191025.3187.29141.stgit@gimli.home> <20180522101346.3442e1af.cohuck@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 22 May 2018 15:53:39 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [Cc +GVT-g maintainers/lists] On Tue, 22 May 2018 10:13:46 +0200 Cornelia Huck wrote: > On Fri, 18 May 2018 13:10:25 -0600 > Alex Williamson wrote: > > > When we create an mdev device, we check for duplicates against the > > parent device and return -EEXIST if found, but the mdev device > > namespace is global since we'll link all devices from the bus. We do > > catch this later in sysfs_do_create_link_sd() to return -EEXIST, but > > with it comes a kernel warning and stack trace for trying to create > > duplicate sysfs links, which makes it an undesirable response. > > > > Therefore we should really be looking for duplicates across all mdev > > parent devices, or as implemented here, against our mdev device list. > > Using mdev_list to prevent duplicates means that we can remove > > mdev_parent.lock, but in order not to serialize mdev device creation > > and removal globally, we add mdev_device.active which allows UUIDs to > > be reserved such that we can drop the mdev_list_lock before the mdev > > device is fully in place. > > > > Two behavioral notes; first, mdev_parent.lock had the side-effect of > > serializing mdev create and remove ops per parent device. This was > > an implementation detail, not an intentional guarantee provided to > > the mdev vendor drivers. Vendor drivers can trivially provide this > > serialization internally if necessary. Second, review comments note > > the new -EAGAIN behavior when the device, and in particular the remove > > attribute, becomes visible in sysfs. If a remove is triggered prior > > to completion of mdev_device_create() the user will see a -EAGAIN > > error. While the errno is different, receiving an error during this > > period is not, the previous implementation returned -ENODEV for the > > same condition. Furthermore, the consistency to the user is improved > > in the case where mdev_device_remove_ops() returns error. Previously > > concurrent calls to mdev_device_remove() could see the device > > disappear with -ENODEV and return in the case of error. Now a user > > would see -EAGAIN while the device is in this transitory state. > > > > Signed-off-by: Alex Williamson > > --- > > Documentation/vfio-mediated-device.txt | 5 ++ > > drivers/vfio/mdev/mdev_core.c | 102 +++++++++++--------------------- > > drivers/vfio/mdev/mdev_private.h | 2 - > > 3 files changed, 42 insertions(+), 67 deletions(-) > > Reviewed-by: Cornelia Huck > > I think it is better to deal with any possible vendor driver > implications on top of this (I still believe that vfio-ccw is fine). Thanks Cornelia. So if vfio-ccw is fine, presumably NVIDIA is fine, then this leaves GVT-g to see if there's any fallout. Zhenyu & Zhi, I've linked the series under discussion here below[1]. The question to you is the first of the two behavioral notes listed above, does GVT-g have any dependency on the mdev core providing serialization per mdev parent device for the create and remove callbacks within the mdev_parent_ops? This was never an intended feature of the implementation and as noted it should be trivial for for an mdev vendor driver to provide equivalent course grained serialization if necessary. Of course it would be better to implement that sooner rather than later if required. I see that __intel_gvt_create_vgpu() makes use of gvt->lock, which would seem to already provide this level of per-parent locking. The remove path makes use of this same lock, so I think we're ok, but looking for an explicit ack so there are no surprises. I'd like to queue this series for v4.18. Thanks, Alex [1] https://lkml.org/lkml/2018/5/18/1035