All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, lvivier@redhat.com, thuth@redhat.com
Subject: Re: [kvm-unit-tests PATCH v2 6/6] lib/x86/vm: enable malloc and friends
Date: Thu, 3 Nov 2016 19:42:35 +0100	[thread overview]
Message-ID: <20161103184235.nsc3o5m3ai63aiyr@kamzik.brq.redhat.com> (raw)
In-Reply-To: <da123594-afc5-d16a-5aa6-d87ad1397f75@redhat.com>

On Thu, Nov 03, 2016 at 07:20:20PM +0100, Paolo Bonzini wrote:
> 
> 
> On 03/11/2016 19:12, Andrew Jones wrote:
> > On Thu, Nov 03, 2016 at 06:34:45PM +0100, Paolo Bonzini wrote:
> >> You're right, it needs alignment too.  So yeah, early_memalign's code
> >> can be repurposed as the early allocator's morecore callback.  For the
> >> current trivial malloc implementation, malloc would be implemented as
> >> ops->morecore(size, align_min).  I think we agree on the overall idea
> >> and on having only one function pointer.
> > 
> > Yup, already done. But 2, not 1, pointers. Still need 'free' too.
> 
> Didn't we say that the morecore allocator would only grow?

morecore[phys_alloc] only grows, free -> {}
morecore[vmemalign] can do both, free -> vfree

> 
> >> 3) make alloc_vpages go bottom to top (not strictly necessary but nice);
> > 
> > OK, from what base though? 0x8, i.e. just skip NULL?
> 
> Well, the right one would be "after the last thing that phys allocated".
>  For x86 however you'd have to init the phys allocator to edata.  But
> let's leave this for later.

Hmm, I see what's going on now in x86. First, setup_vm should be doing
setup_mmu *before* 'free_memory' (what I renamed to heap_init), because
it assumes it's using virtual address with page_alloc/free. Second, x86
creates an identity map up to end_of_memory, and that's the last address
the heap knows about too. So, if we want to allocate free virtual
addresses upwards, then we should start from end_of_memory.

> 
> >>
> >> 4) replaces vmalloc/vfree with memalign(align=4096)/free in x86/;
> > 
> > I thought about this already, but I wasn't sure we wanted to abandon
> > the explicit "I want virt mem" vmalloc naming. memalign/malloc will
> > be vmalloc for any unit test that does setup_vm, but otherwise (if
> > x86 adopted phys_alloc) it wouldn't. Maybe x86 should just never
> > adopt phys_alloc, leading to asserts when setup_vm hasn't been
> > called?
> 
> I don't think the tests want virtual memory specifically.  If they want,
> they use things like vmap.

OK

> 
> Paolo
> 
> >>
> >> 5) moves the virt allocator and the vmalloc ops to a new file
> >> lib/vmalloc.c (with install_page() remaining as the sole hook into
> >> arch-specific code), removing what's now dead from lib/vmalloc.c.
> > 
> > Yeah, this is a good next step. Will do.

This one looks like we'll need to cleanup the install_page parameter
expectations a bit in order to keep arch-specific stuff out of the callers,
but that should be doable.

drew

  reply	other threads:[~2016-11-03 18:42 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-02 20:52 [kvm-unit-tests PATCH v2 0/6] x86: enable malloc and friends Andrew Jones
2016-11-02 20:52 ` [kvm-unit-tests PATCH v2 1/6] lib/x86/vm: collection of improvements Andrew Jones
2016-11-03  9:40   ` Laurent Vivier
2016-11-03 10:42     ` Andrew Jones
2016-11-02 20:52 ` [kvm-unit-tests PATCH v2 2/6] lib/alloc: improve init Andrew Jones
2016-11-03 10:57   ` Laurent Vivier
2016-11-02 20:52 ` [kvm-unit-tests PATCH v2 3/6] lib/alloc: prepare to extend alloc.c's purpose Andrew Jones
2016-11-03 12:30   ` Laurent Vivier
2016-11-02 20:52 ` [kvm-unit-tests PATCH v2 4/6] x86: lib/alloc: move heap management to lib Andrew Jones
2016-11-03 13:28   ` Laurent Vivier
2016-11-03 13:38     ` Andrew Jones
2016-11-03 17:21   ` Paolo Bonzini
2016-11-03 17:53     ` Andrew Jones
2016-11-02 20:52 ` [kvm-unit-tests PATCH v2 5/6] x86: lib/alloc: introduce alloc_zeroed_page Andrew Jones
2016-11-03 12:02   ` Laurent Vivier
2016-11-03 12:47     ` Andrew Jones
2016-11-03 13:03       ` Laurent Vivier
2016-11-02 20:52 ` [kvm-unit-tests PATCH v2 6/6] lib/x86/vm: enable malloc and friends Andrew Jones
2016-11-03 14:12   ` Paolo Bonzini
2016-11-03 14:58     ` Andrew Jones
2016-11-03 16:00       ` Paolo Bonzini
2016-11-03 16:51         ` Andrew Jones
2016-11-03 17:34           ` Paolo Bonzini
2016-11-03 18:12             ` Andrew Jones
2016-11-03 18:20               ` Paolo Bonzini
2016-11-03 18:42                 ` Andrew Jones [this message]
2016-11-03 19:19                   ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161103184235.nsc3o5m3ai63aiyr@kamzik.brq.redhat.com \
    --to=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.