From patchwork Thu Jan 2 21:54:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 306327 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from casper.infradead.org (unknown [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C684E2C0096 for ; Fri, 3 Jan 2014 10:19:14 +1100 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VyqFL-0000jI-Eb; Thu, 02 Jan 2014 21:56:08 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VyqEe-00079C-5r; Thu, 02 Jan 2014 21:55:24 +0000 Received: from mail-pa0-f43.google.com ([209.85.220.43]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VyqEb-00076n-9o for linux-arm-kernel@lists.infradead.org; Thu, 02 Jan 2014 21:55:21 +0000 Received: by mail-pa0-f43.google.com with SMTP id bj1so15043690pad.2 for ; Thu, 02 Jan 2014 13:54:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=7M/FfjcNzlKyRtbGEVU6ROh6tw7ekUR+9gUwpsSfs9M=; b=XZIIFMshcO6FsbJJAFiiwrnyHNV7S0rc+nmNScxEIxJ6Z63mUR+QC/KKhQ0rc8TIeR Q8Uwv3OrhqVJIiNEn96ZiaYNiPTh5DW08pqefZP97V90Ku/0stBAGwm9nqMA5ZRpQKdT yArXtCWInGfWMpCxejZivSiM5uU/bJfmRlusP2+UCB4uF/or7Kg6troNyOAGhR+GPN41 wpVHhxgDA2lGCaodosffLxo00TRaQ5ChbHSaX/QVAihsTalkCc5cZ+Wib7eMvIgdLUJZ IY20T0Wa81esusv0/IEhPNVxgpClT61Biftt51dm1KGGykq2p9KcCNvoVg4bUTPHlAV6 DsMA== X-Gm-Message-State: ALoCoQlBwpeOErMyDa9/YBrRx6bgQ1Gu97KTMW6VTV2kd8BuRFl1tfK5R5DlDZLYN1RYrAxbtOor X-Received: by 10.67.4.169 with SMTP id cf9mr33071302pad.45.1388699696946; Thu, 02 Jan 2014 13:54:56 -0800 (PST) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id xv2sm104089036pbb.39.2014.01.02.13.54.55 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 02 Jan 2014 13:54:56 -0800 (PST) From: John Stultz To: LKML Subject: [PATCH] sched_clock: Disable seqlock lockdep usage in sched_clock Date: Thu, 2 Jan 2014 13:54:46 -0800 Message-Id: <1388699686-4834-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <52C5DB5B.9050604@linaro.org> References: <52C5DB5B.9050604@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140102_165521_427389_31A1D355 X-CRM114-Status: GOOD ( 14.74 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.43 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Peter Zijlstra , Stephen Boyd , Willy Tarreau , =?UTF-8?q?Krzysztof=20Ha=C5=82asa?= , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , John Stultz , Linus Torvalds , Ingo Molnar , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org Unforunately the seqlock lockdep enablmenet can't be used in sched_clock, since the lockdep infrastructure eventually calls into sched_clock, which causes a deadlock. Thus, this patch adds _no_lockdep() seqlock methods for the writer side, and changes all generic sched_clock usage to use the _no_lockdep methods. This solves the issue I was able to reproduce, but it would be good to get Krzysztof to confirm it solves his problem. Cc: Krzysztof Hałasa Cc: Uwe Kleine-König Cc: Willy Tarreau Cc: Ingo Molnar , Cc: Peter Zijlstra Cc: Stephen Boyd Cc: Linus Torvalds Cc: linux-arm-kernel@lists.infradead.org Reported-by: Krzysztof Hałasa Signed-off-by: John Stultz --- include/linux/seqlock.h | 19 +++++++++++++++---- kernel/time/sched_clock.c | 6 +++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h index cf87a24..7664f68 100644 --- a/include/linux/seqlock.h +++ b/include/linux/seqlock.h @@ -206,14 +206,26 @@ static inline int read_seqcount_retry(const seqcount_t *s, unsigned start) } + +static inline void write_seqcount_begin_no_lockdep(seqcount_t *s) +{ + s->sequence++; + smp_wmb(); +} + +static inline void write_seqcount_end_no_lockdep(seqcount_t *s) +{ + smp_wmb(); + s->sequence++; +} + /* * Sequence counter only version assumes that callers are using their * own mutexing. */ static inline void write_seqcount_begin_nested(seqcount_t *s, int subclass) { - s->sequence++; - smp_wmb(); + write_seqcount_begin_no_lockdep(s); seqcount_acquire(&s->dep_map, subclass, 0, _RET_IP_); } @@ -225,8 +237,7 @@ static inline void write_seqcount_begin(seqcount_t *s) static inline void write_seqcount_end(seqcount_t *s) { seqcount_release(&s->dep_map, 1, _RET_IP_); - smp_wmb(); - s->sequence++; + write_seqcount_end_no_lockdep(s); } /** diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c index 68b7993..13561a0 100644 --- a/kernel/time/sched_clock.c +++ b/kernel/time/sched_clock.c @@ -74,7 +74,7 @@ unsigned long long notrace sched_clock(void) return cd.epoch_ns; do { - seq = read_seqcount_begin(&cd.seq); + seq = read_seqcount_begin_no_lockdep(&cd.seq); epoch_cyc = cd.epoch_cyc; epoch_ns = cd.epoch_ns; } while (read_seqcount_retry(&cd.seq, seq)); @@ -99,10 +99,10 @@ static void notrace update_sched_clock(void) cd.mult, cd.shift); raw_local_irq_save(flags); - write_seqcount_begin(&cd.seq); + write_seqcount_begin_no_lockdep(&cd.seq); cd.epoch_ns = ns; cd.epoch_cyc = cyc; - write_seqcount_end(&cd.seq); + write_seqcount_end_no_lockdep(&cd.seq); raw_local_irq_restore(flags); }