Re: [PATCH v10 19/21] virt: geniezone: Provide individual VM memory statistics within debugfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 12, 2024 at 02:57:16PM +0800, Yi-De Wu wrote:
> From: "Jerry Wang" <ze-yu.wang@xxxxxxxxxxxx>
> 
> Created a dedicated per-VM debugfs folder under gzvm, providing
> user-level programs with easy access to per-VM memory statistics for
> debugging and profiling purposes. This enables users to effectively
> analyze and optimize the memory usage of individual virtual machines.
> 
> Two types of information can be obtained:
> 
> `cat /sys/kernel/debug/gzvm/<pid>-<vmid>/protected_hyp_mem` shows memory
> used by the hypervisor and the size of the stage 2 table in bytes.
> 
> `cat /sys/kernel/debug/gzvm/<pid>-<vmid>/protected_shared_mem` gives
> memory used by the shared resources of the guest and host in bytes.
> 
> For example:
> console:/ # cat /sys/kernel/debug/gzvm/3417-15/protected_hyp_mem
> 180328
> console:/ # cat /sys/kernel/debug/gzvm/3417-15/protected_shared_mem
> 262144
> console:/ #
> 
> More stats will be added in the future.
> 
> Signed-off-by: Jerry Wang <ze-yu.wang@xxxxxxxxxxxx>
> Signed-off-by: Liju-Clr Chen <liju-clr.chen@xxxxxxxxxxxx>
> Signed-off-by: Yi-De Wu <yi-de.wu@xxxxxxxxxxxx>

...

> diff --git a/drivers/virt/geniezone/gzvm_vm.c b/drivers/virt/geniezone/gzvm_vm.c

...

> @@ -398,6 +409,113 @@ static void setup_vm_demand_paging(struct gzvm *vm)
>  	}
>  }
>  
> +static int debugfs_open(struct inode *inode, struct file *file)
> +{
> +	file->private_data = inode->i_private;
> +	return 0;
> +}

nit: Coccinelle suggests that simple_open() can be used in place
     of the debugfs_open() implementation above.

...

> +static const struct file_operations hyp_mem_fops = {
> +	.owner = THIS_MODULE,
> +	.open = debugfs_open,
> +	.read = hyp_mem_read,
> +	.llseek = no_llseek,
> +};
> +
> +static const struct file_operations shared_mem_fops = {
> +	.owner = THIS_MODULE,
> +	.open = debugfs_open,
> +	.read = shared_mem_read,
> +	.llseek = no_llseek,
> +};

...




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux