[PATCH 1/6] mshv: Only map vp->vp_stats_pages if on root scheduler

Nuno Das Neves posted 6 patches 1 month ago
There is a newer version of this series
[PATCH 1/6] mshv: Only map vp->vp_stats_pages if on root scheduler
Posted by Nuno Das Neves 1 month ago
This mapping is only used for checking if the dispatch thread is
blocked. This is only relevant for the root scheduler, so check the
scheduler type to determine whether to map/unmap these pages, instead of
the current check, which is incorrect.

Signed-off-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
---
 drivers/hv/mshv_root_main.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c
index e4ee9beddaf5..bbdefe8a2e9c 100644
--- a/drivers/hv/mshv_root_main.c
+++ b/drivers/hv/mshv_root_main.c
@@ -987,7 +987,11 @@ mshv_partition_ioctl_create_vp(struct mshv_partition *partition,
 			goto unmap_register_page;
 	}
 
-	if (hv_parent_partition()) {
+	/*
+	 * This mapping of the stats page is for detecting if dispatch thread
+	 * is blocked - only relevant for root scheduler
+	 */
+	if (hv_scheduler_type == HV_SCHEDULER_TYPE_ROOT) {
 		ret = mshv_vp_stats_map(partition->pt_id, args.vp_index,
 					stats_pages);
 		if (ret)
@@ -1016,7 +1020,7 @@ mshv_partition_ioctl_create_vp(struct mshv_partition *partition,
 	if (mshv_partition_encrypted(partition) && is_ghcb_mapping_available())
 		vp->vp_ghcb_page = page_to_virt(ghcb_page);
 
-	if (hv_parent_partition())
+	if (hv_scheduler_type == HV_SCHEDULER_TYPE_ROOT)
 		memcpy(vp->vp_stats_pages, stats_pages, sizeof(stats_pages));
 
 	/*
@@ -1039,7 +1043,7 @@ mshv_partition_ioctl_create_vp(struct mshv_partition *partition,
 free_vp:
 	kfree(vp);
 unmap_stats_pages:
-	if (hv_parent_partition())
+	if (hv_scheduler_type == HV_SCHEDULER_TYPE_ROOT)
 		mshv_vp_stats_unmap(partition->pt_id, args.vp_index);
 unmap_ghcb_page:
 	if (mshv_partition_encrypted(partition) && is_ghcb_mapping_available()) {
@@ -1793,7 +1797,7 @@ static void destroy_partition(struct mshv_partition *partition)
 			if (!vp)
 				continue;
 
-			if (hv_parent_partition())
+			if (hv_scheduler_type == HV_SCHEDULER_TYPE_ROOT)
 				mshv_vp_stats_unmap(partition->pt_id, vp->vp_index);
 
 			if (vp->vp_register_page) {
-- 
2.34.1
Re: [PATCH 1/6] mshv: Only map vp->vp_stats_pages if on root scheduler
Posted by Tianyu Lan 3 weeks, 6 days ago
On Fri, Aug 29, 2025 at 9:08 AM Nuno Das Neves
<nunodasneves@linux.microsoft.com> wrote:
>
> This mapping is only used for checking if the dispatch thread is
> blocked. This is only relevant for the root scheduler, so check the
> scheduler type to determine whether to map/unmap these pages, instead of
> the current check, which is incorrect.
>
> Signed-off-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
> ---
>  drivers/hv/mshv_root_main.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c
> index e4ee9beddaf5..bbdefe8a2e9c 100644
> --- a/drivers/hv/mshv_root_main.c
> +++ b/drivers/hv/mshv_root_main.c
> @@ -987,7 +987,11 @@ mshv_partition_ioctl_create_vp(struct mshv_partition *partition,
>                         goto unmap_register_page;
>         }
>
> -       if (hv_parent_partition()) {
> +       /*
> +        * This mapping of the stats page is for detecting if dispatch thread
> +        * is blocked - only relevant for root scheduler
> +        */
> +       if (hv_scheduler_type == HV_SCHEDULER_TYPE_ROOT) {
>                 ret = mshv_vp_stats_map(partition->pt_id, args.vp_index,
>                                         stats_pages);
>                 if (ret)
> @@ -1016,7 +1020,7 @@ mshv_partition_ioctl_create_vp(struct mshv_partition *partition,
>         if (mshv_partition_encrypted(partition) && is_ghcb_mapping_available())
>                 vp->vp_ghcb_page = page_to_virt(ghcb_page);
>
> -       if (hv_parent_partition())
> +       if (hv_scheduler_type == HV_SCHEDULER_TYPE_ROOT)
>                 memcpy(vp->vp_stats_pages, stats_pages, sizeof(stats_pages));
>
>         /*
> @@ -1039,7 +1043,7 @@ mshv_partition_ioctl_create_vp(struct mshv_partition *partition,
>  free_vp:
>         kfree(vp);
>  unmap_stats_pages:
> -       if (hv_parent_partition())
> +       if (hv_scheduler_type == HV_SCHEDULER_TYPE_ROOT)
>                 mshv_vp_stats_unmap(partition->pt_id, args.vp_index);
>  unmap_ghcb_page:
>         if (mshv_partition_encrypted(partition) && is_ghcb_mapping_available()) {
> @@ -1793,7 +1797,7 @@ static void destroy_partition(struct mshv_partition *partition)
>                         if (!vp)
>                                 continue;
>
> -                       if (hv_parent_partition())
> +                       if (hv_scheduler_type == HV_SCHEDULER_TYPE_ROOT)
>                                 mshv_vp_stats_unmap(partition->pt_id, vp->vp_index);
>
>                         if (vp->vp_register_page) {
> --
> 2.34.1
>
>
Reviewed-by: Tianyu Lan <tiala@microsoft.com>

-- 
Thanks
Tianyu Lan
Re: [PATCH 1/6] mshv: Only map vp->vp_stats_pages if on root scheduler
Posted by Easwar Hariharan 3 weeks, 6 days ago
On 8/28/2025 5:43 PM, Nuno Das Neves wrote:
> This mapping is only used for checking if the dispatch thread is
> blocked. This is only relevant for the root scheduler, so check the
> scheduler type to determine whether to map/unmap these pages, instead of
> the current check, which is incorrect.
> 
> Signed-off-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
> ---
>  drivers/hv/mshv_root_main.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)

<snip>
Reviewed-by: Easwar Hariharan <easwar.hariharan@linux.microsoft.com>
Re: [PATCH 1/6] mshv: Only map vp->vp_stats_pages if on root scheduler
Posted by Praveen K Paladugu 3 weeks, 6 days ago

On 8/28/2025 7:43 PM, Nuno Das Neves wrote:
> This mapping is only used for checking if the dispatch thread is
> blocked. This is only relevant for the root scheduler, so check the
> scheduler type to determine whether to map/unmap these pages, instead of
> the current check, which is incorrect.
> 
> Signed-off-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
> ---
>   drivers/hv/mshv_root_main.c | 12 ++++++++----
>   1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c
> index e4ee9beddaf5..bbdefe8a2e9c 100644
> --- a/drivers/hv/mshv_root_main.c
> +++ b/drivers/hv/mshv_root_main.c
> @@ -987,7 +987,11 @@ mshv_partition_ioctl_create_vp(struct mshv_partition *partition,
>   			goto unmap_register_page;
>   	}
>   
> -	if (hv_parent_partition()) {
> +	/*
> +	 * This mapping of the stats page is for detecting if dispatch thread
> +	 * is blocked - only relevant for root scheduler
> +	 */
> +	if (hv_scheduler_type == HV_SCHEDULER_TYPE_ROOT) {
>   		ret = mshv_vp_stats_map(partition->pt_id, args.vp_index,
>   					stats_pages);
>   		if (ret)
> @@ -1016,7 +1020,7 @@ mshv_partition_ioctl_create_vp(struct mshv_partition *partition,
>   	if (mshv_partition_encrypted(partition) && is_ghcb_mapping_available())
>   		vp->vp_ghcb_page = page_to_virt(ghcb_page);
>   
> -	if (hv_parent_partition())
> +	if (hv_scheduler_type == HV_SCHEDULER_TYPE_ROOT)
>   		memcpy(vp->vp_stats_pages, stats_pages, sizeof(stats_pages));
>   
>   	/*
> @@ -1039,7 +1043,7 @@ mshv_partition_ioctl_create_vp(struct mshv_partition *partition,
>   free_vp:
>   	kfree(vp);
>   unmap_stats_pages:
> -	if (hv_parent_partition())
> +	if (hv_scheduler_type == HV_SCHEDULER_TYPE_ROOT)
>   		mshv_vp_stats_unmap(partition->pt_id, args.vp_index);
>   unmap_ghcb_page:
>   	if (mshv_partition_encrypted(partition) && is_ghcb_mapping_available()) {
> @@ -1793,7 +1797,7 @@ static void destroy_partition(struct mshv_partition *partition)
>   			if (!vp)
>   				continue;
>   
> -			if (hv_parent_partition())
> +			if (hv_scheduler_type == HV_SCHEDULER_TYPE_ROOT)
>   				mshv_vp_stats_unmap(partition->pt_id, vp->vp_index);
>   
>   			if (vp->vp_register_page) {

Reviewed-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Re: [PATCH 1/6] mshv: Only map vp->vp_stats_pages if on root scheduler
Posted by Anirudh Rayabharam 4 weeks ago
On Thu, Aug 28, 2025 at 05:43:45PM -0700, Nuno Das Neves wrote:
> This mapping is only used for checking if the dispatch thread is
> blocked. This is only relevant for the root scheduler, so check the
> scheduler type to determine whether to map/unmap these pages, instead of
> the current check, which is incorrect.
> 
> Signed-off-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
> ---
>  drivers/hv/mshv_root_main.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c
> index e4ee9beddaf5..bbdefe8a2e9c 100644
> --- a/drivers/hv/mshv_root_main.c
> +++ b/drivers/hv/mshv_root_main.c
> @@ -987,7 +987,11 @@ mshv_partition_ioctl_create_vp(struct mshv_partition *partition,
>  			goto unmap_register_page;
>  	}
>  
> -	if (hv_parent_partition()) {
> +	/*
> +	 * This mapping of the stats page is for detecting if dispatch thread
> +	 * is blocked - only relevant for root scheduler
> +	 */
> +	if (hv_scheduler_type == HV_SCHEDULER_TYPE_ROOT) {
>  		ret = mshv_vp_stats_map(partition->pt_id, args.vp_index,
>  					stats_pages);
>  		if (ret)
> @@ -1016,7 +1020,7 @@ mshv_partition_ioctl_create_vp(struct mshv_partition *partition,
>  	if (mshv_partition_encrypted(partition) && is_ghcb_mapping_available())
>  		vp->vp_ghcb_page = page_to_virt(ghcb_page);
>  
> -	if (hv_parent_partition())
> +	if (hv_scheduler_type == HV_SCHEDULER_TYPE_ROOT)
>  		memcpy(vp->vp_stats_pages, stats_pages, sizeof(stats_pages));
>  
>  	/*
> @@ -1039,7 +1043,7 @@ mshv_partition_ioctl_create_vp(struct mshv_partition *partition,
>  free_vp:
>  	kfree(vp);
>  unmap_stats_pages:
> -	if (hv_parent_partition())
> +	if (hv_scheduler_type == HV_SCHEDULER_TYPE_ROOT)
>  		mshv_vp_stats_unmap(partition->pt_id, args.vp_index);
>  unmap_ghcb_page:
>  	if (mshv_partition_encrypted(partition) && is_ghcb_mapping_available()) {
> @@ -1793,7 +1797,7 @@ static void destroy_partition(struct mshv_partition *partition)
>  			if (!vp)
>  				continue;
>  
> -			if (hv_parent_partition())
> +			if (hv_scheduler_type == HV_SCHEDULER_TYPE_ROOT)
>  				mshv_vp_stats_unmap(partition->pt_id, vp->vp_index);
>  
>  			if (vp->vp_register_page) {
> -- 
> 2.34.1
> 

Reviewed-by: Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com>