From patchwork Tue Jan 21 05:33:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 23423 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f72.google.com (mail-vb0-f72.google.com [209.85.212.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4C1D82107B for ; Tue, 21 Jan 2014 05:35:29 +0000 (UTC) Received: by mail-vb0-f72.google.com with SMTP id w20sf8764007vbb.3 for ; Mon, 20 Jan 2014 21:35:28 -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=Hhs+H0176mKK7ObQrm6zvCvTLTnAtwh1wPV4xoKJybA=; b=LGSluAXffxcaU0jjb7tfh9OF/YfjAmxQ27GswjuHsZSiDavkwuENQWtjv+I6jXtV2q QYf5xH8w+UPpg+63faWmaDic0t+2wzgFPIZLb/Gg8FlqpjdxCB6hwEJCz1B9LcGHUMAe u86SdLIqpOeqGxJGBqNEWWZXGzEDJDVY79AqFvoDJKjEYpd9uSlLOPxejovs/XQxJDPI mpJupqeFbcG5i0mWfaUZ6D4pCihYFQOsH5WIwzopbmcCMwMaGF57D9EI83wPAuj9qII6 9GkSdgLGCQuMOo/WUPSn9SP6qeWPxEMct6NmIkbgmnfyo8zocYJfxR8YMFEr/yJJmEf+ 5OIg== X-Gm-Message-State: ALoCoQnUky8/lrDod8a6N907es2NQBqLZXuElPibh6ItuXN4x+uxKOzsDpeKQhXTgLs4j84lbLny X-Received: by 10.58.95.97 with SMTP id dj1mr8669069veb.21.1390282528511; Mon, 20 Jan 2014 21:35:28 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.94.167 with SMTP id dd7ls1788215qeb.81.gmail; Mon, 20 Jan 2014 21:35:28 -0800 (PST) X-Received: by 10.220.99.7 with SMTP id s7mr5477162vcn.19.1390282528402; Mon, 20 Jan 2014 21:35:28 -0800 (PST) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id ls10si1308043vec.95.2014.01.20.21.35.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Jan 2014 21:35:28 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id le5so3366435vcb.30 for ; Mon, 20 Jan 2014 21:35:28 -0800 (PST) X-Received: by 10.52.230.35 with SMTP id sv3mr2361880vdc.27.1390282528323; Mon, 20 Jan 2014 21:35:28 -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.220.174.196 with SMTP id u4csp95425vcz; Mon, 20 Jan 2014 21:35:27 -0800 (PST) X-Received: by 10.68.230.137 with SMTP id sy9mr22668396pbc.126.1390282527401; Mon, 20 Jan 2014 21:35:27 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id db2si3764506pbb.277.2014.01.20.21.35.26; Mon, 20 Jan 2014 21:35:26 -0800 (PST) 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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752916AbaAUFfV (ORCPT + 27 others); Tue, 21 Jan 2014 00:35:21 -0500 Received: from mail-pa0-f41.google.com ([209.85.220.41]:64116 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750907AbaAUFfP (ORCPT ); Tue, 21 Jan 2014 00:35:15 -0500 Received: by mail-pa0-f41.google.com with SMTP id fa1so5610244pad.14 for ; Mon, 20 Jan 2014 21:35:14 -0800 (PST) X-Received: by 10.69.1.104 with SMTP id bf8mr22560225pbd.75.1390282514792; Mon, 20 Jan 2014 21:35:14 -0800 (PST) Received: from alex-shi.Home ([162.243.130.63]) by mx.google.com with ESMTPSA id yd4sm8545366pbc.13.2014.01.20.21.34.03 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Jan 2014 21:35:13 -0800 (PST) From: Alex Shi To: mingo@redhat.com, peterz@infradead.org, morten.rasmussen@arm.com, vincent.guittot@linaro.org, daniel.lezcano@linaro.org, efault@gmx.de Cc: wangyun@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, Alex Shi Subject: [RFC PATCH 1/2] sched/update_avg: avoid negative time Date: Tue, 21 Jan 2014 13:33:18 +0800 Message-Id: <1390282399-17091-1-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 1.8.1.2 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: alex.shi@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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: , rq->avg_idle try to reflect the average idle time between the cpu idle and first wakeup. But in the function, it maybe get a negative value if old avg_idle is too small. Then this negative value will be double counted in next time calculation. Guess that is not the original purpose, so recalibrate it to zero. Signed-off-by: Alex Shi --- kernel/sched/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 30eb011..af9121c6 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1358,6 +1358,9 @@ static void update_avg(u64 *avg, u64 sample) { s64 diff = sample - *avg; *avg += diff >> 3; + + if (*avg < 0) + *avg = 0; } #endif