From patchwork Tue Apr 26 03:36:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 66660 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1388341qge; Mon, 25 Apr 2016 21:03:35 -0700 (PDT) X-Received: by 10.66.25.112 with SMTP id b16mr512953pag.154.1461643414947; Mon, 25 Apr 2016 21:03:34 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z68si978345pfz.158.2016.04.25.21.03.34; Mon, 25 Apr 2016 21:03:34 -0700 (PDT) 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; dkim=pass header.i=@linaro.org; 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; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751195AbcDZED1 (ORCPT + 29 others); Tue, 26 Apr 2016 00:03:27 -0400 Received: from mail-pf0-f182.google.com ([209.85.192.182]:34218 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750697AbcDZEDZ (ORCPT ); Tue, 26 Apr 2016 00:03:25 -0400 Received: by mail-pf0-f182.google.com with SMTP id y69so1567748pfb.1 for ; Mon, 25 Apr 2016 21:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=rze3JTRcFYS9byScflonAxCFMJg1q0wsr8Q8sAL/MX0=; b=givbSJ2kujGMoE87kiVkCrI5fIPDoRYv5Oc2R8AuT0xDP5Cr2dFM0/UluaPehFn2Fb +3IxzjIJf2RxcaCU4JKEYDK2SbtAa0gaFQmSinftwX28nGUR/DHE+pN4X6R8tskclTVH FtWHdiLbFgE+cLgv04rTYudt3jewN5NE8+NdY= 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; bh=rze3JTRcFYS9byScflonAxCFMJg1q0wsr8Q8sAL/MX0=; b=fXbyaaAIPbiGcaAUR/nxz04eJ9JNj74oVpRrQ5FMDL8tnIgEbdOPL2iT4PmUWB0Fwv zWYj/hV9GjwFR4bUadkAx6jHkaNwcktpGTYRjQTHkWOV8cOXqnEvu3TQam6bT+/jZY2E 83zo4pSkctI83czQCsHuMtZL5B30gjM8I/uigvzfccGyC2LD7TP/7qvCtohc7i4fwiu7 5a9oIm6ViJOzKEI0c+fbd5sPDq+1M6vmGrqvF/ESYkoYb7FmLneSUz10gkEVW95IYu6T yKPC46zkNXvGZzBLaBCayLGw/Jlyb5ZDVwR97hhQF47+YJd7zZKASn3U4AXadYVtQuDQ 5+Fg== X-Gm-Message-State: AOPr4FU1Fd0SIh7MjeTcBaj5aZn2F3CtI07JNfyuoWl4f5Hyrl2JV5IddFeSNMU+2DsvqLIg X-Received: by 10.98.7.153 with SMTP id 25mr570260pfh.38.1461643400739; Mon, 25 Apr 2016 21:03:20 -0700 (PDT) Received: from yshi-Precision-T5600.corp.ad.wrs.com (unknown-216-82.windriver.com. [147.11.216.82]) by smtp.gmail.com with ESMTPSA id kl14sm33741031pab.23.2016.04.25.21.03.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Apr 2016 21:03:20 -0700 (PDT) From: Yang Shi To: peterz@infradead.org, mingo@redhat.com Cc: linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org, yang.shi@linaro.org Subject: [PATCH] panic: lockdep: correct lock debugging state check Date: Mon, 25 Apr 2016 20:36:37 -0700 Message-Id: <1461641797-9368-1-git-send-email-yang.shi@linaro.org> X-Mailer: git-send-email 2.0.2 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When kernel oops happens, lock debugging is turned off by debug_locks_off() in oops_enter() via calling __debug_locks_off() which set debug_locks to 0 via xchg(). But, calling to __debug_locks_off() to check lock debugging state in add_taint() called by oops_end() will always return false since xchg() returns the old value of debug_locks which is cleared in oops_enter() already. This prevents add_taint() from printing out lock debugging disable information although LOCKDEP_NOW_UNRELIABLE is passed to it. Check lock debugging state via !debug_locks to fix this. Although !__debug_locks_off() could do the same thing, it may look confusing. Before the fix, oops output looks like: RIP [] release_freepages+0x18/0xa0 RSP CR2: 0000000000000000 [ end trace 2e96d09e0ba6342f ] Aftere the fix, it looks like: RIP [] release_freepages+0x18/0xa0 RSP CR2: 0000000000000000 Disabling lock debugging due to kernel taint [ end trace 2e96d09e0ba6342f ] And, fix a trivial typo in the comment of add_taint(). Signed-off-by: Yang Shi --- kernel/panic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.0.2 diff --git a/kernel/panic.c b/kernel/panic.c index 535c965..859499d 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -346,11 +346,11 @@ unsigned long get_taint(void) * @lockdep_ok: whether lock debugging is still OK. * * If something bad has gone wrong, you'll want @lockdebug_ok = false, but for - * some notewortht-but-not-corrupting cases, it can be set to true. + * some noteworthy-but-not-corrupting cases, it can be set to true. */ void add_taint(unsigned flag, enum lockdep_ok lockdep_ok) { - if (lockdep_ok == LOCKDEP_NOW_UNRELIABLE && __debug_locks_off()) + if (lockdep_ok == LOCKDEP_NOW_UNRELIABLE && !debug_locks) pr_warn("Disabling lock debugging due to kernel taint\n"); set_bit(flag, &tainted_mask);