Skip to content

Commit 511ecd7

Browse files
committed
mm/mempolicy: Limit policy ignored messages
Reduce log spamming by limiting messages about policy changes being ignored to 5 consecutive messages per task. Signed-off-by: Phil Elwell <phil@raspberrypi.com>
1 parent a107374 commit 511ecd7

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

mm/mempolicy.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,8 +1625,10 @@ SYSCALL_DEFINE6(mbind, unsigned long, start, unsigned long, len,
16251625
static long kernel_set_mempolicy(int mode, const unsigned long __user *nmask,
16261626
unsigned long maxnode)
16271627
{
1628+
static struct task_struct *prev_task;
16281629
char name[sizeof(current->comm)];
16291630
unsigned short mode_flags;
1631+
static int task_msgs;
16301632
nodemask_t nodes;
16311633
int lmode = mode;
16321634
int err;
@@ -1635,8 +1637,19 @@ static long kernel_set_mempolicy(int mode, const unsigned long __user *nmask,
16351637

16361638
if (mempolicy_cmdline_set) {
16371639
// ignore messages during boot which are expected
1638-
if (ktime_get_boottime_seconds() > 40)
1639-
pr_info("Request by '%s' to set policy to %d ignored\n", get_task_comm(name, current), mode);
1640+
if (ktime_get_boottime_seconds() > 40) {
1641+
if (!prev_task || prev_task != current) {
1642+
task_msgs = 0;
1643+
prev_task = current;
1644+
}
1645+
if (task_msgs < 5) {
1646+
const char *task = get_task_comm(name, current);
1647+
1648+
pr_info("Request by '%s' to set policy to %d ignored\n",
1649+
task, mode);
1650+
task_msgs++;
1651+
}
1652+
}
16401653
return 0;
16411654
}
16421655

0 commit comments

Comments
 (0)