Skip to content

Nvme top - #1

Closed
shroffni wants to merge 8 commits into
masterfrom
nvme-top
Closed

Nvme top#1
shroffni wants to merge 8 commits into
masterfrom
nvme-top

Conversation

@shroffni

Copy link
Copy Markdown
Owner

No description provided.

Extend the coverage report for the nightly tests. This covers the
fabrics features and the passthru code paths in nvme-cli during the
end-to-end tests.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
shroffni added 6 commits May 12, 2026 14:03
The table API automatically adjusts column width based on the width of
the value being printed. While table_print_XXX() already supports
unsigned, unsigned long, and long data types, the corresponding helper
table_get_value_width() does not account for these types.

Add support for unsigned, unsigned long, and long in table_get_value_
width() so that column width calculation is consistent with the
supported print helpers.

This will be used by the nvme top dashboard, where several statistics
are represented using these data types.

Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
table_print_centered() open-codes the logic to determine the width of a
table value, even though a helper already exists for this purpose.

Replace the open-coded width calculation with a call to
table_get_value_width() to avoid duplication and keep the behavior
consistent across the table helpers. Also, ensure that
table_get_value_width() returns -1 on failure so the caller could
then handle error as needed.

Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
The table_print_XXX() APIs do not currently support printing values of
type float or double.

Add support for float and double so that these data types can be used
with the table printing helpers. This will be later used for printing
nvme-top stat.

While at it, switch error reporting to nvme_show_error() for
consistency with the rest of the code.

Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
The table APIs currently print output only to stdout. However, callers
may need to direct output to other destinations such as stderr, a file,
or an in-memory buffer.

Add support for passing a FILE * stream so callers can choose where the
table output is written.

This will be used by the nvme top dashboard to control how statistics
are displayed.

Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
Add a sigaction handler for SIGWINCH so that nvme-top can detect
terminal window size changes.

This allows the dashboard layout to be adjusted and redrawn when the
terminal is resized. To avoid undefined behavior and async-signal-safety
the data type for nvme_sigwinch_received is defined as volatile
sig_atomic_t.

While we are at it, also update the data type of nvme_sigint_received
to volatile sig_atomic_t.

Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
Add a generic dashboard framework to support interactive, top-like
views. The framework renders data within a fixed-size window backed by
a larger buffer and provides event-driven APIs for updating the display.

Supported events:

- key input (ESC, Enter, 'q')
- escape sequences (up/down arrows)
- SIGWINCH for terminal resize handling
- periodic refresh via timeout
- kobject uevents (via netlink) to detect NVMe topology changes
  (subsystem, controller, namespace)
- reverse video highlighting for rows

Exported APIs:

- FILE *dashboard_init(struct dashboard_ctx **db_ctx, int interval)
  Initialize the dashboard context. Returns a FILE * stream used by the
  caller to write data for rendering. The returned context is used by
  all other dashboard APIs. The @interval is specified in seconds which
  represents the dashboard refresh interval.

- void dashboard_exit(struct dashboard_ctx *db_ctx)
  Tear down the dashboard and free all resources.

- int dashboard_draw_frame(struct dashboard_ctx *db_ctx, int scroll)
  Render the current frame. If @scroll is non-zero, adjust the view
  based on scrolling (up/down); otherwise render a new buffer.

- enum event_type dashboard_wait_for_event(struct dashboard_ctx *db_ctx)
  Wait for events such as key input, timeout, uevent, or SIGWINCH.
  Callers are expected to implement an event loop, and then based on
  returned event type take the action. For instance, if the returned
  event is timeout then caller shall update/refill the data store buffer
  and invoke dashboard_draw_frame() so that new/updated data could be
  rendered on dashboard . If the returned event type is up/down arrow
  keys then caller shall adjust the data start index in data store
  buffer and invoke dashboard_draw_frame() for rendering data. If the
  returned event type is key press 'ESC' or 'q' or kobject uevent then
  user shall take action as appropriate.

Reverse video helpers:

dashboard_{set,reset}_header_row_reverse()
dashboard_{set,reset}_footer_row_reverse()
dashboard_{set,reset}_data_row_reverse()

Additional getters/setters:

dashboard_get_interval()
dashboard_get_header_rows()
dashboard_set_header_rows()
dashboard_get_footer_rows()
dashboard_set_footer_rows()
dashboard_get_data_rows()
dashboard_get_data_start()
dashboard_set_data_start()
dashboard_get_frame_data_rows()

This framework is intended for use by nvme-top and similar tools that
require dynamic, event-driven terminal dashboards.

Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
Add a new "nvme top" CLI command that provides an interactive,
top-like dashboard for real-time monitoring of NVMe devices and
paths.

The dashboard presents continuously updated information about
NVMe fabrics/PCIe paths and devices, similar in spirit to tools
such as top or iotop. It helps administrators observe device
health, detect path degradation, identify multipath imbalances,
and catch transient failures.

The interface consists of two views:

* Subsystem list view
  Displays all NVMe subsystems present on the system. Users can
  navigate the list using arrow keys and select a subsystem for
  detailed inspection.

* Subsystem detail view
  Shows detailed statistics for the selected subsystem. When
  native multipath is enabled, this includes namespace head
  statistics, path statistics, path health, and controller
  summary. Without multipath, it displays namespace statistics
  and controller summary.

Users can switch between views using the ESC/return key, exit with
'q', and navigate using arrow keys.

This command builds on the generic dashboard framework to provide
a flexible and extensible real-time monitoring interface.

Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants