From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751623AbbKJGlE (ORCPT ); Tue, 10 Nov 2015 01:41:04 -0500 Received: from terminus.zytor.com ([198.137.202.10]:46690 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751033AbbKJGlC (ORCPT ); Tue, 10 Nov 2015 01:41:02 -0500 Date: Mon, 9 Nov 2015 22:40:25 -0800 From: tip-bot for Rik van Riel Message-ID: Cc: riel@redhat.com, jstancek@redhat.com, mingo@kernel.org, linux-kernel@vger.kernel.org, hpa@zytor.com, peterz@infradead.org, tglx@linutronix.de, torvalds@linux-foundation.org Reply-To: peterz@infradead.org, hpa@zytor.com, torvalds@linux-foundation.org, tglx@linutronix.de, jstancek@redhat.com, riel@redhat.com, linux-kernel@vger.kernel.org, mingo@kernel.org In-Reply-To: <1446756983-28173-2-git-send-email-riel@redhat.com> References: <1446756983-28173-2-git-send-email-riel@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:sched/urgent] sched/numa: Fix math underflow in task_tick_numa() Git-Commit-ID: 25b3e5a3344e1f700c1efec5b6f0199f04707fb1 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 25b3e5a3344e1f700c1efec5b6f0199f04707fb1 Gitweb: http://git.kernel.org/tip/25b3e5a3344e1f700c1efec5b6f0199f04707fb1 Author: Rik van Riel AuthorDate: Thu, 5 Nov 2015 15:56:22 -0500 Committer: Ingo Molnar CommitDate: Mon, 9 Nov 2015 16:13:27 +0100 sched/numa: Fix math underflow in task_tick_numa() The NUMA balancing code implements delays in scanning by advancing curr->node_stamp beyond curr->se.sum_exec_runtime. With unsigned math, that creates an underflow, which results in task_numa_work being queued all the time, even when we don't want to. Avoiding the math underflow makes it possible to reduce CPU overhead in the NUMA balancing code. Reported-and-tested-by: Jan Stancek Signed-off-by: Rik van Riel Signed-off-by: Peter Zijlstra (Intel) Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: mgorman@suse.de Link: http://lkml.kernel.org/r/1446756983-28173-2-git-send-email-riel@redhat.com Signed-off-by: Ingo Molnar --- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 824aa9f..f04fda8 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2302,7 +2302,7 @@ void task_tick_numa(struct rq *rq, struct task_struct *curr) now = curr->se.sum_exec_runtime; period = (u64)curr->numa_scan_period * NSEC_PER_MSEC; - if (now - curr->node_stamp > period) { + if (now > curr->node_stamp + period) { if (!curr->node_stamp) curr->numa_scan_period = task_scan_min(curr); curr->node_stamp += period;