Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933192AbcLSWkW (ORCPT ); Mon, 19 Dec 2016 17:40:22 -0500 Received: from hera.aquilenet.fr ([141.255.128.1]:36133 "EHLO hera.aquilenet.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752720AbcLSWkU (ORCPT ); Mon, 19 Dec 2016 17:40:20 -0500 Date: Mon, 19 Dec 2016 23:40:14 +0100 From: Samuel Thibault To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Thomas Gleixner , Ingo Molnar Subject: [PATCH] sched/fair: fix calc_cfs_shares fixed point arithmetics Message-ID: <20161219224014.GA28238@var.home> Mail-Followup-To: Samuel Thibault , linux-kernel@vger.kernel.org, Peter Zijlstra , Thomas Gleixner , Ingo Molnar MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1077 Lines: 31 2159197d6677 ("sched/core: Enable increased load resolution on 64-bit kernels") exposed yet another miscalculation in calc_cfs_shares: MIN_SHARES is unscaled, and must thus be scaled before being manipulated against "shares" amounts. Signed-off-by: Samuel Thibault Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Ingo Molnar Cc: stable@vger.kernel.org Fixes: 2159197d6677 ("sched/core: Enable increased load resolution on 64-bit kernels") --- This should be backported to 4.7 and 4.8 to fix scheduling priorities miscalculations diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 6559d19..be84f72 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2657,8 +2657,8 @@ static long calc_cfs_shares(struct cfs_rq *cfs_rq, struct task_group *tg) if (tg_weight) shares /= tg_weight; - if (shares < MIN_SHARES) - shares = MIN_SHARES; + if (shares < scale_load(MIN_SHARES)) + shares = scale_load(MIN_SHARES); if (shares > tg->shares) shares = tg->shares;