Skip to content

shell: exchange k_poll for k_event #93154

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

Merged
merged 1 commit into from
Jul 22, 2025

Conversation

bjarki-andreasen
Copy link
Contributor

The shell subsystem currently uses k_poll for signalling. However, k_poll is only used for simple event signals, results are not used.

Replacing the k_poll with k_event greatly simplifies the code, and saves 4 struct k_poll_signal and 4 struct k_poll_event (one of which was entirely unused) while costing a single struct k_event, for every shell instance. It also allows us to not select POLL, as we are using the simpler EVENTS instead.

A quick test build of the shell test suite on an nrf54l15 produces the following build info:

using EVENTS:

       FLASH:       71592 B      1428 KB      4.90%
         RAM:        9872 B       188 KB      5.13%
    IDT_LIST:          0 GB        32 KB      0.00%

using POLL

       FLASH:       75524 B      1428 KB      5.16%
         RAM:       11224 B       188 KB      5.83%
    IDT_LIST:          0 GB        32 KB      0.00%

jakub-uC
jakub-uC previously approved these changes Jul 16, 2025
Copy link
Contributor

@jakub-uC jakub-uC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks ok

nashif
nashif previously approved these changes Jul 16, 2025
Copy link
Member

@nashif nashif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

The shell subsystem currently uses k_poll for signalling. However,
k_poll is only used for simple event signals, results are not used.

Replacing the k_poll with k_event greatly simplifies the code, and
saves 4 struct k_poll_signal and 4 struct k_poll_event (one of which
was entirely unused) while costing a single struct k_event, for
every shell instance. It also allows us to not select POLL,
as we are using the simpler EVENTS instead.

A quick test build of the shell test suite on an nrf54l15 produces
the following build info:

using EVENTS:

           FLASH:       71592 B      1428 KB      4.90%
             RAM:        9872 B       188 KB      5.13%
        IDT_LIST:          0 GB        32 KB      0.00%

using POLL

           FLASH:       75524 B      1428 KB      5.16%
             RAM:       11224 B       188 KB      5.83%
        IDT_LIST:          0 GB        32 KB      0.00%

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
Copy link

@cfriedt cfriedt merged commit a39285b into zephyrproject-rtos:main Jul 22, 2025
25 checks passed
struct k_poll_signal *signal =
&sh->ctx->signals[SHELL_SIGNAL_KILL];

sh->ctx->uninit_cb = cb;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened to this callback? It was lost.

jeremybettis added a commit to jeremybettis/zephyr that referenced this pull request Jul 24, 2025
The sh->ctx->uninit_cb needs to be set before posting the
SHELL_SIGNAL_KILL to the event, like the k_poll based code did prior to

Signed-off-by: Jeremy Bettis <[email protected]>
jeremybettis added a commit to jeremybettis/zephyr that referenced this pull request Jul 24, 2025
The sh->ctx->uninit_cb needs to be set before posting the
SHELL_SIGNAL_KILL to the event, like the k_poll based code did prior to

Signed-off-by: Jeremy Bettis <[email protected]>
fabiobaltieri pushed a commit that referenced this pull request Jul 25, 2025
The sh->ctx->uninit_cb needs to be set before posting the
SHELL_SIGNAL_KILL to the event, like the k_poll based code did prior to

Signed-off-by: Jeremy Bettis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Shell Shell subsystem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants