From: Minchan Kim Date: Mon, 6 Aug 2018 06:02:06 +0000 (+0900) Subject: mm: mm_event: make capture period configurable X-Git-Tag: MMI-RSBS31.Q1-48-36-26~85 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=453d320ef7e5e17c833c9d2e079e01abe9006eb8;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git mm: mm_event: make capture period configurable This patch makes per-process mm event capture inteval configurable. Default is 500ms but admin can change it by below knob. /sys/kernel/debug/mm_event/period_ms The unit is millisecond. Mot-CRs-fixed: (CR) Bug: 80168800 Change-Id: I3b2de3dd5c4a519a2e5e20f1ef0d5f9a4c7afc8a Signed-off-by: Minchan Kim Reviewed-on: https://gerrit.mot.com/1453719 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Xiangpo Zhao Submit-Approved: Jira Key --- diff --git a/mm/mm_event.c b/mm/mm_event.c index f2ba7b9004ae..5d5c90bbd3b9 100644 --- a/mm/mm_event.c +++ b/mm/mm_event.c @@ -7,6 +7,8 @@ #define CREATE_TRACE_POINTS #include +/* msec */ +static unsigned long period_ms = 500; void mm_event_task_init(struct task_struct *tsk) { @@ -27,7 +29,7 @@ static void record_stat(void) memset(¤t->mm_event[i], 0, sizeof(struct mm_event_task)); } - current->next_period = jiffies + (HZ >> 1); + current->next_period = jiffies + msecs_to_jiffies(period_ms); } } @@ -49,14 +51,43 @@ void mm_event_end(enum mm_event_type event, ktime_t start) static struct dentry *mm_event_root; +static int period_ms_set(void *data, u64 val) +{ + if (val < 1 || val > ULONG_MAX) + return -EINVAL; + + period_ms = (unsigned long)val; + return 0; +} + +static int period_ms_get(void *data, u64 *val) +{ + *val = period_ms; + return 0; +} + +DEFINE_SIMPLE_ATTRIBUTE(period_ms_operations, period_ms_get, + period_ms_set, "%llu\n"); + static int __init mm_event_init(void) { + struct dentry *entry; + mm_event_root = debugfs_create_dir("mm_event", NULL); if (!mm_event_root) { pr_warn("debugfs dir creation failed\n"); return PTR_ERR(mm_event_root); } + entry = debugfs_create_file("period_ms", 0644, + mm_event_root, NULL, &period_ms_operations); + + if (IS_ERR(entry)) { + pr_warn("debugfs file mm_event_task creation failed\n"); + debugfs_remove_recursive(mm_event_root); + return PTR_ERR(entry); + } + return 0; } subsys_initcall(mm_event_init);