mbox series

[00/11] device-core: Generic device-lock lockdep validation

Message ID 164610292916.2682974.12924748003366352335.stgit@dwillia2-desk3.amr.corp.intel.com
Headers show
Series device-core: Generic device-lock lockdep validation | expand

Message

Dan Williams March 1, 2022, 2:48 a.m. UTC
Greg, Rafael,

Here are some extensions to the 'lockdep_mutex' I came up with after
getting tired of alternating debug builds between CXL and NVDIMM
subsystem testing, and worrying about the missing lockdep coverage from
device-lock acquisition in the device-core.

The primary insight is that the existing users of the 'lockdep_mutex'
are just wrapping calls to device_lock() with a subsystem local helper
that can apply the proper lock_class for how those subsystems nest the
device_lock(). Instead of local wrapping just instruct the subsystem to
annotate the lock_class directly in the device and let the device_lock()
common code handle acquiring lockdep_mutex with the proper class.

The final patch in the series extends this further and adds an array of
lockdep_mutex instances, 1 per subsystem, so that multiple subsystems can
be validated in a single kernel image.

This has been useful for identifying scenarios when it is safe to
acquire the device_lock() in a sysfs attribute.

Thoughts?

I know its late in the cycle to be messing with device-core internals,
so feel free to put this off until 5.19. This series is based on the
cxl_device_lock() enabling that is currently in -next.

---

Dan Williams (11):
      device-core: Enable lockdep validation
      cxl/core: Refactor a cxl_lock_class() out of cxl_nested_lock()
      cxl/core: Remove cxl_device_lock()
      cxl/core: Clamp max lock_class
      cxl/core: Introduce cxl_set_lock_class()
      cxl/acpi: Add a lock class for the root platform device
      libnvdimm: Refactor an nvdimm_lock_class() helper
      ACPI: NFIT: Drop nfit_device_lock()
      libnvdimm: Drop nd_device_lock()
      libnvdimm: Enable lockdep validation
      device-core: Introduce a per-subsystem lockdep_mutex


 drivers/acpi/nfit/core.c        |   30 +++++----
 drivers/acpi/nfit/nfit.h        |   24 -------
 drivers/base/core.c             |    5 --
 drivers/cxl/acpi.c              |    1 
 drivers/cxl/core/memdev.c       |    1 
 drivers/cxl/core/pmem.c         |    6 +-
 drivers/cxl/core/port.c         |   52 ++++++++--------
 drivers/cxl/core/region.c       |    1 
 drivers/cxl/cxl.h               |   72 ++++++++--------------
 drivers/cxl/mem.c               |    4 +
 drivers/cxl/pmem.c              |   12 ++--
 drivers/cxl/port.c              |    2 -
 drivers/nvdimm/btt_devs.c       |   16 ++---
 drivers/nvdimm/bus.c            |   26 ++++----
 drivers/nvdimm/core.c           |   10 ++-
 drivers/nvdimm/dimm_devs.c      |    8 +-
 drivers/nvdimm/namespace_devs.c |   36 +++++------
 drivers/nvdimm/nd-core.h        |   51 ++++-----------
 drivers/nvdimm/pfn_devs.c       |   24 ++++---
 drivers/nvdimm/pmem.c           |    2 -
 drivers/nvdimm/region.c         |    2 -
 drivers/nvdimm/region_devs.c    |   16 ++---
 include/linux/device.h          |  130 ++++++++++++++++++++++++++++++++++++++-
 lib/Kconfig.debug               |   23 -------
 24 files changed, 291 insertions(+), 263 deletions(-)

base-commit: 74be98774dfbc5b8b795db726bd772e735d2edd4