From patchwork Tue Dec 16 15:58:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "pang.xunlei" X-Patchwork-Id: 42340 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 14CFC26C54 for ; Tue, 16 Dec 2014 15:59:05 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id ex7sf5126931wid.7 for ; Tue, 16 Dec 2014 07:59:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=kf37zQc9aflXFaNQsD3GMcizVTklL1RLguw/fFDUbYY=; b=acDCMunUu7pJFpye7zy56EifKqCHA4Sb21A5Grm6ir5baFcVCgfFtSrsJGQCRBWtDf fGME5S7oZ7P81p0UzDMJM8H6GQXxEibz5qrmZAPlxqlHrgKVtaH2qCGYQOgaGdWtJPT4 9UEqEG5hvix6WqtOjrCFalZ9R29PBRAUNBYQ1uORLTucbyuDbf23r+WqL5mhA1KO6880 2/eUpFFdTnra9T7gTEWs9E88XRV4XH/Sn5iAIo0y0ZC9A+jEnQHb88mcnIWr0fnfs+pv KHAu0E/g7k5YpYS3S5IlR4/SB3mQEfB/L7eYjHgafyGqeUX1uzrNSn2WQT3B1/3HEJ75 BGgg== X-Gm-Message-State: ALoCoQmPTYowqN6cYw6wjdxoXEO+LqaciLYTAiQmIROOBEraSsMsdHJpy5NxuOdaKo2BfLKx0W1v X-Received: by 10.112.14.2 with SMTP id l2mr5639669lbc.5.1418745544304; Tue, 16 Dec 2014 07:59:04 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.88.99 with SMTP id bf3ls972612lab.13.gmail; Tue, 16 Dec 2014 07:59:03 -0800 (PST) X-Received: by 10.152.115.172 with SMTP id jp12mr36257816lab.33.1418745543903; Tue, 16 Dec 2014 07:59:03 -0800 (PST) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id n9si1199041lbc.57.2014.12.16.07.59.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 16 Dec 2014 07:59:03 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by mail-la0-f47.google.com with SMTP id hz20so11689149lab.34 for ; Tue, 16 Dec 2014 07:59:03 -0800 (PST) X-Received: by 10.112.136.69 with SMTP id py5mr22466713lbb.56.1418745543721; Tue, 16 Dec 2014 07:59:03 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.142.69 with SMTP id ru5csp1080173lbb; Tue, 16 Dec 2014 07:59:02 -0800 (PST) X-Received: by 10.68.179.5 with SMTP id dc5mr62254719pbc.147.1418745541762; Tue, 16 Dec 2014 07:59:01 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fv5si1549149pbb.173.2014.12.16.07.59.00; Tue, 16 Dec 2014 07:59:01 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751650AbaLPP67 (ORCPT + 27 others); Tue, 16 Dec 2014 10:58:59 -0500 Received: from mail-pd0-f169.google.com ([209.85.192.169]:59254 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750949AbaLPP65 (ORCPT ); Tue, 16 Dec 2014 10:58:57 -0500 Received: by mail-pd0-f169.google.com with SMTP id z10so14210772pdj.28 for ; Tue, 16 Dec 2014 07:58:57 -0800 (PST) X-Received: by 10.67.22.162 with SMTP id ht2mr62633227pad.49.1418745536935; Tue, 16 Dec 2014 07:58:56 -0800 (PST) Received: from localhost.localdomain ([210.21.223.3]) by mx.google.com with ESMTPSA id c3sm1306800pbu.76.2014.12.16.07.58.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Dec 2014 07:58:56 -0800 (PST) From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Ingo Molnar , Xunlei Pang Subject: [PATCH] sched/fair: Fix the dealing with decay_count in __synchronize_entity_decay() Date: Tue, 16 Dec 2014 23:58:29 +0800 Message-Id: <1418745509-2609-1-git-send-email-pang.xunlei@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: pang.xunlei@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , In __synchronize_entity_decay(), if "decays" happens to be zero, se->avg.decay_count will not be zeroed, holding the positive value assigned when dequeued last time. This is problematic in the following case: If this runnable task is CFS-balanced to other CPUs soon afterwards, migrate_task_rq_fair() will treat it as a blocked task due to its non-zero decay_count, thereby adding its load to cfs_rq->removed_load wrongly. Thus, we must zero se->avg.decay_count in this case as well. Signed-off-by: Xunlei Pang --- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index df2cdf7..ea517cd 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2574,11 +2574,11 @@ static inline u64 __synchronize_entity_decay(struct sched_entity *se) u64 decays = atomic64_read(&cfs_rq->decay_counter); decays -= se->avg.decay_count; + se->avg.decay_count = 0; if (!decays) return 0; se->avg.load_avg_contrib = decay_load(se->avg.load_avg_contrib, decays); - se->avg.decay_count = 0; return decays; }