Re: [PATCH] kanoj-mm17-2.3.21 kswapd vma scanning protection

Manfred Spraul (manfreds@colorfullife.com)
Sat, 16 Oct 1999 01:16:10 +0200


Linus Torvalds wrote:
>
> .. hold a spinlock - we can probably just reuse the
> page_table_lock for this to avoid multiple levels of locking
> here..
>
> file = fget(vma->vm_file);
^^^^^^^
> offset = file->f_offset + (address - vma->vm_start);
> flush_tlb_page(vma, address);
> spin_unlock(&vma->vm_mm->page_table_lock);
>
> error = file->f_ops->swapout(file, offset, page);
> fput(file);
>
> ...
>
> and then the other requirement would be that whenever the vma chain is
> physically modified, you also have to hold the page_table_lock.
>

What about shm? vma->vm_file is NULL, this would oops.
I think that both "prepare for possible vma removal" and the parameters
which are passed to ->swapout() should be vma-specific: what about a
vm_ops->swapprepare()? This function should not allocate memory, ie
parameter passing should be stack based:

<<<<< mm.h
struct private_data
{
void* private[4];
};
struct vm_ops
{
...
void (*swapprepare)(struct vm_area_struct * vma, struct page * page,
struct private_data * info);
void (*swapout)(struct private_data * info, struct page* page);
...
};
>>>>>>>>>
<<<<<<<< vmscan.c

if(vma->vm_ops && vma->vm_ops->swapout) {
int error;
struct private_data info;
void (*swapout)(...);

pte_clear(page_table);
swapout = vma->vm_ops->swapout;
vma->vm_ops->swapprepare(vma,page,&info);
spin_unlock(page_table_lock);
flush_tlb_page();
error = swapout(&info,page);
...
}
>>>>>>>>>>>>>>>>

--
	Manfred

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