Received: by 10.223.185.116 with SMTP id b49csp2380387wrg; Thu, 15 Feb 2018 10:43:19 -0800 (PST) X-Google-Smtp-Source: AH8x225FmRP0agik6v0OX8m6/tbC/x7wHPn5LMRauBn/6RNWLIvNM1PeLhA3dp8AeHpvpcg3jWcW X-Received: by 10.99.95.81 with SMTP id t78mr2999798pgb.380.1518720198982; Thu, 15 Feb 2018 10:43:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518720198; cv=none; d=google.com; s=arc-20160816; b=em0JgYWDVDH7wnkkq6O8MSoLySUDOKcHublnon70E/wtuUrhsmWxgLP886J5cmxnoI C9QtefBhr1h1fpf7diUjofRPLLczXQZy+oY5WFySeX/JFC2b/VUDkppMtsG689G1hM7g Lgw1slO2Op71RBoyZzeOCckwYWDZoWcY/rx0HtkM7WRrW8m29RIMttEksu9sy5pgpIkX 8S20RwrVpIMZ91HqR57piBV93onRkgtwVqy3VSI01f7yOlrb4wkCz7DdD458SQFFFj+e sbQN5P/t2axAMsRiCa5iuqni1zd6LZrBva5fzQn5zvbnxFj7Fv8BreRBEk++tFVlY+Cc Y38w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=hpWvIKjBHBIm+VbP77eWt2Xz5jOkoWb4Gcf9D8vxgvc=; b=fToQI+Gs/lpsQJ0rFJOYZGmoXI9A6r72JV/mMnAmpHgFfal7/FjIQd4G+B69tFEiyY tRU175qHzvNorCJ90TIl53H30aoXKqrLuM15uw5PvBVYOZuySRwwdSkkUUTP4LtFW/hy xnyCromMeAMC/zRBDZcbdMRkuwdK5e/QzxYM8nNzwMG3WInCsrC3+uhhMxvsKctQROaT BsyIxmIKw1uB0fkHF4sF+sdiZRVErJAwh6Ct1gheO4DWE3wvD/MHFZi1pERPyyLFK2vA b7xWEbQ9ZVOnqFuz1ohTDK+vu9ZFSBa5Oc4XJLkpcqt8/dDJXcD/xnoAd3WBsroRcqO2 pung== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t64si1239473pgb.294.2018.02.15.10.43.04; Thu, 15 Feb 2018 10:43:18 -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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1166699AbeBOSlf (ORCPT + 99 others); Thu, 15 Feb 2018 13:41:35 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:51556 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162720AbeBOPXp (ORCPT ); Thu, 15 Feb 2018 10:23:45 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 48374EA1; Thu, 15 Feb 2018 15:22:55 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavan Kondeti , "Steven Rostedt (VMware)" , "Peter Zijlstra (Intel)" , Andrew Morton , Linus Torvalds , Mike Galbraith , Thomas Gleixner , Ingo Molnar Subject: [PATCH 4.4 049/108] sched/rt: Use container_of() to get root domain in rto_push_irq_work_func() Date: Thu, 15 Feb 2018 16:16:46 +0100 Message-Id: <20180215151229.282612884@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151222.267507937@linuxfoundation.org> References: <20180215151222.267507937@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Steven Rostedt (VMware) commit ad0f1d9d65938aec72a698116cd73a980916895e upstream. When the rto_push_irq_work_func() is called, it looks at the RT overloaded bitmask in the root domain via the runqueue (rq->rd). The problem is that during CPU up and down, nothing here stops rq->rd from changing between taking the rq->rd->rto_lock and releasing it. That means the lock that is released is not the same lock that was taken. Instead of using this_rq()->rd to get the root domain, as the irq work is part of the root domain, we can simply get the root domain from the irq work that is passed to the routine: container_of(work, struct root_domain, rto_push_work) This keeps the root domain consistent. Reported-by: Pavan Kondeti Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Peter Zijlstra (Intel) Cc: Andrew Morton Cc: Linus Torvalds Cc: Mike Galbraith Cc: Peter Zijlstra Cc: Thomas Gleixner Fixes: 4bdced5c9a292 ("sched/rt: Simplify the IPI based RT balancing logic") Link: http://lkml.kernel.org/r/CAEU1=PkiHO35Dzna8EQqNSKW1fr1y1zRQ5y66X117MG06sQtNA@mail.gmail.com Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- kernel/sched/rt.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -1833,9 +1833,8 @@ static void push_rt_tasks(struct rq *rq) * the rt_loop_next will cause the iterator to perform another scan. * */ -static int rto_next_cpu(struct rq *rq) +static int rto_next_cpu(struct root_domain *rd) { - struct root_domain *rd = rq->rd; int next; int cpu; @@ -1911,7 +1910,7 @@ static void tell_cpu_to_push(struct rq * * Otherwise it is finishing up and an ipi needs to be sent. */ if (rq->rd->rto_cpu < 0) - cpu = rto_next_cpu(rq); + cpu = rto_next_cpu(rq->rd); raw_spin_unlock(&rq->rd->rto_lock); @@ -1924,6 +1923,8 @@ static void tell_cpu_to_push(struct rq * /* Called from hardirq context */ void rto_push_irq_work_func(struct irq_work *work) { + struct root_domain *rd = + container_of(work, struct root_domain, rto_push_work); struct rq *rq; int cpu; @@ -1939,18 +1940,18 @@ void rto_push_irq_work_func(struct irq_w raw_spin_unlock(&rq->lock); } - raw_spin_lock(&rq->rd->rto_lock); + raw_spin_lock(&rd->rto_lock); /* Pass the IPI to the next rt overloaded queue */ - cpu = rto_next_cpu(rq); + cpu = rto_next_cpu(rd); - raw_spin_unlock(&rq->rd->rto_lock); + raw_spin_unlock(&rd->rto_lock); if (cpu < 0) return; /* Try the next RT overloaded CPU */ - irq_work_queue_on(&rq->rd->rto_push_work, cpu); + irq_work_queue_on(&rd->rto_push_work, cpu); } #endif /* HAVE_RT_PUSH_IPI */