From: Alex Williamson <alex.williamson@redhat.com>
To: Zhen Lei <thunder.leizhen@huawei.com>
Cc: KVM <kvm@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Zefan Li <lizefan@huawei.com>, Xinwei Hu <huxinwei@huawei.com>,
Tianhong Ding <dingtianhong@huawei.com>,
Kefeng Wang <wangkefeng.wang@huawei.com>
Subject: Re: [PATCH 1/1] vfio: put off the allocation of "minor" in vfio_create_group
Date: Mon, 16 Mar 2015 16:00:16 -0600 [thread overview]
Message-ID: <1426543216.3643.277.camel@redhat.com> (raw)
In-Reply-To: <1416482702-10820-1-git-send-email-thunder.leizhen@huawei.com>
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 <thunder.leizhen@huawei.com>
> ---
> 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
prev parent reply other threads:[~2015-03-16 22:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-20 11:25 [PATCH 1/1] vfio: put off the allocation of "minor" in vfio_create_group Zhen Lei
2014-11-20 15:37 ` Alex Williamson
2014-11-21 1:25 ` leizhen
2015-03-16 22:00 ` Alex Williamson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1426543216.3643.277.camel@redhat.com \
--to=alex.williamson@redhat.com \
--cc=dingtianhong@huawei.com \
--cc=huxinwei@huawei.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=thunder.leizhen@huawei.com \
--cc=wangkefeng.wang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox