Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp118785ybg; Mon, 8 Jun 2020 18:07:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYR1MtA8zFWagfUC3A9aegz21lUjVhtrrXkBr8A8vehe67VOo6vhGc2YQx1VL5bTz+jT9G X-Received: by 2002:a17:906:9254:: with SMTP id c20mr24295873ejx.540.1591664879139; Mon, 08 Jun 2020 18:07:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591664879; cv=none; d=google.com; s=arc-20160816; b=j9Db1dJPOv5odrGXjm4CI+qTKS+yEFTS0gULSbkCQOeLWO8+P0c8RdYq4tWlIjEdvK F8N1iPb+NSgwDeeBCAuXdbZeLC2mXe5CBVtSVuSBKflekIU6qI2ZWvDvKoCOaTbpABJy /efE5FmL0WZv2WfrIkuf5Q32Pw75o7cqW8oYxBsT03OtG9F/1yFriPIhxDi1GykA+jCF 9Gtd+VusW/tgSLCNnHgAlpN9fbAugbIWyYcwncHlsnluXcyhFD0t1tdYLK7HiEa+x1Pz f3Im5csZ4wg0YLDuwMTltGG4wlXIZ5lCfoBWUAikqLf+m/a6//9Dupig74voVs+v/TYW iHfg== 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=cgOi4B0sGIF6o1La4ro4NswNBka/IRIlXivWOGzR7Rg=; b=FF/zVtAnPdUFvxXjlaHH2e8ueo/JgUvLKeSQ0IctQ/4KbTIZfTD2YJmoSyDjNCohF1 yL2/D2MXLvgkg/Ih0nTexpVMXfHrfnAnR00tkWn0iyNs8tBOuhNDv65EeAVPli1ajVYW Ted3ltfdvBMaC4zjvrhUP9L7VNU3Ycq5ugzc03l1trVSFG7P/Oozq+y8vkUutXUY/szI p0rgMX5SyhKpyRM6fvOfw+HQoeuaCEcHWX5nPk4tZAUIs2/u2O1/SGHMK0/U9/YvIEIN AWtItOjhIFrKNGoPN9OELlS1QuZRHyJt0gIK61v+G+utW8Cf48UhWQSO2mNq2LYvebYh zIsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=swwSbdIT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d1si9240542ejb.134.2020.06.08.18.07.36; Mon, 08 Jun 2020 18:07:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=swwSbdIT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727826AbgFHXHN (ORCPT + 99 others); Mon, 8 Jun 2020 19:07:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:50044 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726993AbgFHXGm (ORCPT ); Mon, 8 Jun 2020 19:06:42 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0D46420853; Mon, 8 Jun 2020 23:06:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657601; bh=HvvRqZwkh6QFAxuP2/osGSKcmwJD2DscUKII0BRZplw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=swwSbdITupFVkO66bA/IrlyzbWeKGZFDEQTNEShqwzkAfRTrR/gE+PiczdQZ15tlb wtfPUv+fJ+2hpfPnXCIFYhHm7L1mh2rFISJ9Woti9x1IUt7edM6d+Y/Pir2PmpQzzI JvZPIrQgyCm+J82hK5sNb3iX/xrVgiDm7LDnwBpM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Huaixin Chang , Peter Zijlstra , Ben Segall , Phil Auld , Sasha Levin Subject: [PATCH AUTOSEL 5.7 027/274] sched/fair: Refill bandwidth before scaling Date: Mon, 8 Jun 2020 19:02:00 -0400 Message-Id: <20200608230607.3361041-27-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 da3e5b54715b..2ae7e30ccb33 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5170,6 +5170,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); @@ -5199,8 +5201,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