From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752119AbdB1Xcj (ORCPT ); Tue, 28 Feb 2017 18:32:39 -0500 Received: from mail.kernel.org ([198.145.29.136]:46276 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751565AbdB1Xb3 (ORCPT ); Tue, 28 Feb 2017 18:31:29 -0500 Date: Tue, 28 Feb 2017 16:48:56 -0500 From: Steven Rostedt To: Peter Zijlstra Cc: Ingo Molnar , LKML , Andrew Morton Subject: [PATCH] sched/rt: Document why has_pushable_tasks() isn't called with a runqueue lock Message-ID: <20170228164856.3d2e81bd@gandalf.local.home> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Steven Rostedt (VMware) While reviewing the RT scheduling IPI logic, I was thinking that it was a bug that has_pushable_tasks(rq) was not called under the runqueue lock. But then I realized that there isn't a case where a race would cause a problem, as to update has_pushable_tasks() would trigger a push_rt_task() call from the CPU doing the update. This subtle logic deserves a comment. Signed-off-by: Steven Rostedt (VMware) --- diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 4101f9d..f39449b 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -1976,6 +1976,16 @@ static void try_to_push_tasks(void *arg) src_rq = rq_of_rt_rq(rt_rq); again: + /* + * Normally, has_pushable_tasks() would be performed within the + * runqueue lock being held. But if it was not set when entering + * this hard interrupt handler function, then to have it set would + * require a wake up. A wake up of an RT task will either cause a + * schedule if the woken task is higher priority than the running + * task, or it would try to do a push from the CPU doing the wake + * up. Grabbing the runqueue lock in such a case would more likely + * just cause unnecessary contention. + */ if (has_pushable_tasks(rq)) { raw_spin_lock(&rq->lock); push_rt_task(rq);