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

Thread safety: mmio read and write keep lock when being interrupted by pthread_cancel() #101

Open
fhaverkamp opened this issue Dec 20, 2017 · 1 comment

Comments

@fhaverkamp
Copy link
Contributor

We created a pthread which was supposed to poll a hardware register. Once we did not need this thread anymore, we canceled it by doing a pthread_cancel(). That caused in some cases deadlocks, due to a lock in a subsequent call to mmio_read/write which required the lock which was not unlocked.

To circumvent the problem we used

pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate);
do something ...
cxl_mmio_read32()
...
pthread_setcancelstate(oldstate, NULL);

Please review and fix functions which acquire locks and which are likely to be used in multithreaded code which can be stopped with pthread_cancel().

Thanks

Frank

@fhaverkamp
Copy link
Contributor Author

Here is the original bug and our own circumvention for the underlying problem:
open-power/snap#543

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

No branches or pull requests

1 participant