Skip to content
  1. Apr 02, 2022
  2. Mar 24, 2022
    • Linus Torvalds's avatar
      Merge tag 'trace-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace · 1bc19105
      Linus Torvalds authored
      Pull tracing updates from Steven Rostedt:
      
       - New user_events interface. User space can register an event with the
         kernel describing the format of the event. Then it will receive a
         byte in a page mapping that it can check against. A privileged task
         can then enable that event like any other event, which will change
         the mapped byte to true, telling the user space application to start
         writing the event to the tracing buffer.
      
       - Add new "ftrace_boot_snapshot" kernel command line parameter. When
         set, the tracing buffer will be saved in the snapshot buffer at boot
         up when the kernel hands things over to user space. This will keep
         the traces that happened at boot up available even if user space boot
         up has tracing as well.
      
       - Have TRACE_EVENT_ENUM() also update trace event field type
         descriptions. Thus if a static array defines its size with an enum,
         the user space trace event parsers can still know how to parse that
         array.
      
       - Add new TRACE_CUSTOM_EVENT() macro. This acts the same as the
         TRACE_EVENT() macro, but will attach to an existing tracepoint. This
         will make one tracepoint be able to trace different content and not
         be stuck at only what the original TRACE_EVENT() macro exports.
      
       - Fixes to tracing error logging.
      
       - Better saving of cmdlines to PIDs when tracing (use the wakeup events
         for mapping).
      
      * tag 'trace-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (30 commits)
        tracing: Have type enum modifications copy the strings
        user_events: Add trace event call as root for low permission cases
        tracing/user_events: Use alloc_pages instead of kzalloc() for register pages
        tracing: Add snapshot at end of kernel boot up
        tracing: Have TRACE_DEFINE_ENUM affect trace event types as well
        tracing: Fix strncpy warning in trace_events_synth.c
        user_events: Prevent dyn_event delete racing with ioctl add/delete
        tracing: Add TRACE_CUSTOM_EVENT() macro
        tracing: Move the defines to create TRACE_EVENTS into their own files
        tracing: Add sample code for custom trace events
        tracing: Allow custom events to be added to the tracefs directory
        tracing: Fix last_cmd_set() string management in histogram code
        user_events: Fix potential uninitialized pointer while parsing field
        tracing: Fix allocation of last_cmd in last_cmd_set()
        user_events: Add documentation file
        user_events: Add sample code for typical usage
        user_events: Add self-test for validator boundaries
        user_events: Add self-test for perf_event integration
        user_events: Add self-test for dynamic_events integration
        user_events: Add self-test for ftrace integration
        ...
      1bc19105
    • Linus Torvalds's avatar
      Merge tag 'trace-rtla-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace · 20f463fb
      Linus Torvalds authored
      Pull RTLA tracing tool updates from Steven Rostedt:
       "Real Time Analysis Tool updatesfor 5.18:
      
         - Support for adjusting tracing_threashold
      
         - Add -a (auto) option to make it easier for users to debug in the field
      
         - Add -e option to add more events to the trace
      
         - Add --trigger option to add triggers to events
      
         - Add --filter option to filter events
      
         - Add support to save histograms to the file
      
         - Add --dma-latency to set /dev/cpu_dma_latency
      
         - Other fixes and cleanups"
      
      * tag 'trace-rtla-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
        rtla: Tools main loop cleanup
        rtla/timerlat: Add --dma-latency option
        rtla/osnoise: Fix osnoise hist stop tracing message
        rtla: Check for trace off also in the trace instance
        rtla/trace: Save event histogram output to a file
        rtla: Add --filter support
        rtla/trace: Add trace event filter helpers
        rtla: Add --trigger support
        rtla/trace: Add trace event trigger helpers
        rtla: Add -e/--event support
        rtla/trace: Add trace events helpers
        rtla/timerlat: Add the automatic trace option
        rtla/osnoise: Add the automatic trace option
        rtla/osnoise: Add an option to set the threshold
        rtla/osnoise: Add support to adjust the tracing_thresh
      20f463fb
    • Linus Torvalds's avatar
      Merge tag 'printk-for-5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux · 3ef4ea3d
      Linus Torvalds authored
      Pull printk updates from Petr Mladek:
      
       - Make %pK behave the same as %p for kptr_restrict == 0 also with
         no_hash_pointers parameter
      
       - Ignore the default console in the device tree also when console=null
         or console="" is used on the command line
      
       - Document console=null and console="" behavior
      
       - Prevent a deadlock and a livelock caused by console_lock in panic()
      
       - Make console_lock available for panicking CPU
      
       - Fast query for the next to-be-used sequence number
      
       - Use the expected return values in printk.devkmsg __setup handler
      
       - Use the correct atomic operations in wake_up_klogd() irq_work handler
      
       - Avoid possible unaligned access when handling %4cc printing format
      
      * tag 'printk-for-5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux:
        printk: fix return value of printk.devkmsg __setup handler
        vsprintf: Fix %pK with kptr_restrict == 0
        printk: make suppress_panic_printk static
        printk: Set console_set_on_cmdline=1 when __add_preferred_console() is called with user_specified == true
        Docs: printk: add 'console=null|""' to admin/kernel-parameters
        printk: use atomic updates for klogd work
        printk: Drop console_sem during panic
        printk: Avoid livelock with heavy printk during panic
        printk: disable optimistic spin during panic
        printk: Add panic_in_progress helper
        vsprintf: Move space out of string literals in fourcc_string()
        vsprintf: Fix potential unaligned access
        printk: ringbuffer: Improve prb_next_seq() performance
      3ef4ea3d
    • Herbert Xu's avatar
      cacheflush.h: Add forward declaration for struct folio · 30d024b5
      Herbert Xu authored
      
      
      The struct folio is not declared in cacheflush.h so we need to provide
      a forward declaration as otherwise users of this header file may get
      warnings.
      
      Reported-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Fixes: 522a0032
      
       ("Add linux/cacheflush.h")
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Reviewed-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      30d024b5
  3. Mar 23, 2022
    • Linus Torvalds's avatar
      Merge tag 'folio-5.18b' of git://git.infradead.org/users/willy/pagecache · 6b1f86f8
      Linus Torvalds authored
      Pull filesystem folio updates from Matthew Wilcox:
       "Primarily this series converts some of the address_space operations to
        take a folio instead of a page.
      
        Notably:
      
         - a_ops->is_partially_uptodate() takes a folio instead of a page and
           changes the type of the 'from' and 'count' arguments to make it
           obvious they're bytes.
      
         - a_ops->invalidatepage() becomes ->invalidate_folio() and has a
           similar type change.
      
         - a_ops->launder_page() becomes ->launder_folio()
      
         - a_ops->set_page_dirty() becomes ->dirty_folio() and adds the
           address_space as an argument.
      
        There are a couple of other misc changes up front that weren't worth
        separating into their own pull request"
      
      * tag 'folio-5.18b' of git://git.infradead.org/users/willy/pagecache: (53 commits)
        fs: Remove aops ->set_page_dirty
        fb_defio: Use noop_dirty_folio()
        fs: Convert __set_page_dirty_no_writeback to noop_dirty_folio
        fs: Convert __set_page_dirty_buffers to block_dirty_folio
        nilfs: Convert nilfs_set_page_dirty() to nilfs_dirty_folio()
        mm: Convert swap_set_page_dirty() to swap_dirty_folio()
        ubifs: Convert ubifs_set_page_dirty to ubifs_dirty_folio
        f2fs: Convert f2fs_set_node_page_dirty to f2fs_dirty_node_folio
        f2fs: Convert f2fs_set_data_page_dirty to f2fs_dirty_data_folio
        f2fs: Convert f2fs_set_meta_page_dirty to f2fs_dirty_meta_folio
        afs: Convert afs_dir_set_page_dirty() to afs_dir_dirty_folio()
        btrfs: Convert extent_range_redirty_for_io() to use folios
        fs: Convert trivial uses of __set_page_dirty_nobuffers to filemap_dirty_folio
        btrfs: Convert from set_page_dirty to dirty_folio
        fscache: Convert fscache_set_page_dirty() to fscache_dirty_folio()
        fs: Add aops->dirty_folio
        fs: Remove aops->launder_page
        orangefs: Convert launder_page to launder_folio
        nfs: Convert from launder_page to launder_folio
        fuse: Convert from launder_page to launder_folio
        ...
      6b1f86f8
    • Linus Torvalds's avatar
      Merge tag 'folio-5.18c' of git://git.infradead.org/users/willy/pagecache · 9030fb0b
      Linus Torvalds authored
      Pull folio updates from Matthew Wilcox:
      
       - Rewrite how munlock works to massively reduce the contention on
         i_mmap_rwsem (Hugh Dickins):
      
           https://lore.kernel.org/linux-mm/8e4356d-9622-a7f0-b2c-f116b5f2efea@google.com/
      
       - Sort out the page refcount mess for ZONE_DEVICE pages (Christoph
         Hellwig):
      
           https://lore.kernel.org/linux-mm/20220210072828.2930359-1-hch@lst.de/
      
       - Convert GUP to use folios and make pincount available for order-1
         pages. (Matthew Wilcox)
      
       - Convert a few more truncation functions to use folios (Matthew
         Wilcox)
      
       - Convert page_vma_mapped_walk to use PFNs instead of pages (Matthew
         Wilcox)
      
       - Convert rmap_walk to use folios (Matthew Wilcox)
      
       - Convert most of shrink_page_list() to use a folio (Matthew Wilcox)
      
       - Add support for creating large folios in readahead (Matthew Wilcox)
      
      * tag 'folio-5.18c' of git://git.infradead.org/users/willy/pagecache: (114 commits)
        mm/damon: minor cleanup for damon_pa_young
        selftests/vm/transhuge-stress: Support file-backed PMD folios
        mm/filemap: Support VM_HUGEPAGE for file mappings
        mm/readahead: Switch to page_cache_ra_order
        mm/readahead: Align file mappings for non-DAX
        mm/readahead: Add large folio readahead
        mm: Support arbitrary THP sizes
        mm: Make large folios depend on THP
        mm: Fix READ_ONLY_THP warning
        mm/filemap: Allow large folios to be added to the page cache
        mm: Turn can_split_huge_page() into can_split_folio()
        mm/vmscan: Convert pageout() to take a folio
        mm/vmscan: Turn page_check_references() into folio_check_references()
        mm/vmscan: Account large folios correctly
        mm/vmscan: Optimise shrink_page_list for non-PMD-sized folios
        mm/vmscan: Free non-shmem folios without splitting them
        mm/rmap: Constify the rmap_walk_control argument
        mm/rmap: Convert rmap_walk() to take a folio
        mm: Turn page_anon_vma() into folio_anon_vma()
        mm/rmap: Turn page_lock_anon_vma_read() into folio_lock_anon_vma_read()
        ...
      9030fb0b
    • Linus Torvalds's avatar
      Merge branch 'akpm' (patches from Andrew) · 3bf03b9a
      Linus Torvalds authored
      Merge updates from Andrew Morton:
      
       - A few misc subsystems: kthread, scripts, ntfs, ocfs2, block, and vfs
      
       - Most the MM patches which precede the patches in Willy's tree: kasan,
         pagecache, gup, swap, shmem, memcg, selftests, pagemap, mremap,
         sparsemem, vmalloc, pagealloc, memory-failure, mlock, hugetlb,
         userfaultfd, vmscan, compaction, mempolicy, oom-kill, migration, thp,
         cma, autonuma, psi, ksm, page-poison, madvise, memory-hotplug, rmap,
         zswap, uaccess, ioremap, highmem, cleanups, kfence, hmm, and damon.
      
      * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (227 commits)
        mm/damon/sysfs: remove repeat container_of() in damon_sysfs_kdamond_release()
        Docs/ABI/testing: add DAMON sysfs interface ABI document
        Docs/admin-guide/mm/damon/usage: document DAMON sysfs interface
        selftests/damon: add a test for DAMON sysfs interface
        mm/damon/sysfs: support DAMOS stats
        mm/damon/sysfs: support DAMOS watermarks
        mm/damon/sysfs: support schemes prioritization
        mm/damon/sysfs: support DAMOS quotas
        mm/damon/sysfs: support DAMON-based Operation Schemes
        mm/damon/sysfs: support the physical address space monitoring
        mm/damon/sysfs: link DAMON for virtual address spaces monitoring
        mm/damon: implement a minimal stub for sysfs-based DAMON interface
        mm/damon/core: add number of each enum type values
        mm/damon/core: allow non-exclusive DAMON start/stop
        Docs/damon: update outdated term 'regions update interval'
        Docs/vm/damon/design: update DAMON-Idle Page Tracking interference handling
        Docs/vm/damon: call low level monitoring primitives the operations
        mm/damon: remove unnecessary CONFIG_DAMON option
        mm/damon/paddr,vaddr: remove damon_{p,v}a_{target_valid,set_operations}()
        mm/damon/dbgfs-test: fix is_target_id() change
        ...
      3bf03b9a
    • Xin Hao's avatar
      mm/damon/sysfs: remove repeat container_of() in damon_sysfs_kdamond_release() · 15423a52
      Xin Hao authored
      In damon_sysfs_kdamond_release(), we have use container_of() to get
      "kdamond" pointer, so there no need to get it once again.
      
      Link: https://lkml.kernel.org/r/20220303075314.22502-1-xhao@linux.alibaba.com
      
      
      Signed-off-by: default avatarXin Hao <xhao@linux.alibaba.com>
      Reviewed-by: default avatarSeongJae Park <sj@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      15423a52
    • SeongJae Park's avatar
      Docs/ABI/testing: add DAMON sysfs interface ABI document · f968c6a4
      SeongJae Park authored
      This commit adds DAMON sysfs interface ABI document under
      Documentation/ABI/testing.
      
      Link: https://lkml.kernel.org/r/20220228081314.5770-14-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Xin Hao <xhao@linux.alibaba.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      f968c6a4
    • SeongJae Park's avatar
      Docs/admin-guide/mm/damon/usage: document DAMON sysfs interface · b1840272
      SeongJae Park authored
      This commit adds detailed usage of DAMON sysfs interface in the
      admin-guide document for DAMON.
      
      Link: https://lkml.kernel.org/r/20220228081314.5770-13-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Xin Hao <xhao@linux.alibaba.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b1840272
    • SeongJae Park's avatar
      selftests/damon: add a test for DAMON sysfs interface · 40184e48
      SeongJae Park authored
      This commit adds a selftest for DAMON sysfs interface.  It tests the
      functionality of 'nr' files and existence of files in each directory of
      the hierarchy.
      
      Link: https://lkml.kernel.org/r/20220228081314.5770-12-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Xin Hao <xhao@linux.alibaba.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      40184e48
    • SeongJae Park's avatar
      mm/damon/sysfs: support DAMOS stats · 0ac32b8a
      SeongJae Park authored
      This commit makes DAMON sysfs interface supports the DAMOS stats feature.
      Specifically, this commit adds 'stats' directory under each scheme
      directory, and update the contents of the files under the directory
      according to the latest monitoring results, when the user writes special
      keyword, 'update_schemes_stats' to the 'state' file of the kdamond.
      
      As a result, the files hierarchy becomes as below:
      
          /sys/kernel/mm/damon/admin
          │ kdamonds/nr_kdamonds
          │ │ 0/state,pid
          │ │ │ contexts/nr_contexts
          │ │ │ │ 0/operations
          │ │ │ │ │ monitoring_attrs/intervals/sample_us,aggr_us,update_us
          │ │ │ │ │ │ nr_regions/min,max
          │ │ │ │ │ targets/nr_targets
          │ │ │ │ │ │ 0/pid_target
          │ │ │ │ │ │ │ regions/nr_regions
          │ │ │ │ │ │ │ │ 0/start,end
          │ │ │ │ │ │ │ │ ...
          │ │ │ │ │ │ ...
          │ │ │ │ │ schemes/nr_schemes
          │ │ │ │ │ │ 0/action
          │ │ │ │ │ │ │ access_pattern/
          │ │ │ │ │ │ │ │ sz/min,max
          │ │ │ │ │ │ │ │ nr_accesses/min,max
          │ │ │ │ │ │ │ │ age/min,max
          │ │ │ │ │ │ │ quotas/ms,sz,reset_interval_ms
          │ │ │ │ │ │ │ │ weights/sz_permil,nr_accesses_permil,age_permil
          │ │ │ │ │ │ │ watermarks/metric,interval_us,high,mid,low
          │ │ │ │ │ │ │ stats/    <- NEW DIRECTORY
          │ │ │ │ │ │ │ │ nr_tried,sz_tried,nr_applied,sz_applied,qt_exceeds
          │ │ │ │ │ │ ...
          │ │ │ │ ...
          │ │ ...
      
      Link: https://lkml.kernel.org/r/20220228081314.5770-11-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Xin Hao <xhao@linux.alibaba.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      0ac32b8a
    • SeongJae Park's avatar
      mm/damon/sysfs: support DAMOS watermarks · 1b32234a
      SeongJae Park authored
      This commit makes DAMON sysfs interface supports the DAMOS watermarks
      feature.  Specifically, this commit adds 'watermarks' directory under each
      scheme directory and makes kdamond 'state' file writing respects the
      contents in the directory.
      
      As a result, the files hierarchy becomes as below:
      
          /sys/kernel/mm/damon/admin
          │ kdamonds/nr_kdamonds
          │ │ 0/state,pid
          │ │ │ contexts/nr_contexts
          │ │ │ │ 0/operations
          │ │ │ │ │ monitoring_attrs/intervals/sample_us,aggr_us,update_us
          │ │ │ │ │ │ nr_regions/min,max
          │ │ │ │ │ targets/nr_targets
          │ │ │ │ │ │ 0/pid_target
          │ │ │ │ │ │ │ regions/nr_regions
          │ │ │ │ │ │ │ │ 0/start,end
          │ │ │ │ │ │ │ │ ...
          │ │ │ │ │ │ ...
          │ │ │ │ │ schemes/nr_schemes
          │ │ │ │ │ │ 0/action
          │ │ │ │ │ │ │ access_pattern/
          │ │ │ │ │ │ │ │ sz/min,max
          │ │ │ │ │ │ │ │ nr_accesses/min,max
          │ │ │ │ │ │ │ │ age/min,max
          │ │ │ │ │ │ │ quotas/ms,sz,reset_interval_ms
          │ │ │ │ │ │ │ │ weights/sz_permil,nr_accesses_permil,age_permil
          │ │ │ │ │ │ │ watermarks/    <- NEW DIRECTORY
          │ │ │ │ │ │ │ │ metric,interval_us,high,mid,lo
          │ │ │ │ │ │ ...
          │ │ │ │ ...
          │ │ ...
      
      [sj@kernel.org: fix out-of-bound array access for wmark_metric_strs[]]
        Link: https://lkml.kernel.org/r/20220301185619.2904-1-sj@kernel.org
      
      Link: https://lkml.kernel.org/r/20220228081314.5770-10-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Xin Hao <xhao@linux.alibaba.com>
      Cc: Colin Ian King <colin.i.king@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      1b32234a
    • SeongJae Park's avatar
      mm/damon/sysfs: support schemes prioritization · 1c78b2bc
      SeongJae Park authored
      This commit makes DAMON sysfs interface supports the DAMOS' regions
      prioritization weights feature under quotas limitation.  Specifically,
      this commit adds 'weights' directory under each scheme directory and makes
      kdamond 'state' file writing respects the contents in the directory.
      
          /sys/kernel/mm/damon/admin
          │ kdamonds/nr
          │ │ 0/state,pid
          │ │ │ contexts/nr
          │ │ │ │ 0/operations
          │ │ │ │ │ monitoring_attrs/intervals/sample_us,aggr_us,update_us
          │ │ │ │ │ │ nr_regions/min,max
          │ │ │ │ │ targets/nr
          │ │ │ │ │ │ 0/pid
          │ │ │ │ │ │ │ regions/nr
          │ │ │ │ │ │ │ │ 0/start,end
          │ │ │ │ │ │ │ │ ...
          │ │ │ │ │ │ ...
          │ │ │ │ │ schemes/nr
          │ │ │ │ │ │ 0/action
          │ │ │ │ │ │ │ access_pattern/
          │ │ │ │ │ │ │ │ sz/min,max
          │ │ │ │ │ │ │ │ nr_accesses/min,max
          │ │ │ │ │ │ │ │ age/min,max
          │ │ │ │ │ │ │ quotas/ms,bytes,reset_interval_ms
          │ │ │ │ │ │ │ │ weights/    <- NEW DIRECTORY
          │ │ │ │ │ │ │ │ │ weights/sz_permil,nr_accesses_permil,age_permil
          │ │ │ │ │ │ ...
          │ │ │ │ ...
          │ │ ...
      
      Link: https://lkml.kernel.org/r/20220228081314.5770-9-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Xin Hao <xhao@linux.alibaba.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      1c78b2bc
    • SeongJae Park's avatar
      mm/damon/sysfs: support DAMOS quotas · 9bbb820a
      SeongJae Park authored
      This commit makes DAMON sysfs interface supports the DAMOS quotas feature.
      Specifically, this commit adds 'quotas' directory under each scheme
      directory and makes kdamond 'state' file writing respects the contents in
      the directory.
      
      As a result, the files hierarchy becomes as below:
      
          /sys/kernel/mm/damon/admin
          │ kdamonds/nr_kdamonds
          │ │ 0/state,pid
          │ │ │ contexts/nr_contexts
          │ │ │ │ 0/operations
          │ │ │ │ │ monitoring_attrs/intervals/sample_us,aggr_us,update_us
          │ │ │ │ │ │ nr_regions/min,max
          │ │ │ │ │ targets/nr_targets
          │ │ │ │ │ │ 0/pid_target
          │ │ │ │ │ │ │ regions/nr_regions
          │ │ │ │ │ │ │ │ 0/start,end
          │ │ │ │ │ │ │ │ ...
          │ │ │ │ │ │ ...
          │ │ │ │ │ schemes/nr_schemes
          │ │ │ │ │ │ 0/action
          │ │ │ │ │ │ │ access_pattern/
          │ │ │ │ │ │ │ │ sz/min,max
          │ │ │ │ │ │ │ │ nr_accesses/min,max
          │ │ │ │ │ │ │ │ age/min,max
          │ │ │ │ │ │ │ quotas/ms,bytes,reset_interval_ms    <- NEW DIRECTORY
          │ │ │ │ │ │ ...
          │ │ │ │ ...
          │ │ ...
      
      Link: https://lkml.kernel.org/r/20220228081314.5770-8-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Xin Hao <xhao@linux.alibaba.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9bbb820a
    • SeongJae Park's avatar
      mm/damon/sysfs: support DAMON-based Operation Schemes · 7e84b1f8
      SeongJae Park authored
      This commit makes DAMON sysfs interface supports the DAMON-based operation
      schemes (DAMOS) feature.  Specifically, this commit adds 'schemes'
      directory under each context direcotry, and makes kdamond 'state' file
      writing respects the contents in the directory.
      
      Note that this commit doesn't support all features of DAMOS but only the
      target access pattern and action feature.  Supports for quotas,
      prioritization, watermarks will follow.
      
      As a result, the files hierarchy becomes as below:
      
          /sys/kernel/mm/damon/admin
          │ kdamonds/nr_kdamonds
          │ │ 0/state,pid
          │ │ │ contexts/nr_contexts
          │ │ │ │ 0/operations
          │ │ │ │ │ monitoring_attrs/intervals/sample_us,aggr_us,update_us
          │ │ │ │ │ │ nr_regions/min,max
          │ │ │ │ │ targets/nr_targets
          │ │ │ │ │ │ 0/pid_target
          │ │ │ │ │ │ │ regions/nr_regions
          │ │ │ │ │ │ │ │ 0/start,end
          │ │ │ │ │ │ │ │ ...
          │ │ │ │ │ │ ...
          │ │ │ │ │ schemes/nr_schemes    <- NEW DIRECTORY
          │ │ │ │ │ │ 0/action
          │ │ │ │ │ │ │ access_pattern/
          │ │ │ │ │ │ │ │ sz/min,max
          │ │ │ │ │ │ │ │ nr_accesses/min,max
          │ │ │ │ │ │ │ │ age/min,max
          │ │ │ │ │ │ ...
          │ │ │ │ ...
          │ │ ...
      
      Link: https://lkml.kernel.org/r/20220228081314.5770-7-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Xin Hao <xhao@linux.alibaba.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      7e84b1f8
    • SeongJae Park's avatar
      mm/damon/sysfs: support the physical address space monitoring · 2031b14e
      SeongJae Park authored
      This commit makes DAMON sysfs interface supports the physical address
      space monitoring.  Specifically, this commit adds support of the initial
      monitoring regions set feature by adding 'regions' directory under each
      target directory and makes context operations file to receive 'paddr' in
      addition to 'vaddr'.
      
      As a result, the files hierarchy becomes as below:
      
          /sys/kernel/mm/damon/admin
          │ kdamonds/nr_kdamonds
          │ │ 0/state,pid
          │ │ │ contexts/nr_contexts
          │ │ │ │ 0/operations
          │ │ │ │ │ monitoring_attrs/
          │ │ │ │ │ │ intervals/sample_us,aggr_us,update_us
          │ │ │ │ │ │ nr_regions/min,max
          │ │ │ │ │ targets/nr_targets
          │ │ │ │ │ │ 0/pid_target
          │ │ │ │ │ │ │ regions/nr_regions    <- NEW DIRECTORY
          │ │ │ │ │ │ │ │ 0/start,end
          │ │ │ │ │ │ │ │ ...
          │ │ │ │ │ │ ...
          │ │ │ │ ...
          │ │ ...
      
      Link: https://lkml.kernel.org/r/20220228081314.5770-6-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Xin Hao <xhao@linux.alibaba.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      2031b14e
    • SeongJae Park's avatar
      mm/damon/sysfs: link DAMON for virtual address spaces monitoring · a61ea561
      SeongJae Park authored
      This commit links the DAMON sysfs interface to DAMON so that users can
      control DAMON via the interface.  In detail, this commit makes writing
      'on' to 'state' file constructs DAMON contexts based on values that users
      have written to relevant sysfs files and start the context.  It supports
      only virtual address spaces monitoring at the moment, though.
      
      The files hierarchy of DAMON sysfs interface after this commit is shown
      below.  In the below figure, parents-children relations are represented
      with indentations, each directory is having ``/`` suffix, and files in
      each directory are separated by comma (",").
      
          /sys/kernel/mm/damon/admin
          │ kdamonds/nr_kdamonds
          │ │ 0/state,pid
          │ │ │ contexts/nr_contexts
          │ │ │ │ 0/operations
          │ │ │ │ │ monitoring_attrs/
          │ │ │ │ │ │ intervals/sample_us,aggr_us,update_us
          │ │ │ │ │ │ nr_regions/min,max
          │ │ │ │ │ targets/nr_targets
          │ │ │ │ │ │ 0/pid_target
          │ │ │ │ │ │ ...
          │ │ │ │ ...
          │ │ ...
      
      The usage is straightforward.  Writing a number ('N') to each 'nr_*' file
      makes directories named '0' to 'N-1'.  Users can construct DAMON contexts
      by writing proper values to the files in the straightforward manner and
      start each kdamond by writing 'on' to 'kdamonds/<N>/state'.
      
      Link: https://lkml.kernel.org/r/20220228081314.5770-5-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Xin Hao <xhao@linux.alibaba.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      a61ea561
    • SeongJae Park's avatar
      mm/damon: implement a minimal stub for sysfs-based DAMON interface · c951cd3b
      SeongJae Park authored
      DAMON's debugfs-based user interface served very well, so far.  However,
      it unnecessarily depends on debugfs, while DAMON is not aimed to be used
      for only debugging.  Also, the interface receives multiple values via one
      file.  For example, schemes file receives 18 values separated by white
      spaces.  As a result, it is ineffient, hard to be used, and difficult to
      be extended.  Especially, keeping backward compatibility of user space
      tools is getting only challenging.  It would be better to implement
      another reliable and flexible interface and deprecate the debugfs
      interface in long term.
      
      To this end, this commit implements a stub of a part of the new user
      interface of DAMON using sysfs.  Specifically, this commit implements the
      sysfs control parts for virtual address space monitoring.
      
      More specifically, the idea of the new interface is, using directory
      hierarchies and making one file for one value.  The hierarchy that this
      commit is introducing is as below.  In the below figure, parents-children
      relations are represented with indentations, each directory is having
      ``/`` suffix, and files in each directory are separated by comma (",").
      
          /sys/kernel/mm/damon/admin
          │ kdamonds/nr_kdamonds
          │ │ 0/state,pid
          │ │ │ contexts/nr_contexts
          │ │ │ │ 0/operations
          │ │ │ │ │ monitoring_attrs/
          │ │ │ │ │ │ intervals/sample_us,aggr_us,update_us
          │ │ │ │ │ │ nr_regions/min,max
          │ │ │ │ │ targets/nr_targets
          │ │ │ │ │ │ 0/pid_target
          │ │ │ │ │ │ ...
          │ │ │ │ ...
          │ │ ...
      
      Writing a number <N> to each 'nr' file makes directories of name <0> to
      <N-1> in the directory of the 'nr' file.  That's all this commit does.
      Writing proper values to relevant files will construct the DAMON contexts,
      and writing a special keyword, 'on', to 'state' files for each kdamond
      will ask DAMON to start the constructed contexts.
      
      For a short example, using below commands for monitoring virtual address
      spaces of a given workload is imaginable:
      
          # cd /sys/kernel/mm/damon/admin/
          # echo 1 > kdamonds/nr_kdamonds
          # echo 1 > kdamonds/0/contexts/nr_contexts
          # echo vaddr > kdamonds/0/contexts/0/operations
          # echo 1 > kdamonds/0/contexts/0/targets/nr_targets
          # echo $(pidof <workload>) > kdamonds/0/contexts/0/targets/0/pid_target
          # echo on > kdamonds/0/state
      
      Please note that this commit is implementing only the sysfs part stub as
      abovely mentioned.  This commit doesn't implement the special keywords for
      'state' files.  Following commits will do that.
      
      [jiapeng.chong@linux.alibaba.com: fix missing error code in damon_sysfs_attrs_add_dirs()]
        Link: https://lkml.kernel.org/r/20220302111120.24984-1-jiapeng.chong@linux.alibaba.com
      
      Link: https://lkml.kernel.org/r/20220228081314.5770-4-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Signed-off-by: default avatarJiapeng Chong <jiapeng.chong@linux.alibaba.com>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Xin Hao <xhao@linux.alibaba.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      c951cd3b
    • SeongJae Park's avatar
      mm/damon/core: add number of each enum type values · 5257f36e
      SeongJae Park authored
      This commit declares the number of legal values for each DAMON enum types
      to make traversals of such DAMON enum types easy and safe.
      
      Link: https://lkml.kernel.org/r/20220228081314.5770-3-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Xin Hao <xhao@linux.alibaba.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      5257f36e
    • SeongJae Park's avatar
      mm/damon/core: allow non-exclusive DAMON start/stop · 8b9b0d33
      SeongJae Park authored
      Patch series "Introduce DAMON sysfs interface", v3.
      
      Introduction
      ============
      
      DAMON's debugfs-based user interface (DAMON_DBGFS) served very well, so
      far.  However, it unnecessarily depends on debugfs, while DAMON is not
      aimed to be used for only debugging.  Also, the interface receives
      multiple values via one file.  For example, schemes file receives 18
      values.  As a result, it is inefficient, hard to be used, and difficult to
      be extended.  Especially, keeping backward compatibility of user space
      tools is getting only challenging.  It would be better to implement
      another reliable and flexible interface and deprecate DAMON_DBGFS in long
      term.
      
      For the reason, this patchset introduces a sysfs-based new user interface
      of DAMON.  The idea of the new interface is, using directory hierarchies
      and having one dedicated file for each value.  For a short example, users
      can do the virtual address monitoring via the interface as below:
      
          # cd /sys/kernel/mm/damon/admin/
          # echo 1 > kdamonds/nr_kdamonds
          # echo 1 > kdamonds/0/contexts/nr_contexts
          # echo vaddr > kdamonds/0/contexts/0/operations
          # echo 1 > kdamonds/0/contexts/0/targets/nr_targets
          # echo $(pidof <workload>) > kdamonds/0/contexts/0/targets/0/pid_target
          # echo on > kdamonds/0/state
      
      A brief representation of the files hierarchy of DAMON sysfs interface is
      as below.  Childs are represented with indentation, directories are having
      '/' suffix, and files in each directory are separated by comma.
      
          /sys/kernel/mm/damon/admin
          │ kdamonds/nr_kdamonds
          │ │ 0/state,pid
          │ │ │ contexts/nr_contexts
          │ │ │ │ 0/operations
          │ │ │ │ │ monitoring_attrs/
          │ │ │ │ │ │ intervals/sample_us,aggr_us,update_us
          │ │ │ │ │ │ nr_regions/min,max
          │ │ │ │ │ targets/nr_targets
          │ │ │ │ │ │ 0/pid_target
          │ │ │ │ │ │ │ regions/nr_regions
          │ │ │ │ │ │ │ │ 0/start,end
          │ │ │ │ │ │ │ │ ...
          │ │ │ │ │ │ ...
          │ │ │ │ │ schemes/nr_schemes
          │ │ │ │ │ │ 0/action
          │ │ │ │ │ │ │ access_pattern/
          │ │ │ │ │ │ │ │ sz/min,max
          │ │ │ │ │ │ │ │ nr_accesses/min,max
          │ │ │ │ │ │ │ │ age/min,max
          │ │ │ │ │ │ │ quotas/ms,bytes,reset_interval_ms
          │ │ │ │ │ │ │ │ weights/sz_permil,nr_accesses_permil,age_permil
          │ │ │ │ │ │ │ watermarks/metric,interval_us,high,mid,low
          │ │ │ │ │ │ │ stats/nr_tried,sz_tried,nr_applied,sz_applied,qt_exceeds
          │ │ │ │ │ │ ...
          │ │ │ │ ...
          │ │ ...
      
      Detailed usage of the files will be described in the final Documentation
      patch of this patchset.
      
      Main Difference Between DAMON_DBGFS and DAMON_SYSFS
      ---------------------------------------------------
      
      At the moment, DAMON_DBGFS and DAMON_SYSFS provides same features.  One
      important difference between them is their exclusiveness.  DAMON_DBGFS
      works in an exclusive manner, so that no DAMON worker thread (kdamond) in
      the system can run concurrently and interfere somehow.  For the reason,
      DAMON_DBGFS asks users to construct all monitoring contexts and start them
      at once.  It's not a big problem but makes the operation a little bit
      complex and unflexible.
      
      For more flexible usage, DAMON_SYSFS moves the responsibility of
      preventing any possible interference to the admins and work in a
      non-exclusive manner.  That is, users can configure and start contexts one
      by one.  Note that DAMON respects both exclusive groups and non-exclusive
      groups of contexts, in a manner similar to that of reader-writer locks.
      That is, if any exclusive monitoring contexts (e.g., contexts that started
      via DAMON_DBGFS) are running, DAMON_SYSFS does not start new contexts, and
      vice versa.
      
      Future Plan of DAMON_DBGFS Deprecation
      ======================================
      
      Once this patchset is merged, DAMON_DBGFS development will be frozen.
      That is, we will maintain it to work as is now so that no users will be
      break.  But, it will not be extended to provide any new feature of DAMON.
      The support will be continued only until next LTS release.  After that, we
      will drop DAMON_DBGFS.
      
      User-space Tooling Compatibility
      --------------------------------
      
      As DAMON_SYSFS provides all features of DAMON_DBGFS, all user space
      tooling can move to DAMON_SYSFS.  As we will continue supporting
      DAMON_DBGFS until next LTS kernel release, user space tools would have
      enough time to move to DAMON_SYSFS.
      
      The official user space tool, damo[1], is already supporting both
      DAMON_SYSFS and DAMON_DBGFS.  Both correctness tests[2] and performance
      tests[3] of DAMON using DAMON_SYSFS also passed.
      
      [1] https://github.com/awslabs/damo
      [2] https://github.com/awslabs/damon-tests/tree/master/corr
      [3] https://github.com/awslabs/damon-tests/tree/master/perf
      
      Sequence of Patches
      ===================
      
      First two patches (patches 1-2) make core changes for DAMON_SYSFS.  The
      first one (patch 1) allows non-exclusive DAMON contexts so that
      DAMON_SYSFS can work in non-exclusive mode, while the second one (patch 2)
      adds size of DAMON enum types so that DAMON API users can safely iterate
      the enums.
      
      Third patch (patch 3) implements basic sysfs stub for virtual address
      spaces monitoring.  Note that this implements only sysfs files and DAMON
      is not linked.  Fourth patch (patch 4) links the DAMON_SYSFS to DAMON so
      that users can control DAMON using the sysfs files.
      
      Following six patches (patches 5-10) implements other DAMON features that
      DAMON_DBGFS supports one by one (physical address space monitoring,
      DAMON-based operation schemes, schemes quotas, schemes prioritization
      weights, schemes watermarks, and schemes stats).
      
      Following patch (patch 11) adds a simple selftest for DAMON_SYSFS, and the
      final one (patch 12) documents DAMON_SYSFS.
      
      This patch (of 13):
      
      To avoid interference between DAMON contexts monitoring overlapping memory
      regions, damon_start() works in an exclusive manner.  That is,
      damon_start() does nothing bug fails if any context that started by
      another instance of the function is still running.  This makes its usage a
      little bit restrictive.  However, admins could aware each DAMON usage and
      address such interferences on their own in some cases.
      
      This commit hence implements non-exclusive mode of the function and allows
      the callers to select the mode.  Note that the exclusive groups and
      non-exclusive groups of contexts will respect each other in a manner
      similar to that of reader-writer locks.  Therefore, this commit will not
      cause any behavioral change to the exclusive groups.
      
      Link: https://lkml.kernel.org/r/20220228081314.5770-1-sj@kernel.org
      Link: https://lkml.kernel.org/r/20220228081314.5770-2-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Xin Hao <xhao@linux.alibaba.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      8b9b0d33
    • SeongJae Park's avatar
      Docs/damon: update outdated term 'regions update interval' · 4c1f287f
      SeongJae Park authored
      Before DAMON is merged in the mainline, the concept of 'regions update
      interval' has generalized to be used as the time interval for update of
      any monitoring operations related data structure, but the document has not
      updated properly.  This commit updates the document for better
      consistency.
      
      Link: https://lkml.kernel.org/r/20220222170100.17068-4-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      4c1f287f
    • SeongJae Park's avatar
      Docs/vm/damon/design: update DAMON-Idle Page Tracking interference handling · 742cc2bf
      SeongJae Park authored
      In DAMON's early development stage before it be merged in the mainline, it
      was first designed to work exclusively with Idle page tracking to avoid
      any interference between each other.  Later, but still before be merged in
      the mainline, because Idle page tracking is fully under the control of
      sysadmins, we made the resolving of conflict as the responsibility of
      sysadmins.  The document is not updated for the change, though.  This
      commit updates the document for that.
      
      Link: https://lkml.kernel.org/r/20220222170100.17068-3-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      742cc2bf
    • SeongJae Park's avatar
      Docs/vm/damon: call low level monitoring primitives the operations · 561f4fc4
      SeongJae Park authored
      Patch series "Docs/damon: Update documents for better consistency".
      
      Some of DAMON document are not properly updated for latest version.  This
      patchset updates such parts.
      
      This patch (of 3):
      
      DAMON code calls the low level monitoring primitives implementations the
      monitoring operations.  The documentation would have no problem at still
      calling those primitives implementation because there is no real
      difference in the concepts, but making it more consistent with the code
      would make it better.  This commit therefore convert sentences in the doc
      specifically pointing the implementations of the primitives to call it
      monitoring operations.
      
      Link: https://lkml.kernel.org/r/20220222170100.17068-1-sj@kernel.org
      Link: https://lkml.kernel.org/r/20220222170100.17068-2-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      561f4fc4
    • tangmeng's avatar
      mm/damon: remove unnecessary CONFIG_DAMON option · 3213a3c1
      tangmeng authored
      In mm/Makefile has:
      
        obj-$(CONFIG_DAMON) += damon/
      
      So that we don't need 'obj-$(CONFIG_DAMON) :=' in mm/damon/Makefile,
      delete it from mm/damon/Makefile.
      
      Link: https://lkml.kernel.org/r/20220221065255.19991-1-tangmeng@uniontech.com
      
      
      Signed-off-by: default avatartangmeng <tangmeng@uniontech.com>
      Cc: SeongJae Park <sj@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      3213a3c1
    • SeongJae Park's avatar
      mm/damon/paddr,vaddr: remove damon_{p,v}a_{target_valid,set_operations}() · 85104056
      SeongJae Park authored
      Because DAMON debugfs interface and DAMON-based proactive reclaim are now
      using monitoring operations via registration mechanism,
      damon_{p,v}a_{target_valid,set_operations}() functions have no user.  This
      commit clean them up.
      
      Link: https://lkml.kernel.org/r/20220215184603.1479-9-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Xin Hao <xhao@linux.alibaba.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      85104056
    • SeongJae Park's avatar
      mm/damon/dbgfs-test: fix is_target_id() change · 999b9467
      SeongJae Park authored
      DAMON kunit tests for DAMON debugfs interface fails because it still
      assumes setting empty monitoring operations makes DAMON debugfs interface
      believe the target of the context don't have pid.  This commit fixes the
      kunit test fails by explicitly setting the context's monitoring operations
      with the operations for the physical address space, which let debugfs
      knows the target will not have pid.
      
      Link: https://lkml.kernel.org/r/20220215184603.1479-8-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Xin Hao <xhao@linux.alibaba.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      999b9467
    • SeongJae Park's avatar
      mm/damon/dbgfs: use operations id for knowing if the target has pid · 4a20865b
      SeongJae Park authored
      DAMON debugfs interface depends on monitoring operations for virtual
      address spaces because it knows if the target has pid or not by seeing if
      the context is configured to use one of the virtual address space
      monitoring operation functions.  We can replace that check with 'enum
      damon_ops_id' now, to make it independent.  This commit makes the change.
      
      Link: https://lkml.kernel.org/r/20220215184603.1479-7-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Xin Hao <xhao@linux.alibaba.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      4a20865b
    • SeongJae Park's avatar
      mm/damon/dbgfs: use damon_select_ops() instead of damon_{v,p}a_set_operations() · da7aaca0
      SeongJae Park authored
      This commit makes DAMON debugfs interface to select the registered
      monitoring operations for the physical address space or virtual address
      spaces depending on user requests instead of setting it on its own.  Note
      that DAMON debugfs interface is still dependent to DAMON_VADDR with this
      change, because it is also using its symbol, 'damon_va_target_valid'.
      
      Link: https://lkml.kernel.org/r/20220215184603.1479-6-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Xin Hao <xhao@linux.alibaba.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      da7aaca0
    • SeongJae Park's avatar
      mm/damon/reclaim: use damon_select_ops() instead of damon_{v,p}a_set_operations() · 4d69c345
      SeongJae Park authored
      This commit makes DAMON_RECLAIM to select the registered monitoring
      operations for the physical address space instead of setting it on its
      own.  This allows DAMON_RECLAIM be independent of DAMON_PADDR, but leave
      the dependency as is, because it's the only one monitoring operations it
      use, and therefore it makes no sense to build DAMON_RECLAIM without
      DAMON_PADDR.
      
      Link: https://lkml.kernel.org/r/20220215184603.1479-5-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Xin Hao <xhao@linux.alibaba.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      4d69c345
    • SeongJae Park's avatar
      mm/damon/paddr,vaddr: register themselves to DAMON in subsys_initcall · 7752925f
      SeongJae Park authored
      This commit makes the monitoring operations for the physical address space
      and virtual address spaces register themselves to DAMON in the
      subsys_initcall step.  Later, in-kernel DAMON user code can use them via
      damon_select_ops() without have to unnecessarily depend on all possible
      monitoring operations implementations.
      
      Link: https://lkml.kernel.org/r/20220215184603.1479-4-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Xin Hao <xhao@linux.alibaba.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      7752925f
    • SeongJae Park's avatar
      mm/damon: let monitoring operations can be registered and selected · 9f7b053a
      SeongJae Park authored
      In-kernel DAMON user code like DAMON debugfs interface should set 'struct
      damon_operations' of its 'struct damon_ctx' on its own.  Therefore, the
      client code should depend on all supporting monitoring operations
      implementations that it could use.  For example, DAMON debugfs interface
      depends on both vaddr and paddr, while some of the users are not always
      interested in both.
      
      To minimize such unnecessary dependencies, this commit makes the
      monitoring operations can be registered by implementing code and then
      dynamically selected by the user code without build-time dependency.
      
      Link: https://lkml.kernel.org/r/20220215184603.1479-3-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Xin Hao <xhao@linux.alibaba.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9f7b053a
    • SeongJae Park's avatar
      mm/damon: rename damon_primitives to damon_operations · f7d911c3
      SeongJae Park authored
      Patch series "Allow DAMON user code independent of monitoring primitives".
      
      In-kernel DAMON user code is required to configure the monitoring context
      (struct damon_ctx) with proper monitoring primitives (struct
      damon_primitive).  This makes the user code dependent to all supporting
      monitoring primitives.  For example, DAMON debugfs interface depends on
      both DAMON_VADDR and DAMON_PADDR, though some users have interest in only
      one use case.  As more monitoring primitives are introduced, the problem
      will be bigger.
      
      To minimize such unnecessary dependency, this patchset makes monitoring
      primitives can be registered by the implemnting code and later dynamically
      searched and selected by the user code.
      
      In addition to that, this patchset renames monitoring primitives to
      monitoring operations, which is more easy to intuitively understand what
      it means and how it would be structed.
      
      This patch (of 8):
      
      DAMON has a set of callback functions called monitoring primitives and let
      it can be configured with various implementations for easy extension for
      different address spaces and usages.  However, the word 'primitive' is not
      so explicit.  Meanwhile, many other structs resembles similar purpose
      calls themselves 'operations'.  To make the code easier to be understood,
      this commit renames 'damon_primitives' to 'damon_operations' before it is
      too late to rename.
      
      Link: https://lkml.kernel.org/r/20220215184603.1479-1-sj@kernel.org
      Link: https://lkml.kernel.org/r/20220215184603.1479-2-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Cc: Xin Hao <xhao@linux.alibaba.com>
      Cc: David Rientjes <rientjes@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      f7d911c3
    • Baolin Wang's avatar
      mm/damon: remove redundant page validation · 242e10a0
      Baolin Wang authored
      It will never get a NULL page by pte_page() as discussed in thread [1],
      thus remove the redundant page validation to fix below Smatch static
      checker warning.
      
          mm/damon/vaddr.c:405 damon_hugetlb_mkold()
          warn: 'page' can't be NULL.
      
      [1] https://lore.kernel.org/linux-mm/20220106091200.GA14564@kili/
      
      Link: https://lkml.kernel.org/r/6d32f7d201b8970d53f51b6c5717d472aed2987c.1642386715.git.baolin.wang@linux.alibaba.com
      
      
      Signed-off-by: default avatarBaolin Wang <baolin.wang@linux.alibaba.com>
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Reviewed-by: default avatarSeongJae Park <sj@kernel.org>
      Acked-by: default avatarDavid Rientjes <rientjes@google.com>
      Acked-by: default avatarSouptick Joarder <jrdr.linux@gmail.com>
      Reviewed-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      242e10a0
    • SeongJae Park's avatar
      mm/damon: remove the target id concept · 1971bd63
      SeongJae Park authored
      DAMON asks each monitoring target ('struct damon_target') to have one
      'unsigned long' integer called 'id', which should be unique among the
      targets of same monitoring context.  Meaning of it is, however, totally up
      to the monitoring primitives that registered to the monitoring context.
      For example, the virtual address spaces monitoring primitives treats the
      id as a 'struct pid' pointer.
      
      This makes the code flexible, but ugly, not well-documented, and
      type-unsafe[1].  Also, identification of each target can be done via its
      index.  For the reason, this commit removes the concept and uses clear
      type definition.  For now, only 'struct pid' pointer is used for the
      virtual address spaces monitoring.  If DAMON is extended in future so that
      we need to put another identifier field in the struct, we will use a union
      for such primitives-dependent fields and document which primitives are
      using which type.
      
      [1] https://lore.kernel.org/linux-mm/20211013154535.4aaeaaf9d0182922e405dd1e@linux-foundation.org/
      
      Link: https://lkml.kernel.org/r/20211230100723.2238-5-sj@kernel.org
      
      
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      1971bd63