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: 22863 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 E35A1202E2 for ; Thu, 2 Jan 2014 21:54:59 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id ht17sf18163523vcb.10 for ; Thu, 02 Jan 2014 13:54:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=7M/FfjcNzlKyRtbGEVU6ROh6tw7ekUR+9gUwpsSfs9M=; b=Bg23ZpU4+2roJDqZFVxCCBkMB7kQaZSHwaEkr6zfHuubFLok2moEm+wP8kzqqoa7Yp vGxqDnWeNPympvQ2W9KUYyjZDd+B2uVUcpD9li50YtxGEoE8vaNE7T8ltNFR2JFuyQIl f5P0DTFz9nt2p7ofnX9KdigJ/jH0C5/mXABgcmgIoTZVl0PJsEOTGECl/FuSYMytbV+x Yoy5ZokdF4UqFK7B6gabLdhUu6KdyFq7h2Ee8ArxCc/eGNEbFqPTr8wbQocBEYIZU+51 G7xDsMVe6ad97pjrKnL35ib7+RGPrJLxMiaYn+B69hZn/CvNkVpR4TU8EoI3GPpmLtyQ CVmQ== X-Gm-Message-State: ALoCoQn1Zv6Nhw0QbXKCK3wLvNlXYPcQRAxO+bJREceIEQbAIVjQSSsz4TLlGq374pP5XjG2+grv X-Received: by 10.58.156.42 with SMTP id wb10mr19875493veb.26.1388699698831; Thu, 02 Jan 2014 13:54:58 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.17.163 with SMTP id p3ls4691834qed.41.gmail; Thu, 02 Jan 2014 13:54:58 -0800 (PST) X-Received: by 10.58.4.138 with SMTP id k10mr38203242vek.8.1388699698708; Thu, 02 Jan 2014 13:54:58 -0800 (PST) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id dr8si19436427vcb.88.2014.01.02.13.54.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 02 Jan 2014 13:54:58 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id ie18so7346455vcb.38 for ; Thu, 02 Jan 2014 13:54:58 -0800 (PST) X-Received: by 10.52.135.201 with SMTP id pu9mr40345503vdb.13.1388699698578; Thu, 02 Jan 2014 13:54:58 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.59.13.131 with SMTP id ey3csp794756ved; Thu, 2 Jan 2014 13:54:58 -0800 (PST) X-Received: by 10.68.8.136 with SMTP id r8mr90560569pba.36.1388699697533; Thu, 02 Jan 2014 13:54:57 -0800 (PST) Received: from mail-pa0-f49.google.com (mail-pa0-f49.google.com [209.85.220.49]) by mx.google.com with ESMTPS id uj8si43628511pac.293.2014.01.02.13.54.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 02 Jan 2014 13:54:57 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.49 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.220.49; Received: by mail-pa0-f49.google.com with SMTP id kx10so14969553pab.36 for ; Thu, 02 Jan 2014 13:54:57 -0800 (PST) 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 Cc: John Stultz , =?UTF-8?q?Krzysztof=20Ha=C5=82asa?= , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Willy Tarreau , Ingo Molnar , Peter Zijlstra , Stephen Boyd , Linus Torvalds , linux-arm-kernel@lists.infradead.org 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-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.179 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 Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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); }