From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934390AbbCPWAU (ORCPT ); Mon, 16 Mar 2015 18:00:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42049 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752669AbbCPWAR (ORCPT ); Mon, 16 Mar 2015 18:00:17 -0400 Message-ID: <1426543216.3643.277.camel@redhat.com> Subject: Re: [PATCH 1/1] vfio: put off the allocation of "minor" in vfio_create_group From: Alex Williamson To: Zhen Lei Cc: KVM , linux-kernel , Zefan Li , Xinwei Hu , Tianhong Ding , Kefeng Wang Date: Mon, 16 Mar 2015 16:00:16 -0600 In-Reply-To: <1416482702-10820-1-git-send-email-thunder.leizhen@huawei.com> References: <1416482702-10820-1-git-send-email-thunder.leizhen@huawei.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2014-11-20 at 19:25 +0800, Zhen Lei wrote: > The next code fragment "list_for_each_entry" is not depend on "minor". With this > patch, the free of "minor" in "list_for_each_entry" can be reduced, and there is > no functional change. > > Signed-off-by: Zhen Lei > --- > drivers/vfio/vfio.c | 13 ++++++------- > 1 file changed, 6 insertions(+), 7 deletions(-) > > diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c > index f018d8d..737eb468 100644 > --- a/drivers/vfio/vfio.c > +++ b/drivers/vfio/vfio.c > @@ -225,22 +225,21 @@ static struct vfio_group *vfio_create_group(struct iommu_group *iommu_group) > > mutex_lock(&vfio.group_lock); > > - minor = vfio_alloc_group_minor(group); > - if (minor < 0) { > - vfio_group_unlock_and_free(group); > - return ERR_PTR(minor); > - } > - > /* Did we race creating this group? */ > list_for_each_entry(tmp, &vfio.group_list, vfio_next) { > if (tmp->iommu_group == iommu_group) { > vfio_group_get(tmp); > - vfio_free_group_minor(minor); > vfio_group_unlock_and_free(group); > return tmp; > } > } > > + minor = vfio_alloc_group_minor(group); > + if (minor < 0) { > + vfio_group_unlock_and_free(group); > + return ERR_PTR(minor); > + } > + > dev = device_create(vfio.class, NULL, > MKDEV(MAJOR(vfio.group_devt), minor), > group, "%d", iommu_group_id(iommu_group)); Applied to next for v4.1. Sorry I didn't put this in earlier, it got lost in my inbox. Thanks, Alex