From patchwork Fri Jan 17 16:45:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 23345 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f69.google.com (mail-yh0-f69.google.com [209.85.213.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 82B89203C6 for ; Fri, 17 Jan 2014 16:45:41 +0000 (UTC) Received: by mail-yh0-f69.google.com with SMTP id b12sf309294yha.8 for ; Fri, 17 Jan 2014 08:45:40 -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: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=HIL1eyt2PziRdSX4V93Ho23OOKlYd2/pAgjh0dUyqI8=; b=iI/Wx/fKzZI88Z8SmKBy+jbi0+LQsE92zIUZrWkfK8P8wz40PFONN05CFT54YFZ6w0 zVzCZRUckf3RDeWA0gk1kUyQ+asCBV2q7VpBz5GzmeCf3obM+4dRHlEe1rIT25gFTPT+ PjzoH19v28oC5a79Hlj4JMPHugZFNfN5CaZNMqC27s9a6w2dDXtA3sqQ7DYQnO0/qqSP ccQ+cmDAwzXCWQILa6rE1Cbu1+9tBk06lLlXVbZ8C+CZn0aj4vFjseA8TWr9drRSoKff +ZfHGz/NfobOouAgteSVMQ1ATLkcFuhQWRoTRvGDj+ijFxJv1bNgf05aX573e2Hos3MU wKSw== X-Gm-Message-State: ALoCoQlRH2mYkd9x5H/Y1p3zYzaPbg0D+HK1psUcGjZ/dDSIy6yH9re17RUzcy8hHg8PK1Sbsnek X-Received: by 10.58.218.40 with SMTP id pd8mr975099vec.39.1389977140728; Fri, 17 Jan 2014 08:45:40 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.39.37 with SMTP id u34ls502107qgu.37.gmail; Fri, 17 Jan 2014 08:45:40 -0800 (PST) X-Received: by 10.58.229.164 with SMTP id sr4mr118895vec.18.1389977140502; Fri, 17 Jan 2014 08:45:40 -0800 (PST) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id z15si5129646vce.72.2014.01.17.08.45.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 Jan 2014 08:45:40 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.181 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.181; Received: by mail-vc0-f181.google.com with SMTP id ie18so1634846vcb.26 for ; Fri, 17 Jan 2014 08:45:40 -0800 (PST) X-Received: by 10.58.75.6 with SMTP id y6mr1366169vev.23.1389977140413; Fri, 17 Jan 2014 08:45:40 -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.59.13.131 with SMTP id ey3csp33098ved; Fri, 17 Jan 2014 08:45:39 -0800 (PST) X-Received: by 10.69.1.104 with SMTP id bf8mr3103129pbd.75.1389977135602; Fri, 17 Jan 2014 08:45:35 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s4si10601133pbg.273.2014.01.17.08.45.33; Fri, 17 Jan 2014 08:45:33 -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 S1752748AbaAQQp1 (ORCPT + 26 others); Fri, 17 Jan 2014 11:45:27 -0500 Received: from mail-wi0-f169.google.com ([209.85.212.169]:49906 "EHLO mail-wi0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752090AbaAQQpG (ORCPT ); Fri, 17 Jan 2014 11:45:06 -0500 Received: by mail-wi0-f169.google.com with SMTP id e4so2245057wiv.0 for ; Fri, 17 Jan 2014 08:45:05 -0800 (PST) X-Received: by 10.194.76.231 with SMTP id n7mr3093180wjw.16.1389977105466; Fri, 17 Jan 2014 08:45:05 -0800 (PST) Received: from localhost.localdomain (AToulouse-654-1-359-206.w90-60.abo.wanadoo.fr. [90.60.118.206]) by mx.google.com with ESMTPSA id hv3sm4056142wib.5.2014.01.17.08.45.04 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 Jan 2014 08:45:04 -0800 (PST) From: Daniel Lezcano To: peterz@infradead.org Cc: mingo@kernel.org, linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org, alex.shi@linaro.org Subject: [PATCH 2/2] sched: Use idle task shortcut Date: Fri, 17 Jan 2014 17:45:02 +0100 Message-Id: <1389977102-4420-2-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1389977102-4420-1-git-send-email-daniel.lezcano@linaro.org> References: <52D95C5E.4070209@linaro.org> <1389977102-4420-1-git-send-email-daniel.lezcano@linaro.org> 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: daniel.lezcano@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.181 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: , From: Peter Zijlstra With the previous patches, we have no ambiguity on going to idle. So we can return directly the idle task instead of looking up all the domains which will in any case return the idle_task. Signed-off-by: Daniel Lezcano --- kernel/sched/core.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 76f0075..b5237dc 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2563,23 +2563,33 @@ pick_next_task(struct rq *rq, struct task_struct *prev) const struct sched_class *class; struct task_struct *p; +again: + if (likely(rq->nr_running)) { + /* + * Optimization: we know that if all tasks are in + * the fair class we can call that function directly: + */ + if (likely(rq->nr_running == rq->cfs.h_nr_running)) + return fair_sched_class.pick_next_task(rq, prev); + + for_each_class(class) { + p = class->pick_next_task(rq, prev); + if (p) + return p; + } + } + /* - * Optimization: we know that if all tasks are in - * the fair class we can call that function directly: + * If there is a task balanced on this cpu, pick the next task, + * otherwise fall in the optimization by picking the idle task + * directly. */ - if (likely(rq->nr_running == rq->cfs.h_nr_running)) { - p = fair_sched_class.pick_next_task(rq, prev); - if (likely(p)) - return p; - } + if (idle_balance(rq)) + goto again; - for_each_class(class) { - p = class->pick_next_task(rq, prev); - if (p) - return p; - } + rq->idle_stamp = rq_clock(rq); - BUG(); /* the idle class will always have a runnable task */ + return idle_sched_class.pick_next_task(rq, prev); } /* @@ -2672,9 +2682,6 @@ need_resched: pre_schedule(rq, prev); - if (unlikely(!rq->nr_running)) - rq->idle_stamp = idle_balance(rq) ? 0 : rq_clock(rq); - if (prev->on_rq || rq->skip_clock_update < 0) update_rq_clock(rq);