From: Claudio Imbrenda <imbrenda@linux.ibm.com>
To: Krish Sadhukhan <krish.sadhukhan@oracle.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 12/12] lib/alloc_page: default flags and zero pages by default
Date: Mon, 4 Jan 2021 14:32:57 +0100 [thread overview]
Message-ID: <20210104143257.31544269@ibm-vm> (raw)
In-Reply-To: <c61ee0fb-5d06-8c61-fa97-975c6a603599@oracle.com>
On Thu, 24 Dec 2020 10:17:30 -0800
Krish Sadhukhan <krish.sadhukhan@oracle.com> wrote:
> On 12/16/20 12:12 PM, Claudio Imbrenda wrote:
> > The new function page_alloc_set_default_flags can be used to set the
> > default flags for allocations. The passed value will be ORed with
> > the flags argument passed to the allocator at each allocation.
> >
> > The default value for the default flags is FLAG_ZERO, which means
> > that by default all allocated memory is now zeroed, restoring the
> > default behaviour that had been accidentally removed by a previous
> > commit.
> >
> > If needed, a testcase can call page_alloc_set_default_flags(0) in
> > order to get non-zeroed pages from the allocator. For example, if
> > the testcase will need fresh memory, the zero flag should be
> > removed from the default.
> >
> > Fixes: 8131e91a4b61 ("lib/alloc_page: complete rewrite of the page
> > allocator") Reported-by: Nadav Amit<nadav.amit@gmail.com>
> >
> > Signed-off-by: Claudio Imbrenda<imbrenda@linux.ibm.com>
> > ---
> > lib/alloc_page.h | 3 +++
> > lib/alloc_page.c | 8 ++++++++
> > 2 files changed, 11 insertions(+)
> >
> > diff --git a/lib/alloc_page.h b/lib/alloc_page.h
> > index 1039814..8b53a58 100644
> > --- a/lib/alloc_page.h
> > +++ b/lib/alloc_page.h
> > @@ -22,6 +22,9 @@
> > /* Returns true if the page allocator has been initialized */
> > bool page_alloc_initialized(void);
> >
> > +/* Sets the default flags for the page allocator, the default is
> > FLAG_ZERO */ +void page_alloc_set_default_flags(unsigned int flags);
> > +
> > /*
> > * Initializes a memory area.
> > * n is the number of the area to initialize
> > diff --git a/lib/alloc_page.c b/lib/alloc_page.c
> > index 4d5722f..08e0d05 100644
> > --- a/lib/alloc_page.c
> > +++ b/lib/alloc_page.c
> > @@ -54,12 +54,19 @@ static struct mem_area areas[MAX_AREAS];
> > static unsigned int areas_mask;
> > /* Protects areas and areas mask */
> > static struct spinlock lock;
> > +/* Default behaviour: zero allocated pages */
> > +static unsigned int default_flags = FLAG_ZERO;
> >
> > bool page_alloc_initialized(void)
> > {
> > return areas_mask != 0;
> > }
> >
> > +void page_alloc_set_default_flags(unsigned int flags)
> > +{
> > + default_flags = flags;
>
>
> Who calls this functions ?
nobody yet, since I have just introduced them.
The idea is that a testcase should call this early on to set the default
> Just wondering if default flag should be a static set of flag values
> which the caller can override based on needs rather than the caller
> setting the default flag.
hmmmmm
I would only need to reverse the semantics of FLAG_ZERO, but then I can
get rid of this patch
I think I'll do it
> > +}
> > +
> > /*
> > * Each memory area contains an array of metadata entries at the
> > very
> > * beginning. The usable memory follows immediately afterwards.
> > @@ -394,6 +401,7 @@ static void *page_memalign_order_flags(u8 ord,
> > u8 al, u32 flags) void *res = NULL;
> > int i, area, fresh;
> >
> > + flags |= default_flags;
> > fresh = !!(flags & FLAG_FRESH);
> > spin_lock(&lock);
> > area = (flags & AREA_MASK) ? flags & areas_mask :
> > areas_mask;
next prev parent reply other threads:[~2021-01-04 13:34 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
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 [this message]
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=20210104143257.31544269@ibm-vm \
--to=imbrenda@linux.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=krish.sadhukhan@oracle.com \
--cc=kvm@vger.kernel.org \
--cc=lvivier@redhat.com \
--cc=nadav.amit@gmail.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.