All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wu Fei <at.wufei@gmail.com>
To: linux-mips@linux-mips.org, Ralf Baechle <ralf@linux-mips.org>
Subject: Re: Shrink the size of tlb handler and fix vmalloc()
Date: Thu, 3 Sep 2009 22:32:02 +0800	[thread overview]
Message-ID: <20090903143202.GC6482@desktop> (raw)
In-Reply-To: <20090903142753.GA6482@desktop>

On Thu, Sep 03, 2009 at 10:27:53PM +0800, Wu Fei wrote:
> This patch tries to shrink the size of the 64bit tlb handler and also fix
> an vmalloc bug at the same time.
> 
Forgot to say, it's only tested on 2.6.27, not the master, I can't get
the environment to run the latest kernel currently.

Thanks,
Wufei.

> By combining the swapper_pg_dir and module_pg_dir, several checks in tlb
> handler, particularly build_get_pgd_vmalloc64, are not necessary. The reason
> they can be combined is that, the effective virtual address of vmalloc returned
> is at the bottom, and of module_alloc returned is at the top.
> 
> In the normal case of 4KB page size:
>   VMALLOC_START, VMALLOC_END	0xc0000000 00000000 - 0xc0000100 00000000
>   MODULE_START,  MODULE_END	0xffffffff c0000000 - 0xffffffff +xxxxxxx
> Change it to:
>   VMALLOC_START, VMALLOC_END	0xc0000000 00000000 - 0xc00000ff 00000000
>   MODULE_START,  MODULE_END	0xffffffff c0000000 - 0xffffffff +xxxxxxx
> We use the least 40 bits to traverse the page table, the change makes it still
> one-to-one mapping without more checking. "+" is in the range of [c,d,e,f], 
> so there even are big holes bewteen them.
> 
> With this patch, the tlb refill handler only contains about 28 instructions,
> instead of the original 38.
> 
> 
> And this patch also fix a bug in vmalloc, which happens when its returned
> address is not covered by the first pgd. e.g. if we do two vmallocs, the first
> returned address is 0xc0000000 00000000, and the 2nd is 0xc0000000 40000000,
> 
>   vmalloc -> __vmalloc_node -> __vmalloc_area_node -> __vmalloc_area_node
>   -> map_vm_area -> pgd_offset_k
> 
> pgd_offset_k doesn't use the address to index the pgd, just return the first one:
> 
>   #define pgd_offset_k(address) \ 
>         ((address) >= MODULE_START ? module_pg_dir : pgd_offset(&init_mm, 0UL))     
> 
> This is wrong, then the 2 addresses are mapped to the same pte. This bug doesn't
> happen because even in the 4KB page case, one pgd can cover 1GB size, and it looks
> like the system won't vmalloc so much area.

      parent reply	other threads:[~2009-09-03 14:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-03 14:27 Shrink the size of tlb handler and fix vmalloc() Wu Fei
2009-09-03 14:29 ` [PATCH] Shrink the size of tlb handler Wu Fei
2009-09-09 22:36   ` David Daney
2009-09-03 14:32 ` Wu Fei [this message]

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=20090903143202.GC6482@desktop \
    --to=at.wufei@gmail.com \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.