diff mbox series

drm/i915/gvt: remove local storage of debugfs file

Message ID 20210518161705.3697143-1-gregkh@linuxfoundation.org (mailing list archive)
State New, archived
Headers show
Series drm/i915/gvt: remove local storage of debugfs file | expand

Commit Message

Greg KH May 18, 2021, 4:17 p.m. UTC
There is no need to keep the dentry around for the debugfs kvmgt cache
file, as we can just look it up when we want to remove it later on.
Simplify the structure by removing the dentry and relying on debugfs
to find the dentry to remove when we want to.

By doing this change, we remove the last in-kernel user that was storing
the result of debugfs_create_long(), so that api can be cleaned up.

Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
Cc: Zhi Wang <zhi.a.wang@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: intel-gvt-dev@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/i915/gvt/kvmgt.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

Comments

Greg KH May 18, 2021, 4:28 p.m. UTC | #1
On Tue, May 18, 2021 at 06:17:05PM +0200, Greg Kroah-Hartman wrote:
> There is no need to keep the dentry around for the debugfs kvmgt cache
> file, as we can just look it up when we want to remove it later on.
> Simplify the structure by removing the dentry and relying on debugfs
> to find the dentry to remove when we want to.
> 
> By doing this change, we remove the last in-kernel user that was storing
> the result of debugfs_create_long(), so that api can be cleaned up.
> 
> Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
> Cc: Zhi Wang <zhi.a.wang@intel.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: intel-gvt-dev@lists.freedesktop.org
> Cc: intel-gfx@lists.freedesktop.org
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  drivers/gpu/drm/i915/gvt/kvmgt.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)

Note, I can take this through my debugfs tree if wanted, that way I can
clean up the debugfs_create_long() api at the same time.  Otherwise it's
fine, I can wait until next -rc1 for that to happen.

thanks,

greg k-h
Zhenyu Wang May 19, 2021, 12:40 a.m. UTC | #2
On 2021.05.18 18:17:05 +0200, Greg Kroah-Hartman wrote:
> There is no need to keep the dentry around for the debugfs kvmgt cache
> file, as we can just look it up when we want to remove it later on.
> Simplify the structure by removing the dentry and relying on debugfs
> to find the dentry to remove when we want to.
> 
> By doing this change, we remove the last in-kernel user that was storing
> the result of debugfs_create_long(), so that api can be cleaned up.
> 
> Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
> Cc: Zhi Wang <zhi.a.wang@intel.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: intel-gvt-dev@lists.freedesktop.org
> Cc: intel-gfx@lists.freedesktop.org
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  drivers/gpu/drm/i915/gvt/kvmgt.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
> index 65ff43cfc0f7..433c2a448f2d 100644
> --- a/drivers/gpu/drm/i915/gvt/kvmgt.c
> +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
> @@ -88,6 +88,7 @@ struct kvmgt_pgfn {
>  	struct hlist_node hnode;
>  };
>  
> +#define KVMGT_DEBUGFS_FILENAME "kvmgt_nr_cache_entries"
>  struct kvmgt_guest_info {
>  	struct kvm *kvm;
>  	struct intel_vgpu *vgpu;
> @@ -95,7 +96,6 @@ struct kvmgt_guest_info {
>  #define NR_BKT (1 << 18)
>  	struct hlist_head ptable[NR_BKT];
>  #undef NR_BKT
> -	struct dentry *debugfs_cache_entries;
>  };
>  
>  struct gvt_dma {
> @@ -1843,16 +1843,15 @@ static int kvmgt_guest_init(struct mdev_device *mdev)
>  	info->track_node.track_flush_slot = kvmgt_page_track_flush_slot;
>  	kvm_page_track_register_notifier(kvm, &info->track_node);
>  
> -	info->debugfs_cache_entries = debugfs_create_ulong(
> -						"kvmgt_nr_cache_entries",
> -						0444, vgpu->debugfs,
> -						&vdev->nr_cache_entries);
> +	debugfs_create_ulong(KVMGT_DEBUGFS_FILENAME, 0444, vgpu->debugfs,
> +			     &vdev->nr_cache_entries);
>  	return 0;
>  }
>  
>  static bool kvmgt_guest_exit(struct kvmgt_guest_info *info)
>  {
> -	debugfs_remove(info->debugfs_cache_entries);
> +	debugfs_remove(debugfs_lookup(KVMGT_DEBUGFS_FILENAME,
> +				      info->vgpu->debugfs));
>  
>  	kvm_page_track_unregister_notifier(info->kvm, &info->track_node);
>  	kvm_put_kvm(info->kvm);
> -- 

Reviewed-by: Zhenyu Wang <zhenyuw@linux.intel.com>

Thanks!
Jani Nikula May 19, 2021, 6:36 a.m. UTC | #3
On Wed, 19 May 2021, Zhenyu Wang <zhenyuw@linux.intel.com> wrote:
> Reviewed-by: Zhenyu Wang <zhenyuw@linux.intel.com>
>
> Thanks!

Thanks for the review. Please also let Greg know whether he can pick
this up via the debugfs tree; I don't care either way.

BR,
Jani.
Zhenyu Wang May 19, 2021, 8:03 a.m. UTC | #4
On 2021.05.18 18:28:53 +0200, Greg Kroah-Hartman wrote:
> On Tue, May 18, 2021 at 06:17:05PM +0200, Greg Kroah-Hartman wrote:
> > There is no need to keep the dentry around for the debugfs kvmgt cache
> > file, as we can just look it up when we want to remove it later on.
> > Simplify the structure by removing the dentry and relying on debugfs
> > to find the dentry to remove when we want to.
> > 
> > By doing this change, we remove the last in-kernel user that was storing
> > the result of debugfs_create_long(), so that api can be cleaned up.
> > 
> > Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
> > Cc: Zhi Wang <zhi.a.wang@intel.com>
> > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > Cc: David Airlie <airlied@linux.ie>
> > Cc: Daniel Vetter <daniel@ffwll.ch>
> > Cc: intel-gvt-dev@lists.freedesktop.org
> > Cc: intel-gfx@lists.freedesktop.org
> > Cc: dri-devel@lists.freedesktop.org
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> >  drivers/gpu/drm/i915/gvt/kvmgt.c | 11 +++++------
> >  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> Note, I can take this through my debugfs tree if wanted, that way I can
> clean up the debugfs_create_long() api at the same time.  Otherwise it's
> fine, I can wait until next -rc1 for that to happen.
> 

It's fine with me to go through debugfs tree. Just double check that recent
kvmgt change would not cause conflict with this as well.

Thanks
Zhenyu Wang May 19, 2021, 8:21 a.m. UTC | #5
On 2021.05.19 10:31:18 +0200, Greg Kroah-Hartman wrote:
> On Wed, May 19, 2021 at 04:03:13PM +0800, Zhenyu Wang wrote:
> > On 2021.05.18 18:28:53 +0200, Greg Kroah-Hartman wrote:
> > > On Tue, May 18, 2021 at 06:17:05PM +0200, Greg Kroah-Hartman wrote:
> > > > There is no need to keep the dentry around for the debugfs kvmgt cache
> > > > file, as we can just look it up when we want to remove it later on.
> > > > Simplify the structure by removing the dentry and relying on debugfs
> > > > to find the dentry to remove when we want to.
> > > > 
> > > > By doing this change, we remove the last in-kernel user that was storing
> > > > the result of debugfs_create_long(), so that api can be cleaned up.
> > > > 
> > > > Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
> > > > Cc: Zhi Wang <zhi.a.wang@intel.com>
> > > > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > > > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> > > > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > > > Cc: David Airlie <airlied@linux.ie>
> > > > Cc: Daniel Vetter <daniel@ffwll.ch>
> > > > Cc: intel-gvt-dev@lists.freedesktop.org
> > > > Cc: intel-gfx@lists.freedesktop.org
> > > > Cc: dri-devel@lists.freedesktop.org
> > > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > > > ---
> > > >  drivers/gpu/drm/i915/gvt/kvmgt.c | 11 +++++------
> > > >  1 file changed, 5 insertions(+), 6 deletions(-)
> > > 
> > > Note, I can take this through my debugfs tree if wanted, that way I can
> > > clean up the debugfs_create_long() api at the same time.  Otherwise it's
> > > fine, I can wait until next -rc1 for that to happen.
> > > 
> > 
> > It's fine with me to go through debugfs tree. Just double check that recent
> > kvmgt change would not cause conflict with this as well.
> 
> How can I check that?  I'll be glad to take this through my tree, we can
> handle the merge issues later for 5.14-rc1 :)
> 

Current kvmgt change in merge queue is just https://patchwork.freedesktop.org/patch/433536/?series=89995&rev=2
It applies fine with debugfs change.
Greg KH May 19, 2021, 8:31 a.m. UTC | #6
On Wed, May 19, 2021 at 04:03:13PM +0800, Zhenyu Wang wrote:
> On 2021.05.18 18:28:53 +0200, Greg Kroah-Hartman wrote:
> > On Tue, May 18, 2021 at 06:17:05PM +0200, Greg Kroah-Hartman wrote:
> > > There is no need to keep the dentry around for the debugfs kvmgt cache
> > > file, as we can just look it up when we want to remove it later on.
> > > Simplify the structure by removing the dentry and relying on debugfs
> > > to find the dentry to remove when we want to.
> > > 
> > > By doing this change, we remove the last in-kernel user that was storing
> > > the result of debugfs_create_long(), so that api can be cleaned up.
> > > 
> > > Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
> > > Cc: Zhi Wang <zhi.a.wang@intel.com>
> > > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> > > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > > Cc: David Airlie <airlied@linux.ie>
> > > Cc: Daniel Vetter <daniel@ffwll.ch>
> > > Cc: intel-gvt-dev@lists.freedesktop.org
> > > Cc: intel-gfx@lists.freedesktop.org
> > > Cc: dri-devel@lists.freedesktop.org
> > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > > ---
> > >  drivers/gpu/drm/i915/gvt/kvmgt.c | 11 +++++------
> > >  1 file changed, 5 insertions(+), 6 deletions(-)
> > 
> > Note, I can take this through my debugfs tree if wanted, that way I can
> > clean up the debugfs_create_long() api at the same time.  Otherwise it's
> > fine, I can wait until next -rc1 for that to happen.
> > 
> 
> It's fine with me to go through debugfs tree. Just double check that recent
> kvmgt change would not cause conflict with this as well.

How can I check that?  I'll be glad to take this through my tree, we can
handle the merge issues later for 5.14-rc1 :)

thanks,

greg k-h
Greg KH May 21, 2021, 6:43 p.m. UTC | #7
On Wed, May 19, 2021 at 04:21:23PM +0800, Zhenyu Wang wrote:
> On 2021.05.19 10:31:18 +0200, Greg Kroah-Hartman wrote:
> > On Wed, May 19, 2021 at 04:03:13PM +0800, Zhenyu Wang wrote:
> > > On 2021.05.18 18:28:53 +0200, Greg Kroah-Hartman wrote:
> > > > On Tue, May 18, 2021 at 06:17:05PM +0200, Greg Kroah-Hartman wrote:
> > > > > There is no need to keep the dentry around for the debugfs kvmgt cache
> > > > > file, as we can just look it up when we want to remove it later on.
> > > > > Simplify the structure by removing the dentry and relying on debugfs
> > > > > to find the dentry to remove when we want to.
> > > > > 
> > > > > By doing this change, we remove the last in-kernel user that was storing
> > > > > the result of debugfs_create_long(), so that api can be cleaned up.
> > > > > 
> > > > > Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
> > > > > Cc: Zhi Wang <zhi.a.wang@intel.com>
> > > > > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > > > > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> > > > > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > > > > Cc: David Airlie <airlied@linux.ie>
> > > > > Cc: Daniel Vetter <daniel@ffwll.ch>
> > > > > Cc: intel-gvt-dev@lists.freedesktop.org
> > > > > Cc: intel-gfx@lists.freedesktop.org
> > > > > Cc: dri-devel@lists.freedesktop.org
> > > > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > > > > ---
> > > > >  drivers/gpu/drm/i915/gvt/kvmgt.c | 11 +++++------
> > > > >  1 file changed, 5 insertions(+), 6 deletions(-)
> > > > 
> > > > Note, I can take this through my debugfs tree if wanted, that way I can
> > > > clean up the debugfs_create_long() api at the same time.  Otherwise it's
> > > > fine, I can wait until next -rc1 for that to happen.
> > > > 
> > > 
> > > It's fine with me to go through debugfs tree. Just double check that recent
> > > kvmgt change would not cause conflict with this as well.
> > 
> > How can I check that?  I'll be glad to take this through my tree, we can
> > handle the merge issues later for 5.14-rc1 :)
> > 
> 
> Current kvmgt change in merge queue is just https://patchwork.freedesktop.org/patch/433536/?series=89995&rev=2
> It applies fine with debugfs change.

Thanks, I'll go take this through my tree now.

greg k-h
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index 65ff43cfc0f7..433c2a448f2d 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -88,6 +88,7 @@  struct kvmgt_pgfn {
 	struct hlist_node hnode;
 };
 
+#define KVMGT_DEBUGFS_FILENAME "kvmgt_nr_cache_entries"
 struct kvmgt_guest_info {
 	struct kvm *kvm;
 	struct intel_vgpu *vgpu;
@@ -95,7 +96,6 @@  struct kvmgt_guest_info {
 #define NR_BKT (1 << 18)
 	struct hlist_head ptable[NR_BKT];
 #undef NR_BKT
-	struct dentry *debugfs_cache_entries;
 };
 
 struct gvt_dma {
@@ -1843,16 +1843,15 @@  static int kvmgt_guest_init(struct mdev_device *mdev)
 	info->track_node.track_flush_slot = kvmgt_page_track_flush_slot;
 	kvm_page_track_register_notifier(kvm, &info->track_node);
 
-	info->debugfs_cache_entries = debugfs_create_ulong(
-						"kvmgt_nr_cache_entries",
-						0444, vgpu->debugfs,
-						&vdev->nr_cache_entries);
+	debugfs_create_ulong(KVMGT_DEBUGFS_FILENAME, 0444, vgpu->debugfs,
+			     &vdev->nr_cache_entries);
 	return 0;
 }
 
 static bool kvmgt_guest_exit(struct kvmgt_guest_info *info)
 {
-	debugfs_remove(info->debugfs_cache_entries);
+	debugfs_remove(debugfs_lookup(KVMGT_DEBUGFS_FILENAME,
+				      info->vgpu->debugfs));
 
 	kvm_page_track_unregister_notifier(info->kvm, &info->track_node);
 	kvm_put_kvm(info->kvm);