[PATCH v2 2/2] drm/i915/kvmgt: Add kvmgt debugfs entry nr_cache_entries under vgpu
Zhenyu Wang
zhenyuw at linux.intel.com
Thu Feb 8 03:22:25 UTC 2018
On 2018.02.07 10:55:42 +0800, changbin.du at intel.com wrote:
> From: Changbin Du <changbin.du at intel.com>
>
> This patch add kvmgt folder under vgpu debugfs path and a new entry
> nr_cache_entries which shows the number of entry in dma cache.
>
> $ cat /sys/kernel/debug/gvt/vgpu1/kvmgt/nr_cache_entries
> 10101
>
I don't think it's necessary on another new directory level for kvmgt,
if other hypervisor doesn't apply, simply would not exist, extra level
just looks weird.
> Signed-off-by: Changbin Du <changbin.du at intel.com>
> ---
> drivers/gpu/drm/i915/gvt/gvt.h | 1 +
> drivers/gpu/drm/i915/gvt/kvmgt.c | 22 ++++++++++++++++++++++
> 2 files changed, 23 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/gvt/gvt.h b/drivers/gpu/drm/i915/gvt/gvt.h
> index 45209da..910f2a3 100644
> --- a/drivers/gpu/drm/i915/gvt/gvt.h
> +++ b/drivers/gpu/drm/i915/gvt/gvt.h
> @@ -210,6 +210,7 @@ struct intel_vgpu {
> */
> struct rb_root gfn_cache;
> struct rb_root dma_addr_cache;
> + unsigned long nr_cache_entries;
> struct mutex cache_lock;
>
> struct notifier_block iommu_notifier;
> diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
> index e3629de..27752e3 100644
> --- a/drivers/gpu/drm/i915/gvt/kvmgt.c
> +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
> @@ -84,6 +84,7 @@ struct kvmgt_guest_info {
> #define NR_BKT (1 << 18)
> struct hlist_head ptable[NR_BKT];
> #undef NR_BKT
> + struct dentry *debugfs;
> };
>
> struct gvt_dma {
> @@ -225,6 +226,8 @@ static void __gvt_cache_add(struct intel_vgpu *vgpu, gfn_t gfn,
> }
> rb_link_node(&new->dma_addr_node, parent, link);
> rb_insert_color(&new->dma_addr_node, &vgpu->vdev.dma_addr_cache);
> +
> + vgpu->vdev.nr_cache_entries++;
> }
>
> static void __gvt_cache_remove_entry(struct intel_vgpu *vgpu,
> @@ -233,6 +236,7 @@ static void __gvt_cache_remove_entry(struct intel_vgpu *vgpu,
> rb_erase(&entry->gfn_node, &vgpu->vdev.gfn_cache);
> rb_erase(&entry->dma_addr_node, &vgpu->vdev.dma_addr_cache);
> kfree(entry);
> + vgpu->vdev.nr_cache_entries--;
> }
>
> static void gvt_cache_destroy(struct intel_vgpu *vgpu)
> @@ -258,6 +262,7 @@ static void gvt_cache_init(struct intel_vgpu *vgpu)
> {
> vgpu->vdev.gfn_cache = RB_ROOT;
> vgpu->vdev.dma_addr_cache = RB_ROOT;
> + vgpu->vdev.nr_cache_entries = 0;
> mutex_init(&vgpu->vdev.cache_lock);
> }
>
> @@ -1452,6 +1457,20 @@ static bool __kvmgt_vgpu_exist(struct intel_vgpu *vgpu, struct kvm *kvm)
> return ret;
> }
>
> +static void kvmgt_guest_debugfs_init(struct kvmgt_guest_info *info)
> +{
> + struct intel_vgpu *vgpu = info->vgpu;
> +
> + info->debugfs = debugfs_create_dir("kvmgt", vgpu->debugfs);
> + if (!info->debugfs) {
> + gvt_vgpu_err("Cannot create kvmgt debugfs dir\n");
> + return;
> + }
> +
> + debugfs_create_ulong("nr_cache_entries", 0444, info->debugfs,
> + &vgpu->vdev.nr_cache_entries);
> +}
> +
> static int kvmgt_guest_init(struct mdev_device *mdev)
> {
> struct kvmgt_guest_info *info;
> @@ -1490,11 +1509,14 @@ 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);
>
> + kvmgt_guest_debugfs_init(info);
> +
> return 0;
> }
>
> static bool kvmgt_guest_exit(struct kvmgt_guest_info *info)
> {
> + debugfs_remove_recursive(info->debugfs);
> kvm_page_track_unregister_notifier(info->kvm, &info->track_node);
> kvm_put_kvm(info->kvm);
> kvmgt_protect_table_destroy(info);
> --
> 2.7.4
>
> _______________________________________________
> intel-gvt-dev mailing list
> intel-gvt-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev
--
Open Source Technology Center, Intel ltd.
$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/intel-gvt-dev/attachments/20180208/2038fc62/attachment.sig>
More information about the intel-gvt-dev
mailing list