From patchwork Wed Jul 9 06:55:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 33262 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f197.google.com (mail-ve0-f197.google.com [209.85.128.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 648A2203F4 for ; Wed, 9 Jul 2014 06:56:37 +0000 (UTC) Received: by mail-ve0-f197.google.com with SMTP id pa12sf1703347veb.0 for ; Tue, 08 Jul 2014 23:56:37 -0700 (PDT) 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:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=nMPRVYDf5qdnvxXJIqFAtB1ncUleTwCfm3raSHC7Ksk=; b=ZtM0SNjQ/T42kKezOjY1uAMwwlJwLNEYjy1iSdifyNrlGqP0XKByGffksBG5rN3LXk ELbCUA+MghT+iTwIogD8bmCyO82XkltqyjLV6x5vtsXv+H34rI4b+rNCfTw7q2CJtDDn l0LsqAB9/2yGFhO4yB9wDiECWa8RcR16U5YZ4nnroIj5kj4ORzAts7/eNhu+Grif0skX gmKz4fsLlNCJvj3C08Bgf52U5mZRj8eY1sHOA09TCtYUfRPrdKG9x46uDb4zrBAqZciM 4HrUevurecMPdJeUsb/pm/d6oxtLSKCwd+Y7eKAQDJDhVbuT42L3tB5KjZ1UNLUzSn92 /2lA== X-Gm-Message-State: ALoCoQkd+oxK3m9iJSpeNqz83e0ppAh6fawiI5LmgTfagsRLl0bx5INn6jn1ViGbiHnm0IDIIVVW X-Received: by 10.236.207.164 with SMTP id n24mr19214851yho.5.1404888997096; Tue, 08 Jul 2014 23:56:37 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.107.198 with SMTP id h64ls2545425qgf.66.gmail; Tue, 08 Jul 2014 23:56:37 -0700 (PDT) X-Received: by 10.52.232.200 with SMTP id tq8mr10501928vdc.32.1404888997026; Tue, 08 Jul 2014 23:56:37 -0700 (PDT) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id u6si17374530vco.53.2014.07.08.23.56.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 08 Jul 2014 23:56:37 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.171 as permitted sender) client-ip=209.85.128.171; Received: by mail-ve0-f171.google.com with SMTP id db12so2133017veb.30 for ; Tue, 08 Jul 2014 23:56:37 -0700 (PDT) X-Received: by 10.220.161.8 with SMTP id p8mr37568846vcx.4.1404888996959; Tue, 08 Jul 2014 23:56:36 -0700 (PDT) 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.221.37.5 with SMTP id tc5csp20657vcb; Tue, 8 Jul 2014 23:56:36 -0700 (PDT) X-Received: by 10.70.41.171 with SMTP id g11mr9906538pdl.16.1404888996115; Tue, 08 Jul 2014 23:56:36 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cv2si45312014pbc.135.2014.07.08.23.56.35; Tue, 08 Jul 2014 23:56:35 -0700 (PDT) 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 S1754724AbaGIG4W (ORCPT + 28 others); Wed, 9 Jul 2014 02:56:22 -0400 Received: from mail-qg0-f46.google.com ([209.85.192.46]:36212 "EHLO mail-qg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751542AbaGIG4R (ORCPT ); Wed, 9 Jul 2014 02:56:17 -0400 Received: by mail-qg0-f46.google.com with SMTP id q107so5747901qgd.19 for ; Tue, 08 Jul 2014 23:56:16 -0700 (PDT) X-Received: by 10.224.167.70 with SMTP id p6mr67290010qay.79.1404888976827; Tue, 08 Jul 2014 23:56:16 -0700 (PDT) Received: from localhost (ec2-23-23-178-99.compute-1.amazonaws.com. [23.23.178.99]) by mx.google.com with ESMTPSA id v6sm45400200qat.16.2014.07.08.23.56.12 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 08 Jul 2014 23:56:16 -0700 (PDT) From: Viresh Kumar To: tglx@linutronix.de Cc: linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, fweisbec@gmail.com, arvind.chauhan@arm.com, preeti@linux.vnet.ibm.com, khilman@linaro.org, Viresh Kumar , Ingo Molnar , Peter Zijlstra Subject: [RFC 4/7] sched: don't check for active hrtimer after adding it Date: Wed, 9 Jul 2014 12:25:36 +0530 Message-Id: <9c72a8d137cfca4e67848a7bf9dc9942eea7452b.1404888801.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.0.0.rc2 In-Reply-To: References: In-Reply-To: References: 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: viresh.kumar@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.128.171 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: , hrtimer_start*() family never fails to enqueue a hrtimer to a clock-base. The only special case is when the hrtimer was in past. If it is getting enqueued to local CPUs's clock-base, we raise a softirq and exit, else we handle that on next interrupt on remote CPU. At several places in the kernel, we try to make sure if hrtimer was added properly or not by calling hrtimer_active(), like: hrtimer_start(timer, expires, mode); if (hrtimer_active(timer)) { /* Added successfully */ } else { /* Was added in the past */ } As hrtimer_start*() never fails, hrtimer_active() is guaranteed to return '1'. So, there is no point calling hrtimer_active(). Also this is done in while loop at several places, which isn't required anymore. This patch updates sched core to get this fixed. Cc: Ingo Molnar Cc: Peter Zijlstra Signed-off-by: Viresh Kumar --- kernel/sched/core.c | 20 +++++++++----------- kernel/sched/deadline.c | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 3bdf01b..4a6ef8d 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -111,19 +111,17 @@ void start_bandwidth_timer(struct hrtimer *period_timer, ktime_t period) unsigned long delta; ktime_t soft, hard, now; - for (;;) { - if (hrtimer_active(period_timer)) - break; + if (hrtimer_active(period_timer)) + return; - now = hrtimer_cb_get_time(period_timer); - hrtimer_forward(period_timer, now, period); + now = hrtimer_cb_get_time(period_timer); + hrtimer_forward(period_timer, now, period); - soft = hrtimer_get_softexpires(period_timer); - hard = hrtimer_get_expires(period_timer); - delta = ktime_to_ns(ktime_sub(hard, soft)); - __hrtimer_start_range_ns(period_timer, soft, delta, - HRTIMER_MODE_ABS_PINNED, 0); - } + soft = hrtimer_get_softexpires(period_timer); + hard = hrtimer_get_expires(period_timer); + delta = ktime_to_ns(ktime_sub(hard, soft)); + __hrtimer_start_range_ns(period_timer, soft, delta, + HRTIMER_MODE_ABS_PINNED, 0); } DEFINE_MUTEX(sched_domains_mutex); diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index fc4f98b1..eeb6786 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -484,7 +484,7 @@ static int start_dl_timer(struct sched_dl_entity *dl_se, bool boosted) __hrtimer_start_range_ns(&dl_se->dl_timer, soft, range, HRTIMER_MODE_ABS, 0); - return hrtimer_active(&dl_se->dl_timer); + return 1; } /*