From: Claudio Imbrenda <imbrenda@linux.ibm.com>
To: kvm@vger.kernel.org, pbonzini@redhat.com
Cc: frankja@linux.ibm.com, david@redhat.com, thuth@redhat.com,
cohuck@redhat.com, lvivier@redhat.com
Subject: [kvm-unit-tests RFC v1 4/5] lib/alloc.h: remove align_min from struct alloc_ops
Date: Fri, 14 Aug 2020 17:10:08 +0200 [thread overview]
Message-ID: <20200814151009.55845-5-imbrenda@linux.ibm.com> (raw)
In-Reply-To: <20200814151009.55845-1-imbrenda@linux.ibm.com>
Remove align_min from struct alloc_ops.
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
---
lib/alloc.h | 1 -
lib/alloc_page.c | 1 -
lib/alloc_phys.c | 9 +++++----
lib/vmalloc.c | 1 -
4 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/lib/alloc.h b/lib/alloc.h
index 9b4b634..db90b01 100644
--- a/lib/alloc.h
+++ b/lib/alloc.h
@@ -25,7 +25,6 @@
struct alloc_ops {
void *(*memalign)(size_t alignment, size_t size);
void (*free)(void *ptr);
- size_t align_min;
};
extern struct alloc_ops *alloc_ops;
diff --git a/lib/alloc_page.c b/lib/alloc_page.c
index 0e720ad..d3ade58 100644
--- a/lib/alloc_page.c
+++ b/lib/alloc_page.c
@@ -325,7 +325,6 @@ void *alloc_page()
static struct alloc_ops page_alloc_ops = {
.memalign = memalign_pages,
.free = free_pages,
- .align_min = PAGE_SIZE,
};
/*
diff --git a/lib/alloc_phys.c b/lib/alloc_phys.c
index 72e20f7..a4d2bf2 100644
--- a/lib/alloc_phys.c
+++ b/lib/alloc_phys.c
@@ -29,8 +29,8 @@ static phys_addr_t base, top;
static void *early_memalign(size_t alignment, size_t size);
static struct alloc_ops early_alloc_ops = {
.memalign = early_memalign,
- .align_min = DEFAULT_MINIMUM_ALIGNMENT
};
+static size_t align_min;
struct alloc_ops *alloc_ops = &early_alloc_ops;
@@ -39,8 +39,7 @@ void phys_alloc_show(void)
int i;
spin_lock(&lock);
- printf("phys_alloc minimum alignment: %#" PRIx64 "\n",
- (u64)early_alloc_ops.align_min);
+ printf("phys_alloc minimum alignment: %#" PRIx64 "\n", (u64)align_min);
for (i = 0; i < nr_regions; ++i)
printf("%016" PRIx64 "-%016" PRIx64 " [%s]\n",
(u64)regions[i].base,
@@ -64,7 +63,7 @@ void phys_alloc_set_minimum_alignment(phys_addr_t align)
{
assert(align && !(align & (align - 1)));
spin_lock(&lock);
- early_alloc_ops.align_min = align;
+ align_min = align;
spin_unlock(&lock);
}
@@ -83,6 +82,8 @@ static phys_addr_t phys_alloc_aligned_safe(phys_addr_t size,
top_safe = MIN(top_safe, 1ULL << 32);
assert(base < top_safe);
+ if (align < align_min)
+ align = align_min;
addr = ALIGN(base, align);
size += addr - base;
diff --git a/lib/vmalloc.c b/lib/vmalloc.c
index 55b7a74..bcb9bf5 100644
--- a/lib/vmalloc.c
+++ b/lib/vmalloc.c
@@ -188,7 +188,6 @@ static void vm_free(void *mem)
static struct alloc_ops vmalloc_ops = {
.memalign = vm_memalign,
.free = vm_free,
- .align_min = PAGE_SIZE,
};
void __attribute__((__weak__)) find_highmem(void)
--
2.26.2
next prev parent reply other threads:[~2020-08-14 15:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-14 15:10 [kvm-unit-tests RFC v1 0/5] Rewrite the allocators Claudio Imbrenda
2020-08-14 15:10 ` [kvm-unit-tests RFC v1 1/5] lib/vmalloc: vmalloc support for handling allocation metadata Claudio Imbrenda
2020-08-19 14:36 ` Janosch Frank
2020-08-19 15:31 ` Claudio Imbrenda
2020-08-19 15:36 ` Janosch Frank
2020-08-14 15:10 ` [kvm-unit-tests RFC v1 2/5] lib/alloc_page: complete rewrite of the page allocator Claudio Imbrenda
2020-08-18 16:06 ` Cornelia Huck
2020-08-19 15:44 ` Janosch Frank
2020-08-19 16:46 ` Claudio Imbrenda
2020-08-14 15:10 ` [kvm-unit-tests RFC v1 3/5] lib/alloc: simplify free and malloc Claudio Imbrenda
2020-08-14 15:10 ` Claudio Imbrenda [this message]
2020-08-14 15:10 ` [kvm-unit-tests RFC v1 5/5] lib/alloc_page: allow reserving arbitrary memory ranges Claudio Imbrenda
2020-08-17 16:44 ` [kvm-unit-tests RFC v1 0/5] Rewrite the allocators 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=20200814151009.55845-5-imbrenda@linux.ibm.com \
--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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox