[patch 00/18] remove nopage - Kernel

This is a discussion on [patch 00/18] remove nopage - Kernel ; This patchset removes the 'nopage' from the tree. I've gone through all the drivers and converted them to use fault as best I can. When using fault, I've also tried to use vmf->pgoff rather than the virtual address to index ...

+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 20 of 34

Thread: [patch 00/18] remove nopage

  1. [patch 00/18] remove nopage

    This patchset removes the 'nopage' from the tree.

    I've gone through all the drivers and converted them to use fault as best
    I can. When using fault, I've also tried to use vmf->pgoff rather than the
    virtual address to index the content (which is preferred). Mostly it has
    been OK, but DRM is a bit difficult, as it seems to use vma->vm_pgoff as
    a 2nd dimension of addressing, so it remains unconverted.

    I've also done some other things while going through at the code...

    Converted incorrect OOM returns to SIGBUS. OOM should only be returned as a
    result of a memory allocation failure. We will actually want the fault path OOM
    handling to be unified with the normal OOM killing path in future, and so
    OOMing when we should be SIGBUSing means the box will panic if panic_on_oom is
    set, or it will oom-kill random processes before retrying the fault, etc.
    SIGBUS means something like "physical address (ie. after translation) does not
    exist", which is appropriate AFAIKS in all cases I've converted.

    Got rid of some bogus looking "disallow mremap" checks that just check for
    address > vma->vm_end. Presumably this is supposed to prevent an mremap
    expanding the mapping outside the limit of the underlying resource, but
    actually mremap will update vma->vm_end, and anyway this condition is already
    checked in the page fault code. Others seem to get this right by checking the
    underlying resource itself. Others don't seem to even care.

    There looks like a fair number of corruption / security problems with mremap,
    so I've done an audit of the tree and tried to plug them.

    --


    --
    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/

  2. [patch 13/18] alsa: nopage

    Convert ALSA from nopage to fault.
    Switch from OOM to SIGBUS if the resource is not available.

    Signed-off-by: Nick Piggin
    Cc: perex@perex.cz
    Cc: tiwai@suse.de
    Cc: alsa-devel@alsa-project.org
    Cc: linux-kernel@vger.kernel.org
    ---
    sound/core/pcm_native.c | 59 ++++++++++++++++++++----------------------------
    1 file changed, 25 insertions(+), 34 deletions(-)

    Index: linux-2.6/sound/core/pcm_native.c
    ================================================== =================
    --- linux-2.6.orig/sound/core/pcm_native.c
    +++ linux-2.6/sound/core/pcm_native.c
    @@ -3018,26 +3018,23 @@ static unsigned int snd_pcm_capture_poll
    /*
    * mmap status record
    */
    -static struct page * snd_pcm_mmap_status_nopage(struct vm_area_struct *area,
    - unsigned long address, int *type)
    +static int snd_pcm_mmap_status_fault(struct vm_area_struct *area,
    + struct vm_fault *vmf)
    {
    struct snd_pcm_substream *substream = area->vm_private_data;
    struct snd_pcm_runtime *runtime;
    - struct page * page;

    if (substream == NULL)
    - return NOPAGE_SIGBUS;
    + return VM_FAULT_SIGBUS;
    runtime = substream->runtime;
    - page = virt_to_page(runtime->status);
    - get_page(page);
    - if (type)
    - *type = VM_FAULT_MINOR;
    - return page;
    + vmf->page = virt_to_page(runtime->status);
    + get_page(vmf->page);
    + return 0;
    }

    static struct vm_operations_struct snd_pcm_vm_ops_status =
    {
    - .nopage = snd_pcm_mmap_status_nopage,
    + .fault = snd_pcm_mmap_status_fault,
    };

    static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file,
    @@ -3061,26 +3058,23 @@ static int snd_pcm_mmap_status(struct sn
    /*
    * mmap control record
    */
    -static struct page * snd_pcm_mmap_control_nopage(struct vm_area_struct *area,
    - unsigned long address, int *type)
    +static int snd_pcm_mmap_control_fault(struct vm_area_struct *area,
    + struct vm_fault *vmf)
    {
    struct snd_pcm_substream *substream = area->vm_private_data;
    struct snd_pcm_runtime *runtime;
    - struct page * page;

    if (substream == NULL)
    - return NOPAGE_SIGBUS;
    + return VM_FAULT_SIGBUS;
    runtime = substream->runtime;
    - page = virt_to_page(runtime->control);
    - get_page(page);
    - if (type)
    - *type = VM_FAULT_MINOR;
    - return page;
    + vmf->page = virt_to_page(runtime->control);
    + get_page(vmf->page);
    + return 0;
    }

    static struct vm_operations_struct snd_pcm_vm_ops_control =
    {
    - .nopage = snd_pcm_mmap_control_nopage,
    + .fault = snd_pcm_mmap_control_fault,
    };

    static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file,
    @@ -3117,10 +3111,10 @@ static int snd_pcm_mmap_control(struct s
    #endif /* coherent mmap */

    /*
    - * nopage callback for mmapping a RAM page
    + * fault callback for mmapping a RAM page
    */
    -static struct page *snd_pcm_mmap_data_nopage(struct vm_area_struct *area,
    - unsigned long address, int *type)
    +static int snd_pcm_mmap_data_fault(struct vm_area_struct *area,
    + struct vm_fault *vmf)
    {
    struct snd_pcm_substream *substream = area->vm_private_data;
    struct snd_pcm_runtime *runtime;
    @@ -3130,33 +3124,30 @@ static struct page *snd_pcm_mmap_data_no
    size_t dma_bytes;

    if (substream == NULL)
    - return NOPAGE_SIGBUS;
    + return VM_FAULT_SIGBUS;
    runtime = substream->runtime;
    - offset = area->vm_pgoff << PAGE_SHIFT;
    - offset += address - area->vm_start;
    - snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_SIGBUS);
    + offset = vmf->pgoff << PAGE_SHIFT;
    dma_bytes = PAGE_ALIGN(runtime->dma_bytes);
    if (offset > dma_bytes - PAGE_SIZE)
    - return NOPAGE_SIGBUS;
    + return VM_FAULT_SIGBUS;
    if (substream->ops->page) {
    page = substream->ops->page(substream, offset);
    - if (! page)
    - return NOPAGE_OOM; /* XXX: is this really due to OOM? */
    + if (!page)
    + return VM_FAULT_SIGBUS;
    } else {
    vaddr = runtime->dma_area + offset;
    page = virt_to_page(vaddr);
    }
    get_page(page);
    - if (type)
    - *type = VM_FAULT_MINOR;
    - return page;
    + vmf->page = page;
    + return 0;
    }

    static struct vm_operations_struct snd_pcm_vm_ops_data =
    {
    .open = snd_pcm_mmap_data_open,
    .close = snd_pcm_mmap_data_close,
    - .nopage = snd_pcm_mmap_data_nopage,
    + .fault = snd_pcm_mmap_data_fault,
    };

    /*

    --

    --
    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/

  3. [patch 14/18] oss: via nopage

    Convert OSS via driver from nopage to fault.
    Remove redundant vma range checks.

    Signed-off-by: Nick Piggin
    Cc: jgarzik@pobox.com
    Cc: linux-kernel@vger.kernel.org
    ---
    sound/oss/via82cxxx_audio.c | 28 +++++++++-------------------
    1 file changed, 9 insertions(+), 19 deletions(-)

    Index: linux-2.6/sound/oss/via82cxxx_audio.c
    ================================================== =================
    --- linux-2.6.orig/sound/oss/via82cxxx_audio.c
    +++ linux-2.6/sound/oss/via82cxxx_audio.c
    @@ -2099,8 +2099,7 @@ static void via_dsp_cleanup (struct via_
    }


    -static struct page * via_mm_nopage (struct vm_area_struct * vma,
    - unsigned long address, int *type)
    +static int via_mm_fault (struct vm_area_struct *vma, struct vm_fault *vmf)
    {
    struct via_info *card = vma->vm_private_data;
    struct via_channel *chan = &card->ch_out;
    @@ -2108,22 +2107,14 @@ static struct page * via_mm_nopage (stru
    unsigned long pgoff;
    int rd, wr;

    - DPRINTK ("ENTER, start %lXh, ofs %lXh, pgoff %ld, addr %lXh\n",
    - vma->vm_start,
    - address - vma->vm_start,
    - (address - vma->vm_start) >> PAGE_SHIFT,
    - address);
    -
    - if (address > vma->vm_end) {
    - DPRINTK ("EXIT, returning NOPAGE_SIGBUS\n");
    - return NOPAGE_SIGBUS; /* Disallow mremap */
    - }
    + DPRINTK ("ENTER, pgoff %ld\n", vmf->pgoff);
    +
    if (!card) {
    - DPRINTK ("EXIT, returning NOPAGE_SIGBUS\n");
    - return NOPAGE_SIGBUS; /* Nothing allocated */
    + DPRINTK ("EXIT, returning VM_FAULT_SIGBUS\n");
    + return VM_FAULT_SIGBUS; /* Nothing allocated */
    }

    - pgoff = vma->vm_pgoff + ((address - vma->vm_start) >> PAGE_SHIFT);
    + pgoff = vmf->pgoff;
    rd = card->ch_in.is_mapped;
    wr = card->ch_out.is_mapped;

    @@ -2150,9 +2141,8 @@ static struct page * via_mm_nopage (stru
    DPRINTK ("EXIT, returning page %p for cpuaddr %lXh\n",
    dmapage, (unsigned long) chan->pgtbl[pgoff].cpuaddr);
    get_page (dmapage);
    - if (type)
    - *type = VM_FAULT_MINOR;
    - return dmapage;
    + vmf->page = dmapage;
    + return 0;
    }


    @@ -2165,7 +2155,7 @@ static int via_mm_swapout (struct page *


    static struct vm_operations_struct via_mm_ops = {
    - .nopage = via_mm_nopage,
    + .fault = via_mm_fault,

    #ifndef VM_RESERVED
    .swapout = via_mm_swapout,

    --

    --
    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/

  4. [patch 11/18] ib: nopage

    Convert IB from nopage to fault.

    Signed-off-by: Nick Piggin
    Cc: rolandd@cisco.com
    Cc: mshefty@ichips.intel.com
    Cc: hal.rosenstock@gmail.com
    Cc: general@lists.openfabrics.org
    Cc: linux-kernel@vger.kernel.org
    ---
    drivers/infiniband/hw/ipath/ipath_debug.h | 4 +--
    drivers/infiniband/hw/ipath/ipath_file_ops.c | 29 +++++++++------------------
    2 files changed, 12 insertions(+), 21 deletions(-)

    Index: linux-2.6/drivers/infiniband/hw/ipath/ipath_file_ops.c
    ================================================== =================
    --- linux-2.6.orig/drivers/infiniband/hw/ipath/ipath_file_ops.c
    +++ linux-2.6/drivers/infiniband/hw/ipath/ipath_file_ops.c
    @@ -1120,33 +1120,24 @@ bail:
    }

    /*
    - * ipath_file_vma_nopage - handle a VMA page fault.
    + * ipath_file_vma_fault - handle a VMA page fault.
    */
    -static struct page *ipath_file_vma_nopage(struct vm_area_struct *vma,
    - unsigned long address, int *type)
    +static int ipath_file_vma_fault(struct vm_area_struct *vma,
    + struct vm_fault *vmf)
    {
    - unsigned long offset = address - vma->vm_start;
    - struct page *page = NOPAGE_SIGBUS;
    - void *pageptr;
    + struct page *page;

    - /*
    - * Convert the vmalloc address into a struct page.
    - */
    - pageptr = (void *)(offset + (vma->vm_pgoff << PAGE_SHIFT));
    - page = vmalloc_to_page(pageptr);
    + page = vmalloc_to_page((void *)(vmf->pgoff << PAGE_SHIFT));
    if (!page)
    - goto out;
    -
    - /* Increment the reference count. */
    + return VM_FAULT_SIGBUS;
    get_page(page);
    - if (type)
    - *type = VM_FAULT_MINOR;
    -out:
    - return page;
    + vmf->page = page;
    +
    + return 0;
    }

    static struct vm_operations_struct ipath_file_vm_ops = {
    - .nopage = ipath_file_vma_nopage,
    + .fault = ipath_file_vma_fault,
    };

    static int mmap_kvaddr(struct vm_area_struct *vma, u64 pgaddr,
    Index: linux-2.6/drivers/infiniband/hw/ipath/ipath_debug.h
    ================================================== =================
    --- linux-2.6.orig/drivers/infiniband/hw/ipath/ipath_debug.h
    +++ linux-2.6/drivers/infiniband/hw/ipath/ipath_debug.h
    @@ -55,7 +55,7 @@
    #define __IPATH_PKTDBG 0x80 /* print packet data */
    /* print process startup (init)/exit messages */
    #define __IPATH_PROCDBG 0x100
    -/* print mmap/nopage stuff, not using VDBG any more */
    +/* print mmap/fault stuff, not using VDBG any more */
    #define __IPATH_MMDBG 0x200
    #define __IPATH_ERRPKTDBG 0x400
    #define __IPATH_USER_SEND 0x1000 /* use user mode send */
    @@ -81,7 +81,7 @@
    #define __IPATH_VERBDBG 0x0 /* very verbose debug */
    #define __IPATH_PKTDBG 0x0 /* print packet data */
    #define __IPATH_PROCDBG 0x0 /* process startup (init)/exit messages */
    -/* print mmap/nopage stuff, not using VDBG any more */
    +/* print mmap/fault stuff, not using VDBG any more */
    #define __IPATH_MMDBG 0x0
    #define __IPATH_EPKTDBG 0x0 /* print ethernet packet data */
    #define __IPATH_IPATHDBG 0x0 /* Ethernet (IPATH) table dump on */

    --

    --
    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/

  5. [patch 16/18] mm: special mapping nopage

    Convert special mapping install from nopage to fault. This requires a
    small special case in the do_linear_fault calculation in order to handle
    vmas without ->vm_file set.

    Signed-off-by: Nick Piggin
    Cc: linux-mm@kvack.org
    Cc: linux-kernel@vger.kernel.org
    ---
    mm/memory.c | 10 +++++++---
    mm/mmap.c | 19 +++++++++----------
    2 files changed, 16 insertions(+), 13 deletions(-)

    Index: linux-2.6/mm/memory.c
    ================================================== =================
    --- linux-2.6.orig/mm/memory.c
    +++ linux-2.6/mm/memory.c
    @@ -2352,9 +2352,13 @@ static int do_linear_fault(struct mm_str
    unsigned long address, pte_t *page_table, pmd_t *pmd,
    int write_access, pte_t orig_pte)
    {
    - pgoff_t pgoff = (((address & PAGE_MASK)
    - - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
    - unsigned int flags = (write_access ? FAULT_FLAG_WRITE : 0);
    + pgoff_t pgoff;
    + unsigned int flags;
    +
    + pgoff = (((address) - vma->vm_start) >> PAGE_SHIFT);
    + if (likely(vma->vm_file))
    + pgoff += vma->vm_pgoff;
    + flags = (write_access ? FAULT_FLAG_WRITE : 0);

    pte_unmap(page_table);
    return __do_fault(mm, vma, address, pmd, pgoff, flags, orig_pte);
    Index: linux-2.6/mm/mmap.c
    ================================================== =================
    --- linux-2.6.orig/mm/mmap.c
    +++ linux-2.6/mm/mmap.c
    @@ -2149,24 +2149,23 @@ int may_expand_vm(struct mm_struct *mm,
    }


    -static struct page *special_mapping_nopage(struct vm_area_struct *vma,
    - unsigned long address, int *type)
    +static int special_mapping_fault(struct vm_area_struct *vma,
    + struct vm_fault *vmf)
    {
    + pgoff_t pgoff = vmf->pgoff;
    struct page **pages;

    - BUG_ON(address < vma->vm_start || address >= vma->vm_end);
    -
    - address -= vma->vm_start;
    - for (pages = vma->vm_private_data; address > 0 && *pages; ++pages)
    - address -= PAGE_SIZE;
    + for (pages = vma->vm_private_data; pgoff && *pages; ++pages)
    + pgoff--;

    if (*pages) {
    struct page *page = *pages;
    get_page(page);
    - return page;
    + vmf->page = page;
    + return 0;
    }

    - return NOPAGE_SIGBUS;
    + return VM_FAULT_SIGBUS;
    }

    /*
    @@ -2178,7 +2177,7 @@ static void special_mapping_close(struct

    static struct vm_operations_struct special_mapping_vmops = {
    .close = special_mapping_close,
    - .nopage = special_mapping_nopage,
    + .fault = special_mapping_fault,
    };

    /*

    --

    --
    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/

  6. [patch 09/18] agp: alpha nopage

    Convert AGP alpha driver from nopage to fault.
    NULL is NOPAGE_SIGBUS, so we aren't changing behaviour there.

    Signed-off-by: Nick Piggin
    Cc: rth@twiddle.net
    Cc: ink@jurassic.park.msu.ru
    Cc: linux-kernel@vger.kernel.org
    ---
    drivers/char/agp/alpha-agp.c | 17 ++++++++---------
    1 file changed, 8 insertions(+), 9 deletions(-)

    Index: linux-2.6/drivers/char/agp/alpha-agp.c
    ================================================== =================
    --- linux-2.6.orig/drivers/char/agp/alpha-agp.c
    +++ linux-2.6/drivers/char/agp/alpha-agp.c
    @@ -11,29 +11,28 @@

    #include "agp.h"

    -static struct page *alpha_core_agp_vm_nopage(struct vm_area_struct *vma,
    - unsigned long address,
    - int *type)
    +static int alpha_core_agp_vm_fault(struct vm_area_struct *vma,
    + struct vm_fault *vmf)
    {
    alpha_agp_info *agp = agp_bridge->dev_private_data;
    dma_addr_t dma_addr;
    unsigned long pa;
    struct page *page;

    - dma_addr = address - vma->vm_start + agp->aperture.bus_base;
    + dma_addr = (unsigned long)vmf->virtual_address - vma->vm_start
    + + agp->aperture.bus_base;
    pa = agp->ops->translate(agp, dma_addr);

    if (pa == (unsigned long)-EINVAL)
    - return NULL; /* no translation */
    + return VM_FAULT_SIGBUS; /* no translation */

    /*
    * Get the page, inc the use count, and return it
    */
    page = virt_to_page(__va(pa));
    get_page(page);
    - if (type)
    - *type = VM_FAULT_MINOR;
    - return page;
    + vmf->page = page;
    + return 0;
    }

    static struct aper_size_info_fixed alpha_core_agp_sizes[] =
    @@ -42,7 +41,7 @@ static struct aper_size_info_fixed alpha
    };

    struct vm_operations_struct alpha_core_agp_vm_ops = {
    - .nopage = alpha_core_agp_vm_nopage,
    + .fault = alpha_core_agp_vm_fault,
    };



    --

    --
    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/

  7. [patch 15/18] alsa: usx2y nopage

    Convert alsa usx2y driver from nopage to fault.

    Signed-off-by: Nick Piggin
    Cc: tiwai@suse.de
    Cc: annabellesgarden@yahoo.de
    Cc: linux-kernel@vger.kernel.org
    ---
    sound/usb/usx2y/usX2Yhwdep.c | 21 ++++++++-------------
    sound/usb/usx2y/usx2yhwdeppcm.c | 19 ++++++-------------
    2 files changed, 14 insertions(+), 26 deletions(-)

    Index: linux-2.6/sound/usb/usx2y/usX2Yhwdep.c
    ================================================== =================
    --- linux-2.6.orig/sound/usb/usx2y/usX2Yhwdep.c
    +++ linux-2.6/sound/usb/usx2y/usX2Yhwdep.c
    @@ -34,34 +34,29 @@
    int usX2Y_hwdep_pcm_new(struct snd_card *card);


    -static struct page * snd_us428ctls_vm_nopage(struct vm_area_struct *area, unsigned long address, int *type)
    +static int snd_us428ctls_vm_fault(struct vm_area_struct *area, struct vm_fault *vmf)
    {
    unsigned long offset;
    struct page * page;
    void *vaddr;

    - snd_printdd("ENTER, start %lXh, ofs %lXh, pgoff %ld, addr %lXh\n",
    + snd_printdd("ENTER, start %lXh, pgoff %ld\n",
    area->vm_start,
    - address - area->vm_start,
    - (address - area->vm_start) >> PAGE_SHIFT,
    - address);
    + vmf->pgoff);

    - offset = area->vm_pgoff << PAGE_SHIFT;
    - offset += address - area->vm_start;
    - snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_SIGBUS);
    + offset = vmf->pgoff << PAGE_SHIFT;
    vaddr = (char*)((struct usX2Ydev *)area->vm_private_data)->us428ctls_sharedmem + offset;
    page = virt_to_page(vaddr);
    get_page(page);
    - snd_printdd( "vaddr=%p made us428ctls_vm_nopage() return %p; offset=%lX\n", vaddr, page, offset);
    + vmf->page = page;

    - if (type)
    - *type = VM_FAULT_MINOR;
    + snd_printdd( "vaddr=%p made us428ctls_vm_fault() page %p\n", vaddr, page);

    - return page;
    + return 0;
    }

    static struct vm_operations_struct us428ctls_vm_ops = {
    - .nopage = snd_us428ctls_vm_nopage,
    + .fault = snd_us428ctls_vm_fault,
    };

    static int snd_us428ctls_mmap(struct snd_hwdep * hw, struct file *filp, struct vm_area_struct *area)
    Index: linux-2.6/sound/usb/usx2y/usx2yhwdeppcm.c
    ================================================== =================
    --- linux-2.6.orig/sound/usb/usx2y/usx2yhwdeppcm.c
    +++ linux-2.6/sound/usb/usx2y/usx2yhwdeppcm.c
    @@ -683,30 +683,23 @@ static void snd_usX2Y_hwdep_pcm_vm_close
    }


    -static struct page * snd_usX2Y_hwdep_pcm_vm_nopage(struct vm_area_struct *area, unsigned long address, int *type)
    +static int snd_usX2Y_hwdep_pcm_vm_fault(struct vm_area_struct *area, struct vm_fault *vmf)
    {
    unsigned long offset;
    - struct page *page;
    void *vaddr;

    - offset = area->vm_pgoff << PAGE_SHIFT;
    - offset += address - area->vm_start;
    - snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_OOM);
    + offset = vmf->pgoff << PAGE_SHIFT;
    vaddr = (char*)((struct usX2Ydev *)area->vm_private_data)->hwdep_pcm_shm + offset;
    - page = virt_to_page(vaddr);
    - get_page(page);
    -
    - if (type)
    - *type = VM_FAULT_MINOR;
    -
    - return page;
    + vmf->page = virt_to_page(vaddr);
    + get_page(vmf->page);
    + return 0;
    }


    static struct vm_operations_struct snd_usX2Y_hwdep_pcm_vm_ops = {
    .open = snd_usX2Y_hwdep_pcm_vm_open,
    .close = snd_usX2Y_hwdep_pcm_vm_close,
    - .nopage = snd_usX2Y_hwdep_pcm_vm_nopage,
    + .fault = snd_usX2Y_hwdep_pcm_vm_fault,
    };



    --

    --
    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/

  8. [patch 02/18] relay: nopage

    Convert relay from nopage to fault.
    Remove redundant vma range checks.
    Switch from OOM to SIGBUS if the resource is not available.

    Signed-off-by: Nick Piggin
    Cc: zanussi@us.ibm.com
    Cc: karim@opersys.com
    Cc: linux-kernel@vger.kernel.org
    ---
    kernel/relay.c | 24 +++++++++---------------
    1 file changed, 9 insertions(+), 15 deletions(-)

    Index: linux-2.6/kernel/relay.c
    ================================================== =================
    --- linux-2.6.orig/kernel/relay.c
    +++ linux-2.6/kernel/relay.c
    @@ -37,37 +37,31 @@ static void relay_file_mmap_close(struct
    }

    /*
    - * nopage() vm_op implementation for relay file mapping.
    + * fault() vm_op implementation for relay file mapping.
    */
    -static struct page *relay_buf_nopage(struct vm_area_struct *vma,
    - unsigned long address,
    - int *type)
    +static int relay_buf_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
    {
    struct page *page;
    struct rchan_buf *buf = vma->vm_private_data;
    - unsigned long offset = address - vma->vm_start;
    + pgoff_t pgoff = vmf->pgoff;

    - if (address > vma->vm_end)
    - return NOPAGE_SIGBUS; /* Disallow mremap */
    if (!buf)
    - return NOPAGE_OOM;
    + return VM_FAULT_OOM;

    - page = vmalloc_to_page(buf->start + offset);
    + page = vmalloc_to_page(buf->start + (pgoff << PAGE_SHIFT));
    if (!page)
    - return NOPAGE_OOM;
    + return VM_FAULT_SIGBUS;
    get_page(page);
    + vmf->page = page;

    - if (type)
    - *type = VM_FAULT_MINOR;
    -
    - return page;
    + return 0;
    }

    /*
    * vm_ops for relay file mappings.
    */
    static struct vm_operations_struct relay_file_mmap_ops = {
    - .nopage = relay_buf_nopage,
    + .fault = relay_buf_fault,
    .close = relay_file_mmap_close,
    };


    --

    --
    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/

  9. Re: [patch 03/18] drm: nopage


    > Convert drm from nopage to fault.
    > Remove redundant vma range checks.


    Hi Nick,

    can you rebase against the -mm tree? or are you pushing this for before
    then? if so can you supply me a patch against -mm?

    The drm git tree has a new VM user for the memory manager..

    Dave.

    >
    > Signed-off-by: Nick Piggin
    > Cc: airlied@linux.ie
    > Cc: linux-kernel@vger.kernel.org
    > ---
    > drivers/char/drm/drm_vm.c | 131 +++++++++++++++++++++-------------------------
    > 1 file changed, 61 insertions(+), 70 deletions(-)
    >
    > Index: linux-2.6/drivers/char/drm/drm_vm.c
    > ================================================== =================
    > --- linux-2.6.orig/drivers/char/drm/drm_vm.c
    > +++ linux-2.6/drivers/char/drm/drm_vm.c
    > @@ -66,7 +66,7 @@ static pgprot_t drm_io_prot(uint32_t map
    > }
    >
    > /**
    > - * \c nopage method for AGP virtual memory.
    > + * \c fault method for AGP virtual memory.
    > *
    > * \param vma virtual memory area.
    > * \param address access address.
    > @@ -76,8 +76,8 @@ static pgprot_t drm_io_prot(uint32_t map
    > * map, get the page, increment the use count and return it.
    > */
    > #if __OS_HAS_AGP
    > -static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma,
    > - unsigned long address)
    > +static __inline__ int drm_do_vm_fault(struct vm_area_struct *vma,
    > + struct vm_fault *vmf)
    > {
    > struct drm_file *priv = vma->vm_file->private_data;
    > struct drm_device *dev = priv->head->dev;
    > @@ -89,19 +89,24 @@ static __inline__ struct page *drm_do_vm
    > * Find the right map
    > */
    > if (!drm_core_has_AGP(dev))
    > - goto vm_nopage_error;
    > + goto vm_fault_error;
    >
    > if (!dev->agp || !dev->agp->cant_use_aperture)
    > - goto vm_nopage_error;
    > + goto vm_fault_error;
    >
    > if (drm_ht_find_item(&dev->map_hash, vma->vm_pgoff, &hash))
    > - goto vm_nopage_error;
    > + goto vm_fault_error;
    >
    > r_list = drm_hash_entry(hash, struct drm_map_list, hash);
    > map = r_list->map;
    >
    > if (map && map->type == _DRM_AGP) {
    > - unsigned long offset = address - vma->vm_start;
    > + /*
    > + * Using vm_pgoff as a selector forces us to use this unusual
    > + * addressing scheme.
    > + */
    > + unsigned long offset = (unsigned long)vmf->virtual_address -
    > + vma->vm_start;
    > unsigned long baddr = map->offset + offset;
    > struct drm_agp_mem *agpmem;
    > struct page *page;
    > @@ -123,7 +128,7 @@ static __inline__ struct page *drm_do_vm
    > }
    >
    > if (!agpmem)
    > - goto vm_nopage_error;
    > + goto vm_fault_error;
    >
    > /*
    > * Get the page, inc the use count, and return it
    > @@ -131,27 +136,28 @@ static __inline__ struct page *drm_do_vm
    > offset = (baddr - agpmem->bound) >> PAGE_SHIFT;
    > page = virt_to_page(__va(agpmem->memory->memory[offset]));
    > get_page(page);
    > + vmf->page = page;
    >
    > DRM_DEBUG
    > ("baddr = 0x%lx page = 0x%p, offset = 0x%lx, count=%d\n",
    > baddr, __va(agpmem->memory->memory[offset]), offset,
    > page_count(page));
    >
    > - return page;
    > + return 0;
    > }
    > - vm_nopage_error:
    > - return NOPAGE_SIGBUS; /* Disallow mremap */
    > + vm_fault_error:
    > + return VM_FAULT_SIGBUS; /* Disallow mremap */
    > }
    > #else /* __OS_HAS_AGP */
    > -static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma,
    > - unsigned long address)
    > +static __inline__ int drm_do_vm_fault(struct vm_area_struct *vma,
    > + struct vm_fault *vmf)
    > {
    > - return NOPAGE_SIGBUS;
    > + return VM_FAULT_SIGBUS;
    > }
    > #endif /* __OS_HAS_AGP */
    >
    > /**
    > - * \c nopage method for shared virtual memory.
    > + * \c fault method for shared virtual memory.
    > *
    > * \param vma virtual memory area.
    > * \param address access address.
    > @@ -160,28 +166,27 @@ static __inline__ struct page *drm_do_vm
    > * Get the mapping, find the real physical page to map, get the page, and
    > * return it.
    > */
    > -static __inline__ struct page *drm_do_vm_shm_nopage(struct vm_area_struct *vma,
    > - unsigned long address)
    > +static __inline__ int drm_do_vm_shm_fault(struct vm_area_struct *vma,
    > + struct vm_fault *vmf)
    > {
    > struct drm_map *map = (struct drm_map *) vma->vm_private_data;
    > unsigned long offset;
    > unsigned long i;
    > struct page *page;
    >
    > - if (address > vma->vm_end)
    > - return NOPAGE_SIGBUS; /* Disallow mremap */
    > if (!map)
    > - return NOPAGE_SIGBUS; /* Nothing allocated */
    > + return VM_FAULT_SIGBUS; /* Nothing allocated */
    >
    > - offset = address - vma->vm_start;
    > + offset = (unsigned long)vmf->virtual_address - vma->vm_start;
    > i = (unsigned long)map->handle + offset;
    > page = vmalloc_to_page((void *)i);
    > if (!page)
    > - return NOPAGE_SIGBUS;
    > + return VM_FAULT_SIGBUS;
    > get_page(page);
    > + vmf->page = page;
    >
    > - DRM_DEBUG("shm_nopage 0x%lx\n", address);
    > - return page;
    > + DRM_DEBUG("shm_fault 0x%lx\n", offset);
    > + return 0;
    > }
    >
    > /**
    > @@ -263,7 +268,7 @@ static void drm_vm_shm_close(struct vm_a
    > }
    >
    > /**
    > - * \c nopage method for DMA virtual memory.
    > + * \c fault method for DMA virtual memory.
    > *
    > * \param vma virtual memory area.
    > * \param address access address.
    > @@ -271,8 +276,8 @@ static void drm_vm_shm_close(struct vm_a
    > *
    > * Determine the page number from the page offset and get it from drm_device_dma:agelist.
    > */
    > -static __inline__ struct page *drm_do_vm_dma_nopage(struct vm_area_struct *vma,
    > - unsigned long address)
    > +static __inline__ int drm_do_vm_dma_fault(struct vm_area_struct *vma,
    > + struct vm_fault *vmf)
    > {
    > struct drm_file *priv = vma->vm_file->private_data;
    > struct drm_device *dev = priv->head->dev;
    > @@ -282,24 +287,23 @@ static __inline__ struct page *drm_do_vm
    > struct page *page;
    >
    > if (!dma)
    > - return NOPAGE_SIGBUS; /* Error */
    > - if (address > vma->vm_end)
    > - return NOPAGE_SIGBUS; /* Disallow mremap */
    > + return VM_FAULT_SIGBUS; /* Error */
    > if (!dma->pagelist)
    > - return NOPAGE_SIGBUS; /* Nothing allocated */
    > + return VM_FAULT_SIGBUS; /* Nothing allocated */
    >
    > - offset = address - vma->vm_start; /* vm_[pg]off[set] should be 0 */
    > - page_nr = offset >> PAGE_SHIFT;
    > + offset = (unsigned long)vmf->virtual_address - vma->vm_start; /* vm_[pg]off[set] should be 0 */
    > + page_nr = offset >> PAGE_SHIFT; /* page_nr could just be vmf->pgoff */
    > page = virt_to_page((dma->pagelist[page_nr] + (offset & (~PAGE_MASK))));
    >
    > get_page(page);
    > + vmf->page = page;
    >
    > - DRM_DEBUG("dma_nopage 0x%lx (page %lu)\n", address, page_nr);
    > - return page;
    > + DRM_DEBUG("dma_fault 0x%lx (page %lu)\n", offset, page_nr);
    > + return 0;
    > }
    >
    > /**
    > - * \c nopage method for scatter-gather virtual memory.
    > + * \c fault method for scatter-gather virtual memory.
    > *
    > * \param vma virtual memory area.
    > * \param address access address.
    > @@ -307,8 +311,8 @@ static __inline__ struct page *drm_do_vm
    > *
    > * Determine the map offset from the page offset and get it from drm_sg_mem:agelist.
    > */
    > -static __inline__ struct page *drm_do_vm_sg_nopage(struct vm_area_struct *vma,
    > - unsigned long address)
    > +static __inline__ int drm_do_vm_sg_fault(struct vm_area_struct *vma,
    > + struct vm_fault *vmf)
    > {
    > struct drm_map *map = (struct drm_map *) vma->vm_private_data;
    > struct drm_file *priv = vma->vm_file->private_data;
    > @@ -320,77 +324,64 @@ static __inline__ struct page *drm_do_vm
    > struct page *page;
    >
    > if (!entry)
    > - return NOPAGE_SIGBUS; /* Error */
    > - if (address > vma->vm_end)
    > - return NOPAGE_SIGBUS; /* Disallow mremap */
    > + return VM_FAULT_SIGBUS; /* Error */
    > if (!entry->pagelist)
    > - return NOPAGE_SIGBUS; /* Nothing allocated */
    > + return VM_FAULT_SIGBUS; /* Nothing allocated */
    >
    > - offset = address - vma->vm_start;
    > + offset = (unsigned long)vmf->virtual_address - vma->vm_start;
    > map_offset = map->offset - (unsigned long)dev->sg->virtual;
    > page_offset = (offset >> PAGE_SHIFT) + (map_offset >> PAGE_SHIFT);
    > page = entry->pagelist[page_offset];
    > get_page(page);
    > + vmf->page = page;
    >
    > - return page;
    > + return 0;
    > }
    >
    > -static struct page *drm_vm_nopage(struct vm_area_struct *vma,
    > - unsigned long address, int *type)
    > +static int drm_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
    > {
    > - if (type)
    > - *type = VM_FAULT_MINOR;
    > - return drm_do_vm_nopage(vma, address);
    > + return drm_do_vm_fault(vma, vmf);
    > }
    >
    > -static struct page *drm_vm_shm_nopage(struct vm_area_struct *vma,
    > - unsigned long address, int *type)
    > +static int drm_vm_shm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
    > {
    > - if (type)
    > - *type = VM_FAULT_MINOR;
    > - return drm_do_vm_shm_nopage(vma, address);
    > + return drm_do_vm_shm_fault(vma, vmf);
    > }
    >
    > -static struct page *drm_vm_dma_nopage(struct vm_area_struct *vma,
    > - unsigned long address, int *type)
    > +static int drm_vm_dma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
    > {
    > - if (type)
    > - *type = VM_FAULT_MINOR;
    > - return drm_do_vm_dma_nopage(vma, address);
    > + return drm_do_vm_dma_fault(vma, vmf);
    > }
    >
    > -static struct page *drm_vm_sg_nopage(struct vm_area_struct *vma,
    > - unsigned long address, int *type)
    > +static int drm_vm_sg_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
    > {
    > - if (type)
    > - *type = VM_FAULT_MINOR;
    > - return drm_do_vm_sg_nopage(vma, address);
    > + return drm_do_vm_sg_fault(vma, vmf);
    > }
    >
    > /** AGP virtual memory operations */
    > static struct vm_operations_struct drm_vm_ops = {
    > - .nopage = drm_vm_nopage,
    > + .fault = drm_vm_fault,
    > .open = drm_vm_open,
    > .close = drm_vm_close,
    > };
    >
    > /** Shared virtual memory operations */
    > static struct vm_operations_struct drm_vm_shm_ops = {
    > - .nopage = drm_vm_shm_nopage,
    > + .fault = drm_vm_shm_fault,
    > .open = drm_vm_open,
    > .close = drm_vm_shm_close,
    > };
    >
    > /** DMA virtual memory operations */
    > static struct vm_operations_struct drm_vm_dma_ops = {
    > - .nopage = drm_vm_dma_nopage,
    > + .fault = drm_vm_dma_fault,
    > .open = drm_vm_open,
    > .close = drm_vm_close,
    > };
    >
    > /** Scatter-gather virtual memory operations */
    > static struct vm_operations_struct drm_vm_sg_ops = {
    > - .nopage = drm_vm_sg_nopage,
    > + .fault = drm_vm_sg_fault,
    > .open = drm_vm_open,
    > .close = drm_vm_close,
    > };
    > @@ -603,7 +594,7 @@ static int drm_mmap_locked(struct file *
    > /*
    > * On some platforms we can't talk to bus dma address from the CPU, so for
    > * memory of type DRM_AGP, we'll deal with sorting out the real physical
    > - * pages and mappings in nopage()
    > + * pages and mappings in fault()
    > */
    > #if defined(__powerpc__)
    > pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE;
    > @@ -633,7 +624,7 @@ static int drm_mmap_locked(struct file *
    > break;
    > case _DRM_CONSISTENT:
    > /* Consistent memory is really like shared memory. But
    > - * it's allocated in a different way, so avoid nopage */
    > + * it's allocated in a different way, so avoid fault */
    > if (remap_pfn_range(vma, vma->vm_start,
    > page_to_pfn(virt_to_page(map->handle)),
    > vma->vm_end - vma->vm_start, vma->vm_page_prot))
    >
    >

    --
    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/

  10. Re: [patch 03/18] drm: nopage

    On Wed, Dec 05, 2007 at 09:05:06AM +0000, Dave Airlie wrote:
    >
    > > Convert drm from nopage to fault.
    > > Remove redundant vma range checks.

    >
    > Hi Nick,
    >
    > can you rebase against the -mm tree? or are you pushing this for before
    > then? if so can you supply me a patch against -mm?


    I'm not sure where I am in the pecking order, although there are some
    security issues (I didn't cc you on that patch, doh). So the patches
    are against mainline to give the option of merging them earlier.

    All the patches except 17/18 are standalone, however. So if any of them
    don't apply for Andrew, I can do another pass to catch the remainders.
    I'll definitely help you with the new drm VM one way or the other

    --
    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/

  11. Re: [patch 04/18] uio: nopage

    Am Wed, 05 Dec 2007 18:15:51 +1100
    schrieb npiggin@suse.de:

    > Convert uio from nopage to fault.
    >
    > Signed-off-by: Nick Piggin
    > Cc: greg@kroah.com


    Hi Nick,
    could you please add me to Cc: for UIO stuff:

    Cc: hjk@linutronix.de

    The patch itself looks alright to me, but I didn't test with a real
    driver.

    Acked-by: Hans J Koch

    Thanks,
    Hans


    > Cc: linux-kernel@vger.kernel.org
    > ---
    > drivers/uio/uio.c | 14 ++++++--------
    > 1 file changed, 6 insertions(+), 8 deletions(-)
    >
    > Index: linux-2.6/drivers/uio/uio.c
    > ================================================== =================
    > --- linux-2.6.orig/drivers/uio/uio.c
    > +++ linux-2.6/drivers/uio/uio.c
    > @@ -412,30 +412,28 @@ static void uio_vma_close(struct vm_area
    > idev->vma_count--;
    > }
    >
    > -static struct page *uio_vma_nopage(struct vm_area_struct *vma,
    > - unsigned long address, int *type)
    > +static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault
    > *vmf) {
    > struct uio_device *idev = vma->vm_private_data;
    > - struct page* page = NOPAGE_SIGBUS;
    > + struct page *page;
    >
    > int mi = uio_find_mem_index(vma);
    > if (mi < 0)
    > - return page;
    > + return VM_FAULT_SIGBUS;
    >
    > if (idev->info->mem[mi].memtype == UIO_MEM_LOGICAL)
    > page = virt_to_page(idev->info->mem[mi].addr);
    > else
    > page =
    > vmalloc_to_page((void*)idev->info->mem[mi].addr); get_page(page);
    > - if (type)
    > - *type = VM_FAULT_MINOR;
    > - return page;
    > + vmf->page = page;
    > + return 0;
    > }
    >
    > static struct vm_operations_struct uio_vm_ops = {
    > .open = uio_vma_open,
    > .close = uio_vma_close,
    > - .nopage = uio_vma_nopage,
    > + .fault = uio_vma_fault,
    > };
    >
    > static int uio_mmap_physical(struct vm_area_struct *vma)
    >

    --
    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/

  12. Re: [patch 04/18] uio: nopage

    On Wed, Dec 05, 2007 at 11:04:08AM +0100, Hans-Jürgen Koch wrote:
    > Am Wed, 05 Dec 2007 18:15:51 +1100
    > schrieb npiggin@suse.de:
    >
    > > Convert uio from nopage to fault.
    > >
    > > Signed-off-by: Nick Piggin
    > > Cc: greg@kroah.com

    >
    > Hi Nick,
    > could you please add me to Cc: for UIO stuff:
    >
    > Cc: hjk@linutronix.de


    Sure, I'll try to remember in future. It would be helpful if you could
    add an entry to MAINTAINERS?

    >
    > The patch itself looks alright to me, but I didn't test with a real
    > driver.
    >
    > Acked-by: Hans J Koch


    Thanks,
    Nick


    --
    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/

  13. Re: [patch 04/18] uio: nopage

    Am Wed, 5 Dec 2007 11:10:42 +0100
    schrieb Nick Piggin :

    > On Wed, Dec 05, 2007 at 11:04:08AM +0100, Hans-Jürgen Koch wrote:
    > > Am Wed, 05 Dec 2007 18:15:51 +1100
    > > schrieb npiggin@suse.de:
    > >
    > > > Convert uio from nopage to fault.
    > > >
    > > > Signed-off-by: Nick Piggin
    > > > Cc: greg@kroah.com

    > >
    > > Hi Nick,
    > > could you please add me to Cc: for UIO stuff:
    > >
    > > Cc: hjk@linutronix.de

    >
    > Sure, I'll try to remember in future. It would be helpful if you could
    > add an entry to MAINTAINERS?


    Well, although I wrote a lot of UIO code and feel a bit responsible for
    it, I don't know if I can call myself an UIO maintainer. ATM, I think
    it's considered "driver core" and is therefore in Greg's domain.

    Thanks,
    Hans

    >
    > >
    > > The patch itself looks alright to me, but I didn't test with a real
    > > driver.
    > >
    > > Acked-by: Hans J Koch

    >
    > Thanks,
    > Nick
    >
    >
    > --
    > 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/

    --
    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/

  14. Re: [patch 04/18] uio: nopage

    On Wed, Dec 05, 2007 at 11:25:00AM +0100, Hans-Jürgen Koch wrote:
    > Am Wed, 5 Dec 2007 11:10:42 +0100
    > schrieb Nick Piggin :
    >
    > > On Wed, Dec 05, 2007 at 11:04:08AM +0100, Hans-Jürgen Koch wrote:
    > > > Am Wed, 05 Dec 2007 18:15:51 +1100
    > > > schrieb npiggin@suse.de:
    > > >
    > > > > Convert uio from nopage to fault.
    > > > >
    > > > > Signed-off-by: Nick Piggin
    > > > > Cc: greg@kroah.com
    > > >
    > > > Hi Nick,
    > > > could you please add me to Cc: for UIO stuff:
    > > >
    > > > Cc: hjk@linutronix.de

    > >
    > > Sure, I'll try to remember in future. It would be helpful if you could
    > > add an entry to MAINTAINERS?

    >
    > Well, although I wrote a lot of UIO code and feel a bit responsible for
    > it, I don't know if I can call myself an UIO maintainer. ATM, I think
    > it's considered "driver core" and is therefore in Greg's domain.


    If you're interested in reviewing patches for it, I think that's
    valuable enough that we don't have to worry about formal titles

    Also, you can have more than one email address for a given MAINTAINERS
    entry. So I'm sure Greg wouldn't mind if you were there too.

    Thanks,
    Nick

    --
    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/

  15. Re: [patch 05/18] kvm: nopage

    npiggin@suse.de wrote:
    > Convert KVM from nopage to fault.
    >
    >


    > @@ -3111,27 +3105,21 @@ out:
    > return r;
    > }
    >
    > -static struct page *kvm_vm_nopage(struct vm_area_struct *vma,
    > - unsigned long address,
    > - int *type)
    > +static int kvm_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
    > {
    > struct kvm *kvm = vma->vm_file->private_data;
    > - unsigned long pgoff;
    > struct page *page;
    >
    > - pgoff = ((address - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
    > - page = gfn_to_page(kvm, pgoff);
    > + page = gfn_to_page(kvm, vmf->pgoff);
    > if (!page)
    > - return NOPAGE_SIGBUS;
    > + return VM_FAULT_SIGBUS;
    > get_page(page);
    > - if (type != NULL)
    > - *type = VM_FAULT_MINOR;
    > -
    > - return page;
    > + vmf->page = page;
    > + return 0;
    > }
    >
    >


    This part has changed in kvm.git, so this won't apply to -mm. I ported
    it and applied to my tree, so it should arrive in -mm when Andrew
    re-fetches.

    --
    error compiling committee.c: too many arguments to function

    --
    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/

  16. Re: [patch 06/18] ieee1394: nopage

    > npiggin@suse.de wrote:
    >> @@ -275,7 +270,7 @@ int dma_region_mmap(struct dma_region *d
    >> if (!dma->kvirt)
    >> return -EINVAL;
    >>
    >> - /* must be page-aligned */
    >> + /* must be page-aligned (XXX: comment is wrong, we could allow pgoff) */
    >> if (vma->vm_pgoff != 0)
    >> return -EINVAL;
    >>

    >
    > Are you sure that the comment is wrong? Could it be that there are
    > assumptions elsewhere which require page alignment? (I should be able
    > to answer that, but I'm not.)


    PS: Assumed the comment is wrong, is the code wrong then too?
    --
    Stefan Richter
    -=====-=-=== ==-- --=-=
    http://arcgraph.de/sr/
    --
    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/

  17. Re: [patch 06/18] ieee1394: nopage

    npiggin@suse.de wrote:
    > Convert ieee1394 from nopage to fault.
    > Remove redundant vma range checks (correct resource range check is retained).


    I never really looked into that part of the 1394 drivers and I'm too
    lazy to figure this out myself, so I ask: What would trip the .fault
    handler? Would be good if I could runtime-test it.

    > Signed-off-by: Nick Piggin
    > Cc: krh@redhat.com


    It's an obscure and unimportant detail but I mention it nevertheless:
    It's not necessary to Cc krh on drivers/ieee1394 stuff. He is more into
    drivers/firewire. :-)

    > Cc: stefanr@s5r6.in-berlin.de
    > Cc: linux1394-devel@lists.sourceforge.net
    > Cc: linux-kernel@vger.kernel.org
    > ---
    > drivers/ieee1394/dma.c | 39 +++++++++++++++++----------------------
    > 1 file changed, 17 insertions(+), 22 deletions(-)
    >
    > Index: linux-2.6/drivers/ieee1394/dma.c
    > ================================================== =================
    > --- linux-2.6.orig/drivers/ieee1394/dma.c
    > +++ linux-2.6/drivers/ieee1394/dma.c
    > @@ -231,37 +231,32 @@ void dma_region_sync_for_device(struct d
    >
    > #ifdef CONFIG_MMU
    >
    > -/* nopage() handler for mmap access */
    > +/* fault() handler for mmap access */
    >
    > -static struct page *dma_region_pagefault(struct vm_area_struct *area,
    > - unsigned long address, int *type)
    > +static int dma_region_pagefault(struct vm_area_struct *vma,
    > + struct vm_fault *vmf)
    > {
    > - unsigned long offset;
    > unsigned long kernel_virt_addr;
    > - struct page *ret = NOPAGE_SIGBUS;
    >
    > - struct dma_region *dma = (struct dma_region *)area->vm_private_data;
    > + struct dma_region *dma = (struct dma_region *)vma->vm_private_data;
    >
    > if (!dma->kvirt)
    > - goto out;
    > + goto error;
    >
    > - if ((address < (unsigned long)area->vm_start) ||
    > - (address >
    > - (unsigned long)area->vm_start + (dma->n_pages << PAGE_SHIFT)))
    > - goto out;
    > -
    > - if (type)
    > - *type = VM_FAULT_MINOR;
    > - offset = address - area->vm_start;
    > - kernel_virt_addr = (unsigned long)dma->kvirt + offset;
    > - ret = vmalloc_to_page((void *)kernel_virt_addr);
    > - get_page(ret);
    > - out:
    > - return ret;
    > + if (vmf->pgoff >= dma->n_pages)
    > + goto error;
    > +
    > + kernel_virt_addr = (unsigned long)dma->kvirt + (vmf->pgoff << PAGE_SHIFT);
    > + vmf->page = vmalloc_to_page((void *)kernel_virt_addr);
    > + get_page(vmf->page);
    > + return 0;
    > +
    > + error:
    > + return VM_FAULT_SIGBUS;
    > }


    Why not replacing the two 'goto error' by 'return VM_FAULT_SIGBUS'? If
    there is no cleanup after that error jump, I find it sensible to return
    early.

    >
    > static struct vm_operations_struct dma_region_vm_ops = {
    > - .nopage = dma_region_pagefault,
    > + .fault = dma_region_pagefault,
    > };
    >
    > /**
    > @@ -275,7 +270,7 @@ int dma_region_mmap(struct dma_region *d
    > if (!dma->kvirt)
    > return -EINVAL;
    >
    > - /* must be page-aligned */
    > + /* must be page-aligned (XXX: comment is wrong, we could allow pgoff) */
    > if (vma->vm_pgoff != 0)
    > return -EINVAL;
    >


    Are you sure that the comment is wrong? Could it be that there are
    assumptions elsewhere which require page alignment? (I should be able
    to answer that, but I'm not.)
    --
    Stefan Richter
    -=====-=-=== ==-- --=-=
    http://arcgraph.de/sr/
    --
    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/

  18. Re: [patch 12/18] usb: mon nopage

    On Wed, 05 Dec 2007 18:15:59 +1100, npiggin@suse.de wrote:

    > Convert USB mon driver from nopage to fault.


    > if (offset >= rp->b_size)
    > - return NOPAGE_SIGBUS;
    > + return VM_FAULT_SIGBUS;
    > chunk_idx = offset / CHUNK_SIZE;
    > pageptr = rp->b_vec[chunk_idx].pg;
    > get_page(pageptr);
    > - if (type)
    > - *type = VM_FAULT_MINOR;
    > - return pageptr;
    > + vmf->page = pageptr;
    > + return 0;


    Looks like a trivial change, I ack this. It's a rarely used API, I have
    to run tests to see how it works. I'll collect any failing pieces later
    if any.

    Signed-off-by: Pete Zaitcev

    -- Pete
    --
    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/

  19. Re: [patch 17/18] mm: remove nopage

    On Wed, 05 Dec 2007 18:16:04 +1100
    npiggin@suse.de wrote:

    > Nothing in the tree uses nopage any more. Remove support for it in the
    > core mm code and documentation (and a few stray references to it in comments).


    I'll duck this for now. It's going to take a long time to get all those
    other patches merged given my usual ~75% dropped-on-the-floor rate from
    subsystem maintainers. Please resend when mainline is nopage-free.


    --
    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/

  20. Re: [patch 17/18] mm: remove nopage

    On Wed, Dec 05, 2007 at 02:47:00PM -0800, Andrew Morton wrote:
    > On Wed, 05 Dec 2007 18:16:04 +1100
    > npiggin@suse.de wrote:
    >
    > > Nothing in the tree uses nopage any more. Remove support for it in the
    > > core mm code and documentation (and a few stray references to it in comments).

    >
    > I'll duck this for now. It's going to take a long time to get all those
    > other patches merged given my usual ~75% dropped-on-the-floor rate from
    > subsystem maintainers. Please resend when mainline is nopage-free.


    Sure, no problem.
    --
    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/

+ Reply to Thread
Page 1 of 2 1 2 LastLast