From patchwork Thu Nov 20 11:25:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhen Lei X-Patchwork-Id: 41229 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 96F2323C27 for ; Thu, 20 Nov 2014 11:25:42 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id bs8sf1897784wib.10 for ; Thu, 20 Nov 2014 03:25:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :mime-version:content-type:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=/QAgEMQBwgrtTad+xTeOVNWay8I3ktzUWmjLOvhLawE=; b=TGVkc3u54HuvtRHZUXcDvydP39z64dc0yTm0y0pVyMMdsbpEZaF3fIhy2Vvkw2Ym6L 7IbAkPu0EKlcj5S38BhuPW9cHHPH9lB9oqbQe91OMD6gBPraIC38RcSDRtErEjznEzT/ xQQ6bND7Uu18+1E6Hhy/p43xPo7LBCKRCSNGDR/sqUPXNabAu0kY+Unr3UJM3fmmhlXR 8HJEehv8VdMDz6ZPiXbHtj3wRQsZNi6p+YGp5ktnnix1eIAO2GY7qCgGG6U+EeW7fkjS UHO+KMC4+XK0Aqh9hyyEe9FyoWljwnC+74CHZ0UG4L64eZX/Bcc6EgDlYE4EQipbf8tS RSkg== X-Gm-Message-State: ALoCoQlN52r9TctUCRpFDfTRAAdF5s7u/BMyMU68Wodsg3qaXIh8BEppymSZI6LcFYSzPgUC9AH6 X-Received: by 10.152.30.66 with SMTP id q2mr18291124lah.2.1416482741904; Thu, 20 Nov 2014 03:25:41 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.99 with SMTP id s3ls52585lag.100.gmail; Thu, 20 Nov 2014 03:25:41 -0800 (PST) X-Received: by 10.152.207.71 with SMTP id lu7mr1715348lac.81.1416482741384; Thu, 20 Nov 2014 03:25:41 -0800 (PST) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id iz2si1885238lbc.92.2014.11.20.03.25.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Nov 2014 03:25:41 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by mail-lb0-f174.google.com with SMTP id w7so2110680lbi.33 for ; Thu, 20 Nov 2014 03:25:41 -0800 (PST) X-Received: by 10.112.235.196 with SMTP id uo4mr10553131lbc.66.1416482741263; Thu, 20 Nov 2014 03:25:41 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp243630lbc; Thu, 20 Nov 2014 03:25:40 -0800 (PST) X-Received: by 10.66.145.42 with SMTP id sr10mr54142443pab.73.1416482739797; Thu, 20 Nov 2014 03:25:39 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fb1si2929304pab.61.2014.11.20.03.25.36 for ; Thu, 20 Nov 2014 03:25:39 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756424AbaKTLZf (ORCPT + 26 others); Thu, 20 Nov 2014 06:25:35 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:57098 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750780AbaKTLZd (ORCPT ); Thu, 20 Nov 2014 06:25:33 -0500 Received: from 172.24.2.119 (EHLO szxeml418-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id AXK37679; Thu, 20 Nov 2014 19:25:29 +0800 (CST) Received: from localhost (10.177.27.142) by szxeml418-hub.china.huawei.com (10.82.67.157) with Microsoft SMTP Server id 14.3.158.1; Thu, 20 Nov 2014 19:25:20 +0800 From: Zhen Lei To: Alex Williamson , KVM , linux-kernel CC: Zefan Li , Xinwei Hu , "Tianhong Ding" , Kefeng Wang , Zhen Lei Subject: [PATCH 1/1] vfio: put off the allocation of "minor" in vfio_create_group Date: Thu, 20 Nov 2014 19:25:02 +0800 Message-ID: <1416482702-10820-1-git-send-email-thunder.leizhen@huawei.com> X-Mailer: git-send-email 1.8.4.msysgit.0 MIME-Version: 1.0 X-Originating-IP: [10.177.27.142] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020208.546DCFA9.0168, ss=1, re=0.001, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: bb8afcf09c407c032735d983d62b5599 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: thunder.leizhen@huawei.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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(-) -- 1.8.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ 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));