login
Login
/
Register
Search
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2007
»
October
»
29
Re: vm_ops.page_mkwrite() fails with vmalloc on 2.6.23
view
thread
!MAILaRCHIVE_VOTE_RePLACE
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From:
Andrew Morton <akpm@...>
To: <stefani@...>
Cc: <linux-kernel@...>, David Howells <dhowells@...>, <linux-mm@...>
Subject:
Re: vm_ops.page_mkwrite() fails with vmalloc on 2.6.23
Date: Monday, October 29, 2007 - 3:40 am
On Mon, 22 Oct 2007 16:40:57 +0200 Stefani Seibold <stefani@seibold.net> wrote:
quoted text
> Hi, > > i have a problem with vmalloc() and vm_ops.page_mkwrite(). > > ReadOnly access works, but on a write access the VM will > endless invoke the vm_ops.page_mkwrite() handler. > > I tracked down the problem to the > struct page.mapping pointer, > which is NULL. > > The problem original occurs with the fb_defio driver (driver/video/fb_defio.c). > This driver use the vm_ops.page_mkwrite() handler for tracking the modified pages, > which will be in an extra thread handled, to perform the IO and clean and > write protect all pages with page_clean(). > > I am not sure if the is a feature of the new rmap code or a bug. > > Is there an way to get a similar functionality? Currently, i have no > idea > how to get the ptep from a page alloced with vmalloc(). > > Greetings, > Stefani > > Here is a small sample driver: > > #include <linux/module.h> > #include <linux/errno.h> > #include <linux/string.h> > #include <linux/mm.h> > #include <linux/vmalloc.h> > #include <linux/fs.h> > > #define DEVICE_NAME "mydrv" > #define DEVICE_MAJOR 240 > > static u8 *mydrv_memory; > static const u_long mydrv_memory_size=1024*1024; // 1 Megabyte > > #ifdef MODULE > static u_long vmas=0; > #endif > > static void mydrv_vma_open(struct vm_area_struct *vma) > { > #ifdef MODULE > if (vmas++==0) > try_module_get(THIS_MODULE); > #endif > } > > static void mydrv_vma_close(struct vm_area_struct *vma) > { > #ifdef MODULE > if (--vmas==0) > module_put(THIS_MODULE); > #endif > } > > struct page *mydrv_vma_nopage(struct vm_area_struct *vma,unsigned long > address,int *type) > { > unsigned long offset; > struct page *page; > > offset = (address - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT); > printk("--> mydrv_vma_nopage:%lu(%08lx)\n",offset,offset); > > if (offset >= mydrv_memory_size) > return NOPAGE_SIGBUS; > > page = vmalloc_to_page(mydrv_memory + offset); > if (!page) > return NOPAGE_OOM; > > get_page(page); > if (type) > *type = VM_FAULT_MINOR; > return page; > } > > int mydrv_mkwrite(struct vm_area_struct *vma,struct page *page) > { > printk("--> mydrv_mkwrite:%p\n",page->mapping); > > return 0; > } > > struct vm_operations_struct mydrv_vm_ops = { > .open = mydrv_vma_open, > .close = mydrv_vma_close, > .nopage = mydrv_vma_nopage, > .page_mkwrite = mydrv_mkwrite, > }; > > static int mydrv_mmap(struct file *file, struct vm_area_struct *vma) > { > vma->vm_ops = &mydrv_vm_ops; > vma->vm_flags |= ( VM_IO | VM_RESERVED | VM_DONTEXPAND ); > vma->vm_private_data = 0; > mydrv_vma_open(vma); > return 0; > } > > int mydrv_open(struct inode *inode, struct file *file) > { > int minor; > > minor=MINOR(file->f_dentry->d_inode->i_rdev); > printk("--> mydrv_open called for minor: %d\n", minor); > > if (minor>0) { > printk("--> mydrv_open minor %d failed\n",minor); > return -ENODEV; > } > > printk("--> mydrv_open o.K.\n"); > return 0; > } > > > int mydrv_close(struct inode *inode, struct file *file) > { > int minor; > > minor=MINOR(file->f_dentry->d_inode->i_rdev); > printk("--> mydrv_close for minor: %d\n", minor); > return 0; > } > > struct file_operations mydrv_fops = { > .owner=THIS_MODULE, > .mmap=mydrv_mmap, > .open=mydrv_open, > .release=mydrv_close, > }; > > int init_module(void) > { > printk("--> init_module called\n"); > > if (!(mydrv_memory = vmalloc(mydrv_memory_size))) > return -ENOMEM; > > if (register_chrdev(DEVICE_MAJOR, DEVICE_NAME, &mydrv_fops) < 0) { > printk("--> Error registering driver.\n"); > return -ENODEV; > } > > memset(mydrv_memory, 0, mydrv_memory_size); > printk("--> init_module done\n"); > return 0; > } > > > void cleanup_module(void) > { > printk("--> cleanup_module called\n"); > unregister_chrdev(DEVICE_MAJOR,DEVICE_NAME); > vfree(mydrv_memory); > printk("--> cleanup_module done\n"); > } > > MODULE_LICENSE("GPL"); > MODULE_AUTHOR("Stefan Seibold <Stefani@Seibold.net>"); > MODULE_DESCRIPTION("Test Driver"); >
(cc's added) -
unsubscribe notice
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/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
vm_ops.page_mkwrite() fails with vmalloc on 2.6.23
, Stefani Seibold
, (Mon Oct 22, 10:40 am)
Re: vm_ops.page_mkwrite() fails with vmalloc on 2.6.23
, Andrew Morton
, (Mon Oct 29, 3:40 am)
Re: vm_ops.page_mkwrite() fails with vmalloc on 2.6.23
, Jaya Kumar
, (Mon Oct 29, 4:17 am)
Re: vm_ops.page_mkwrite() fails with vmalloc on 2.6.23
, Peter Zijlstra
, (Mon Oct 29, 1:01 pm)
Re: vm_ops.page_mkwrite() fails with vmalloc on 2.6.23
, Jaya Kumar
, (Mon Oct 29, 1:51 pm)
Re: vm_ops.page_mkwrite() fails with vmalloc on 2.6.23
, Peter Zijlstra
, (Mon Oct 29, 2:17 pm)
Re: vm_ops.page_mkwrite() fails with vmalloc on 2.6.23
, Peter Zijlstra
, (Mon Oct 29, 6:16 pm)
Re: vm_ops.page_mkwrite() fails with vmalloc on 2.6.23
, Jaya Kumar
, (Mon Oct 29, 9:22 pm)
Re: vm_ops.page_mkwrite() fails with vmalloc on 2.6.23
, Peter Zijlstra
, (Tue Oct 30, 5:56 am)
Re: vm_ops.page_mkwrite() fails with vmalloc on 2.6.23
, Jaya Kumar
, (Tue Oct 30, 9:16 am)
Re: vm_ops.page_mkwrite() fails with vmalloc on 2.6.23
, Peter Zijlstra
, (Tue Oct 30, 9:25 am)
Re: vm_ops.page_mkwrite() fails with vmalloc on 2.6.23
, Hugh Dickins
, (Tue Oct 30, 11:47 am)
Re: vm_ops.page_mkwrite() fails with vmalloc on 2.6.23
, Jaya Kumar
, (Thu Nov 1, 4:02 am)
Re: vm_ops.page_mkwrite() fails with vmalloc on 2.6.23
, Peter Zijlstra
, (Tue Oct 30, 11:51 am)
Re: vm_ops.page_mkwrite() fails with vmalloc on 2.6.23
, Stefani Seibold
, (Tue Oct 30, 6:49 am)
Re: vm_ops.page_mkwrite() fails with vmalloc on 2.6.23
, Hugh Dickins
, (Tue Oct 30, 8:39 am)
Re: vm_ops.page_mkwrite() fails with vmalloc on 2.6.23
, Peter Zijlstra
, (Tue Oct 30, 9:12 am)
Re: vm_ops.page_mkwrite() fails with vmalloc on 2.6.23
, Peter Zijlstra
, (Mon Oct 29, 6:11 am)
Re: vm_ops.page_mkwrite() fails with vmalloc on 2.6.23
, Peter Zijlstra
, (Mon Oct 29, 8:35 am)
Re: vm_ops.page_mkwrite() fails with vmalloc on 2.6.23
, Nick Piggin
, (Mon Oct 29, 10:28 am)
Navigation
Create content
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Parag Warudkar
BUG: soft lockup - CPU#1 stuck for 15s! [swapper:0]
Tarkan Erimer
Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3
Bart Van Assche
Integration of SCST in the mainstream Linux kernel
Greg Kroah-Hartman
[PATCH 001/196] Chinese: Add the known_regression URI to the HOWTO
git
:
linux-netdev
:
Gerrit Renker
[PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side)
David Miller
Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock().
Arjan van de Ven
Re: [GIT]: Networking
David Miller
Re: [BUG] New Kernel Bugs
openbsd-misc
:
Colocation donated by:
Who's online
There are currently
3 users
and
843 guests
online.
Online users
strcmp
plianc20
roundtheruggedd
Syndicate