[PATCH 2/3] mm: memdelay: idle time is not productive time

From: Johannes Weiner
Date: Thu Oct 05 2017 - 12:34:49 EST


There is an error in the multi-core logic, where memory delay numbers
drop as the number of CPU cores increases. Idle CPUs, even though they
don't host delayed processes, shouldn't contribute to the "not
delayed" bucket. Because that's the baseline for productivity, and
idle CPUs aren't productive.

Do not consider idle CPU time in the productivity baseline.

Signed-off-by: Johannes Weiner <hannes@xxxxxxxxxxx>
---
include/linux/memdelay.h | 3 ++-
mm/memdelay.c | 4 +++-
2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/include/linux/memdelay.h b/include/linux/memdelay.h
index d85d01692610..c49f65338c1f 100644
--- a/include/linux/memdelay.h
+++ b/include/linux/memdelay.h
@@ -24,7 +24,8 @@ enum memdelay_task_state {
* productivity states of all tasks inside the domain.
*/
enum memdelay_domain_state {
- MDS_NONE, /* No delayed tasks */
+ MDS_IDLE, /* No tasks */
+ MDS_NONE, /* Working tasks */
MDS_PART, /* Delayed tasks, working tasks */
MDS_FULL, /* Delayed tasks, no working tasks */
NR_MEMDELAY_DOMAIN_STATES,
diff --git a/mm/memdelay.c b/mm/memdelay.c
index c7c32dbb67ac..ea5ede79f044 100644
--- a/mm/memdelay.c
+++ b/mm/memdelay.c
@@ -118,8 +118,10 @@ static void domain_cpu_update(struct memdelay_domain *md, int cpu,
else if (mdc->tasks[MTS_DELAYED])
state = (mdc->tasks[MTS_RUNNABLE] || mdc->tasks[MTS_IOWAIT]) ?
MDS_PART : MDS_FULL;
- else
+ else if (mdc->tasks[MTS_RUNNABLE] || mdc->tasks[MTS_IOWAIT])
state = MDS_NONE;
+ else
+ state = MDS_IDLE;

if (mdc->state == state)
return;
--
2.14.2


--0F1p//8PRICkK4MW
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="0003-mm-memdelay-drop-IO-as-productive-time.patch"