On Thu, Jan 26, 2023, Huang, Kai wrote: > On Wed, 2023-01-25 at 17:22 +0000, Sean Christopherson wrote: > > I agree that handling this in the common code would be cleaner, but repurposing > > gfp_zero gets kludgy because it would require a magic value to say "don't initialize > > the data", e.g. x86's mmu_shadowed_info_cache isn't pre-filled. ... > > @@ -400,6 +405,13 @@ int __kvm_mmu_topup_memory_cache(struct kvm_mmu_memory_cache *mc, int capacity, > > if (WARN_ON_ONCE(!capacity)) > > return -EIO; > > > > + /* > > + * Custom init values can be used only for page allocations, > > + * and obviously conflict with __GFP_ZERO. > > + */ > > + if (WARN_ON_ONCE(mc->init_value && (mc->kmem_cache || mc->gfp_zero))) > > + return -EIO; > > + > > mc->objects = kvmalloc_array(sizeof(void *), capacity, gfp); > > if (!mc->objects) > > return -ENOMEM; > > > > base-commit: 503f0315c97739d3f8e645c500d81757dfbf76be > > init_value and gfp_zone is kinda redundant. How about removing gfp_zero > completely? > > mmu_memory_cache_alloc_obj(...) > { > ... > if (!mc->init_value) > gfp_flags |= __GFP_ZERO; > ... > } > > And in kvm_mmu_create() you initialize all caches' init_value explicitly. No, as mentioned above there's also a "don't initialize the data" case. Leaving init_value=0 means those users would see unnecessary zeroing, and again I don't want to use a magic value to say "don't initialize".