Re: [PATCH] mm/vmalloc: don't use vmalloc_end

From: Geert Uytterhoeven
Date: Tue Dec 08 2009 - 04:11:58 EST


On Tue, Dec 8, 2009 at 00:35, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
> (cc linux-ia64)
>
> On Mon, 07 Dec 2009 16:24:03 +0000
> "Jan Beulich" <JBeulich@xxxxxxxxxx> wrote:
>
>> At least on ia64 vmalloc_end is a global variable that VMALLOC_END
>> expands to. Hence having a local variable named vmalloc_end and
>> initialized from VMALLOC_END won't work on such platforms. Rename
>> these variables, and for consistency also rename vmalloc_start.
>>
>
> erk. ÂSo does 2.6.32's vmalloc() actually work correctly on ia64?
>
> Perhaps vmalloc_end wasn't a well chosen name for an arch-specific
> global variable.
>
> arch/m68k/include/asm/pgtable_mm.h does the same thing. ÂDid it break too?

Rename to m68k_vmalloc_{end,start}?

Hmm, sounds better than introducing allcaps variables...

>
>> ---
>> Âmm/vmalloc.c | Â 16 ++++++++--------
>> Â1 file changed, 8 insertions(+), 8 deletions(-)
>>
>> --- linux-2.6.32/mm/vmalloc.c
>> +++ 2.6.32-dont-use-vmalloc_end/mm/vmalloc.c
>> @@ -2060,13 +2060,13 @@ static unsigned long pvm_determine_end(s
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âstruct vmap_area **pprev,
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âunsigned long align)
>> Â{
>> - Â Â const unsigned long vmalloc_end = VMALLOC_END & ~(align - 1);
>> + Â Â const unsigned long end = VMALLOC_END & ~(align - 1);
>> Â Â Â unsigned long addr;
>>
>> Â Â Â if (*pnext)
>> - Â Â Â Â Â Â addr = min((*pnext)->va_start & ~(align - 1), vmalloc_end);
>> + Â Â Â Â Â Â addr = min((*pnext)->va_start & ~(align - 1), end);
>> Â Â Â else
>> - Â Â Â Â Â Â addr = vmalloc_end;
>> + Â Â Â Â Â Â addr = end;
>>
>> Â Â Â while (*pprev && (*pprev)->va_end > addr) {
>> Â Â Â Â Â Â Â *pnext = *pprev;
>> @@ -2105,8 +2105,8 @@ struct vm_struct **pcpu_get_vm_areas(con
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âconst size_t *sizes, int nr_vms,
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âsize_t align, gfp_t gfp_mask)
>> Â{
>> - Â Â const unsigned long vmalloc_start = ALIGN(VMALLOC_START, align);
>> - Â Â const unsigned long vmalloc_end = VMALLOC_END & ~(align - 1);
>> + Â Â const unsigned long vstart = ALIGN(VMALLOC_START, align);
>> + Â Â const unsigned long vend = VMALLOC_END & ~(align - 1);
>> Â Â Â struct vmap_area **vas, *prev, *next;
>> Â Â Â struct vm_struct **vms;
>> Â Â Â int area, area2, last_area, term_area;
>> @@ -2142,7 +2142,7 @@ struct vm_struct **pcpu_get_vm_areas(con
>> Â Â Â }
>> Â Â Â last_end = offsets[last_area] + sizes[last_area];
>>
>> - Â Â if (vmalloc_end - vmalloc_start < last_end) {
>> + Â Â if (vend - vstart < last_end) {
>> Â Â Â Â Â Â Â WARN_ON(true);
>> Â Â Â Â Â Â Â return NULL;
>> Â Â Â }
>> @@ -2167,7 +2167,7 @@ retry:
>> Â Â Â end = start + sizes[area];
>>
>> Â Â Â if (!pvm_find_next_prev(vmap_area_pcpu_hole, &next, &prev)) {
>> - Â Â Â Â Â Â base = vmalloc_end - last_end;
>> + Â Â Â Â Â Â base = vend - last_end;
>> Â Â Â Â Â Â Â goto found;
>> Â Â Â }
>> Â Â Â base = pvm_determine_end(&next, &prev, align) - end;
>> @@ -2180,7 +2180,7 @@ retry:
>> Â Â Â Â Â Â Â Â* base might have underflowed, add last_end before
>> Â Â Â Â Â Â Â Â* comparing.
>> Â Â Â Â Â Â Â Â*/
>> - Â Â Â Â Â Â if (base + last_end < vmalloc_start + last_end) {
>> + Â Â Â Â Â Â if (base + last_end < vstart + last_end) {
>> Â Â Â Â Â Â Â Â Â Â Â spin_unlock(&vmap_area_lock);
>> Â Â Â Â Â Â Â Â Â Â Â if (!purged) {
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â purge_vmap_area_lazy();
>>
>



--
Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/