diff mbox series

kvm: exit halt polling on need_resched() as well

Message ID 20210429162233.116849-1-venkateshs@chromium.org (mailing list archive)
State New, archived
Headers show
Series kvm: exit halt polling on need_resched() as well | expand

Commit Message

Venkatesh Srinivas April 29, 2021, 4:22 p.m. UTC
From: Benjamin Segall <bsegall@google.com>

single_task_running() is usually more general than need_resched()
but CFS_BANDWIDTH throttling will use resched_task() when there
is just one task to get the task to block. This was causing
long-need_resched warnings and was likely allowing VMs to
overrun their quota when halt polling.

Signed-off-by: Ben Segall <bsegall@google.com>
Signed-off-by: Venkatesh Srinivas <venkateshs@chromium.org>
---
 virt/kvm/kvm_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jim Mattson April 29, 2021, 4:39 p.m. UTC | #1
On Thu, Apr 29, 2021 at 9:22 AM Venkatesh Srinivas
<venkateshs@chromium.org> wrote:
>
> From: Benjamin Segall <bsegall@google.com>
>
> single_task_running() is usually more general than need_resched()
> but CFS_BANDWIDTH throttling will use resched_task() when there
> is just one task to get the task to block. This was causing
> long-need_resched warnings and was likely allowing VMs to
> overrun their quota when halt polling.
>
> Signed-off-by: Ben Segall <bsegall@google.com>
> Signed-off-by: Venkatesh Srinivas <venkateshs@chromium.org>
Reviewed-by: Jim Mattson <jmattson@google.com>
David Matlack April 30, 2021, 3:48 p.m. UTC | #2
On Thu, Apr 29, 2021 at 9:22 AM Venkatesh Srinivas
<venkateshs@chromium.org> wrote:
>
> From: Benjamin Segall <bsegall@google.com>
>
> single_task_running() is usually more general than need_resched()
> but CFS_BANDWIDTH throttling will use resched_task() when there
> is just one task to get the task to block. This was causing
> long-need_resched warnings and was likely allowing VMs to
> overrun their quota when halt polling.
>
> Signed-off-by: Ben Segall <bsegall@google.com>
> Signed-off-by: Venkatesh Srinivas <venkateshs@chromium.org>

Reviewed-by: David Matlack <dmatlack@google.com>
Christian Borntraeger April 30, 2021, 5:43 p.m. UTC | #3
On 29.04.21 18:22, Venkatesh Srinivas wrote:
> From: Benjamin Segall <bsegall@google.com>
> 
> single_task_running() is usually more general than need_resched()
> but CFS_BANDWIDTH throttling will use resched_task() when there
> is just one task to get the task to block. This was causing
> long-need_resched warnings and was likely allowing VMs to
> overrun their quota when halt polling.
> 
> Signed-off-by: Ben Segall <bsegall@google.com>
> Signed-off-by: Venkatesh Srinivas <venkateshs@chromium.org>

would that qualify for stable?

> ---
>   virt/kvm/kvm_main.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 2799c6660cce..b9f12da6af0e 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -2973,7 +2973,8 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
>   				goto out;
>   			}
>   			poll_end = cur = ktime_get();
> -		} while (single_task_running() && ktime_before(cur, stop));
> +		} while (single_task_running() && !need_resched() &&
> +			 ktime_before(cur, stop));
>   	}
> 
>   	prepare_to_rcuwait(&vcpu->wait);
>
Paolo Bonzini May 3, 2021, 2:52 p.m. UTC | #4
On 30/04/21 19:43, Christian Borntraeger wrote:
> 
> 
> On 29.04.21 18:22, Venkatesh Srinivas wrote:
>> From: Benjamin Segall <bsegall@google.com>
>>
>> single_task_running() is usually more general than need_resched()
>> but CFS_BANDWIDTH throttling will use resched_task() when there
>> is just one task to get the task to block. This was causing
>> long-need_resched warnings and was likely allowing VMs to
>> overrun their quota when halt polling.
>>
>> Signed-off-by: Ben Segall <bsegall@google.com>
>> Signed-off-by: Venkatesh Srinivas <venkateshs@chromium.org>
> 
> would that qualify for stable?

Good idea indeed, I added the Cc.

Paolo

>> ---
>>   virt/kvm/kvm_main.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
>> index 2799c6660cce..b9f12da6af0e 100644
>> --- a/virt/kvm/kvm_main.c
>> +++ b/virt/kvm/kvm_main.c
>> @@ -2973,7 +2973,8 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
>>                   goto out;
>>               }
>>               poll_end = cur = ktime_get();
>> -        } while (single_task_running() && ktime_before(cur, stop));
>> +        } while (single_task_running() && !need_resched() &&
>> +             ktime_before(cur, stop));
>>       }
>>
>>       prepare_to_rcuwait(&vcpu->wait);
>>
>
diff mbox series

Patch

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 2799c6660cce..b9f12da6af0e 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2973,7 +2973,8 @@  void kvm_vcpu_block(struct kvm_vcpu *vcpu)
 				goto out;
 			}
 			poll_end = cur = ktime_get();
-		} while (single_task_running() && ktime_before(cur, stop));
+		} while (single_task_running() && !need_resched() &&
+			 ktime_before(cur, stop));
 	}
 
 	prepare_to_rcuwait(&vcpu->wait);