Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5314015ybi; Wed, 12 Jun 2019 00:02:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqy9A7j+utFVCxc10WmP5J3mRUO9fE8HPD5/KGuFTsOecJLJcNcyH211Bi91JzpTp9mxkLEM X-Received: by 2002:a63:591d:: with SMTP id n29mr23350026pgb.75.1560322968656; Wed, 12 Jun 2019 00:02:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560322968; cv=none; d=google.com; s=arc-20160816; b=OCmJU4U2D5b0lMWrchL16C65hE1pOmTGSIppX9FOkB6zZ4JwHo61lZJxpzOnjKvpWj X3I5yU7sIlPqMD+iUY3evuy0XnnOb9KO59pduw4Zqh8SzTMTP8s0Lz+LpXGOXywSx8vh /q0tNi6PYhCHnjUkLTPa/bfCeK4ggaL9L0TLIysn9eWQgo9z8cAt7hi+fVRuViV8L6HC Sfdp+hEPQAQuzjrZ4G9FvhYGK+BrqqV85TbNBlZPu+19M8TsxXoq37HTrC4JnZ/r0zDv z9PgK1ktHS9E1/SSyLUGLro6xrINS6WWJI5PXXCPuQuw/oEHCJmMo7jZ4wEZDavmTcH5 JSJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:message-id:date:cc:to:from:subject; bh=yFxCxdlqMdcTa/7hKNRCq29byUH9VHp3sQ4S7qFGGu8=; b=0FIm7/XMGs1/IMkhjroDEGxMbsUzXQ5dRjDpkz1qJ9dr05RM34DA/rEMfv5E04fmfn i+cqzcJ/NPCoFhkKFO6Vu8Zr9jSWUpK2kZ8GOgcTjQGVkEgztQLP0S+bZ9JvQGy6Psvo AolRoHEWnhlscegnqmqITf7wB+5uUyfJNSN/Uo9ynE7+lm+9LSGCWIBp9fzfPq2grFPU Phoxkr3zOIiFmJ/15n4/dPwJCgqlvqgbaGts5fjszHSeFM66MM5BBTNWlFldG5Ez24Q3 zMQXivEG1JmMkhz2dA69xprQ9r2WBoAu3gsj2rt2WLdrs7LwI7+0QRPJJ6sWtBB+HcqD STBg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h5si14142357plt.232.2019.06.12.00.02.26; Wed, 12 Jun 2019 00:02:48 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2408190AbfFKXkB (ORCPT + 99 others); Tue, 11 Jun 2019 19:40:01 -0400 Received: from mga17.intel.com ([192.55.52.151]:43209 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405380AbfFKXkB (ORCPT ); Tue, 11 Jun 2019 19:40:01 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jun 2019 16:40:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,363,1557212400"; d="scan'208";a="184035062" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga002.fm.intel.com with ESMTP; 11 Jun 2019 16:39:59 -0700 Subject: [PATCH 0/6] libnvdimm: Fix async operations and locking From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Ira Weiny , Dave Jiang , Keith Busch , Jane Chu , stable@vger.kernel.org, Peter Zijlstra , Will Deacon , Ingo Molnar , Greg Kroah-Hartman , Erwin Tsaur , "Rafael J. Wysocki" , Vishal Verma , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org Date: Tue, 11 Jun 2019 16:25:43 -0700 Message-ID: <156029554317.419799.1324389595953183385.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The libnvdimm subsystem uses async operations to parallelize device probing operations and to allow sysfs to trigger device_unregister() on deleted namepsaces. A multithreaded stress test of the libnvdimm sysfs interface uncovered a case where device_unregister() is triggered multiple times, and the subsequent investigation uncovered a broken locking scenario. The lack of lockdep coverage for device_lock() stymied the debug. That is, until patch6 "driver-core, libnvdimm: Let device subsystems add local lockdep coverage" solved that with a shadow lock, with lockdep coverage, to mirror device_lock() operations. Given the time saved with shadow-lock debug-hack, patch6 attempts to generalize device_lock() debug facility that might be able to be carried upstream. Patch6 is staged at the end of this fix series in case it is contentious and needs to be dropped. Patch1 "drivers/base: Introduce kill_device()" could be achieved with local libnvdimm infrastructure. However, the existing 'dead' flag in 'struct device_private' aims to solve similar async register/unregister races so the fix in patch2 "libnvdimm/bus: Prevent duplicate device_unregister() calls" can be implemented with existing driver-core infrastructure. Patch3 is a rare lockdep warning that is intermittent based on namespaces racing ahead of the completion of probe of their parent region. It is not related to the other fixes, it just happened to trigger as a result of the async stress test. Patch4 and patch5 address an ABBA deadlock tripped by the stress test. These patches pass the failing stress test and the existing libnvdimm unit tests with CONFIG_PROVE_LOCKING=y and the new "dev->lockdep_mutex" shadow lock with no lockdep warnings. --- Dan Williams (6): drivers/base: Introduce kill_device() libnvdimm/bus: Prevent duplicate device_unregister() calls libnvdimm/region: Register badblocks before namespaces libnvdimm/bus: Stop holding nvdimm_bus_list_mutex over __nd_ioctl() libnvdimm/bus: Fix wait_nvdimm_bus_probe_idle() ABBA deadlock driver-core, libnvdimm: Let device subsystems add local lockdep coverage drivers/acpi/nfit/core.c | 28 ++++--- drivers/acpi/nfit/nfit.h | 24 ++++++ drivers/base/core.c | 30 ++++++-- drivers/nvdimm/btt_devs.c | 16 ++-- drivers/nvdimm/bus.c | 154 +++++++++++++++++++++++++++------------ drivers/nvdimm/core.c | 10 +-- drivers/nvdimm/dimm_devs.c | 4 + drivers/nvdimm/namespace_devs.c | 36 +++++---- drivers/nvdimm/nd-core.h | 71 ++++++++++++++++++ drivers/nvdimm/pfn_devs.c | 24 +++--- drivers/nvdimm/pmem.c | 4 + drivers/nvdimm/region.c | 24 +++--- drivers/nvdimm/region_devs.c | 12 ++- include/linux/device.h | 6 ++ 14 files changed, 308 insertions(+), 135 deletions(-)