All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/15] Introduce block device LED trigger
@ 2021-09-09 22:24 Ian Pilcher
  2021-09-09 22:24 ` [PATCH v2 01/15] docs: Add block device (blkdev) LED trigger documentation Ian Pilcher
                   ` (15 more replies)
  0 siblings, 16 replies; 39+ messages in thread
From: Ian Pilcher @ 2021-09-09 22:24 UTC (permalink / raw)
  To: axboe, pavel; +Cc: linux-leds, linux-block, linux-kernel, gregkh, kabel

Changes from v1:
================

* Use correct address for LKML.

* Renamed the sysfs attributes used to manage and view the set of block
  devices associated ("linked") with an LED.

  - /sys/class/leds/<LED>/link_device to create associations

  - /sys/class/leds/<LED>/unlink_device to remove associations

  - /sys/class/leds/<LED>/linked_devices/ contains symlinks to all block
    devices associated with the LED

  - /sys/block/<DEVICE>/linked_leds (which only exists when the device is
    associated with at least one LED) contains symlinks to all LEDs with
    which the device is associated

  link_device and unlink_device are write-only attributes, each of which
  represents a single action, rather than any state.  (The current state
  is shown by the symbolic links in the <LED>/linked_devices/ and
  <DEVICE>/linked_leds/ directories.)

* Simplified sysfs attribute store functions.  link_device and
  unlink_device no longer accept multiple devices at once, but this was
  really just an artifact of the way that sysfs repeatedly calls the
  store function when it doesn't "consume" all of its input, and it
  seemed to be confusing and unpopular anyway.

* Use DEVICE_ATTR_* macros (rather than __ATTR) for the sysfs attributes.

* Removed all pr_info() "system administrator error" messages.

* Different minimum values for LED blink time (10 ms) and activity check
  interval (25 ms).

Notes:
======

* Documentation for all sysfs attributes added in the first patch.

* All patches build without warnings or errors when trigger is disabled,
  modular or built-in.

V1 summary:
===========

This patch series adds a new "blkdev" LED trigger for disk (or other block
device) activity LEDs.

It has the following functionality.

* Supports all types of block devices, including virtual devices
  (unlike the existing disk trigger which only works with ATA devices).

* LEDs can be configured to show read activity, write activity, or both.

* Supports multiple devices and multiple LEDs in arbitrary many-to-many
  configurations.  For example, it is possible to configure multiple
  devices with device-specific read activity LEDs and a shared write
  activity LED.  (See Documentation/leds/ledtrig-blkdev.rst in the first
  patch.)

* Doesn't add any overhead in the I/O path.  Like the netdev LED trigger,
  it periodically checks the configured devices for activity and blinks
  its LEDs as appropriate.

* Blink duration (per LED) and interval between activity checks (global)
  are configurable.

* Requires minimal changes to the block subsystem.

  - Adds 1 pointer to struct gendisk,

  - Adds (inline function) call in device_add_disk() to ensure that the
    pointer is initialized to NULL (as protection against any drivers
    that allocate a gendisk themselves and don't use kzalloc()), and

  - Adds call in del_gendisk() to remove a device from the trigger when
    that device is being removed.

  These changes are all in patch #4, "block: Add block device LED trigger
  integrations."

* The trigger can be mostly built as a module.

  When the trigger is modular, a small portion is built in to provide a
  "stub" function which can be called from del_gendisk().  The stub calls
  into the modular code via a function pointer when needed.  The trigger
  also needs the ability to find gendisk's by name, which requires access
  to the un-exported block_class and disk_type symbols.


Ian Pilcher (15):
  docs: Add block device (blkdev) LED trigger documentation
  leds: trigger: blkdev: Add build infrastructure
  leds: trigger: blkdev: Add functions needed by block changes
  block: Add block device LED trigger integrations
  leds: trigger: blkdev: Complete functions called by block subsys
  leds: trigger: blkdev: Add function to get gendisk by name
  leds: trigger: blkdev: Add constants and types
  leds: trigger: blkdev: Add stub LED trigger structure
  leds: trigger: blkdev: Check devices for activity and blink LEDs
  leds: trigger: blkdev: Add LED trigger activate function
  leds: trigger: blkdev: Enable linking block devices to LEDs
  leds: trigger: blkdev: Enable unlinking block devices from LEDs
  leds: trigger: blkdev: Add LED trigger deactivate function
  leds: trigger: blkdev: Add remaining sysfs attributes
  leds: trigger: blkdev: Add disk cleanup and init/exit functions

 Documentation/ABI/testing/sysfs-block         |   9 +
 .../testing/sysfs-class-led-trigger-blkdev    |  46 ++
 Documentation/leds/index.rst                  |   1 +
 Documentation/leds/ledtrig-blkdev.rst         | 138 ++++
 block/genhd.c                                 |   4 +
 drivers/leds/trigger/Kconfig                  |  18 +
 drivers/leds/trigger/Makefile                 |   2 +
 drivers/leds/trigger/ledtrig-blkdev-core.c    |  55 ++
 drivers/leds/trigger/ledtrig-blkdev.c         | 686 ++++++++++++++++++
 drivers/leds/trigger/ledtrig-blkdev.h         |  18 +
 include/linux/genhd.h                         |   3 +
 include/linux/leds.h                          |  20 +
 12 files changed, 1000 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-led-trigger-blkdev
 create mode 100644 Documentation/leds/ledtrig-blkdev.rst
 create mode 100644 drivers/leds/trigger/ledtrig-blkdev-core.c
 create mode 100644 drivers/leds/trigger/ledtrig-blkdev.c
 create mode 100644 drivers/leds/trigger/ledtrig-blkdev.h


base-commit: a3fa7a101dcff93791d1b1bdb3affcad1410c8c1
-- 
2.31.1


^ permalink raw reply	[flat|nested] 39+ messages in thread
* Re: [PATCH v2 12/15] leds: trigger: blkdev: Enable unlinking block devices from LEDs
  2021-09-09 22:25 ` [PATCH v2 12/15] leds: trigger: blkdev: Enable unlinking block devices from LEDs Ian Pilcher
  (?)
@ 2021-09-14  9:58 ` Dan Carpenter
  -1 siblings, 0 replies; 39+ messages in thread
From: kernel test robot @ 2021-09-12  7:44 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 3540 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20210909222513.2184795-13-arequipeno@gmail.com>
References: <20210909222513.2184795-13-arequipeno@gmail.com>
TO: Ian Pilcher <arequipeno@gmail.com>
TO: axboe(a)kernel.dk
TO: pavel(a)ucw.cz
CC: linux-leds(a)vger.kernel.org
CC: linux-block(a)vger.kernel.org
CC: linux-kernel(a)vger.kernel.org
CC: gregkh(a)linuxfoundation.org
CC: kabel(a)kernel.org

Hi Ian,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on a3fa7a101dcff93791d1b1bdb3affcad1410c8c1]

url:    https://github.com/0day-ci/linux/commits/Ian-Pilcher/Introduce-block-device-LED-trigger/20210910-062756
base:   a3fa7a101dcff93791d1b1bdb3affcad1410c8c1
:::::: branch date: 2 days ago
:::::: commit date: 2 days ago
config: i386-randconfig-m021-20210912 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/leds/trigger/ledtrig-blkdev.c:410 blkdev_disk_unlink_locked() error: dereferencing freed memory 'disk'

vim +/disk +410 drivers/leds/trigger/ledtrig-blkdev.c

4a00ef60e59b58 Ian Pilcher 2021-09-09  380  
4a00ef60e59b58 Ian Pilcher 2021-09-09  381  
66cb682de7e8bd Ian Pilcher 2021-09-09  382  /*
66cb682de7e8bd Ian Pilcher 2021-09-09  383   *
66cb682de7e8bd Ian Pilcher 2021-09-09  384   *	unlink_device sysfs attribute - disassociate a device from this LED
66cb682de7e8bd Ian Pilcher 2021-09-09  385   *
66cb682de7e8bd Ian Pilcher 2021-09-09  386   */
66cb682de7e8bd Ian Pilcher 2021-09-09  387  
66cb682de7e8bd Ian Pilcher 2021-09-09  388  static void blkdev_disk_unlink_locked(struct ledtrig_blkdev_led *const led,
66cb682de7e8bd Ian Pilcher 2021-09-09  389  				      struct ledtrig_blkdev_link *const link,
66cb682de7e8bd Ian Pilcher 2021-09-09  390  				      struct ledtrig_blkdev_disk *const disk)
66cb682de7e8bd Ian Pilcher 2021-09-09  391  {
66cb682de7e8bd Ian Pilcher 2021-09-09  392  	--ledtrig_blkdev_count;
66cb682de7e8bd Ian Pilcher 2021-09-09  393  
66cb682de7e8bd Ian Pilcher 2021-09-09  394  	if (ledtrig_blkdev_count == 0)
66cb682de7e8bd Ian Pilcher 2021-09-09  395  		WARN_ON(!cancel_delayed_work_sync(&ledtrig_blkdev_work));
66cb682de7e8bd Ian Pilcher 2021-09-09  396  
66cb682de7e8bd Ian Pilcher 2021-09-09  397  	sysfs_remove_link(led->dir, disk->gd->disk_name);
66cb682de7e8bd Ian Pilcher 2021-09-09  398  	sysfs_remove_link(disk->dir, led->led_dev->name);
66cb682de7e8bd Ian Pilcher 2021-09-09  399  	kobject_put(disk->dir);
66cb682de7e8bd Ian Pilcher 2021-09-09  400  
66cb682de7e8bd Ian Pilcher 2021-09-09  401  	hlist_del(&link->led_disks_node);
66cb682de7e8bd Ian Pilcher 2021-09-09  402  	hlist_del(&link->disk_leds_node);
66cb682de7e8bd Ian Pilcher 2021-09-09  403  	kfree(link);
66cb682de7e8bd Ian Pilcher 2021-09-09  404  
66cb682de7e8bd Ian Pilcher 2021-09-09  405  	if (hlist_empty(&disk->leds)) {
66cb682de7e8bd Ian Pilcher 2021-09-09  406  		disk->gd->ledtrig = NULL;
66cb682de7e8bd Ian Pilcher 2021-09-09  407  		kfree(disk);
66cb682de7e8bd Ian Pilcher 2021-09-09  408  	}
66cb682de7e8bd Ian Pilcher 2021-09-09  409  
66cb682de7e8bd Ian Pilcher 2021-09-09 @410  	put_disk(disk->gd);
66cb682de7e8bd Ian Pilcher 2021-09-09  411  }
66cb682de7e8bd Ian Pilcher 2021-09-09  412  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 28974 bytes --]

^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2021-09-14  9:59 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-09 22:24 [PATCH v2 00/15] Introduce block device LED trigger Ian Pilcher
2021-09-09 22:24 ` [PATCH v2 01/15] docs: Add block device (blkdev) LED trigger documentation Ian Pilcher
2021-09-09 22:25 ` [PATCH v2 02/15] leds: trigger: blkdev: Add build infrastructure Ian Pilcher
2021-09-10  1:32   ` Marek Behún
2021-09-09 22:25 ` [PATCH v2 03/15] leds: trigger: blkdev: Add functions needed by block changes Ian Pilcher
2021-09-09 22:25 ` [PATCH v2 04/15] block: Add block device LED trigger integrations Ian Pilcher
2021-09-09 23:27   ` Chaitanya Kulkarni
2021-09-10  1:23   ` Marek Behún
2021-09-10 15:00     ` Ian Pilcher
2021-09-10  1:38   ` Marek Behún
2021-09-09 22:25 ` [PATCH v2 05/15] leds: trigger: blkdev: Complete functions called by block subsys Ian Pilcher
2021-09-09 22:25 ` [PATCH v2 06/15] leds: trigger: blkdev: Add function to get gendisk by name Ian Pilcher
2021-09-10  6:45   ` Greg KH
2021-09-10 15:17     ` Ian Pilcher
2021-09-10 15:23       ` Greg KH
2021-09-10 16:28     ` Ian Pilcher
2021-09-09 22:25 ` [PATCH v2 07/15] leds: trigger: blkdev: Add constants and types Ian Pilcher
2021-09-09 22:25 ` [PATCH v2 08/15] leds: trigger: blkdev: Add stub LED trigger structure Ian Pilcher
2021-09-09 22:25 ` [PATCH v2 09/15] leds: trigger: blkdev: Check devices for activity and blink LEDs Ian Pilcher
2021-09-10  1:48   ` Marek Behún
2021-09-10  2:17   ` Marek Behún
2021-09-10 15:09     ` Ian Pilcher
2021-09-10 15:12       ` Marek Behún
2021-09-10 21:23         ` Ian Pilcher
2021-09-09 22:25 ` [PATCH v2 10/15] leds: trigger: blkdev: Add LED trigger activate function Ian Pilcher
2021-09-10  6:47   ` Greg KH
2021-09-10 16:10     ` Ian Pilcher
2021-09-09 22:25 ` [PATCH v2 11/15] leds: trigger: blkdev: Enable linking block devices to LEDs Ian Pilcher
2021-09-10  6:48   ` Greg KH
2021-09-10 16:25     ` Ian Pilcher
2021-09-09 22:25 ` [PATCH v2 12/15] leds: trigger: blkdev: Enable unlinking block devices from LEDs Ian Pilcher
2021-09-09 22:25 ` [PATCH v2 13/15] leds: trigger: blkdev: Add LED trigger deactivate function Ian Pilcher
2021-09-09 22:25 ` [PATCH v2 14/15] leds: trigger: blkdev: Add remaining sysfs attributes Ian Pilcher
2021-09-09 22:25 ` [PATCH v2 15/15] leds: trigger: blkdev: Add disk cleanup and init/exit functions Ian Pilcher
2021-09-10  2:09 ` [PATCH v2 00/15] Introduce block device LED trigger Marek Behún
2021-09-10 14:04   ` Ian Pilcher
  -- strict thread matches above, loose matches on Subject: below --
2021-09-12  7:44 [PATCH v2 12/15] leds: trigger: blkdev: Enable unlinking block devices from LEDs kernel test robot
2021-09-14  9:58 ` Dan Carpenter
2021-09-14  9:58 ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.