Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp656719imu; Mon, 5 Nov 2018 06:55:22 -0800 (PST) X-Google-Smtp-Source: AJdET5f3MKagAImU7XWlrdHXi/jGzH1tSiTRf63QQSz8yS6W8HSdPaXi2Qm6IqYFI7E7x0fHjv6m X-Received: by 2002:a62:3a54:: with SMTP id h81-v6mr22103164pfa.119.1541429722874; Mon, 05 Nov 2018 06:55:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541429722; cv=none; d=google.com; s=arc-20160816; b=EI0Jhnzw/FgsGREOTZHCQbKUy6/uhOtrVyk75vwr3r11V2ScH5oytswJOExTJm2+/1 MJ5+WmDQCXYWCVg1XLLcJV+MkVDJiKX18K10CLej3f0kFyVtPBpNiK7HjIoqLud7kSmA BIr3PP5wTXldUnKcrJG2X28ibmgarekGAom6paPucb9FbTb//KImFo4+BUmgKrFaMGeU mmgmiEMD6ZarqidtRq/JN91W0P+d9zz9DXBieB0622jXojFEgzOzJNmDdd7q8kne5+Ye be6Py1wLVWnmwnwFoQLfk5fW8NLxoXp/x18TzllJDDFAHBa4nCwrJoN4eE9oWLjSlEzx D1iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=GsBgbKIESZeEACTAou/gU1IsFQmrrnazundYe5u0cQQ=; b=XuUgoKBrkX48Z/SeCle22TnAybSIlUHwq7k+tpvbyetYH+/F6JwY7pAiJmbv3tJSd8 FKVwzgYCLyMLXN4J5C/dIY+3fuEEl29pZHOx8AfYgL3pjyXB2uJWLZZHAdLx79dokG1b KwicjLeqt7Dp+CBBIMIupKtE/Q5lyqg1Y0s09vh3EWSfJErMU9Cb7yzWR0MPOix+YdWz ACPGxftEgV3SfxxIh7izka/MbncR34xuFV1VQbr69ouOgMLzSNMUqT1hU8xzkU69tnM2 VZWx7dtuWymc1O3h74Qe3GPbTB/ofDG3U45eUGVJhf73VLN87c2iC/y5zfxd/1EBJrNX I3mQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 2si6286066pgz.395.2018.11.05.06.55.06; Mon, 05 Nov 2018 06:55:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387443AbeKFAOb (ORCPT + 99 others); Mon, 5 Nov 2018 19:14:31 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:45318 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387428AbeKFAOb (ORCPT ); Mon, 5 Nov 2018 19:14:31 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E82E015AD; Mon, 5 Nov 2018 06:54:25 -0800 (PST) Received: from e110439-lin.cambridge.arm.com (e110439-lin.cambridge.arm.com [10.1.194.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B3C1B3F5CF; Mon, 5 Nov 2018 06:54:23 -0800 (PST) From: Patrick Bellasi To: linux-kernel@vger.kernel.org Cc: Ingo Molnar , Peter Zijlstra , Vincent Guittot , Quentin Perret , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Todd Kjos , Steve Muckle , Suren Baghdasaryan , Ingo Molnar Subject: [PATCH v2 2/3] sched/fair: util_est: mask UTIL_AVG_UNCHANGED usages Date: Mon, 5 Nov 2018 14:53:59 +0000 Message-Id: <20181105145400.935-3-patrick.bellasi@arm.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181105145400.935-1-patrick.bellasi@arm.com> References: <20181105145400.935-1-patrick.bellasi@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The _task_util_est() is mainly used to add/remove the task contribution to/from the rq's estimated utilization at task enqueue/dequeue time. In both cases we ensure the UTIL_AVG_UNCHANGED flag is set to keep consistency between enqueue and dequeue time while still being transparent to update_load_avg calls which will eventually reset the flag. Let's move the flag forcing within _task_util_est() itself so that we can simplify calling code by hiding that estimated utilization implementation detail into one of its internal functions. This will affect also the "public" API task_util_est() but we know that the flag will (eventually) impact just on the LSB of the estimated utilization, thus it's certainly acceptable. Signed-off-by: Patrick Bellasi Cc: Ingo Molnar Cc: Peter Zijlstra Cc: linux-kernel@vger.kernel.org --- kernel/sched/fair.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 473a9cc559e8..aeb37fe4dbb1 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -3604,7 +3604,7 @@ static inline unsigned long _task_util_est(struct task_struct *p) { struct util_est ue = READ_ONCE(p->se.avg.util_est); - return max(ue.ewma, ue.enqueued); + return (max(ue.ewma, ue.enqueued) | UTIL_AVG_UNCHANGED); } static inline unsigned long task_util_est(struct task_struct *p) @@ -3622,7 +3622,7 @@ static inline void util_est_enqueue(struct cfs_rq *cfs_rq, /* Update root cfs_rq's estimated utilization */ enqueued = cfs_rq->avg.util_est.enqueued; - enqueued += (_task_util_est(p) | UTIL_AVG_UNCHANGED); + enqueued += _task_util_est(p); WRITE_ONCE(cfs_rq->avg.util_est.enqueued, enqueued); } @@ -3650,8 +3650,7 @@ util_est_dequeue(struct cfs_rq *cfs_rq, struct task_struct *p, bool task_sleep) /* Update root cfs_rq's estimated utilization */ ue.enqueued = cfs_rq->avg.util_est.enqueued; - ue.enqueued -= min_t(unsigned int, ue.enqueued, - (_task_util_est(p) | UTIL_AVG_UNCHANGED)); + ue.enqueued -= min_t(unsigned int, ue.enqueued, _task_util_est(p)); WRITE_ONCE(cfs_rq->avg.util_est.enqueued, ue.enqueued); /* @@ -6292,7 +6291,7 @@ static unsigned long cpu_util_without(int cpu, struct task_struct *p) */ if (unlikely(task_on_rq_queued(p) || current == p)) { estimated -= min_t(unsigned int, estimated, - (_task_util_est(p) | UTIL_AVG_UNCHANGED)); + _task_util_est(p)); } util = max(util, estimated); } -- 2.18.0