From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A7D3C433E0 for ; Fri, 19 Jun 2020 15:05:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D23EE21974 for ; Fri, 19 Jun 2020 15:05:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592579134; bh=ersofygXme+/BkgbL4dcJ8IHAm2yRV7XhuVsKmB8d5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Sd9vPUYtzTIWkRWrcUycj4588EXHTNORj5fBmDT09VeRu2UukEc2/Wjit8Zg6xmzT n7mc9yp5iMqbubo6I/o8H3il0drH/H1DLkxlpzzmpMpo/tcyT8TWwKuNhValECTKX0 jDNIDDk/q9ylRkmEMGBCywloIAWjKLZqMxQNAcuM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391316AbgFSPFd (ORCPT ); Fri, 19 Jun 2020 11:05:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:34316 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391293AbgFSPFY (ORCPT ); Fri, 19 Jun 2020 11:05:24 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B462D21D95; Fri, 19 Jun 2020 15:05:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592579124; bh=ersofygXme+/BkgbL4dcJ8IHAm2yRV7XhuVsKmB8d5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LeeXfhJ5e+yrc1hGtpQIeBMCOHRQM+Xg9Hkfv6vxiehyzDPitz/a/ppnG3JF8Qnrt omAwzNvxEtHopj2+g2O2yn7RetOWIqx3yoRdkU5j6sameTKlQ21QgCqbvv2TmNl264 jSKJT1JMP9Fk/IrBlgW1FyzvmqlmJEk6+C06GDqE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Huaixin Chang , "Peter Zijlstra (Intel)" , Ben Segall , Phil Auld , Sasha Levin Subject: [PATCH 5.4 017/261] sched/fair: Refill bandwidth before scaling Date: Fri, 19 Jun 2020 16:30:28 +0200 Message-Id: <20200619141650.693573754@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141649.878808811@linuxfoundation.org> References: <20200619141649.878808811@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Huaixin Chang [ Upstream commit 5a6d6a6ccb5f48ca8cf7c6d64ff83fd9c7999390 ] In order to prevent possible hardlockup of sched_cfs_period_timer() loop, loop count is introduced to denote whether to scale quota and period or not. However, scale is done between forwarding period timer and refilling cfs bandwidth runtime, which means that period timer is forwarded with old "period" while runtime is refilled with scaled "quota". Move do_sched_cfs_period_timer() before scaling to solve this. Fixes: 2e8e19226398 ("sched/fair: Limit sched_cfs_period_timer() loop to avoid hard lockup") Signed-off-by: Huaixin Chang Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Ben Segall Reviewed-by: Phil Auld Link: https://lkml.kernel.org/r/20200420024421.22442-3-changhuaixin@linux.alibaba.com Signed-off-by: Sasha Levin --- kernel/sched/fair.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 8a0e6bdba50d..2f81e4ae844e 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4942,6 +4942,8 @@ static enum hrtimer_restart sched_cfs_period_timer(struct hrtimer *timer) if (!overrun) break; + idle = do_sched_cfs_period_timer(cfs_b, overrun, flags); + if (++count > 3) { u64 new, old = ktime_to_ns(cfs_b->period); @@ -4971,8 +4973,6 @@ static enum hrtimer_restart sched_cfs_period_timer(struct hrtimer *timer) /* reset count so we don't come right back in here */ count = 0; } - - idle = do_sched_cfs_period_timer(cfs_b, overrun, flags); } if (idle) cfs_b->period_active = 0; -- 2.25.1