Skip to content
Snippets Groups Projects
  1. Oct 04, 2023
  2. Aug 21, 2023
  3. Aug 18, 2023
  4. May 31, 2023
  5. Feb 03, 2023
  6. Jan 19, 2023
  7. Nov 25, 2022
    • Al Viro's avatar
      use less confusing names for iov_iter direction initializers · de4eda9d
      Al Viro authored
      
      READ/WRITE proved to be actively confusing - the meanings are
      "data destination, as used with read(2)" and "data source, as
      used with write(2)", but people keep interpreting those as
      "we read data from it" and "we write data to it", i.e. exactly
      the wrong way.
      
      Call them ITER_DEST and ITER_SOURCE - at least that is harder
      to misinterpret...
      
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      de4eda9d
  8. Oct 03, 2022
  9. Sep 27, 2022
  10. Sep 12, 2022
  11. May 10, 2022
  12. May 09, 2022
  13. May 02, 2022
  14. Apr 15, 2022
    • Minchan Kim's avatar
      mm: fix unexpected zeroed page mapping with zram swap · e914d8f0
      Minchan Kim authored
      Two processes under CLONE_VM cloning, user process can be corrupted by
      seeing zeroed page unexpectedly.
      
            CPU A                        CPU B
      
        do_swap_page                do_swap_page
        SWP_SYNCHRONOUS_IO path     SWP_SYNCHRONOUS_IO path
        swap_readpage valid data
          swap_slot_free_notify
            delete zram entry
                                    swap_readpage zeroed(invalid) data
                                    pte_lock
                                    map the *zero data* to userspace
                                    pte_unlock
        pte_lock
        if (!pte_same)
          goto out_nomap;
        pte_unlock
        return and next refault will
        read zeroed data
      
      The swap_slot_free_notify is bogus for CLONE_VM case since it doesn't
      increase the refcount of swap slot at copy_mm so it couldn't catch up
      whether it's safe or not to discard data from backing device.  In the
      case, only the lock it could rely on to synchronize swap slot freeing is
      page table lock.  Thus, this patch gets rid of the swap_slot_free_notify
      function.  With this patch, CPU A will see correct data.
      
            CPU A                        CPU B
      
        do_swap_page                do_swap_page
        SWP_SYNCHRONOUS_IO path     SWP_SYNCHRONOUS_IO path
                                    swap_readpage original data
                                    pte_lock
                                    map the original data
                                    swap_free
                                      swap_range_free
                                        bd_disk->fops->swap_slot_free_notify
        swap_readpage read zeroed data
                                    pte_unlock
        pte_lock
        if (!pte_same)
          goto out_nomap;
        pte_unlock
        return
        on next refault will see mapped data by CPU B
      
      The concern of the patch would increase memory consumption since it
      could keep wasted memory with compressed form in zram as well as
      uncompressed form in address space.  However, most of cases of zram uses
      no readahead and do_swap_page is followed by swap_free so it will free
      the compressed form from in zram quickly.
      
      Link: https://lkml.kernel.org/r/YjTVVxIAsnKAXjTd@google.com
      
      
      Fixes: 0bcac06f ("mm, swap: skip swapcache for swapin of synchronous device")
      Reported-by: default avatarIvan Babrou <ivan@cloudflare.com>
      Tested-by: default avatarIvan Babrou <ivan@cloudflare.com>
      Signed-off-by: default avatarMinchan Kim <minchan@kernel.org>
      Cc: Nitin Gupta <ngupta@vflare.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: David Hildenbrand <david@redhat.com>
      Cc: <stable@vger.kernel.org>	[4.14+]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      e914d8f0
  15. Mar 22, 2022
    • Johannes Weiner's avatar
      mm: page_io: fix psi memory pressure error on cold swapins · d8c47cc7
      Johannes Weiner authored
      Once upon a time, all swapins counted toward memory pressure[1].  Then
      Joonsoo introduced workingset detection for anonymous pages and we gained
      the ability to distinguish hot from cold swapins[2][3].  But we failed to
      update swap_readpage() accordingly, and now we account partial memory
      pressure in the swapin path of cold memory.
      
      Not for all situations - which adds more inconsistency: paths using the
      conventional submit_bio() and lock_page() route will not see much pressure
      - unless storage itself is heavily congested and the bio submissions
      stall.  ZRAM and ZSWAP do most of the work directly from swap_readpage()
      and will see all swapins reflected as pressure.
      
      IOW, a workload doing cold swapins could see little to no pressure
      reported with on-disk swap, but potentially high pressure with a zram or
      zswap backend.  That confuses any psi-based health monitoring, load
      shedding, proactive reclaim, or userspace OOM killing schemes that might
      be in place for the workload.
      
      Restore consistency by making all swapin stall accounting conditional on
      the page actually being part of the workingset.
      
      [1] commit 93779069 ("mm/page_io.c: annotate refault stalls from swap_readpage")
      [2] commit aae466b0 ("mm/swap: implement workingset detection for anonymous LRU")
      [3] commit cad8320b ("mm/swap: don't SetPageWorkingset unconditionally during swapin")
      
      Link: https://lkml.kernel.org/r/20220214214921.419687-1-hannes@cmpxchg.org
      
      
      Signed-off-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Reported-by: default avatarCGEL <cgel.zte@gmail.com>
      Acked-by: default avatarMinchan Kim <minchan@kernel.org>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Cc: Yu Zhao <yuzhao@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d8c47cc7
  16. Mar 16, 2022
Loading