All of lore.kernel.org
 help / color / mirror / Atom feed
From: Claudio Imbrenda <imbrenda@linux.ibm.com>
To: Sean Christopherson <seanjc@google.com>
Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com,
	thuth@redhat.com, pbonzini@redhat.com, cohuck@redhat.com,
	lvivier@redhat.com, nadav.amit@gmail.com
Subject: Re: [kvm-unit-tests PATCH v1 05/12] lib/alloc_page: fix and improve the page allocator
Date: Mon, 4 Jan 2021 18:23:41 +0100	[thread overview]
Message-ID: <20210104182341.00c82b55@ibm-vm> (raw)
In-Reply-To: <X+ozTlQD0wePcOXJ@google.com>

On Mon, 28 Dec 2020 11:34:38 -0800
Sean Christopherson <seanjc@google.com> wrote:

> On Wed, Dec 16, 2020, Claudio Imbrenda wrote:
> >  /*
> > - * Allocates and reserves the specified memory range if possible.
> > - * Returns NULL in case of failure.
> > + * Allocates and reserves the specified physical memory range if
> > possible.
> > + * If the specified range cannot be reserved in its entirety, no
> > action is
> > + * performed and false is returned.
> > + *
> > + * Returns true in case of success, false otherwise.
> >   */
> > -void *alloc_pages_special(uintptr_t addr, size_t npages);
> > +bool alloc_pages_special(phys_addr_t addr, size_t npages);  
> 
> The boolean return is a bit awkward as kernel programmers will likely

do you prefer int, with 0 for success and -1 for failure?
that's surely not a problem

> expect a non-zero return to mean failure.  But, since there are no
> users, can we simply drop the entire *_pages_special() API?
> Allocating a specific PFN that isn't MMIO seems doomed to fail
> anyways; I'm having a hard time envisioning a test that would be able
> to use such an API without being horribly fragile.

I can. s390x can use this for some tests, where we need to allocate
memory at within or outside of specific areas, which might only be
known at run time (so we can't use the memory areas)

the alternative would be to allocate all the memory, take what is
needed, and then free the rest.... not very elegant

> >  
> >  /*
> >   * Frees a reserved memory range that had been reserved with
> > @@ -91,6 +110,6 @@ void *alloc_pages_special(uintptr_t addr, size_t
> > npages);
> >   * exactly, it can also be a subset, in which case only the
> > specified
> >   * pages will be freed and unreserved.
> >   */
> > -void free_pages_special(uintptr_t addr, size_t npages);
> > +void free_pages_special(phys_addr_t addr, size_t npages);  


  reply	other threads:[~2021-01-04 17:24 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-16 20:11 [kvm-unit-tests PATCH v1 00/12] Fix and improve the page allocator Claudio Imbrenda
2020-12-16 20:11 ` [kvm-unit-tests PATCH v1 01/12] lib/x86: fix page.h to include the generic header Claudio Imbrenda
2020-12-17 12:33   ` Thomas Huth
2020-12-16 20:11 ` [kvm-unit-tests PATCH v1 02/12] lib/list.h: add list_add_tail Claudio Imbrenda
2020-12-17 12:39   ` Thomas Huth
2020-12-16 20:11 ` [kvm-unit-tests PATCH v1 03/12] lib/vmalloc: add some asserts and improvements Claudio Imbrenda
2020-12-24 18:16   ` Krish Sadhukhan
2021-01-04 13:27     ` Claudio Imbrenda
2020-12-16 20:11 ` [kvm-unit-tests PATCH v1 04/12] lib/asm: Fix definitions of memory areas Claudio Imbrenda
2020-12-24 18:17   ` Krish Sadhukhan
2021-01-04 13:19     ` Claudio Imbrenda
2021-01-05  1:17       ` Krish Sadhukhan
2020-12-16 20:11 ` [kvm-unit-tests PATCH v1 05/12] lib/alloc_page: fix and improve the page allocator Claudio Imbrenda
2020-12-24 18:17   ` Krish Sadhukhan
2021-01-04 13:11     ` Claudio Imbrenda
2021-01-05  1:15       ` Krish Sadhukhan
2020-12-28 19:34   ` Sean Christopherson
2021-01-04 17:23     ` Claudio Imbrenda [this message]
2020-12-16 20:11 ` [kvm-unit-tests PATCH v1 06/12] lib/alloc.h: remove align_min from struct alloc_ops Claudio Imbrenda
2020-12-24 18:17   ` Krish Sadhukhan
2021-01-04 13:05     ` Claudio Imbrenda
2021-01-05  0:39       ` Krish Sadhukhan
2020-12-16 20:11 ` [kvm-unit-tests PATCH v1 07/12] lib/alloc_page: Optimization to skip known empty freelists Claudio Imbrenda
2020-12-16 20:11 ` [kvm-unit-tests PATCH v1 08/12] lib/alloc_page: rework metadata format Claudio Imbrenda
2020-12-16 20:11 ` [kvm-unit-tests PATCH v1 09/12] lib/alloc: replace areas with more generic flags Claudio Imbrenda
2020-12-16 20:11 ` [kvm-unit-tests PATCH v1 10/12] lib/alloc_page: Wire up ZERO_FLAG Claudio Imbrenda
2020-12-16 20:11 ` [kvm-unit-tests PATCH v1 11/12] lib/alloc_page: Properly handle requests for fresh blocks Claudio Imbrenda
2020-12-16 20:12 ` [kvm-unit-tests PATCH v1 12/12] lib/alloc_page: default flags and zero pages by default Claudio Imbrenda
2020-12-24 18:17   ` Krish Sadhukhan
2021-01-04 13:32     ` Claudio Imbrenda
2020-12-17 19:41 ` [kvm-unit-tests PATCH v1 00/12] Fix and improve the page allocator Nadav Amit
2020-12-18 14:19   ` Claudio Imbrenda
2020-12-28  6:31     ` Nadav Amit
2021-01-05 15:26       ` Claudio Imbrenda
2020-12-24 18:19 ` Krish Sadhukhan

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=20210104182341.00c82b55@ibm-vm \
    --to=imbrenda@linux.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=lvivier@redhat.com \
    --cc=nadav.amit@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.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.