Re: [PATCH 4/4] Use kmem cache for allocating vcpus, simplify FPU ops

Rusty Russell
2007-07-30T10:04:42Z

On Mon, 2007-07-30 at 12:12 +0300, Avi Kivity wrote:
> Rusty Russell wrote:
> > If we use a kmem cache for allocating vcpus, we can get the 16-byte
> > alignment required by fxsave & fxrstor instructions, and avoid
> > manually aligning the buffer.
>
> Please separate the slabification from the fpu cleanups into separate
> patches.

Hmm, are you trying to get my patch count up?

> > static int __init svm_init(void)
> > {
> > - return kvm_init_arch(&svm_arch_ops, THIS_MODULE);
> > + int err;
> > +
> > + /* A kmem cache lets us meet the alignment requirements of fx_save. */
> > + svm_kmem_cache = KMEM_CACHE(vcpu_svm, 0);
> >
>
> kvm slab caches are prefixed with kvm_; this makes it easy to 'grep kvm
> /proc/slabinfo' to see kvm leaks. Please preserve that.

How horrible. We'd be better with KMEM_CACHE() prefixing the module
name. I'll change this to use the manual "non-recommended" way for the
moment and submit a patch later.

> Also, the allocation and destruction can be in common code, reducing the
> amount of rarely-executed error paths.

Sure, we could pass the size into the core so it can allocate the slab
cache, then have the core do the allocation itself (undoing the recent
create_vcpu change).

Is it worth it?

Rusty.