-
Notifications
You must be signed in to change notification settings - Fork 721
nvme-top: add paging support and improve topology update handling #3529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -463,6 +463,16 @@ static int wait_for_event(struct dashboard_ctx *db_ctx, | |
| if (errno == EINTR) | ||
| continue; | ||
|
|
||
| /* | ||
| * We may have missed some netlink | ||
| * uevents from kernel. This is not a | ||
| * fatal error and we may synthesize it | ||
| * as an NVME kobject change event and | ||
| * force a topology rescan. | ||
| */ | ||
| if (errno == ENOBUFS) | ||
| return EVENT_TYPE_NVME_UEVENT; | ||
|
|
||
| nvme_show_perror("read from uevent fd"); | ||
| return n; | ||
| } | ||
|
|
@@ -509,6 +519,48 @@ static int wait_for_event(struct dashboard_ctx *db_ctx, | |
| } | ||
| } | ||
|
|
||
| static enum event_type wait_for_esc_seq(struct dashboard_ctx *db_ctx) | ||
| { | ||
| unsigned char c; | ||
| enum event_type event; | ||
|
|
||
| event = wait_for_event(db_ctx, &c, 1); | ||
| switch (event) { | ||
| case EVENT_TYPE_ERROR: /* fall through */ | ||
| case EVENT_TYPE_KEY_QUIT: /* fall through */ | ||
| case EVENT_TYPE_TIMEOUT: | ||
| return event; | ||
| default: | ||
|
Comment on lines
+528
to
+533
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree we may receive EVENT_TYPE_NVME_UEVENT or EVENT_TYPE_SIGWINCH while waiting for escape key sequence. I'd rather update wait_for_esc_seq() to not include fds which monitor uevents and sigwinch. As the name wait_for_esc_seq() suggests we're waiting for escape sequence, it makes more sense to only include key stroke monitor fd. I'll update the patch and resend. |
||
| if (c == 65) | ||
| return EVENT_TYPE_KEY_UP; | ||
| else if (c == 66) | ||
| return EVENT_TYPE_KEY_DOWN; | ||
| else if (c == 53 || c == 54) { | ||
| char prev = c; | ||
|
|
||
| event = wait_for_event(db_ctx, &c, 1); | ||
| switch (event) { | ||
| case EVENT_TYPE_ERROR: /* fall through */ | ||
| case EVENT_TYPE_KEY_QUIT: /* fall through */ | ||
| case EVENT_TYPE_TIMEOUT: | ||
| return event; | ||
| default: | ||
|
Comment on lines
+542
to
+547
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above. I will exclude monitor fds which doesn't wait for or monitor key press. |
||
| if (c == 126) { | ||
| if (prev == 53) | ||
| return EVENT_TYPE_KEY_PAGE_UP; | ||
| else | ||
| return EVENT_TYPE_KEY_PAGE_DOWN; | ||
| } | ||
| /* else ignore */ | ||
| break; | ||
| } | ||
| } | ||
| /* else ignore */ | ||
| break; | ||
| } | ||
| return EVENT_TYPE_IGNORE; | ||
| } | ||
|
|
||
| enum event_type dashboard_wait_for_event(struct dashboard_ctx *db_ctx) | ||
| { | ||
| int event; | ||
|
|
@@ -538,21 +590,12 @@ enum event_type dashboard_wait_for_event(struct dashboard_ctx *db_ctx) | |
| return EVENT_TYPE_KEY_ESC; | ||
| default: | ||
| if (c == 91) { /* '[' key */ | ||
| event = wait_for_event(db_ctx, &c, 1); | ||
| switch (event) { | ||
| case EVENT_TYPE_ERROR: /* fall through */ | ||
| case EVENT_TYPE_KEY_QUIT: | ||
| return event; | ||
| case EVENT_TYPE_TIMEOUT: | ||
| break; | ||
| default: | ||
| if (c == 65) | ||
| return EVENT_TYPE_KEY_UP; | ||
| else if (c == 66) | ||
| return EVENT_TYPE_KEY_DOWN; | ||
| /* else ignore */ | ||
| event = wait_for_esc_seq(db_ctx); | ||
| if (event == EVENT_TYPE_TIMEOUT || | ||
| event == EVENT_TYPE_IGNORE) | ||
| break; | ||
| } | ||
|
|
||
| return event; | ||
| } /* else ignore */ | ||
| break; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't noticed during the initial review. I assume you have to free the global context so that all resources are freed from
libnvme_scan_topology? The idea about the global context that it is allocated only once, so we need to look into alibnvme_rescan_topologyI think.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So for this series this is fine, but we should really make the library able to deal with this use case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is
libnvme_refresh_topology, which should do the trick,There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this looks good. Should I fix it in this series? Or shall I post it in a separate patch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can post a separate patch for this or update the series. whatever you prefer. Could you look through the copilot findings below though? No need for long explanation if you think it's wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay so I have addressed comments from copilot and per the review comment I will update the code. I am glad that copilot-pro is really able to find subtle issues which human eyes may miss.
Regarding libnvme_refresh_topology(), I will handle it in a separate patch.