Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1411870imm; Fri, 27 Jul 2018 17:26:23 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeDBe10l/WfKJ7nKqag8pAfPRBqsMoHG7pIhWbkByR+DrKjG/E8d66cwIGPnkpOjj+e3Gsx X-Received: by 2002:a17:902:a58b:: with SMTP id az11-v6mr7676973plb.36.1532737583265; Fri, 27 Jul 2018 17:26:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532737583; cv=none; d=google.com; s=arc-20160816; b=BZR5xMjQnQVnrQ+MthPGXhQP51yBScrMewZpXEsisTGH333wG6yPtPMotxgxqGbwBq bR+PZ0CjFWv0jgTBBME87PJwHfz+UFerReY0WkyyiStXIGcaq6IwE84+V3xlPQrJWRwr 13Sy/AozwR2n9v6TdXqFz1nGNyeBjUgHNYMEMrsSfuuEdBf1oYsbtNEaHe0iUbH6+wn5 J+2FVfXZMaWoD3bR3daMOLwgr+Qq9TQmB7UAcdDdttQ7VJ3asOJRDzG4b8ftRFh5LhQY YpG8pM/neVGoCOdXQk39YY+O/JvwBQW1VPyW5VMav+c0eChHdnpCi6yz3ed5wUAXQe1C s+zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=IvsC6PIBsmEaE4mlDdp6wGYswjjP4f05wewW0lYb8Dw=; b=sRctl7CNaJhQRFEJUxyBFt/PlJNqsriknjXt7CSUx/R9buq/yerbk4XmdKwTVmAeBb aQdbuKjhY2oWQQwfg96NHdWHuorfVcy1nzUKqMGHlPXJUmT8UPUAx6QJ7gNF+M/gHT9p oZVKWu78VLIU9x+U8FRPjbtjtspBKCuajrjuQ3DAnrk8Xx8pLoBU/LdUgMfZh90CcRhN DnHJ1dDRUez5Z7DA4bx6KaGHlDFeZzXwUVVd8GEes/Fm5M54JkqpEiTA0VPf71jjgKoH 7yjKwUcdzTTfR7JgNdVezFTwWw7Yl7jwxJ7wjzuobDh6IVqD57pW57unluEqnUQZg6hu LuDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=o8Z8WNTd; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d30-v6si4429397pla.64.2018.07.27.17.26.08; Fri, 27 Jul 2018 17:26:23 -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=@gmail.com header.s=20161025 header.b=o8Z8WNTd; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389268AbeG1Bsv (ORCPT + 99 others); Fri, 27 Jul 2018 21:48:51 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:46957 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388735AbeG1Bsv (ORCPT ); Fri, 27 Jul 2018 21:48:51 -0400 Received: by mail-pl0-f65.google.com with SMTP id t17-v6so2954954ply.13 for ; Fri, 27 Jul 2018 17:24:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=IvsC6PIBsmEaE4mlDdp6wGYswjjP4f05wewW0lYb8Dw=; b=o8Z8WNTd5pvEU4nYnC/U6P7zeh/AF9rpV8QTwwb7vO3xGkWZPEiALUeTCI4KNkcfrI YnVv3g6wQApZ0tnqsCQrnSJpcxUwdSrLZaeQ3l/HZwK2xRlsHg2Uz3Wz/x/3WwPzsKBi V0Z+ED2YPUnue7FCbNibiPsYt5gY7kjkWyf9VOXNfF3vxgSDC/MRn/D60zIr5zi2fInO F2SOHCtAynZVUILKeUwrCacf6tn5qR62Uj0p+K7vtMugXWf1LxnOwPTNrd5pqbzVNpDh RBWBNCSq3STKhzWVEfD/vAVbWDyfMB3vgeRrFsKL/JIdCc/SsAsLJEHmxjvfRRbWF+zi NjFg== 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:date:message-id; bh=IvsC6PIBsmEaE4mlDdp6wGYswjjP4f05wewW0lYb8Dw=; b=N3FQSiyzFPM88+fJ0Si0NY+bjVaFkiPauGBi6C1X8/TZES8BvPU3QK/6Xyyqnar8sy lkl30a++WtxYRug4C4OEh+TNyUq/VrbYbfE+wfGMPiaPWY8439wYeO5cbP6vCe3P6bi7 HSZGSI9GwMGfiWIwZ5xMgEjy622J/1kP+Y7rB0HQQDbDNo1cuvM390JF4YxFpfRFoUvN Ivdz6y9V82jNx9//Ql+9O+1qK231TTiuJz5jxHn2CwJThVR6W5zZFALlOFyl2cuGr3kA MvgfnvHWicTIrEAICl+Fo+kgwKQwLgCCzCa7bfp4DkhEjtSwWv2TcqyCup0KR542JEi+ NmHw== X-Gm-Message-State: AOUpUlHP6IPNpHpDdiQljB1IabJv1s1D35cKv8DJI0LE4mzHI0M6uNCA e8CV/mdXJ/trXYcnKZ6v9R2rdBWh X-Received: by 2002:a17:902:243:: with SMTP id 61-v6mr7761921plc.301.1532737472089; Fri, 27 Jul 2018 17:24:32 -0700 (PDT) Received: from tw-172-25-29-199.office.twttr.net ([8.25.197.27]) by smtp.gmail.com with ESMTPSA id a134-v6sm7284118pfa.158.2018.07.27.17.24.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Jul 2018 17:24:31 -0700 (PDT) From: Cong Wang To: linux-kernel@vger.kernel.org Cc: Cong Wang , Xunlei Pang , Ben Segall , Linus Torvalds , Peter Zijlstra , Thomas Gleixner Subject: [PATCH] sched/fair: sync expires_seq in distribute_cfs_runtime() Date: Fri, 27 Jul 2018 17:24:09 -0700 Message-Id: <20180728002409.5781-1-xiyou.wangcong@gmail.com> X-Mailer: git-send-email 2.14.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Each time we sync cfs_rq->runtime_expires with cfs_b->runtime_expires, we should sync its ->expires_seq too. However it is missing for distribute_cfs_runtime(), especially the slack timer call path. Fixes: 512ac999d275 ("sched/fair: Fix bandwidth timer clock drift condition") Cc: Xunlei Pang Cc: Ben Segall Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Signed-off-by: Cong Wang --- kernel/sched/fair.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 2f0a0be4d344..910c50db3d74 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4857,7 +4857,7 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq) } static u64 distribute_cfs_runtime(struct cfs_bandwidth *cfs_b, - u64 remaining, u64 expires) + u64 remaining, u64 expires, int expires_seq) { struct cfs_rq *cfs_rq; u64 runtime; @@ -4880,6 +4880,7 @@ static u64 distribute_cfs_runtime(struct cfs_bandwidth *cfs_b, cfs_rq->runtime_remaining += runtime; cfs_rq->runtime_expires = expires; + cfs_rq->expires_seq = expires_seq; /* we check whether we're throttled above */ if (cfs_rq->runtime_remaining > 0) @@ -4905,7 +4906,7 @@ static u64 distribute_cfs_runtime(struct cfs_bandwidth *cfs_b, static int do_sched_cfs_period_timer(struct cfs_bandwidth *cfs_b, int overrun) { u64 runtime, runtime_expires; - int throttled; + int throttled, expires_seq; /* no need to continue the timer with no bandwidth constraint */ if (cfs_b->quota == RUNTIME_INF) @@ -4933,6 +4934,7 @@ static int do_sched_cfs_period_timer(struct cfs_bandwidth *cfs_b, int overrun) cfs_b->nr_throttled += overrun; runtime_expires = cfs_b->runtime_expires; + expires_seq = cfs_b->expires_seq; /* * This check is repeated as we are holding onto the new bandwidth while @@ -4946,7 +4948,7 @@ static int do_sched_cfs_period_timer(struct cfs_bandwidth *cfs_b, int overrun) raw_spin_unlock(&cfs_b->lock); /* we can't nest cfs_b->lock while distributing bandwidth */ runtime = distribute_cfs_runtime(cfs_b, runtime, - runtime_expires); + runtime_expires, expires_seq); raw_spin_lock(&cfs_b->lock); throttled = !list_empty(&cfs_b->throttled_cfs_rq); @@ -5055,6 +5057,7 @@ static __always_inline void return_cfs_rq_runtime(struct cfs_rq *cfs_rq) static void do_sched_cfs_slack_timer(struct cfs_bandwidth *cfs_b) { u64 runtime = 0, slice = sched_cfs_bandwidth_slice(); + int expires_seq; u64 expires; /* confirm we're still not at a refresh boundary */ @@ -5068,12 +5071,13 @@ static void do_sched_cfs_slack_timer(struct cfs_bandwidth *cfs_b) runtime = cfs_b->runtime; expires = cfs_b->runtime_expires; + expires_seq = cfs_b->expires_seq; raw_spin_unlock(&cfs_b->lock); if (!runtime) return; - runtime = distribute_cfs_runtime(cfs_b, runtime, expires); + runtime = distribute_cfs_runtime(cfs_b, runtime, expires, expires_seq); raw_spin_lock(&cfs_b->lock); if (expires == cfs_b->runtime_expires) -- 2.14.4