Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1009424imm; Wed, 20 Jun 2018 10:03:44 -0700 (PDT) X-Google-Smtp-Source: ADUXVKID3tUfVH5ftqepNsJCUX+iOpfIyOk/bpckfC4/1neQDfdwa4Cfn65ZDETCDuCMydNtS/C7 X-Received: by 2002:a17:902:8d91:: with SMTP id v17-v6mr11813608plo.9.1529514224615; Wed, 20 Jun 2018 10:03:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529514224; cv=none; d=google.com; s=arc-20160816; b=SHMwx7Q7fK9D8/UdMD/9npZQchvUMI5uLPpuzhzhGmBp4P7ODZSOtNhS3iNw6R3FFw dIOZEjPUpOghbMz1jXUMpie1eRMHQarQeIE2b38JW4NEj0BaAFJc/+pqqyvQlAchLiLf Pzu+JQ4cFuIs3r5kRrnxSOA82H6tvKoDjAzSOU95JQM83MaseAOYECBCB3VyGoG4uH6m uOQh/qZLTLht5JQEixbdeNn9FLTFTaGLaM1GJb9deJdRmaRuOCFgGdg4Mp8LOKRdoz2y tlG85Or6gE2CGnkrFlGrSS0xANc8cEL5GrdLxh4VHpuDo1cGOuIvilyUgqjBY4snwrPn INkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=ahU7ALUz1vq36SiZ4NnO4BpdcSb3zBWgPmiXbVmkhVM=; b=OfZGwu65alSymLEv7ucYxEKnhDYQRFETJzdcjiqt71icp5lHY41DmbxGpgmjIWvsEC NTbs4UtPGO36/odRF4sdqcwX8ooUOkKhsTafw8FnyoM0HOn1QE3sPP9w0WrBMHwRdJ4A XcHy4sLY56NJ4v1sG805NpsWx0xs5ByOJe9fxNn2FFZlb9zOYQ158FmE/pF9uGsKBaOw J4Fk2ej7HV9YFBwxdd7uuuQROpZ0lAFLPw9UM08Xi3ecdYyO/anK+ARN53gxnPMoqu/j TshY0VapfVUU25zcpB0r1IkgHwnZDtURadxSS+PAQyTr4s+ddnA/RjuT70+nbC4EMiWC iiLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=bptJ+1BM; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q19-v6si2276458pgn.392.2018.06.20.10.03.30; Wed, 20 Jun 2018 10:03:44 -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=@google.com header.s=20161025 header.b=bptJ+1BM; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932636AbeFTRCH (ORCPT + 99 others); Wed, 20 Jun 2018 13:02:07 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:46720 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932153AbeFTRCG (ORCPT ); Wed, 20 Jun 2018 13:02:06 -0400 Received: by mail-pf0-f193.google.com with SMTP id q1-v6so95642pff.13 for ; Wed, 20 Jun 2018 10:02:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=ahU7ALUz1vq36SiZ4NnO4BpdcSb3zBWgPmiXbVmkhVM=; b=bptJ+1BMTZ962eyIj/baQvdezCaP6atlNqtQW3pP3k7wfg6shezDrmk0ReRLv2lnf1 r6JtkZMZDPoIWcGM2S0ZdpAfg7YfvOFmvj6W+uljMhXeCySQBONC5qG+vX5WhdzUc0Nu aG5IUeGXyoh/q2yLcXmFgMrpLfDTGZjbdWR4WHGixvyYjwNL1t1uSwkGVaZeZKLwj11t 0ptbdhrQ09A96TUU5q5aOQzte0ijYoi9fz19ScllzMOQGr/I/FDGIs2zJC8DZnoSk7i1 vAiLqQdF2JdQxh/uUja5qJIhj6lDqNfzgNjbDF9k18J5oXDzbYglxWH6f5fJAuSAfsYe XH9A== 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:references:date:in-reply-to :message-id:user-agent:mime-version; bh=ahU7ALUz1vq36SiZ4NnO4BpdcSb3zBWgPmiXbVmkhVM=; b=AkigrlPj97c+cQHylNeFWhodUSlbQinf81AB/NdDhIh2ivrs/KJUFtsnMtkbnXrnM7 mjgjFE/j6qpB5CH2HsxFiNkAY6BZ1JFfaGOBLN6z504UOjqqShNltTtaod0nyRjZyC+m dLcsP39qWfsayJ17g2a8+VRX0rnYt6w2468ZnviSocIkSceGa6wcSdjT0g62SR2zrSys zE3TXSdJ/6V4HmneaR0SwJaPd2gPoaqBNtG18ViJm6pV45LsbZdS8KJr+9JrbX1ur5eF Ac/YQLFPRuY+1rXj+RrbFzVQiqVyotxU+aCSaHGXhh1R4JKmZ2XErCWaFXW3slLvr5Dg P4tg== X-Gm-Message-State: APt69E3fycd9i7TEcOVkw4QXjZMyBUR2y21xytqWbrkIy62nzyjHm1WM C+ky8Rw0CUxbLkoJn3lPrUeURJG6LGU= X-Received: by 2002:a62:499b:: with SMTP id r27-v6mr23889336pfi.74.1529514123667; Wed, 20 Jun 2018 10:02:03 -0700 (PDT) Received: from bsegall-linux.svl.corp.google.com.localhost ([2620:15c:2cb:201:549c:c572:5008:d36f]) by smtp.gmail.com with ESMTPSA id t3-v6sm4165599pgs.91.2018.06.20.10.02.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Jun 2018 10:02:02 -0700 (PDT) From: bsegall@google.com To: Xunlei Pang Cc: Peter Zijlstra , Ingo Molnar , Ben Segall , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] sched/fair: Advance global expiration when period timer is restarted References: <20180620101834.24455-1-xlpang@linux.alibaba.com> <20180620101834.24455-2-xlpang@linux.alibaba.com> Date: Wed, 20 Jun 2018 10:02:01 -0700 In-Reply-To: <20180620101834.24455-2-xlpang@linux.alibaba.com> (Xunlei Pang's message of "Wed, 20 Jun 2018 18:18:34 +0800") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Xunlei Pang writes: > When period gets restarted after some idle time, start_cfs_bandwidth() > doesn't update the expiration information, expire_cfs_rq_runtime() will > see cfs_rq->runtime_expires smaller than rq clock and go to the clock > drift logic, wasting needless cpu cycles on the scheduler hot path. > > Update the global expiration in start_cfs_bandwidth() to avoid frequent > expire_cfs_rq_runtime() calls once a new period begins. > > Signed-off-by: Xunlei Pang Reviewed-By: Ben Segall > --- > kernel/sched/fair.c | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index e6bb68d52962..f167aca066cc 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -5204,13 +5204,18 @@ static void init_cfs_rq_runtime(struct cfs_rq *cfs_rq) > > void start_cfs_bandwidth(struct cfs_bandwidth *cfs_b) > { > + u64 overrun; > + > lockdep_assert_held(&cfs_b->lock); > > - if (!cfs_b->period_active) { > - cfs_b->period_active = 1; > - hrtimer_forward_now(&cfs_b->period_timer, cfs_b->period); > - hrtimer_start_expires(&cfs_b->period_timer, HRTIMER_MODE_ABS_PINNED); > - } > + if (cfs_b->period_active) > + return; > + > + cfs_b->period_active = 1; > + overrun = hrtimer_forward_now(&cfs_b->period_timer, cfs_b->period); > + cfs_b->runtime_expires += (overrun + 1) * ktime_to_ns(cfs_b->period); > + cfs_b->expires_seq++; > + hrtimer_start_expires(&cfs_b->period_timer, HRTIMER_MODE_ABS_PINNED); > } > > static void destroy_cfs_bandwidth(struct cfs_bandwidth *cfs_b)