05 Apr, 2016

1 commit

  • PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
    ago with promise that one day it will be possible to implement page
    cache with bigger chunks than PAGE_SIZE.

    This promise never materialized. And unlikely will.

    We have many places where PAGE_CACHE_SIZE assumed to be equal to
    PAGE_SIZE. And it's constant source of confusion on whether
    PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
    especially on the border between fs and mm.

    Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
    breakage to be doable.

    Let's stop pretending that pages in page cache are special. They are
    not.

    The changes are pretty straight-forward:

    - << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> ;

    - >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> ;

    - PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};

    - page_cache_get() -> get_page();

    - page_cache_release() -> put_page();

    This patch contains automated changes generated with coccinelle using
    script below. For some reason, coccinelle doesn't patch header files.
    I've called spatch for them manually.

    The only adjustment after coccinelle is revert of changes to
    PAGE_CAHCE_ALIGN definition: we are going to drop it later.

    There are few places in the code where coccinelle didn't reach. I'll
    fix them manually in a separate patch. Comments and documentation also
    will be addressed with the separate patch.

    virtual patch

    @@
    expression E;
    @@
    - E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
    + E

    @@
    expression E;
    @@
    - E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
    + E

    @@
    @@
    - PAGE_CACHE_SHIFT
    + PAGE_SHIFT

    @@
    @@
    - PAGE_CACHE_SIZE
    + PAGE_SIZE

    @@
    @@
    - PAGE_CACHE_MASK
    + PAGE_MASK

    @@
    expression E;
    @@
    - PAGE_CACHE_ALIGN(E)
    + PAGE_ALIGN(E)

    @@
    expression E;
    @@
    - page_cache_get(E)
    + get_page(E)

    @@
    expression E;
    @@
    - page_cache_release(E)
    + put_page(E)

    Signed-off-by: Kirill A. Shutemov
    Acked-by: Michal Hocko
    Signed-off-by: Linus Torvalds

    Kirill A. Shutemov
     

16 Feb, 2016

1 commit

  • We will soon modify the vanilla get_user_pages() so it can no
    longer be used on mm/tasks other than 'current/current->mm',
    which is by far the most common way it is called. For now,
    we allow the old-style calls, but warn when they are used.
    (implemented in previous patch)

    This patch switches all callers of:

    get_user_pages()
    get_user_pages_unlocked()
    get_user_pages_locked()

    to stop passing tsk/mm so they will no longer see the warnings.

    Signed-off-by: Dave Hansen
    Reviewed-by: Thomas Gleixner
    Cc: Andrea Arcangeli
    Cc: Andrew Morton
    Cc: Andy Lutomirski
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: Dave Hansen
    Cc: Denys Vlasenko
    Cc: H. Peter Anvin
    Cc: Kirill A. Shutemov
    Cc: Linus Torvalds
    Cc: Naoya Horiguchi
    Cc: Peter Zijlstra
    Cc: Rik van Riel
    Cc: Srikar Dronamraju
    Cc: Vlastimil Babka
    Cc: jack@suse.cz
    Cc: linux-mm@kvack.org
    Link: http://lkml.kernel.org/r/20160212210156.113E9407@viggo.jf.intel.com
    Signed-off-by: Ingo Molnar

    Dave Hansen
     

27 Jan, 2015

1 commit

  • The videobuf_dma_init* and videobuf_dma_map() functions are no longer
    used except in videobuf-dma-sg.c itself. Make them static.

    These functions were abused in various drivers. All those drivers
    have now been fixed, so by no longer exporting these functions
    future abuse is now prevented.

    Signed-off-by: Hans Verkuil
    Signed-off-by: Mauro Carvalho Chehab

    Hans Verkuil
     

22 Aug, 2014

1 commit

  • The "i--" needs to happen at the start of the loop or it will try to
    release something bogus (probably it will crash) and it won't release
    the first ->vaddr_page[].

    Fixes: 7b4eeed174b7 ('[media] vmalloc_sg: make sure all pages in vmalloc area are really DMA-ready')

    Signed-off-by: Dan Carpenter
    Signed-off-by: Hans Verkuil
    Signed-off-by: Mauro Carvalho Chehab

    Dan Carpenter
     

26 Jul, 2014

1 commit

  • Patch originally written by Konrad. Rebased on current linux media tree.

    Under Xen, vmalloc_32() isn't guaranteed to return pages which are really
    under 4G in machine physical addresses (only in virtual pseudo-physical
    addresses). To work around this, implement a vmalloc variant which
    allocates each page with dma_alloc_coherent() to guarantee that each
    page is suitable for the device in question.

    Signed-off-by: Konrad Rzeszutek Wilk
    Signed-off-by: James Harper
    Signed-off-by: Mauro Carvalho Chehab

    James Harper
     

04 Feb, 2014

1 commit

  • This reverts commit a242f426108c284049a69710f871cc9f11b13e61.

    That commit actually caused deadlocks, rather then fixing them.

    If ext_lock is set to NULL (otherwise videobuf_queue_lock doesn't do
    anything), then you get this deadlock:

    The driver's mmap function calls videobuf_mmap_mapper which calls
    videobuf_queue_lock on q. videobuf_mmap_mapper calls __videobuf_mmap_mapper,
    __videobuf_mmap_mapper calls videobuf_vm_open and videobuf_vm_open
    calls videobuf_queue_lock on q (introduced by above patch): deadlocked.

    This affects drivers using dma-contig and dma-vmalloc. Only dma-sg is
    not affected since it doesn't call videobuf_vm_open from __videobuf_mmap_mapper.

    Most drivers these days have a non-NULL ext_lock. Those that still use
    NULL there are all fairly obscure drivers, which is why this hasn't been
    seen earlier.

    Since everything worked perfectly fine for many years I prefer to just
    revert this patch rather than trying to fix it. videobuf is quite fragile
    and I rather not touch it too much. Work is (slowly) progressing to move
    everything over to vb2 or at the very least use non-NULL ext_lock in
    videobuf.

    Signed-off-by: Hans Verkuil
    Cc: # for v3.11 and up
    Cc: Al Viro
    Reported-by: Pete Eberlein
    Signed-off-by: Mauro Carvalho Chehab

    Hans Verkuil
     

21 May, 2013

1 commit

  • just use videobuf_queue_lock(map->q) to protect map->count; vm_area_operations
    ->open() and ->close() are called just under vma->vm_mm->mmap_sem, which
    doesn't help the drivers at all, since clonal VMAs are normally in different
    address spaces...

    Signed-off-by: Al Viro
    Signed-off-by: Mauro Carvalho Chehab

    Al Viro
     

09 Oct, 2012

1 commit

  • A long time ago, in v2.4, VM_RESERVED kept swapout process off VMA,
    currently it lost original meaning but still has some effects:

    | effect | alternative flags
    -+------------------------+---------------------------------------------
    1| account as reserved_vm | VM_IO
    2| skip in core dump | VM_IO, VM_DONTDUMP
    3| do not merge or expand | VM_IO, VM_DONTEXPAND, VM_HUGETLB, VM_PFNMAP
    4| do not mlock | VM_IO, VM_DONTEXPAND, VM_HUGETLB, VM_PFNMAP

    This patch removes reserved_vm counter from mm_struct. Seems like nobody
    cares about it, it does not exported into userspace directly, it only
    reduces total_vm showed in proc.

    Thus VM_RESERVED can be replaced with VM_IO or pair VM_DONTEXPAND | VM_DONTDUMP.

    remap_pfn_range() and io_remap_pfn_range() set VM_IO|VM_DONTEXPAND|VM_DONTDUMP.
    remap_vmalloc_range() set VM_DONTEXPAND | VM_DONTDUMP.

    [akpm@linux-foundation.org: drivers/vfio/pci/vfio_pci.c fixup]
    Signed-off-by: Konstantin Khlebnikov
    Cc: Alexander Viro
    Cc: Carsten Otte
    Cc: Chris Metcalf
    Cc: Cyrill Gorcunov
    Cc: Eric Paris
    Cc: H. Peter Anvin
    Cc: Hugh Dickins
    Cc: Ingo Molnar
    Cc: James Morris
    Cc: Jason Baron
    Cc: Kentaro Takeda
    Cc: Matt Helsley
    Cc: Nick Piggin
    Cc: Oleg Nesterov
    Cc: Peter Zijlstra
    Cc: Robert Richter
    Cc: Suresh Siddha
    Cc: Tetsuo Handa
    Cc: Venkatesh Pallipadi
    Acked-by: Linus Torvalds
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Konstantin Khlebnikov
     

14 Aug, 2012

1 commit