lkml.org 
[lkml]   [2018]   [Dec]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] kvm/arm: return 0 when the number of objects is not lessthan min
On Thu, Dec 06, 2018 at 09:56:30AM +0800, peng.hao2@zte.com.cn wrote:
> >On Wed, Dec 05, 2018 at 09:15:51AM +0800, Peng Hao wrote:
> >> Return 0 when there is enough kvm_mmu_memory_cache object.
> >>
> >> Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
> >> ---
> >> virt/kvm/arm/mmu.c | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c
> >> index ed162a6..fcda0ce 100644
> >> --- a/virt/kvm/arm/mmu.c
> >> +++ b/virt/kvm/arm/mmu.c
> >> @@ -127,7 +127,7 @@ static int mmu_topup_memory_cache(struct kvm_mmu_memory_cache *cache,
> >> while (cache->nobjs < max) {
> >> page = (void *)__get_free_page(PGALLOC_GFP);
> >> if (!page)
> >> - return -ENOMEM;
> >> + return cache->nobjs >= min ? 0 : -ENOMEM;
> >
> >This condition will never be true here, as the exact same condition is
> >already checked above, and if it had been true, then we wouldn't be here.
> >
> >What problem are you attempting to solve?
> >
> if (cache->nobjs >= min) ------here cache->nobjs<min,it can continue downward
> return 0;
> while (cache->nobjs < max) {
> page = (void *)__get_free_page(PGALLOC_GFP);
> if (!page)
> return -ENOMEM; -----here it is possible that (cache->nobjs >= min) and (cache->nobjs<max)
> cache->objects[cache->nobjs++] = page; ---here cache->nobjs increasing
> }
>
> I just think the logic of this function is to return 0 as long as (cache->nobjs >= min).
> thanks.

Oh, I see now. This is the case where we can do enough allocating to over
the min line, but fail before we get to the max.

Thanks,
drew

\
 
 \ /
  Last update: 2018-12-06 15:30    [W:0.045 / U:2.320 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site