* [PATCH/RFC] mm: add vm_area_add_early()
@ 2011-09-14 18:35 Nicolas Pitre
2011-10-06 23:10 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Pitre @ 2011-09-14 18:35 UTC (permalink / raw)
To: linux-kernel, linux-mm; +Cc: linux-arm-kernel
The existing vm_area_register_early() allows for early vmalloc space
allocation. However upcoming cleanups in the ARM architecture require
that some fixed locations in the vmalloc area be reserved also very early.
The name "vm_area_register_early" would have been a good name for the
reservation part without the allocation. Since it is already in use with
different semantics, let's create vm_area_add_early() instead.
Both vm_area_register_early() and vm_area_add_early() can be used together
meaning that the former is now implemented using the later where it is
ensured that no conflicting areas are added, but no attempt is made to
make the allocation scheme in vm_area_register_early() more sophisticated.
After all, you must know what you're doing when using those functions.
Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
---
Comments / ACKs appreciated.
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index 9332e52ea8..e7d2cba995 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -130,6 +130,7 @@ extern long vwrite(char *buf, char *addr, unsigned long count);
*/
extern rwlock_t vmlist_lock;
extern struct vm_struct *vmlist;
+extern __init void vm_area_add_early(struct vm_struct *vm);
extern __init void vm_area_register_early(struct vm_struct *vm, size_t align);
#ifdef CONFIG_SMP
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 7ef0903058..bf20a0ff95 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -1118,6 +1118,31 @@ void *vm_map_ram(struct page **pages, unsigned int count, int node, pgprot_t pro
EXPORT_SYMBOL(vm_map_ram);
/**
+ * vm_area_add_early - add vmap area early during boot
+ * @vm: vm_struct to add
+ *
+ * This function is used to add fixed kernel vm area to vmlist before
+ * vmalloc_init() is called. @vm->addr, @vm->size, and @vm->flags
+ * should contain proper values and the other fields should be zero.
+ *
+ * DO NOT USE THIS FUNCTION UNLESS YOU KNOW WHAT YOU'RE DOING.
+ */
+void __init vm_area_add_early(struct vm_struct *vm)
+{
+ struct vm_struct *tmp, **p;
+
+ for (p = &vmlist; (tmp = *p) != NULL; p = &tmp->next) {
+ if (tmp->addr >= vm->addr) {
+ BUG_ON(tmp->addr < vm->addr + vm->size);
+ break;
+ } else
+ BUG_ON(tmp->addr + tmp->size > vm->addr);
+ }
+ vm->next = *p;
+ *p = vm;
+}
+
+/**
* vm_area_register_early - register vmap area early during boot
* @vm: vm_struct to register
* @align: requested alignment
@@ -1139,8 +1164,7 @@ void __init vm_area_register_early(struct vm_struct *vm, size_t align)
vm->addr = (void *)addr;
- vm->next = vmlist;
- vmlist = vm;
+ vm_area_add_early(vm);
}
void __init vmalloc_init(void)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH/RFC] mm: add vm_area_add_early()
2011-09-14 18:35 [PATCH/RFC] mm: add vm_area_add_early() Nicolas Pitre
@ 2011-10-06 23:10 ` Andrew Morton
2011-10-07 0:17 ` Nicolas Pitre
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2011-10-06 23:10 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: linux-kernel, linux-mm, linux-arm-kernel
On Wed, 14 Sep 2011 14:35:21 -0400 (EDT)
Nicolas Pitre <nicolas.pitre@linaro.org> wrote:
>
> The existing vm_area_register_early() allows for early vmalloc space
> allocation. However upcoming cleanups in the ARM architecture require
> that some fixed locations in the vmalloc area be reserved also very early.
>
> The name "vm_area_register_early" would have been a good name for the
> reservation part without the allocation. Since it is already in use with
> different semantics, let's create vm_area_add_early() instead.
>
> Both vm_area_register_early() and vm_area_add_early() can be used together
> meaning that the former is now implemented using the later where it is
> ensured that no conflicting areas are added, but no attempt is made to
> make the allocation scheme in vm_area_register_early() more sophisticated.
> After all, you must know what you're doing when using those functions.
>
> Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
> ---
>
> Comments / ACKs appreciated.
Deafening silence?
> diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
> index 9332e52ea8..e7d2cba995 100644
> --- a/include/linux/vmalloc.h
> +++ b/include/linux/vmalloc.h
> @@ -130,6 +130,7 @@ extern long vwrite(char *buf, char *addr, unsigned long count);
> */
> extern rwlock_t vmlist_lock;
> extern struct vm_struct *vmlist;
> +extern __init void vm_area_add_early(struct vm_struct *vm);
> extern __init void vm_area_register_early(struct vm_struct *vm, size_t align);
>
> #ifdef CONFIG_SMP
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index 7ef0903058..bf20a0ff95 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -1118,6 +1118,31 @@ void *vm_map_ram(struct page **pages, unsigned int count, int node, pgprot_t pro
> EXPORT_SYMBOL(vm_map_ram);
>
> /**
> + * vm_area_add_early - add vmap area early during boot
> + * @vm: vm_struct to add
> + *
> + * This function is used to add fixed kernel vm area to vmlist before
> + * vmalloc_init() is called. @vm->addr, @vm->size, and @vm->flags
> + * should contain proper values and the other fields should be zero.
> + *
> + * DO NOT USE THIS FUNCTION UNLESS YOU KNOW WHAT YOU'RE DOING.
> + */
> +void __init vm_area_add_early(struct vm_struct *vm)
> +{
> + struct vm_struct *tmp, **p;
> +
> + for (p = &vmlist; (tmp = *p) != NULL; p = &tmp->next) {
> + if (tmp->addr >= vm->addr) {
> + BUG_ON(tmp->addr < vm->addr + vm->size);
> + break;
> + } else
> + BUG_ON(tmp->addr + tmp->size > vm->addr);
> + }
> + vm->next = *p;
> + *p = vm;
> +}
> +
> +/**
> * vm_area_register_early - register vmap area early during boot
> * @vm: vm_struct to register
> * @align: requested alignment
> @@ -1139,8 +1164,7 @@ void __init vm_area_register_early(struct vm_struct *vm, size_t align)
>
> vm->addr = (void *)addr;
>
> - vm->next = vmlist;
> - vmlist = vm;
> + vm_area_add_early(vm);
> }
>
> void __init vmalloc_init(void)
I tossed this into my tree for a bit of testing, assuming it's
up-to-date and still desired?
Feel free to add it to some ARM tree. I'll drop my copy when that
turns up in linux-next.
Yes, the naming scheme in there is gruseome.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH/RFC] mm: add vm_area_add_early()
2011-10-06 23:10 ` Andrew Morton
@ 2011-10-07 0:17 ` Nicolas Pitre
0 siblings, 0 replies; 3+ messages in thread
From: Nicolas Pitre @ 2011-10-07 0:17 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, linux-mm, linux-arm-kernel
On Thu, 6 Oct 2011, Andrew Morton wrote:
> On Wed, 14 Sep 2011 14:35:21 -0400 (EDT)
> Nicolas Pitre <nicolas.pitre@linaro.org> wrote:
>
> >
> > The existing vm_area_register_early() allows for early vmalloc space
> > allocation. However upcoming cleanups in the ARM architecture require
> > that some fixed locations in the vmalloc area be reserved also very early.
> >
> > The name "vm_area_register_early" would have been a good name for the
> > reservation part without the allocation. Since it is already in use with
> > different semantics, let's create vm_area_add_early() instead.
> >
> > Both vm_area_register_early() and vm_area_add_early() can be used together
> > meaning that the former is now implemented using the later where it is
> > ensured that no conflicting areas are added, but no attempt is made to
> > make the allocation scheme in vm_area_register_early() more sophisticated.
> > After all, you must know what you're doing when using those functions.
> >
> > Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
> > ---
> >
> > Comments / ACKs appreciated.
>
> Deafening silence?
I interpreted it as "no objections".
> > diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
> > index 9332e52ea8..e7d2cba995 100644
> > --- a/include/linux/vmalloc.h
> > +++ b/include/linux/vmalloc.h
> > @@ -130,6 +130,7 @@ extern long vwrite(char *buf, char *addr, unsigned long count);
> > */
> > extern rwlock_t vmlist_lock;
> > extern struct vm_struct *vmlist;
> > +extern __init void vm_area_add_early(struct vm_struct *vm);
> > extern __init void vm_area_register_early(struct vm_struct *vm, size_t align);
> >
> > #ifdef CONFIG_SMP
> > diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> > index 7ef0903058..bf20a0ff95 100644
> > --- a/mm/vmalloc.c
> > +++ b/mm/vmalloc.c
> > @@ -1118,6 +1118,31 @@ void *vm_map_ram(struct page **pages, unsigned int count, int node, pgprot_t pro
> > EXPORT_SYMBOL(vm_map_ram);
> >
> > /**
> > + * vm_area_add_early - add vmap area early during boot
> > + * @vm: vm_struct to add
> > + *
> > + * This function is used to add fixed kernel vm area to vmlist before
> > + * vmalloc_init() is called. @vm->addr, @vm->size, and @vm->flags
> > + * should contain proper values and the other fields should be zero.
> > + *
> > + * DO NOT USE THIS FUNCTION UNLESS YOU KNOW WHAT YOU'RE DOING.
> > + */
> > +void __init vm_area_add_early(struct vm_struct *vm)
> > +{
> > + struct vm_struct *tmp, **p;
> > +
> > + for (p = &vmlist; (tmp = *p) != NULL; p = &tmp->next) {
> > + if (tmp->addr >= vm->addr) {
> > + BUG_ON(tmp->addr < vm->addr + vm->size);
> > + break;
> > + } else
> > + BUG_ON(tmp->addr + tmp->size > vm->addr);
> > + }
> > + vm->next = *p;
> > + *p = vm;
> > +}
> > +
> > +/**
> > * vm_area_register_early - register vmap area early during boot
> > * @vm: vm_struct to register
> > * @align: requested alignment
> > @@ -1139,8 +1164,7 @@ void __init vm_area_register_early(struct vm_struct *vm, size_t align)
> >
> > vm->addr = (void *)addr;
> >
> > - vm->next = vmlist;
> > - vmlist = vm;
> > + vm_area_add_early(vm);
> > }
> >
> > void __init vmalloc_init(void)
>
> I tossed this into my tree for a bit of testing, assuming it's
> up-to-date and still desired?
Yes it is, on both counts.
> Feel free to add it to some ARM tree. I'll drop my copy when that
> turns up in linux-next.
So I did, however I'm postponing the whole series that depend on this to
the next cycle because of other prerequisite cleanups that are going in
this cycle from different paths.
> Yes, the naming scheme in there is gruseome.
I didn't want to go as far as renaming it across the tree, in case other
people are relying on the current name in their own tree.
Nicolas
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-10-07 0:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-14 18:35 [PATCH/RFC] mm: add vm_area_add_early() Nicolas Pitre
2011-10-06 23:10 ` Andrew Morton
2011-10-07 0:17 ` Nicolas Pitre
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).