On 04/09/2018 17:57, Wei Yang wrote: > The code tries to pre-allocate *min* number of objects, so it is ok to > return 0 when the kvm_mmu_memory_cache meets the requirement. > > Signed-off-by: Wei Yang <richard.weiyang@xxxxxxxxx> > --- > arch/x86/kvm/mmu.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c > index 28da8a9bd37b..aee296c579e1 100644 > --- a/arch/x86/kvm/mmu.c > +++ b/arch/x86/kvm/mmu.c > @@ -916,7 +916,7 @@ static int mmu_topup_memory_cache(struct kvm_mmu_memory_cache *cache, > while (cache->nobjs < ARRAY_SIZE(cache->objects)) { > obj = kmem_cache_zalloc(base_cache, GFP_KERNEL); > if (!obj) > - return -ENOMEM; > + return (cache->nobjs >= min)?0 : -ENOMEM; > cache->objects[cache->nobjs++] = obj; > } > return 0; > @@ -944,7 +944,7 @@ static int mmu_topup_memory_cache_page(struct kvm_mmu_memory_cache *cache, > while (cache->nobjs < ARRAY_SIZE(cache->objects)) { > page = (void *)__get_free_page(GFP_KERNEL_ACCOUNT); > if (!page) > - return -ENOMEM; > + return (cache->nobjs >= min)?0 : -ENOMEM; > cache->objects[cache->nobjs++] = page; > } > return 0; > Queued, thanks. Paolo