Message ID | 1572060239-17401-5-git-send-email-zhenzhong.duan@oracle.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | misc fixes on halt-poll code both KVM and guest | expand |
On Sat, Oct 26, 2019 at 11:23:58AM +0800, Zhenzhong Duan wrote: > dev->poll_limit_ns could be zeroed in certain cases (e.g. by > guest_halt_poll_shrink). If guest_halt_poll_grow_start is zero, > dev->poll_limit_ns will never be larger than zero. > > Signed-off-by: Zhenzhong Duan <zhenzhong.duan@oracle.com> > --- > drivers/cpuidle/governors/haltpoll.c | 15 ++++++++++++--- > 1 file changed, 12 insertions(+), 3 deletions(-) I would rather disallow setting grow_start to zero rather than silently setting it to one on the back of the user.
On 2019/11/2 5:19, Marcelo Tosatti wrote: > On Sat, Oct 26, 2019 at 11:23:58AM +0800, Zhenzhong Duan wrote: >> dev->poll_limit_ns could be zeroed in certain cases (e.g. by >> guest_halt_poll_shrink). If guest_halt_poll_grow_start is zero, >> dev->poll_limit_ns will never be larger than zero. >> >> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@oracle.com> >> --- >> drivers/cpuidle/governors/haltpoll.c | 15 ++++++++++++--- >> 1 file changed, 12 insertions(+), 3 deletions(-) > I would rather disallow setting grow_start to zero rather > than silently setting it to one on the back of the user. Ok, will do. Thanks Zhenzhong
On 04/11/19 03:56, Zhenzhong Duan wrote: > > On 2019/11/2 5:19, Marcelo Tosatti wrote: >> On Sat, Oct 26, 2019 at 11:23:58AM +0800, Zhenzhong Duan wrote: >>> dev->poll_limit_ns could be zeroed in certain cases (e.g. by >>> guest_halt_poll_shrink). If guest_halt_poll_grow_start is zero, >>> dev->poll_limit_ns will never be larger than zero. >>> >>> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@oracle.com> >>> --- >>> drivers/cpuidle/governors/haltpoll.c | 15 ++++++++++++--- >>> 1 file changed, 12 insertions(+), 3 deletions(-) >> I would rather disallow setting grow_start to zero rather >> than silently setting it to one on the back of the user. > > Ok, will do. Similar to patch 2, I think disabling halt polling is a good behavior if grow_start = 0. Paolo
diff --git a/drivers/cpuidle/governors/haltpoll.c b/drivers/cpuidle/governors/haltpoll.c index 7a703d2..4b00d7a 100644 --- a/drivers/cpuidle/governors/haltpoll.c +++ b/drivers/cpuidle/governors/haltpoll.c @@ -77,7 +77,7 @@ static int haltpoll_select(struct cpuidle_driver *drv, static void adjust_poll_limit(struct cpuidle_device *dev, unsigned int block_us) { - unsigned int val; + unsigned int val, grow_start; u64 block_ns = block_us*NSEC_PER_USEC; /* Grow cpu_halt_poll_us if @@ -86,8 +86,17 @@ static void adjust_poll_limit(struct cpuidle_device *dev, unsigned int block_us) if (block_ns > dev->poll_limit_ns && block_ns <= guest_halt_poll_ns) { val = dev->poll_limit_ns * guest_halt_poll_grow; - if (val < guest_halt_poll_grow_start) - val = guest_halt_poll_grow_start; + /* + * vcpu->halt_poll_ns needs a nonzero start point to grow if + * it's zero. + */ + grow_start = guest_halt_poll_grow_start; + if (!grow_start) + grow_start = 1; + + if (val < grow_start) + val = grow_start; + if (val > guest_halt_poll_ns) val = guest_halt_poll_ns;
dev->poll_limit_ns could be zeroed in certain cases (e.g. by guest_halt_poll_shrink). If guest_halt_poll_grow_start is zero, dev->poll_limit_ns will never be larger than zero. Signed-off-by: Zhenzhong Duan <zhenzhong.duan@oracle.com> --- drivers/cpuidle/governors/haltpoll.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)