mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Tejun Heo <tj@kernel.org>
Cc: rusty@rustcorp.com.au, tglx@linutronix.de, x86@kernel.org,
	linux-kernel@vger.kernel.org, hpa@zytor.com, jeremy@goop.org,
	cpw@sgi.com, mingo@elte.hu
Subject: Re: [PATCH 07/10] vmalloc: implement vm_area_register_early()
Date: Thu, 19 Feb 2009 23:09:28 +1100	[thread overview]
Message-ID: <200902192309.29576.nickpiggin@yahoo.com.au> (raw)
In-Reply-To: <1234958676-27618-8-git-send-email-tj@kernel.org>

On Wednesday 18 February 2009 23:04:33 Tejun Heo wrote:
> Impact: allow multiple early vm areas
>
> There are places where kernel VM area needs to be allocated before
> vmalloc is initialized.  This is done by allocating static vm_struct,
> initializing several fields and linking it to vmlist and later vmalloc
> initialization picking up these from vmlist.  This is currently done
> manually and if there's more than one such areas, there's no defined
> way to arbitrate who gets which address.
>
> This patch implements vm_area_register_early(), which takes vm_area
> struct with flags and size initialized, assigns address to it and puts
> it on the vmlist.  This way, multiple early vm areas can determine
> which addresses they should use.  The only current user - alpha mm
> init - is converted to use it.

Yes, this is much cleaner. Arguably could go upstream earlier, but
if there are no other callers, probably doesn't matter so much.

Acked-by: Nick Piggin <npiggin@suse.de>

>
> Signed-off-by: Tejun Heo <tj@kernel.org>
> ---
>  arch/alpha/mm/init.c    |   20 +++++++++++++-------
>  include/linux/vmalloc.h |    1 +
>  mm/vmalloc.c            |   24 ++++++++++++++++++++++++
>  3 files changed, 38 insertions(+), 7 deletions(-)
>
> diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c
> index 5d7a16e..df6df02 100644
> --- a/arch/alpha/mm/init.c
> +++ b/arch/alpha/mm/init.c
> @@ -189,9 +189,21 @@ callback_init(void * kernel_end)
>
>  	if (alpha_using_srm) {
>  		static struct vm_struct console_remap_vm;
> -		unsigned long vaddr = VMALLOC_START;
> +		unsigned long nr_pages = 0;
> +		unsigned long vaddr;
>  		unsigned long i, j;
>
> +		/* calculate needed size */
> +		for (i = 0; i < crb->map_entries; ++i)
> +			nr_pages += crb->map[i].count;
> +
> +		/* register the vm area */
> +		console_remap_vm.flags = VM_ALLOC;
> +		console_remap_vm.size = nr_pages << PAGE_SHIFT;
> +		vm_area_register_early(&console_remap_vm);
> +
> +		vaddr = (unsigned long)consle_remap_vm.addr;
> +
>  		/* Set up the third level PTEs and update the virtual
>  		   addresses of the CRB entries.  */
>  		for (i = 0; i < crb->map_entries; ++i) {
> @@ -213,12 +225,6 @@ callback_init(void * kernel_end)
>  				vaddr += PAGE_SIZE;
>  			}
>  		}
> -
> -		/* Let vmalloc know that we've allocated some space.  */
> -		console_remap_vm.flags = VM_ALLOC;
> -		console_remap_vm.addr = (void *) VMALLOC_START;
> -		console_remap_vm.size = vaddr - VMALLOC_START;
> -		vmlist = &console_remap_vm;
>  	}
>
>  	callback_init_done = 1;
> diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
> index 506e762..bbc0513 100644
> --- a/include/linux/vmalloc.h
> +++ b/include/linux/vmalloc.h
> @@ -106,5 +106,6 @@ 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_register_early(struct vm_struct *vm);
>
>  #endif /* _LINUX_VMALLOC_H */
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index c37924a..d206261 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -24,6 +24,7 @@
>  #include <linux/radix-tree.h>
>  #include <linux/rcupdate.h>
>  #include <linux/bootmem.h>
> +#include <linux/pfn.h>
>
>  #include <asm/atomic.h>
>  #include <asm/uaccess.h>
> @@ -982,6 +983,29 @@ void *vm_map_ram(struct page **pages, unsigned int
> count, int node, pgprot_t pro }
>  EXPORT_SYMBOL(vm_map_ram);
>
> +/**
> + * vm_area_register_early - register vmap area early during boot
> + * @vm: vm_struct to register
> + * @size: size of area to register
> + *
> + * This function is used to register kernel vm area before
> + * vmalloc_init() is called.  @vm->size and @vm->flags should contain
> + * proper values on entry and other fields should be zero.  On return,
> + * vm->addr contains the allocated address.
> + *
> + * DO NOT USE THIS FUNCTION UNLESS YOU KNOW WHAT YOU'RE DOING.
> + */
> +void __init vm_area_register_early(struct vm_struct *vm)
> +{
> +	static size_t vm_init_off __initdata;
> +
> +	vm->addr = (void *)VMALLOC_START + vm_init_off;
> +	vm_init_off = PFN_ALIGN(vm_init_off + vm->size);
> +
> +	vm->next = vmlist;
> +	vmlist = vm;
> +}
> +
>  void __init vmalloc_init(void)
>  {
>  	struct vmap_area *va;



  parent reply	other threads:[~2009-02-19 12:10 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-18 12:04 [PATCHSET x86/core/percpu] implement dynamic percpu allocator Tejun Heo
2009-02-18 12:04 ` [PATCH 01/10] vmalloc: call flush_cache_vunmap() from unmap_kernel_range() Tejun Heo
2009-02-19 12:06   ` Nick Piggin
2009-02-19 22:36     ` David Miller
2009-02-18 12:04 ` [PATCH 02/10] module: fix out-of-range memory access Tejun Heo
2009-02-19 12:08   ` Nick Piggin
2009-02-20  7:16   ` Tejun Heo
2009-02-18 12:04 ` [PATCH 03/10] module: reorder module pcpu related functions Tejun Heo
2009-02-18 12:04 ` [PATCH 04/10] alloc_percpu: change percpu_ptr to per_cpu_ptr Tejun Heo
2009-02-18 12:04 ` [PATCH 05/10] alloc_percpu: add align argument to __alloc_percpu Tejun Heo
2009-02-18 12:04 ` [PATCH 06/10] percpu: kill percpu_alloc() and friends Tejun Heo
2009-02-19  0:17   ` Rusty Russell
2009-03-11 18:36   ` Tony Luck
2009-03-11 22:44     ` Rusty Russell
2009-03-12  2:06     ` Tejun Heo
2009-02-18 12:04 ` [PATCH 07/10] vmalloc: implement vm_area_register_early() Tejun Heo
2009-02-19  0:55   ` Tejun Heo
2009-02-19 12:09   ` Nick Piggin [this message]
2009-02-18 12:04 ` [PATCH 08/10] vmalloc: add un/map_kernel_range_noflush() Tejun Heo
2009-02-19 12:17   ` Nick Piggin
2009-02-20  1:27     ` Tejun Heo
2009-02-20  7:15   ` Subject: [PATCH 08/10 UPDATED] " Tejun Heo
2009-02-20  8:32     ` Andrew Morton
2009-02-21  3:21       ` Tejun Heo
2009-02-18 12:04 ` [PATCH 09/10] percpu: implement new dynamic percpu allocator Tejun Heo
2009-02-19 10:10   ` Andrew Morton
2009-02-19 11:01     ` Ingo Molnar
2009-02-20  2:45       ` Tejun Heo
2009-02-19 12:07     ` Rusty Russell
2009-02-20  2:35     ` Tejun Heo
2009-02-20  3:04       ` Andrew Morton
2009-02-20  5:29         ` Tejun Heo
2009-02-24  2:52         ` Rusty Russell
2009-02-19 11:51   ` Rusty Russell
2009-02-20  3:01     ` Tejun Heo
2009-02-20  3:02       ` Tejun Heo
2009-02-24  2:56       ` Rusty Russell
2009-02-24  5:27         ` [PATCH tj-percpu] percpu: add __read_mostly to variables which are mostly read only Tejun Heo
2009-02-24  5:47         ` [PATCH 09/10] percpu: implement new dynamic percpu allocator Tejun Heo
2009-02-24 17:41           ` Luck, Tony
2009-02-26  3:17             ` Tejun Heo
2009-02-27 19:41               ` Luck, Tony
2009-02-19 12:36   ` Nick Piggin
2009-02-20  3:04     ` Tejun Heo
2009-02-20  7:30   ` [PATCH UPDATED " Tejun Heo
2009-02-20  8:37     ` Andrew Morton
2009-02-21  3:23       ` Tejun Heo
2009-02-21  3:42         ` [PATCH tj-percpu] percpu: s/size/bytes/g in new percpu allocator and interface Tejun Heo
2009-02-21  7:48           ` Tejun Heo
2009-02-21  7:55             ` [PATCH tj-percpu] percpu: clean up size usage Tejun Heo
2009-02-21  7:56               ` Tejun Heo
2009-02-18 12:04 ` [PATCH 10/10] x86: convert to the new dynamic percpu allocator Tejun Heo
2009-02-18 13:43 ` [PATCHSET x86/core/percpu] implement " Ingo Molnar
2009-02-19  0:31   ` Tejun Heo
2009-02-19 10:51   ` Rusty Russell
2009-02-19 11:06     ` Ingo Molnar
2009-02-19 12:14       ` Rusty Russell
2009-02-20  3:08         ` Tejun Heo
2009-02-20  5:36           ` Tejun Heo
2009-02-20  7:33             ` Tejun Heo
2009-02-19  0:30 ` Tejun Heo
2009-02-19 11:07   ` Ingo Molnar
2009-02-20  3:17     ` Tejun Heo
2009-02-20  9:32       ` Ingo Molnar
2009-02-21  7:10         ` Tejun Heo
2009-02-21  7:33           ` Tejun Heo
2009-02-22 19:38             ` Ingo Molnar
2009-02-23  0:43               ` Tejun Heo
2009-02-23 10:17                 ` Ingo Molnar
2009-02-23 13:38                   ` [patch] x86: optimize __pa() to be linear again on 64-bit x86 Ingo Molnar
2009-02-23 14:08                     ` Nick Piggin
2009-02-23 14:53                       ` Ingo Molnar
2009-02-24 16:00                         ` Andi Kleen
2009-02-27  5:57                         ` Tejun Heo
2009-02-27  6:57                           ` Ingo Molnar
2009-02-27  7:11                             ` Tejun Heo
2009-02-22 19:27           ` [PATCHSET x86/core/percpu] implement dynamic percpu allocator Ingo Molnar
2009-02-23  0:47             ` Tejun Heo

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=200902192309.29576.nickpiggin@yahoo.com.au \
    --to=nickpiggin@yahoo.com.au \
    --cc=cpw@sgi.com \
    --cc=hpa@zytor.com \
    --cc=jeremy@goop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rusty@rustcorp.com.au \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    --cc=x86@kernel.org \
    /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

Powered by JetHome