Hello,
I have a kernel extension that does some filtering and collects statistics in several identical data structures. These data structures are stored in a TAILQ list and are updated appropriately.
Meanwhile, a userspace application can request access to the data structures to inspect them and send feedback to the kernel.
This feedback can be : a request for more information, the order to discard the data, to stop recording statistics for a particular structure, etc.
Currently, I am using the following pattern:
1. Notify the userspace app that a data structure has been updated (by sending a custom notification containing the UID of the data structure)
2. If interested, the userspace app ask the content of the data structure by sending a request along with the data structure UID
3. The kext runs through the TAILQ list and searches for any data structure with a matching UID and sends it back
4. The app may want do perform additional request (modification, deletion, getting more info…) on the data structure (request + UID)
5. The kext searches again for any data structure with a matching UID and performs the task.
6. etc…
In parallel to this, the kext may want to perform other operations on its own (such as delete the oldest unrequested datastructures if their number grows too large, various updates, etc).
And as all the lookup operations are happening frequently and in a locked context, they are processor-cycle consuming.
I was wondering:
Instead of using true UIDs, is it wise to just send the data structure's address (structure data*) to the userspace app, and then using it back when the app makes its requests ?
This would save all the searches in the TAILQ lists. The lists would only be used to occasionally pop the first data structure, modify the last, or remove random elements.
Additional informations :
- The UID's only purpose is to identify a single data structure among all *currently* alive data structures.
- A data structure for which the address has been communicated to the userspace application can only be deleted at the app's request. So I don't fear dangling pointers.
- Size of the pointer has been taken into account.
What do you think ?
Best regards,
Jean
-----------
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden