From patchwork Tue Feb 11 08:24:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juri Lelli X-Patchwork-Id: 24439 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 497E9206FF for ; Tue, 11 Feb 2014 08:25:21 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id hu8sf16704124vcb.2 for ; Tue, 11 Feb 2014 00:25:20 -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=s1zKiSrnuCtvYlp2T3xPRmit3WuMmTnqmhyeIJWllPs=; b=UnohNj7F4Elx/441lmCEmUoNsJnBPVnqbhJcb3FdFz2S04znREuyTUAgxfXK8ZYEfX xft+i2PtNScihD0ma5P73iGcrnm0+PdU2U5K4ekYo3Brrh0NP8wfUCio+kD+Z32BiBPr ufLJBMXs5kmI0sWkZf891HqKxgHNw0LnqIQHsQXXbGO2ZYgEBRzSvHfaa5yYwnz8DdHr CiJke62xgvzyX9LMa9Pw5djed8GNXN66GEZzsAUgXoLrUz3AHUY8HlByszSHxzFv92kj oYWiekdS2QEMxPs5QhXjRZurWgc7haCJ72Guc1Go7lRWCoA7wfeolH+K0tlMw0T9hIOR ubHQ== X-Gm-Message-State: ALoCoQkAOvS8+okOKIWSkOL646CVqQn7QhY7axDG9JUQgm9V/wscYUC+7CI5nF2uMikQPf4wAjKF X-Received: by 10.236.83.112 with SMTP id p76mr5501740yhe.51.1392107120462; Tue, 11 Feb 2014 00:25:20 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.50.5 with SMTP id r5ls2219678qga.22.gmail; Tue, 11 Feb 2014 00:25:20 -0800 (PST) X-Received: by 10.52.30.230 with SMTP id v6mr23009766vdh.6.1392107120269; Tue, 11 Feb 2014 00:25:20 -0800 (PST) Received: from mail-vc0-x22b.google.com (mail-vc0-x22b.google.com [2607:f8b0:400c:c03::22b]) by mx.google.com with ESMTPS id yv5si5647664veb.26.2014.02.11.00.25.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Feb 2014 00:25:20 -0800 (PST) Received-SPF: neutral (google.com: 2607:f8b0:400c:c03::22b is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c03::22b; Received: by mail-vc0-f171.google.com with SMTP id le5so5735100vcb.30 for ; Tue, 11 Feb 2014 00:25:20 -0800 (PST) X-Received: by 10.52.117.115 with SMTP id kd19mr22848034vdb.15.1392107120168; Tue, 11 Feb 2014 00:25:20 -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.220.174.196 with SMTP id u4csp228888vcz; Tue, 11 Feb 2014 00:25:19 -0800 (PST) X-Received: by 10.68.92.98 with SMTP id cl2mr42895370pbb.81.1392107118442; Tue, 11 Feb 2014 00:25:18 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i8si18162814pav.74.2014.02.11.00.25.15; Tue, 11 Feb 2014 00:25:15 -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 S1752727AbaBKIYx (ORCPT + 27 others); Tue, 11 Feb 2014 03:24:53 -0500 Received: from mail-ea0-f169.google.com ([209.85.215.169]:57148 "EHLO mail-ea0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752641AbaBKIYt (ORCPT ); Tue, 11 Feb 2014 03:24:49 -0500 Received: by mail-ea0-f169.google.com with SMTP id h10so3541683eak.28 for ; Tue, 11 Feb 2014 00:24:48 -0800 (PST) X-Received: by 10.15.41.140 with SMTP id s12mr42533517eev.4.1392107088204; Tue, 11 Feb 2014 00:24:48 -0800 (PST) Received: from neville.retis (nat-cataldo.sssup.it. [193.205.81.5]) by mx.google.com with ESMTPSA id s46sm64274726eeb.0.2014.02.11.00.24.46 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Feb 2014 00:24:47 -0800 (PST) From: Juri Lelli To: mingo@redhat.com, peterz@infradead.org Cc: linux-kernel@vger.kernel.org, Juri Lelli Subject: [PATCH 2/2] sched/core: make dl_b->lock IRQ safe Date: Tue, 11 Feb 2014 09:24:27 +0100 Message-Id: <1392107067-19907-3-git-send-email-juri.lelli@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1392107067-19907-1-git-send-email-juri.lelli@gmail.com> References: <1392107067-19907-1-git-send-email-juri.lelli@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Original-Sender: juri.lelli@gmail.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c03::22b 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; dkim=neutral (bad format) header.i=@gmail.com; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com 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: , Fix this lockdep warning: [ 44.804600] ========================================================= [ 44.805746] [ INFO: possible irq lock inversion dependency detected ] [ 44.805746] 3.14.0-rc2-test+ #14 Not tainted [ 44.805746] --------------------------------------------------------- [ 44.805746] bash/3674 just changed the state of lock: [ 44.805746] (&dl_b->lock){+.....}, at: [] sched_rt_handler+0x132/0x248 [ 44.805746] but this lock was taken by another, HARDIRQ-safe lock in the past: [ 44.805746] (&rq->lock){-.-.-.} and interrupts could create inverse lock ordering between them. [ 44.805746] [ 44.805746] other info that might help us debug this: [ 44.805746] Possible interrupt unsafe locking scenario: [ 44.805746] [ 44.805746] CPU0 CPU1 [ 44.805746] ---- ---- [ 44.805746] lock(&dl_b->lock); [ 44.805746] local_irq_disable(); [ 44.805746] lock(&rq->lock); [ 44.805746] lock(&dl_b->lock); [ 44.805746] [ 44.805746] lock(&rq->lock); by making dl_b->lock acquiring always IRQ safe. Cc: Ingo Molnar Cc: Peter Zijlstra Signed-off-by: Juri Lelli --- kernel/sched/core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 604dd4e..ed006be 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -7412,6 +7412,7 @@ static int sched_dl_global_constraints(void) u64 period = global_rt_period(); u64 new_bw = to_ratio(period, runtime); int cpu, ret = 0; + unsigned long flags; /* * Here we want to check the bandwidth not being set to some @@ -7425,10 +7426,10 @@ static int sched_dl_global_constraints(void) for_each_possible_cpu(cpu) { struct dl_bw *dl_b = dl_bw_of(cpu); - raw_spin_lock(&dl_b->lock); + raw_spin_lock_irqsave(&dl_b->lock, flags); if (new_bw < dl_b->total_bw) ret = -EBUSY; - raw_spin_unlock(&dl_b->lock); + raw_spin_unlock_irqrestore(&dl_b->lock, flags); if (ret) break; @@ -7441,6 +7442,7 @@ static void sched_dl_do_global(void) { u64 new_bw = -1; int cpu; + unsigned long flags; def_dl_bandwidth.dl_period = global_rt_period(); def_dl_bandwidth.dl_runtime = global_rt_runtime(); @@ -7454,9 +7456,9 @@ static void sched_dl_do_global(void) for_each_possible_cpu(cpu) { struct dl_bw *dl_b = dl_bw_of(cpu); - raw_spin_lock(&dl_b->lock); + raw_spin_lock_irqsave(&dl_b->lock, flags); dl_b->bw = new_bw; - raw_spin_unlock(&dl_b->lock); + raw_spin_unlock_irqrestore(&dl_b->lock, flags); } }