@@ -143,6 +143,7 @@ __printf(2, 3)
struct shrinker *shrinker_alloc(unsigned int flags, const char *fmt, ...);
void shrinker_register(struct shrinker *shrinker);
void shrinker_free(struct shrinker *shrinker);
+void shrinker_to_text(struct seq_buf *, struct shrinker *);
void shrinkers_to_text(struct seq_buf *);
static inline bool shrinker_try_get(struct shrinker *shrinker)
@@ -2,6 +2,7 @@
#include <linux/idr.h>
#include <linux/slab.h>
#include <linux/debugfs.h>
+#include <linux/seq_buf.h>
#include <linux/seq_file.h>
#include <linux/shrinker.h>
#include <linux/memcontrol.h>
@@ -159,6 +160,21 @@ static const struct file_operations shrinker_debugfs_scan_fops = {
.write = shrinker_debugfs_scan_write,
};
+static int shrinker_debugfs_report_show(struct seq_file *m, void *v)
+{
+ struct shrinker *shrinker = m->private;
+ char *bufp;
+ size_t buflen = seq_get_buf(m, &bufp);
+ struct seq_buf out;
+
+ seq_buf_init(&out, bufp, buflen);
+ shrinker_to_text(&out, shrinker);
+ seq_commit(m, seq_buf_used(&out));
+
+ return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(shrinker_debugfs_report);
+
int shrinker_debugfs_add(struct shrinker *shrinker)
{
struct dentry *entry;
@@ -190,6 +206,8 @@ int shrinker_debugfs_add(struct shrinker *shrinker)
&shrinker_debugfs_count_fops);
debugfs_create_file("scan", 0220, entry, shrinker,
&shrinker_debugfs_scan_fops);
+ debugfs_create_file("report", 0440, entry, shrinker,
+ &shrinker_debugfs_report_fops);
return 0;
}
Previously, we added shrinker_to_text() and hooked it up to the OOM report - now, the same report is available via debugfs. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev> --- include/linux/shrinker.h | 1 + mm/shrinker_debug.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+)