lkml.org 
[lkml]   [2000]   [Oct]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: kmalloc() allocation.
On Tue, 31 Oct 2000, Alan Cox wrote:

> > The code for vmalloc allocates the pages at vmalloc time, not after. The
> > TLB is populated lazily, but most definately not the page tables.
>
> Is the lazy tlb population interrupt safe or do I need to change any driver
> using vmalloced memory from an IRQ ?

It should be safe since it's just copying pgd/pmd pointers into the
per-process page tables; the pte's are still shared.

That said, reading vmalloc.c leads to the discovery that
vmalloc_area_pages will currently race on SMP (the pmd/pte allocation
routines are not SMP safe). Untested/obvious patch below. Ultimately
we'll have to move the locking into pmd_alloc/pte_alloc, but I'm not sure
if that's appropriate so close to 2.4.

-ben


--- v2.4.0-test10-pre7/mm/vmalloc.c Mon Oct 30 16:02:27 2000
+++ test-10-7/mm/vmalloc.c Tue Oct 31 10:58:47 2000
@@ -121,7 +121,11 @@
if (end > PGDIR_SIZE)
end = PGDIR_SIZE;
do {
- pte_t * pte = pte_alloc_kernel(pmd, address);
+ pte_t * pte;
+
+ lock_kernel();
+ pte = pte_alloc_kernel(pmd, address);
+ unlock_kernel();
if (!pte)
return -ENOMEM;
if (alloc_area_pte(pte, address, end - address, gfp_mask, prot))
@@ -142,8 +146,10 @@
flush_cache_all();
do {
pmd_t *pmd;
-
+
+ lock_kernel();
pmd = pmd_alloc_kernel(dir, address);
+ unlock_kernel();
if (!pmd)
return -ENOMEM;

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

\
 
 \ /
  Last update: 2005-03-22 12:45    [W:0.065 / U:1.636 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site