Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1874860ybv; Fri, 14 Feb 2020 07:30:10 -0800 (PST) X-Google-Smtp-Source: APXvYqzH8KDShafHP7Nmw64mlXqny2sSuIQ7wlgqMqFBNm15ZgV3GVx7qqFDzJW5Ysk4aR45M6C7 X-Received: by 2002:a9d:6d10:: with SMTP id o16mr2845861otp.28.1581694210549; Fri, 14 Feb 2020 07:30:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581694210; cv=none; d=google.com; s=arc-20160816; b=o8PtneAeSoEAhjAq7+gEiC3u0nDOQsALKoTDyUFrxScwvzzZjNwc5PY1gnRiQA/ef6 a0kRhFrgl8QhZf6mzo+zEnOIukI/gUI2w0wsp9Au6WIi9ghQuf/lJ/nmLHkyPZcoGThT 84Ks9eC4LTiLJ1/I3nJ7PK489evkIinKl16btowh1jk7cj0nC46PlZNeUPdDwJ/gmx1D GkNeKqI9YNSZ7ON5T/s2YJ94VgHQTX4t3j5zGEudHv1osZSuDoWnZvNSVxh46PWQzxAo FEdNoORZr6yRap05GbJAgu5IsecC7ONz2Tj9DMbzT7IM5xa9AUH/Iqw93UTYV2STMXsh Bl9g== 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:dkim-signature; bh=gsG7nYRG2ez7Yu2vgAjQ2CySO/YYdEQuwwHAtfrdvuE=; b=sfEfKZINv9lWyup+ey2RukYw05nCJxdDJm/RlWUX4nk2x96ZBegZH9a1odg3qY2gGT WAxWbj0RwLwHMmdMtRg1Bq4Pf1D4iu8DSbgTNx088kjmGyiv11ntBjXwcnJ6WYZXHZ6y BwmxHHJnqDEsp/Sr9Y9x9mQ5bDSROJFfmcMq4T+IFiMdrNrGhZXgH+j2pFG1k2P9M2id nEv6aoHqrdU1Px0qpG+RqtZaXuKQwOYqGPezBMuDC4Qcc9bFyywbKIbpxZPzlwvKg59E FuCi/FdXLkwS126pO2zxbYuxSGnxI5HGfbwsF2F3+ArmxxY2u2w9AZnG1zz4M4AqVsmZ +fhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xUbSXGIl; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p22si3091380ota.43.2020.02.14.07.29.58; Fri, 14 Feb 2020 07:30:10 -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; dkim=pass header.i=@linaro.org header.s=google header.b=xUbSXGIl; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387640AbgBNP1p (ORCPT + 99 others); Fri, 14 Feb 2020 10:27:45 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:43977 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387401AbgBNP1n (ORCPT ); Fri, 14 Feb 2020 10:27:43 -0500 Received: by mail-wr1-f67.google.com with SMTP id r11so11317583wrq.10 for ; Fri, 14 Feb 2020 07:27:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gsG7nYRG2ez7Yu2vgAjQ2CySO/YYdEQuwwHAtfrdvuE=; b=xUbSXGIl5vB2+hyhqTnBfv7pJCX933FqucZ4uupnBMSqWMfswF8nmuWvd5UijDXCKr 8A3b8uIYC39KDpSA/XdBSQpG6XodWVDMiSc+h0h8q2wCHzSOetD8Q0LnVFiz+MlCWvIq OMQ8A7165qqbQ4llDTNw/vNawkmFPHyX0G0dhqUQdispheBvDhFIvhoRypu6Cgkg7vnJ J4Ai9eszxNxAluVqJAjStzjkoBZjypPbdkBFP4vG0VWYU67T6VsCzijoYhc0VEUvx+pu +t98YgHDp0SvEmYjg7JgZCmo47qnDHQ2eFjTdOlp2j0/c/ve6Wm/Xvhn9dnsuFRwjqg/ VLwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gsG7nYRG2ez7Yu2vgAjQ2CySO/YYdEQuwwHAtfrdvuE=; b=AslRMBuYbih4KYZrhDcVfk7cH6XqeU6J1avWeGu5kVDjEtDYaxNGf6vfOFJGaCEi95 tQXAQJSimWwrBsp2OD7pZHLN0nw0nB89xkxjVmD0pcZlVnGPPiJ4qH6uFxeS6iKSfq3E Hs8V2HQ5LHvIN1P9DcChTDRNoTd5BXihLC+4D2yGBhiZibkTs3vm6XF59vEBd7vrw3nO cY2TZwSTje1ono5eF4xvB+nExuSa1pD9ZeCFupGb/Sg4pydjWgecn0sSjGdNiJsuY224 usyAg3uxqSRY+YxkYv5NjN7wd3fG27/sVCt3afpRkgwewkZgOy2eBQ61nZQBi0e4aVB3 hdpQ== X-Gm-Message-State: APjAAAX8uNHoUyKjDgBv9zJPDWTDWtiSZDlM1SbQpM+/ufJ1ov3D0bIn xULKqUBCWNb7cDx+GijYQcKYIcYcxDeZww== X-Received: by 2002:adf:94e3:: with SMTP id 90mr4536214wrr.268.1581694061447; Fri, 14 Feb 2020 07:27:41 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:f:6020:b5b3:5d19:723a:398f]) by smtp.gmail.com with ESMTPSA id c13sm7442963wrn.46.2020.02.14.07.27.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Feb 2020 07:27:40 -0800 (PST) From: Vincent Guittot To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, linux-kernel@vger.kernel.org Cc: pauld@redhat.com, parth@linux.ibm.com, valentin.schneider@arm.com, hdanton@sina.com, Vincent Guittot Subject: [PATCH v2 1/5] sched/fair: Reorder enqueue/dequeue_task_fair path Date: Fri, 14 Feb 2020 16:27:25 +0100 Message-Id: <20200214152729.6059-2-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200214152729.6059-1-vincent.guittot@linaro.org> References: <20200214152729.6059-1-vincent.guittot@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The walk through the cgroup hierarchy during the enqueue/dequeue of a task is split in 2 distinct parts for throttled cfs_rq without any added value but making code less readable. Change the code ordering such that everything related to a cfs_rq (throttled or not) will be done in the same loop. In addition, the same steps ordering is used when updating a cfs_rq: - update_load_avg - update_cfs_group - update *h_nr_running No functional and performance changes are expected and have been noticed during tests. Signed-off-by: Vincent Guittot --- kernel/sched/fair.c | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index a7e11b1bb64c..27450c4ddc81 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5259,32 +5259,31 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) cfs_rq = cfs_rq_of(se); enqueue_entity(cfs_rq, se, flags); - /* - * end evaluation on encountering a throttled cfs_rq - * - * note: in the case of encountering a throttled cfs_rq we will - * post the final h_nr_running increment below. - */ - if (cfs_rq_throttled(cfs_rq)) - break; cfs_rq->h_nr_running++; cfs_rq->idle_h_nr_running += idle_h_nr_running; + /* end evaluation on encountering a throttled cfs_rq */ + if (cfs_rq_throttled(cfs_rq)) + goto enqueue_throttle; + flags = ENQUEUE_WAKEUP; } for_each_sched_entity(se) { cfs_rq = cfs_rq_of(se); - cfs_rq->h_nr_running++; - cfs_rq->idle_h_nr_running += idle_h_nr_running; + /* end evaluation on encountering a throttled cfs_rq */ if (cfs_rq_throttled(cfs_rq)) - break; + goto enqueue_throttle; update_load_avg(cfs_rq, se, UPDATE_TG); update_cfs_group(se); + + cfs_rq->h_nr_running++; + cfs_rq->idle_h_nr_running += idle_h_nr_running; } +enqueue_throttle: if (!se) { add_nr_running(rq, 1); /* @@ -5345,17 +5344,13 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) cfs_rq = cfs_rq_of(se); dequeue_entity(cfs_rq, se, flags); - /* - * end evaluation on encountering a throttled cfs_rq - * - * note: in the case of encountering a throttled cfs_rq we will - * post the final h_nr_running decrement below. - */ - if (cfs_rq_throttled(cfs_rq)) - break; cfs_rq->h_nr_running--; cfs_rq->idle_h_nr_running -= idle_h_nr_running; + /* end evaluation on encountering a throttled cfs_rq */ + if (cfs_rq_throttled(cfs_rq)) + goto dequeue_throttle; + /* Don't dequeue parent if it has other entities besides us */ if (cfs_rq->load.weight) { /* Avoid re-evaluating load for this entity: */ @@ -5373,16 +5368,19 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) for_each_sched_entity(se) { cfs_rq = cfs_rq_of(se); - cfs_rq->h_nr_running--; - cfs_rq->idle_h_nr_running -= idle_h_nr_running; + /* end evaluation on encountering a throttled cfs_rq */ if (cfs_rq_throttled(cfs_rq)) - break; + goto dequeue_throttle; update_load_avg(cfs_rq, se, UPDATE_TG); update_cfs_group(se); + + cfs_rq->h_nr_running--; + cfs_rq->idle_h_nr_running -= idle_h_nr_running; } +dequeue_throttle: if (!se) sub_nr_running(rq, 1); -- 2.17.1