From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=13.77.154.182 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796273466; b=aHQ+FR4y1kStF8wX3NGd9HPKZu7PDlb/kPP7+NFZWoz7LvQEy8BclQmRbtnJA8Dn3n9e PAAUh8KQ1IF1tKC3fTpayKoXpunNjih1/O3kSXlv+xL4HI7KWNBzVBGf4iMJsh/hL2GeX qRxZzU4P6aoc1xsfuEKiDu6OkQvUu2KNU7h9vBDLxiy+JQQk+VWwXkhdKXJ1gRV53fiJr xKtSmt3OV5SHJKeusHr2QcsZwyPcsjkx82A9AtT6oa6njKpDmzLSGKwWGRkY1iuX9xuUF L3Yg/L8IIgQ0dEzCO2X9mLrdrx6L9ROr93Yl9S1cY041RZAZoMprd0xlsiSut9Vlydw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796273466; h=DMARC-Filter:Received:DKIM-Filter:DKIM-Signature:Message-ID:Date: MIME-Version:User-Agent:Subject:To:Cc:References:Content-Language: From:In-Reply-To:Content-Type:Content-Transfer-Encoding:X-Spam-Status: X-Spam-Checker-Version; bh=g0dEd0+/LcAYUzwSAU/q0XQbWtVywzEplrr57t3YCR8=; b=wiHz2H5F0cfm+0jcppxvITHPPhByXgnaiq9MgHWBnAp6F4UCnlE/PSnxNtshXEhp2so4 /SkPcwc+i/9U9+UH7a79ZmHa1f0SVFCDTu24DVqoQccupT/70q6DB0/Ys7jYLaSPUKoxm un4t0dm1mGoytUUlXPt35xkwVgzREqNsscuz+0KxpaXPqKIfkNUPw8mX33SytDB3Tn/TX X/uU6ISBTJT/1Yc1dxSzRliy5Y+hV0i9CXJexI1IXpss3YnRyUuwzZifMEEH9KhK/3Y3+ g/e6xysYqi7pdkG4RZs8kRyQxJN1SvsiDROPMHI7/c4oBfcvkVFO9eEX0D6PCttrI8w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass header.d=linux.microsoft.com header.i=@linux.microsoft.com header.a=rsa-sha256 header.s=default header.b=ZXvKoi1z; arc=none smtp.remote-ip=13.77.154.182 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 39FB5606A322; Thu, 3 Dec 2026 04:51:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 39FB5606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.a=rsa-sha256 header.s=default header.b=ZXvKoi1z Received: from [10.95.64.251] (unknown [52.172.102.187]) by linux.microsoft.com (Postfix) with ESMTPSA id 29EFE20B7166; Wed, 2 Dec 2026 20:51:00 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 29EFE20B7166 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1796273464; bh=g0dEd0+/LcAYUzwSAU/q0XQbWtVywzEplrr57t3YCR8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=ZXvKoi1zstgH+KPedO13qDepoZz5fV1BNp5INZXItBjOTM/Tc30NKFH7xoA5mB/YA TRTaf4HL5kYKwZbLdnmY+3JCavMuFML1YlKNb1v+I+lxjoYVgb0jwk2HelChAPoAc8 zfDfh1WoI+HmS6ywCeYFfC2j7/oZtmsFbZjFkPwo= Message-ID: <94f35dc0-9cd5-486e-98e9-ee96993b1644@linux.microsoft.com> Date: Thu, 3 Dec 2026 10:21:00 +0530 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mshv_vtl: Add a per-CPU transition statistics ioctl To: Hardik Garg 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 References: <20261117081211.2063781-1-namjain@linux.microsoft.com> <32770833-626e-46f2-8600-089e1b1c6e33@linux.microsoft.com> Content-Language: en-US From: Naman Jain In-Reply-To: <32770833-626e-46f2-8600-089e1b1c6e33@linux.microsoft.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 >> --- >> 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 >> >> + >> +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; >> } >> >> 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 >