Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1424777ybl; Wed, 28 Aug 2019 14:38:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7yvCm4bfEA5uXLWhUx+Fwspj7p4uifhwTebt5AR5kY+AQ1atDmW7U8b2uY/25GyH4xMsl X-Received: by 2002:a65:640a:: with SMTP id a10mr5208397pgv.338.1567028286699; Wed, 28 Aug 2019 14:38:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567028286; cv=none; d=google.com; s=arc-20160816; b=x/WqMjnjhSBdq3IyU0Avuwrtab+LCnoVlYA+spQL2amy6/VDCwcz87cPwhdsYuqzzj IYNig3kMbLPmNjj3Wsh7kiH2gxnYBlI+HgwR7QTDzBFe27u2mGr/n3bIB7iuj1AbKhQk wolGr3HdzGNSJal0JM02OgGmN54XXXJf/Qg6iu0/XRT3kxFLo4FZWwbP7A1zOCpXYtJP 9ksjyRoEhUGcUOQVHnhZmhYdWbxYU+OQ4wE9EHGBOxeDWytDCQLvUSt2es9ganJvdSAs HJh4zExn8VbTHGIPtIREh4A2Y13yI3Ar1jDagpe1Egx3kLm6BqKgf7+FXCy0smb8XNxa BC9g== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=tN4C8g5+X+rr0fvkef2ieJX7YkeSKm4Do4RLfSq5KZY=; b=KL+Y2ij9y4PVYoDqlO67FMvBS9wNlvDbPM+QyHbY8MzRQMykfE3yQoM5fB7/qTHeLy 4t+n2R6Awsd5Djsehud4OcIL8vYo6UQZyvrGZJOAfKogyXuO1urSOYP2Hd1Dz/z5VkA6 O711J9ybIsNEDXCFKSUHIdlrbzY8HdsG3iOB+E2Hz4GXoKnaNM4q2mtl/Pf4gRBobxVn 9R//pfY13cCNZj4e4Dt56VxeyMfCv+cJ22VxQ4AdyZ9ytt4YgE292oES2pw5mP8ZxafA 1ZE1s/2cYinB53rqn4+u9/0mYKG/czF/SfwS2FbYxOCY5zVfi3VjGa+ZFfmD+cQyxcME O/VA== 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 q24si136965pls.7.2019.08.28.14.37.50; Wed, 28 Aug 2019 14:38:06 -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 S1726925AbfH1Vg7 (ORCPT + 99 others); Wed, 28 Aug 2019 17:36:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58562 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726828AbfH1Vg6 (ORCPT ); Wed, 28 Aug 2019 17:36:58 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 819EC75752; Wed, 28 Aug 2019 21:36:58 +0000 (UTC) Received: from x1.home (ovpn-116-131.phx2.redhat.com [10.3.116.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id DDAA6600CD; Wed, 28 Aug 2019 21:36:57 +0000 (UTC) Date: Wed, 28 Aug 2019 15:36:52 -0600 From: Alex Williamson To: Parav Pandit Cc: jiri@mellanox.com, kwankhede@nvidia.com, cohuck@redhat.com, davem@davemloft.net, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH v1 2/5] mdev: Make mdev alias unique among all mdevs Message-ID: <20190828153652.7eb6d6d6@x1.home> In-Reply-To: <20190827191654.41161-3-parav@mellanox.com> References: <20190826204119.54386-1-parav@mellanox.com> <20190827191654.41161-1-parav@mellanox.com> <20190827191654.41161-3-parav@mellanox.com> Organization: Red Hat 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 28 Aug 2019 21:36:58 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 27 Aug 2019 14:16:51 -0500 Parav Pandit wrote: > Mdev alias should be unique among all the mdevs, so that when such alias > is used by the mdev users to derive other objects, there is no > collision in a given system. > > Signed-off-by: Parav Pandit > > --- > Changelog: > v0->v1: > - Fixed inclusiong of alias for NULL check > - Added ratelimited debug print for sha1 hash collision error > --- > drivers/vfio/mdev/mdev_core.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c > index 62d29f57fe0c..4b9899e40665 100644 > --- a/drivers/vfio/mdev/mdev_core.c > +++ b/drivers/vfio/mdev/mdev_core.c > @@ -375,6 +375,13 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, > ret = -EEXIST; > goto mdev_fail; > } > + if (tmp->alias && alias && strcmp(tmp->alias, alias) == 0) { Nit, test if the device we adding has an alias before the device we're testing against. The compiler can better optimize keeping alias hot. Thanks, Alex > + mutex_unlock(&mdev_list_lock); > + ret = -EEXIST; > + dev_dbg_ratelimited(dev, "Hash collision in alias creation for UUID %pUl\n", > + uuid); > + goto mdev_fail; > + } > } > > mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);