Skip to content
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

PX4 general work queue and move all drivers to new work queue #11571

Merged
merged 51 commits into from
May 24, 2019

Conversation

dagar
Copy link
Member

@dagar dagar commented Mar 2, 2019

Continuation of #11261.

This pull request migrates nearly all drivers to the new PX4 work queue (#11570). This includes drivers running out of hrt callbacks, or NuttX HPWORK/LPWORK.

Continuation of #11261.

More background to come, but in short this general px4 work queue will allow us to finally unblock several important things.

  • SPI DMA IMU drivers
  • running rate controllers at 1 kHz or faster
  • better all around real time system performance
  • significant memory savings

Closes #8814

Design Notes

Each PX4 module that previously used hrt_calls, HPWORK, or LPWORK can now easily be moved into this framework. These classes inherit either WorkItem to be run as needed, or ScheduledWorkItem if a fixed interval is desired.

The reason for the (somewhat awkward) WorkQueueManager is to get every queue (a pthread) running within the same task group on NuttX. This significantly reduces overhead, and when combined with uORB changes (#11176) has no disadvantages. The cost of each work queue is little more than the stack (1-2 kB).

The other option for scheduling WorkItems is something I've bolted into uORB itself. The common pattern throughout most important PX4 modules is a task that polls a uORB topic for updates. Many of these processes are already fundamentally serialized, so the coexistence of all these tasks wastes quite a lot of memory. Any work pipeline (a collection of tasks) that's fundamentally serial can be moved to share the same WorkQueue. Then we can lean on the uORB publication to schedule appropriate work.

Copy link
Contributor

@julianoes julianoes left a comment

Choose a reason for hiding this comment

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

I'll probably have to trust you and the compiler on this one, right?

@dagar dagar mentioned this pull request Mar 12, 2019
2 tasks
@dagar
Copy link
Member Author

dagar commented Mar 12, 2019

I'll probably have to trust you and the compiler on this one, right?

I'd do a direct comparison with a platform you have on hand. Make sure all the drivers and running and providing sane data at the expected publication rate. Once we're closer I'll expand that testing and log review across a wider range of boards.

I intentionally tried to keep it close to the original usage so we could make the change safely and easily. Any driver that wasn't using the same basic HPWORK/LPWORK pattern was skipped in this pass.

@julianoes
Copy link
Contributor

Ok will do.

@dagar dagar changed the base branch from master to pr-px4_general_wq March 15, 2019 03:48
@dagar dagar force-pushed the pr-drivers_general_wq branch from ee35dde to 6fee1b8 Compare March 15, 2019 03:49
@dagar dagar changed the title [DO NOT MERGE] move all drivers to new work queue move all drivers to new work queue Mar 15, 2019
@dagar dagar marked this pull request as ready for review March 15, 2019 04:14
@dagar
Copy link
Member Author

dagar commented Mar 15, 2019

Tested on px4_fmu-v4 and px4_fmu-v5.

@dagar dagar force-pushed the pr-px4_general_wq branch from 1bc2527 to 990d8a0 Compare March 16, 2019 19:32
@dagar dagar force-pushed the pr-px4_general_wq branch from 990d8a0 to ac6c467 Compare April 24, 2019 17:45
@dagar dagar force-pushed the pr-px4_general_wq branch 3 times, most recently from 541b400 to 3c49eae Compare May 9, 2019 17:46
@dagar dagar force-pushed the pr-drivers_general_wq branch from 8652ddb to 6814da7 Compare May 10, 2019 14:20
@dagar dagar force-pushed the pr-drivers_general_wq branch from 6814da7 to 4163720 Compare May 17, 2019 15:06
@dagar dagar changed the base branch from pr-px4_general_wq to master May 17, 2019 15:45
@dagar dagar force-pushed the pr-drivers_general_wq branch 2 times, most recently from 1848651 to 8334f7d Compare May 17, 2019 17:41
@dagar dagar force-pushed the pr-drivers_general_wq branch from cc7276d to c46f946 Compare May 24, 2019 14:58
@dagar
Copy link
Member Author

dagar commented May 24, 2019

Let's finally get this in and start pushing on the other fundamental driver improvements that build on it (eg IMU full raw sampling with FIFOs and SPI DMA).

@dagar dagar merged commit 8e6708b into master May 24, 2019
@dagar dagar deleted the pr-drivers_general_wq branch May 24, 2019 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PX4 general work queue
7 participants