Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp693396pxv; Thu, 22 Jul 2021 09:51:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyURkm04as+4oSwUUao/PVjM+wHZBijbBEB4XZVcf3SsD9RnvWXXd4E1kT57BA2QlCZeZcL X-Received: by 2002:a92:3610:: with SMTP id d16mr507503ila.16.1626972710725; Thu, 22 Jul 2021 09:51:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626972710; cv=none; d=google.com; s=arc-20160816; b=CM1QBa6PfFBak9C9ebIX9ikG348HQ1Q1jLsGs2MPR/gmhwRR8UhcAedHedjHSVKyZ1 dbLwYzONPzbRmvRWQVV1rwMCIaB0URc1NCCunEw7AIvXPRDqhqofEm12cfyNah+Irkfm LeEl2etNvcmDYCN5NUmjrk4qGANMsHfPfDdGs2G68lgaZOQhO1L9DzwH5CKbGJA9E5QA +lXQaWoA1CBzEQH5kRDWrTj03GxsewGDFeI0ZevEUOWRjawcd1AzUMzvgGT5wy293n8d l/2Xn62BYUnkm+oUwI5RH0m+rVaAVYcGYvdih8Q2nUN++0cBjVGAG8LMAUfKefxya8vs wDkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RbTlVQWV6EJWAuydNzlRKvWyiu4QNVi7v4DqrbRsJJA=; b=Sbdg3eEJuZ0a7EhsU+bueKnCF/yCachjjpQVaN7JK4fIm0ll0xknABLGfFMpzb6/CH n7Z+hC9dGqZNuGIy+Mh/Bd2ciiQiIzlywtcm1vs+Bui/M9mQHZbBIWMXLY8XPGCr1+Sv DC4Gm5eUQ3E2evpn+fy/n7HDPCooOnuh/sN2nmW1KkNJFkvbHB0KW0HhcSoVuS1eD/r3 zYr4DCPqrktN1/4UuYSlin3cGbxjSJqYba7neaoODi/4pgi9E5uPzmLKj3lnYPlQaO0M +r7VWDZIorkBG50UkCkJX8sBkektfE8o+eAgibS0FUD8AduLpE3iFdKreW+WQg6LBdDm e8Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Z+2rhpjG; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g13si10147008iow.65.2021.07.22.09.51.39; Thu, 22 Jul 2021 09:51:50 -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=@linuxfoundation.org header.s=korg header.b=Z+2rhpjG; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234020AbhGVQJ6 (ORCPT + 99 others); Thu, 22 Jul 2021 12:09:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:43910 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235005AbhGVQFx (ORCPT ); Thu, 22 Jul 2021 12:05:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D47BE61CAD; Thu, 22 Jul 2021 16:46:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626972388; bh=GEIBzoPz4KjWOTEK4LLYg4kh2WlRuDJ+SxxuemeZiI0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z+2rhpjGdB+SS0xyR72PrIj6jpehon7i+YVYGDk0gd0JXXhuu8LrEz/rb60Meav3M BObKdnHblWDdHV5iRnkBHDMIdkNEu7lwe6Afz5qVFdmWgysqfV2SYGnB1x5Jj6PONN /rYW59ufpTn9wLEj+ewls2/zCoQ49w+yu4zrRkSY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Odin Ugedal , "Peter Zijlstra (Intel)" , Ben Segall , Sasha Levin Subject: [PATCH 5.13 095/156] sched/fair: Fix CFS bandwidth hrtimer expiry type Date: Thu, 22 Jul 2021 18:31:10 +0200 Message-Id: <20210722155631.454574690@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210722155628.371356843@linuxfoundation.org> References: <20210722155628.371356843@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Odin Ugedal [ Upstream commit 72d0ad7cb5bad265adb2014dbe46c4ccb11afaba ] The time remaining until expiry of the refresh_timer can be negative. Casting the type to an unsigned 64-bit value will cause integer underflow, making the runtime_refresh_within return false instead of true. These situations are rare, but they do happen. This does not cause user-facing issues or errors; other than possibly unthrottling cfs_rq's using runtime from the previous period(s), making the CFS bandwidth enforcement less strict in those (special) situations. Signed-off-by: Odin Ugedal Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Ben Segall Link: https://lore.kernel.org/r/20210629121452.18429-1-odin@uged.al 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 7dd0d859d95b..f60ef0b4ec33 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5108,7 +5108,7 @@ static const u64 cfs_bandwidth_slack_period = 5 * NSEC_PER_MSEC; static int runtime_refresh_within(struct cfs_bandwidth *cfs_b, u64 min_expire) { struct hrtimer *refresh_timer = &cfs_b->period_timer; - u64 remaining; + s64 remaining; /* if the call-back is running a quota refresh is already occurring */ if (hrtimer_callback_running(refresh_timer)) @@ -5116,7 +5116,7 @@ static int runtime_refresh_within(struct cfs_bandwidth *cfs_b, u64 min_expire) /* is a quota refresh about to occur? */ remaining = ktime_to_ns(hrtimer_expires_remaining(refresh_timer)); - if (remaining < min_expire) + if (remaining < (s64)min_expire) return 1; return 0; -- 2.30.2