Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2326821imm; Fri, 7 Sep 2018 14:43:39 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb5x+YcWxZkndJfyQMtomdwBCf5DLP/PQHvy/1oEP9iKbYSSNYMjddIdM7OK3WgwCnL5NAn X-Received: by 2002:aa7:800f:: with SMTP id j15-v6mr10784129pfi.174.1536356619073; Fri, 07 Sep 2018 14:43:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536356619; cv=none; d=google.com; s=arc-20160816; b=wC0lnnRZOcgBqC+Cq6bsSV5dpGbXxHpXhY/UX0gj5QDaXRDuVRYv05ueyJIjVkaITD UmjGmhqGOzZQWCBqU3D0S8gx/6F4f/ouxVxgpzh59BjGIbICLq4Yz+z04G1PTOD95QDx iCvzdR+VeuxspHIwyeiz3zc+Tgv9oggPz0ige7p7DhWLvYODW3aYy8clOzxFQ7IrRgg6 uUr9UM+8w+OxdSc6Wa5UKI5F8UdJaN49EwDwIt/loIYV8eGoXsDhxM3zDkNSkMIVPsF8 4JuVMC4oGERc0odMr0L0u66k0VmMBm5lwalC+4PdYXh06pE1QrLQId9PBHdgSjklIPUU zWYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DVD7rAPBUimF5wAJp1SQhf/Aih/IV9vNclwGQZ9xpaE=; b=mxJ/IEqYzI1MmS/9DGsH6vxA6NFWU+6997AkBDJf0Vg0KUGdx3DWbTlrShh3jTtazG IWn2pp2fw4G/JUbiCS3/iHEmFqTYzOxp9+l8j0tOoKjrJdh8aNFxCphZZAr/E70HbC8z 4R0Koh8kyexyL8JHmvs50Rw9Fk23dmK7DegmHV0R/3Y4jijdiIUfqkO7zrB/mJVGaRuu JRutNouikoE7ximG6ue5SydSnJ31NiQWGBX5YXCAofYpw33Bb1ljrdeUtFjRjq8gP+gq 2JwoQZpzOD+ztHaSvmVphCmfMPSzQsiEFYW0JjxyVaJpcnmXGNC0gPht8BPxboZ5807e EgYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=N0VSfm3U; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m21-v6si9720510pgh.664.2018.09.07.14.43.23; Fri, 07 Sep 2018 14:43:39 -0700 (PDT) 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=@amazon.de header.s=amazon201209 header.b=N0VSfm3U; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730436AbeIHCYy (ORCPT + 99 others); Fri, 7 Sep 2018 22:24:54 -0400 Received: from smtp-fw-6001.amazon.com ([52.95.48.154]:2723 "EHLO smtp-fw-6001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727876AbeIHCYx (ORCPT ); Fri, 7 Sep 2018 22:24:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1536356518; x=1567892518; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DVD7rAPBUimF5wAJp1SQhf/Aih/IV9vNclwGQZ9xpaE=; b=N0VSfm3U+a+t8qGm0HNFdr543Ua+w2ao+TbSvCFkN3YOQQZOnjknIMHz 7a1HIzhpuROTspR1K8LLhh4rpvJNMElZHNekjQ2/7CGKfEeAkCxwowXgH cIaGw0Lf5Q0bUQo7Ef4M8f3dR/TKwlYzo6FhBQSv0HE2T5sGAbBrjfK3T Y=; X-IronPort-AV: E=Sophos;i="5.53,343,1531785600"; d="scan'208";a="355980832" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1d-2c665b5d.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 07 Sep 2018 21:41:58 +0000 Received: from u7588a65da6b65f.ant.amazon.com (iad7-ws-svc-lb50-vlan3.amazon.com [10.0.93.214]) by email-inbound-relay-1d-2c665b5d.us-east-1.amazon.com (8.14.7/8.14.7) with ESMTP id w87LfqQY048136 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 7 Sep 2018 21:41:54 GMT Received: from u7588a65da6b65f.ant.amazon.com (localhost [127.0.0.1]) by u7588a65da6b65f.ant.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTPS id w87LfoOC027327 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 7 Sep 2018 23:41:50 +0200 Received: (from jschoenh@localhost) by u7588a65da6b65f.ant.amazon.com (8.15.2/8.15.2/Submit) id w87Lfn5F027322; Fri, 7 Sep 2018 23:41:49 +0200 From: =?UTF-8?q?Jan=20H=2E=20Sch=C3=B6nherr?= To: Ingo Molnar , Peter Zijlstra Cc: =?UTF-8?q?Jan=20H=2E=20Sch=C3=B6nherr?= , linux-kernel@vger.kernel.org Subject: [RFC 20/60] sched: Let {en,de}queue_entity_fair() work with a varying amount of tasks Date: Fri, 7 Sep 2018 23:40:07 +0200 Message-Id: <20180907214047.26914-21-jschoenh@amazon.de> X-Mailer: git-send-email 2.9.3.1.gcba166c.dirty In-Reply-To: <20180907214047.26914-1-jschoenh@amazon.de> References: <20180907214047.26914-1-jschoenh@amazon.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make the task delta handled by enqueue_entity_fair() and dequeue_task_fair() variable as required by unthrottle_cfs_rq() and throttle_cfs_rq(). Signed-off-by: Jan H. Schönherr --- kernel/sched/fair.c | 18 ++++++++++-------- kernel/sched/sched.h | 6 ++++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index a96328c5a864..f13fb4460b66 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4979,7 +4979,8 @@ static inline void hrtick_update(struct rq *rq) } #endif -bool enqueue_entity_fair(struct rq *rq, struct sched_entity *se, int flags) +bool enqueue_entity_fair(struct rq *rq, struct sched_entity *se, int flags, + unsigned int task_delta) { struct cfs_rq *cfs_rq; @@ -4997,14 +4998,14 @@ bool enqueue_entity_fair(struct rq *rq, struct sched_entity *se, int flags) */ if (cfs_rq_throttled(cfs_rq)) break; - cfs_rq->h_nr_running++; + cfs_rq->h_nr_running += task_delta; flags = ENQUEUE_WAKEUP; } for_each_sched_entity(se) { cfs_rq = cfs_rq_of(se); - cfs_rq->h_nr_running++; + cfs_rq->h_nr_running += task_delta; if (cfs_rq_throttled(cfs_rq)) break; @@ -5042,7 +5043,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) if (p->in_iowait) cpufreq_update_util(rq, SCHED_CPUFREQ_IOWAIT); - throttled = enqueue_entity_fair(rq, &p->se, flags); + throttled = enqueue_entity_fair(rq, &p->se, flags, 1); if (!throttled) add_nr_running(rq, 1); @@ -5052,7 +5053,8 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) static void set_next_buddy(struct sched_entity *se); -bool dequeue_entity_fair(struct rq *rq, struct sched_entity *se, int flags) +bool dequeue_entity_fair(struct rq *rq, struct sched_entity *se, int flags, + unsigned int task_delta) { struct cfs_rq *cfs_rq; int task_sleep = flags & DEQUEUE_SLEEP; @@ -5069,7 +5071,7 @@ bool dequeue_entity_fair(struct rq *rq, struct sched_entity *se, int flags) */ if (cfs_rq_throttled(cfs_rq)) break; - cfs_rq->h_nr_running--; + cfs_rq->h_nr_running -= task_delta; /* Don't dequeue parent if it has other entities besides us */ if (cfs_rq->load.weight) { @@ -5088,7 +5090,7 @@ bool dequeue_entity_fair(struct rq *rq, struct sched_entity *se, int flags) for_each_sched_entity(se) { cfs_rq = cfs_rq_of(se); - cfs_rq->h_nr_running--; + cfs_rq->h_nr_running -= task_delta; if (cfs_rq_throttled(cfs_rq)) break; @@ -5107,7 +5109,7 @@ bool dequeue_entity_fair(struct rq *rq, struct sched_entity *se, int flags) */ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) { - bool throttled = dequeue_entity_fair(rq, &p->se, flags); + bool throttled = dequeue_entity_fair(rq, &p->se, flags, 1); if (!throttled) sub_nr_running(rq, 1); diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 9016049f36c3..569a487ed07c 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1543,8 +1543,10 @@ extern const u32 sched_prio_to_wmult[40]; #define RETRY_TASK ((void *)-1UL) -bool enqueue_entity_fair(struct rq *rq, struct sched_entity *se, int flags); -bool dequeue_entity_fair(struct rq *rq, struct sched_entity *se, int flags); +bool enqueue_entity_fair(struct rq *rq, struct sched_entity *se, int flags, + unsigned int task_delta); +bool dequeue_entity_fair(struct rq *rq, struct sched_entity *se, int flags, + unsigned int task_delta); struct sched_class { const struct sched_class *next; -- 2.9.3.1.gcba166c.dirty