lkml.org 
[lkml]   [2006]   [Dec]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC] [PATCH] virtual memmap on sparsemem v3 [1/4] map and unmap
On Fri, 8 Dec 2006 16:01:42 +0900
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:

> When we want to map pages into the kernel space by vmalloc()'s routine,
> we always need 'struct page' to do that.
>
> There are cases where there is no page struct to use (bootstrap, etc..).
> This function is designed to help map any memory to anywhere, anytime.
>
> Users should manage their virtual/physical space by themselves.
> Because it's complex and danger to manage virtual address space by
> each function's own code, it's better to use fixed address.
>
> Note: My first purpose is supporting virtual mem_map both at boot/hotplug
> sharing the same logic.
>

A little thing:


> + if (ops->k_pte_alloc) {
> + ret = ops->k_pte_alloc(pmd, addr, data);
> + if (ret)
> + return ret;
> + } else {
> + pte = pte_alloc_kernel(pmd, addr);
> + if (!pte)
> + return -ENOMEM;
> + }

> + if (ops->k_pmd_alloc) {
> + ret = ops->k_pmd_alloc(pud, addr, data);
> + if (ret)
> + return ret;
> + } else {
> + pmd = pmd_alloc(&init_mm, pud, addr);
> + if (!pmd)
> + return -ENOMEM;

> + if (ops->k_pud_alloc) {
> + ret = ops->k_pud_alloc(pgd, addr, data);
> + if (ret)
> + return ret;
> + } else {
> + pud = pud_alloc(&init_mm, pgd, addr);
> + if (!pud)
> + return -ENOMEM;
> + }

Generally we prefer to simply *require* that the function vector be filled
in appropriately. So if the caller has no special needs, the caller will
set their gen_map_kern_ops.k_pte_alloc to point at pte_alloc_kernel().

erk, pte_alloc_kernel() is a macro. As is pmd_alloc(), etc. Well, let
that be a lesson to us. What a mess.

I suppose we could go through and convert them all to inlines and then the
compiler will generate an out-of-line copy for us. Better would be to turn
these things into regular, out-of-line C functions.

What a mess.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-12-09 01:31    [from the cache]
©2003-2011 Jasper Spaans