mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Naman Jain <namjain@linux.microsoft.com>
To: Hardik Garg <hargar@linux.microsoft.com>
Cc: skhan@linuxfoundation.org, rdunlap@infradead.org,
	mhklinux@outlook.com, muislam@microsoft.com,
	anbelski@linux.microsoft.com, linux-hyperv@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com,
	corbet@lwn.net
Subject: Re: [PATCH] mshv_vtl: Add a per-CPU transition statistics ioctl
Date: Thu, 3 Dec 2026 10:21:00 +0530	[thread overview]
Message-ID: <94f35dc0-9cd5-486e-98e9-ee96993b1644@linux.microsoft.com> (raw)
In-Reply-To: <32770833-626e-46f2-8600-089e1b1c6e33@linux.microsoft.com>



On 12/3/2026 7:35 AM, Hardik Garg wrote:
> 
> On 11/17/2026 12:12 AM, Naman Jain wrote:
>> The VTL driver does not expose per-CPU transition counts or timing.
>> This information is important to track number of VTL transitions based
>> on the use-case, debug issues where a VP gets stuck in VTL2 etc.
>> Add MSHV_GET_VTL_STATS IOCTL so userspace can query them and print this
>> information periodically or on error handling paths. Report entry and
>> return counts, the latest timestamps, and total and maximum interval
>> durations. Include the last observed state so userspace
>> can calculate the age of an unfinished interval. These are elapsed times,
>> not exclusive CPU execution times.
>>
>> While at it, remove the unused num_vtl0_transitions counter.
>> Add documentation in a generic VTL interface file. Documentation for
>> existing ioctls is outside the scope of this patch.
>>
>> Signed-off-by: Naman Jain<namjain@linux.microsoft.com>
>> ---
>>   Documentation/virt/hyperv/index.rst    |  1 +
>>   Documentation/virt/hyperv/mshv-vtl.rst | 98 ++++++++++++++++++++++++++
>>   drivers/hv/mshv_vtl_main.c             | 72 ++++++++++++++++++-
>>   include/uapi/linux/mshv.h              | 35 +++++++++
>>   4 files changed, 204 insertions(+), 2 deletions(-)
>>   create mode 100644 Documentation/virt/hyperv/mshv-vtl.rst
>>

<snip>

>> +
>> +static DEFINE_PER_CPU(struct mshv_vtl_cpu_stats, mshv_vtl_stats) = {
>> +	.lock = __RAW_SPIN_LOCK_UNLOCKED(mshv_vtl_stats.lock),
>> +};
> nit: the per-CPU variable is named after the uapi struct
> (struct mshv_vtl_stats) rather than its own type, which makes
> mshv_vtl_ioctl_get_stats() a bit confusing to read and grep:
> 
>      struct mshv_vtl_stats stats;
>      ...
>      cpu_stats = per_cpu_ptr(&mshv_vtl_stats, cpu);
> 
> Could it be mshv_vtl_cpu_stats, matching how mshv_vtl_poll_file and
> mshv_vtl_per_cpu are named?

Acked. I'll change this in v2.

> 
>> +
>>   static DEFINE_PER_CPU(struct mshv_vtl_per_cpu, mshv_vtl_per_cpu);
>>   
>>   static const union hv_input_vtl input_vtl_zero;
>> @@ -649,6 +660,36 @@ static int mshv_vtl_get_set_reg(struct hv_register_assoc *regs, bool set)
>>   	return 1;
>>   }
>>   

<snip>

>>   struct mshv_vtl_hvcall_setup {
>>   	__u64 bitmap_array_size; /* stores number of bytes */
>>   	__u64 allow_bitmap_ptr;
>> @@ -392,6 +426,7 @@ struct mshv_sint_mask {
>>   #define MSHV_ADD_VTL0_MEMORY	_IOW(MSHV_IOCTL, 0x21, struct mshv_vtl_ram_disposition)
>>   #define MSHV_SET_POLL_FILE		_IOW(MSHV_IOCTL, 0x25, struct mshv_vtl_set_poll_file)
>>   #define MSHV_RETURN_TO_LOWER_VTL	_IO(MSHV_IOCTL, 0x27)
>> +#define MSHV_GET_VTL_STATS	_IOWR(MSHV_IOCTL, 0x41, struct mshv_vtl_stats)
> Why use 0x41 here?
> The VTL fd ioctls in this header currently end at 0x27, and the comment
> at the top of the file asks for monotonically increasing numbers per
> fd. Could you explain in the commit message why this jumps to 0x41
> instead of using 0x28?


This was to avoid a clash with IOCTL numbers already in use by
downstream OpenVMM. On checking further, even 0x41 was reserved for ARM
usecases in OpenVMM, so I would reserve the first available 0x46 for 
this IOCTL and use it here. I'll also add a note in the commit msg for
the same.

Thanks for reviewing.

Regards,
Naman
> 
>>   #define MSHV_GET_VP_REGISTERS		_IOWR(MSHV_IOCTL, 0x05, struct mshv_vp_registers)
>>   #define MSHV_SET_VP_REGISTERS		_IOW(MSHV_IOCTL, 0x06, struct mshv_vp_registers)
>>   
> Thanks,
> Hardik
> 


      reply	other threads:[~2026-12-03  4:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  8:12 Naman Jain
2026-12-03  2:05 ` Hardik Garg
2026-12-03  4:51   ` Naman Jain [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=94f35dc0-9cd5-486e-98e9-ee96993b1644@linux.microsoft.com \
    --to=namjain@linux.microsoft.com \
    --cc=anbelski@linux.microsoft.com \
    --cc=corbet@lwn.net \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=hargar@linux.microsoft.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhklinux@outlook.com \
    --cc=muislam@microsoft.com \
    --cc=rdunlap@infradead.org \
    --cc=skhan@linuxfoundation.org \
    --cc=wei.liu@kernel.org \
    /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

all inboxes | Powered by JetHome®