From patchwork Tue Nov 6 10:38:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 12678 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 94BF31987CF for ; Tue, 6 Nov 2012 10:39:16 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 43C01A19396 for ; Tue, 6 Nov 2012 10:39:16 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so313696iej.11 for ; Tue, 06 Nov 2012 02:39:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references:in-reply-to :references:x-originalarrivaltime:x-mc-unique:content-type :content-transfer-encoding:x-gm-message-state; bh=3/CsVRjSbPs7i3P8R/sWyVee98TYYC14SWr70+5v/Hc=; b=FdLUy+UlYNdf0osYI8nwgYeMgAZoZtftTbWLZWFlf+T2KdLszgl9mghbuIKK9BTMvT LiYA7EzYUSwQcA/Xxn8TOeRtvONXPG3KVhhpJZoYmGhllG8WyHANfTyBlAWxEKwRAnnH iQ3VQU1wpdIIvQuMPJ04by3V0iTIJnCNi3bi3v5BzQR8/zSZhdm88W2SKvdjf/3Gx1m8 2+E/LoYMw6J8k/SAQLIbJDZFS4U+wijgsuvKlvKmBIOyDgBjqNfUBR5CpfhtcC3zRrKx J+80zPhWHpn/WGh++2+VGOVC1tx/b+Ef8nuHZ7C6j+Q7FIWKjZFrNU0Zi/E0d8QUM88X 79hQ== Received: by 10.50.88.233 with SMTP id bj9mr423449igb.70.1352198356068; Tue, 06 Nov 2012 02:39:16 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp15185igt; Tue, 6 Nov 2012 02:39:15 -0800 (PST) Received: by 10.216.210.214 with SMTP id u64mr241655weo.177.1352198354761; Tue, 06 Nov 2012 02:39:14 -0800 (PST) Received: from service87.mimecast.com (service87.mimecast.com. [91.220.42.44]) by mx.google.com with ESMTP id i42si10773984wep.151.2012.11.06.02.39.14; Tue, 06 Nov 2012 02:39:14 -0800 (PST) Received-SPF: pass (google.com: domain of viresh.kumar2@arm.com designates 91.220.42.44 as permitted sender) client-ip=91.220.42.44; Authentication-Results: mx.google.com; spf=pass (google.com: domain of viresh.kumar2@arm.com designates 91.220.42.44 as permitted sender) smtp.mail=viresh.kumar2@arm.com Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Tue, 06 Nov 2012 10:39:04 +0000 Received: from localhost ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.0); Tue, 6 Nov 2012 10:38:57 +0000 From: Viresh Kumar To: pjt@google.com, paul.mckenney@linaro.org, tglx@linutronix.de, tj@kernel.org, suresh.b.siddha@intel.com, venki@google.com, mingo@redhat.com, peterz@infradead.org, rostedt@goodmis.org Cc: Arvind.Chauhan@arm.com, linaro-dev@lists.linaro.org, patches@linaro.org, pdsw-power-team@arm.com, linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, Viresh Kumar Subject: [PATCH V2 Resend 3/4] workqueue: Schedule work on non-idle cpu instead of current one Date: Tue, 6 Nov 2012 16:08:45 +0530 Message-Id: X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: X-OriginalArrivalTime: 06 Nov 2012 10:38:57.0842 (UTC) FILETIME=[ED2C7120:01CDBC0A] X-MC-Unique: 112110610390404301 X-Gm-Message-State: ALoCoQmppAysSpzJvrRJfFIQGlTmCmYvTREP7bz6P7UMGTvgYJ0TFpxCWWLeu+5BfsCoU5Ufawh6 Workqueues queues work on current cpu, if the caller haven't passed a preferred cpu. This may wake up an idle CPU, which is actually not required. This work can be processed by any CPU and so we must select a non-idle CPU here. This patch adds in support in workqueue framework to get preferred CPU details from the scheduler, instead of using current CPU. Most of the time when a work is queued, the current cpu isn't idle and so we will choose it only. There are cases when a cpu is idle when it queues some work. For example, consider following scenario: - A cpu has programmed a timer and is IDLE now. - CPU gets into interrupt handler due to timer and queues a work. As the CPU is currently IDLE, we can queue this work to some other CPU. Signed-off-by: Viresh Kumar --- kernel/workqueue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 042d221..d32efa2 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -1238,7 +1238,7 @@ static void __queue_work(unsigned int cpu, struct workqueue_struct *wq, struct global_cwq *last_gcwq; if (cpu == WORK_CPU_UNBOUND) - cpu = raw_smp_processor_id(); + cpu = sched_select_cpu(0); /* * It's multi cpu. If @work was previously on a different @@ -1383,7 +1383,7 @@ static void __queue_delayed_work(int cpu, struct workqueue_struct *wq, if (gcwq) lcpu = gcwq->cpu; if (lcpu == WORK_CPU_UNBOUND) - lcpu = raw_smp_processor_id(); + lcpu = sched_select_cpu(0); } else { lcpu = WORK_CPU_UNBOUND; }