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

Implement assert-based virtual locks on IDs #7

Open
wants to merge 5 commits into
base: multithread_h5vl
Choose a base branch
from

Conversation

mattjala
Copy link
Owner

@mattjala mattjala commented Nov 14, 2024

Implement virtual locks for IDs

When the library is built in debug mode, H5I will track how many concurrent API routines reference application-exposed IDs passed in through the H5VL API, and throw an assertion if an ID is simultaneously provided to more library threads than its reference count permits. The purpose of this is to help multi-threaded application developers detect invalid API usage early on in development.

The virtual locks are implemented by allowing variants of the FUNC_ENTER and FUNC_LEAVE macros to take a variable numbers of IDs as additional arguments.

The _NOINIT enter/exit variants do not interact with the virtual locks, since routines using these macros generally aren't meant to be directly used by applications (e.g. the routines for passthrough VOLs in H5VLcallback.c).

There are a few other factors the virtual locks must consider which complicate the implementation somewhat:

  • Default and library-created IDs (H5P_DEFAULT and predefined datatypes) aren't reference counted in the same way as other IDs, and so are ignored by the virtual locks.
  • API routines that decrement the application ref count of a provided ID (e.g. H5VLunregister_connector()). If using a simple virtual lock scheme, a routine that decrements the app ref count before calling the virtual lock exit would create a region where another thread could, on entry, apparently find the ID exceeding its application reference count, even though the usage is valid. The solution is that routines which decrement the app ref count indicate that an "application unlock" has taken place on the ID. Verification of ID ref counts compare the virtual lock count to the sum of application references plus 'application unlocks'. The application unlock count also serves to prevent double-counting of virtual lock releases in H5I_vlock_exit().

@mattjala mattjala force-pushed the mt_vl_virtual_locks branch 2 times, most recently from 062140b to 1f74b5b Compare November 15, 2024 20:41
@mattjala mattjala force-pushed the mt_vl_virtual_locks branch from 1f74b5b to fb1ef77 Compare November 20, 2024 14:30
@mattjala mattjala force-pushed the mt_vl_virtual_locks branch from fb1ef77 to b8e4cab Compare November 20, 2024 21:13
@mattjala mattjala force-pushed the multithread_h5vl branch 2 times, most recently from 80bced4 to 855ea52 Compare November 21, 2024 16:44
@mattjala mattjala force-pushed the mt_vl_virtual_locks branch from b8e4cab to 2ad4f09 Compare November 21, 2024 16:44
@mattjala mattjala force-pushed the mt_vl_virtual_locks branch from 2ad4f09 to 80a50a5 Compare November 21, 2024 20:49
@mattjala mattjala force-pushed the multithread_h5vl branch 3 times, most recently from ea71c8c to 7c3bdd3 Compare November 26, 2024 15:15
@mattjala mattjala force-pushed the mt_vl_virtual_locks branch from 80a50a5 to 2978a6e Compare November 26, 2024 15:17
@mattjala mattjala force-pushed the mt_vl_virtual_locks branch from 2978a6e to 4cf1d75 Compare November 26, 2024 15:20
@mattjala mattjala force-pushed the multithread_h5vl branch 4 times, most recently from b17a009 to 8879327 Compare November 26, 2024 19:52
@mattjala mattjala force-pushed the mt_vl_virtual_locks branch from 4cf1d75 to 2f7d9a9 Compare November 26, 2024 19:53
@mattjala mattjala force-pushed the multithread_h5vl branch 3 times, most recently from cb61a02 to fc31a40 Compare December 6, 2024 16:31
@mattjala mattjala force-pushed the mt_vl_virtual_locks branch from 2f7d9a9 to 61fe6b0 Compare December 19, 2024 17:16
@mattjala mattjala force-pushed the mt_vl_virtual_locks branch from 61fe6b0 to 49913f4 Compare December 19, 2024 19:40
@mattjala mattjala force-pushed the mt_vl_virtual_locks branch 3 times, most recently from f967ee4 to 13c35d4 Compare December 24, 2024 16:46
@mattjala mattjala force-pushed the mt_vl_virtual_locks branch from 13c35d4 to baf19b9 Compare December 24, 2024 21:46
@mattjala mattjala force-pushed the mt_vl_virtual_locks branch from baf19b9 to de44883 Compare December 30, 2024 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant