commit e09799ef03276b05ff2afec0e9a41f640ee6fae2 Author: Park Ju Hyung Date: Tue Jul 9 16:15:31 2019 +0900 alloc_stats: add reset Signed-off-by: Park Ju Hyung diff --git a/mm/alloc_stats.c b/mm/alloc_stats.c index d5f6fced27dd..c1940ba44075 100644 --- a/mm/alloc_stats.c +++ b/mm/alloc_stats.c @@ -121,9 +121,31 @@ static int alloc_stats_open(struct inode *inode, struct file *file) return single_open(file, alloc_stats_show, NULL); } +static ssize_t alloc_stats_write(struct file *filp, const char __user *ubuf, + size_t len, loff_t *ppos) +{ + // Do nothing but reset counters at the moment + unsigned long flags; + int i, count; + + spin_lock_irqsave(&stats_lock, flags); + count = ARRAY_SIZE(alloc_stats_g); + + for (i = 0; i < count; i++) { + struct alloc_stats *stats = alloc_stats_g + i; + + atomic_set(&stats->freed_samefunc, 0); + atomic_set(&stats->count, 0); + } + spin_unlock_irqrestore(&stats_lock, flags); + + return len; +} + static const struct file_operations alloc_stats_fops = { .owner = THIS_MODULE, .open = alloc_stats_open, + .write = alloc_stats_write, .read = seq_read, .llseek = seq_lseek, .release = single_release