Skip to content
  • Minchan Kim's avatar
    zram: idle writeback fixes and cleanup · 1d69a3f8
    Minchan Kim authored
    This patch includes some fixes and cleanup for idle-page writeback.
    
    1. writeback_limit interface
    
    Now writeback_limit interface is rather conusing.  For example, once
    writeback limit budget is exausted, admin can see 0 from
    /sys/block/zramX/writeback_limit which is same semantic with disable
    writeback_limit at this moment.  IOW, admin cannot tell that zero came
    from disable writeback limit or exausted writeback limit.
    
    To make the interface clear, let's sepatate enable of writeback limit to
    another knob - /sys/block/zram0/writeback_limit_enable
    
    * before:
      while true :
        # to re-enable writeback limit once previous one is used up
        echo 0 > /sys/block/zram0/writeback_limit
        echo $((200<<20)) > /sys/block/zram0/writeback_limit
        ..
        .. # used up the writeback limit budget
    
    * new
      # To enable writeback limit, from the beginning, admin should
      # enable it.
      echo $((200<<20)) > /sys/block/zram0/writeback_limit
      echo 1 > /sys/block/zram/0/writeback_limit_enable
      while true :
        echo $((200<<20)) > /sys/block/zram0/writeback_limit
        ..
        .. # used up the writeback limit budget
    
    It's much strightforward.
    
    2. fix condition check idle/huge writeback mode check
    
    The mode in writeback_store is not bit opeartion any more so no need to
    use bit operations.  Furthermore, current condition check is broken in
    that it does writeback every pages regardless of huge/idle.
    
    3. clean up idle_store
    
    No need to use goto.
    
    [minchan@kernel.org: missed spin_lock_init]
      Link: http://lkml.kernel.org/r/20190103001601.GA255139@google.com
    Link: http://lkml.kernel.org/r/20181224033529.19450-1-minchan@kernel.org
    
    
    Signed-off-by: default avatarMinchan Kim <minchan@kernel.org>
    Suggested-by: default avatarJohn Dias <joaodias@google.com>
    Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
    Cc: John Dias <joaodias@google.com>
    Cc: Srinivas Paladugu <srnvs@google.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    1d69a3f8