mm: cma: support sysfs 27/262727/3
authorMinchan Kim <minchan@kernel.org>
Wed, 21 Apr 2021 04:44:12 +0000 (14:44 +1000)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Thu, 19 Aug 2021 02:51:59 +0000 (02:51 +0000)
commit80a582d1f8d92dab248183a84ed7fb1cf2f4ee68
tree16b61ef03f70c48673da5953e614fab2f94ce9dd
parent494b93600055204610f46f5766990e23ed0816b6
mm: cma: support sysfs

Since CMA is getting used more widely, it's more important to keep
monitoring CMA statistics for system health since it's directly related to
user experience.

This patch introduces sysfs statistics for CMA, in order to provide some
basic monitoring of the CMA allocator.

 * the number of CMA page successful allocations
 * the number of CMA page allocation failures

These two values allow the user to calcuate the allocation
failure rate for each CMA area.

e.g.)
  /sys/kernel/mm/cma/WIFI/alloc_pages_[success|fail]
  /sys/kernel/mm/cma/SENSOR/alloc_pages_[success|fail]
  /sys/kernel/mm/cma/BLUETOOTH/alloc_pages_[success|fail]

The cma_stat was intentionally allocated by dynamic allocation
to harmonize with kobject lifetime management.
https://lore.kernel.org/linux-mm/YCOAmXqt6dZkCQYs@kroah.com/

Link: https://lkml.kernel.org/r/20210324230759.2213957-1-minchan@kernel.org
Link: https://lore.kernel.org/linux-mm/20210316100433.17665-1-colin.king@canonical.com/
Signed-off-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Tested-by: Dmitry Osipenko <digetx@gmail.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: John Hubbard <jhubbard@nvidia.com>
Tested-by: Anders Roxell <anders.roxell@linaro.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: John Dias <joaodias@google.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Origin: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=43ca106fa8ec7d684776fbe561214d3b2b7cb9cb
Signed-off-by: Ɓukasz Stelmach <l.stelmach@samsung.com>
Change-Id: I80c0f2c8d60d250418002260b0a20e5a796a9823
Documentation/ABI/testing/sysfs-kernel-mm-cma [new file with mode: 0644]
mm/Kconfig
mm/Makefile
mm/cma.c
mm/cma.h
mm/cma_sysfs.c [new file with mode: 0644]