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

uORB::DeviceNode allocate buffer on advertise #12802

Closed
wants to merge 2 commits into from

Conversation

dagar
Copy link
Member

@dagar dagar commented Aug 24, 2019

With the updated uORB::Subscription we've eliminated the majority of the unpublished uORB device nodes created from every orb_subscribe. As a result we can allocate the internal buffer immediately (on advertise) and relax the null checks (and interrupt context check).

@dagar dagar changed the title uORB::DeviceNode allocate buffer initially uORB::DeviceNode allocate buffer on advertise Aug 24, 2019
@dagar dagar force-pushed the pr-uorb_advertise_buffer branch 4 times, most recently from 2089058 to 3343a2f Compare August 26, 2019 19:44
@dagar dagar marked this pull request as ready for review August 27, 2019 00:53
@dagar dagar force-pushed the pr-uorb_advertise_buffer branch from 58e7b23 to ed15a96 Compare September 28, 2019 19:01
@dagar dagar requested a review from julianoes September 28, 2019 19:01
src/modules/uORB/uORBDeviceNode.cpp Outdated Show resolved Hide resolved
src/modules/uORB/uORBDeviceNode.cpp Show resolved Hide resolved
@dagar dagar requested a review from julianoes October 1, 2019 15:57
@dagar dagar force-pushed the pr-uorb_advertise_buffer branch from ed15a96 to 9f8b481 Compare October 1, 2019 15:57
return PX4_ERROR;
}

// switch to new data
memcpy(data, _data, _meta->o_size * _queue_size);
Copy link
Member

Choose a reason for hiding this comment

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

Increasing the queue size does not work: due to the generation % _queue_size logic, a subscriber could access invalid data after this update.
Better keep the existing logic until we move the queue size to the meta-data.

@@ -267,7 +269,7 @@ class uORB::DeviceNode : public cdev::CDev, public ListNode<uORB::DeviceNode *>
const uint8_t _instance; /**< orb multi instance identifier */
uint8_t *_data{nullptr}; /**< allocated object buffer */
hrt_abstime _last_update{0}; /**< time the object was last updated */
volatile unsigned _generation{0}; /**< object generation count */
unsigned _generation{0}; /**< object generation count */
Copy link
Member

Choose a reason for hiding this comment

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

Can you make this atomic? It's accessed concurrently w/o locks.

@stale
Copy link

stale bot commented Jan 1, 2020

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

@stale stale bot added the stale label Jan 1, 2020
@dagar dagar closed this Jan 22, 2020
@LorenzMeier LorenzMeier deleted the pr-uorb_advertise_buffer branch January 18, 2021 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants