-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[TSan] Yet another idea about whitelisting data races #5310
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
Conversation
|
@cherusker, |
mono/utils/racing.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These functions should also be marked MONO_ALWAYS_INLINE.
mono/utils/racing.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
explicitly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
|
I like this idea. |
mono/utils/racing.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add this file to mono/utils/Makefile.am and msvc/libmonoutils.vcxproj, msvc/libmonoutils.vcxproj.filters.
388a26f to
7d30a0c
Compare
mono/metadata/class-internals.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason to prefer glib types to standard C types in internal headers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just working with the code since June and most things I do are based on observation. Personally, I do not not have any preferences (yet). However, I understand that the glib types are preferred wherever possible. (I might be wrong there!)
My thought was that atomic.h uses gint* so it might be nice to use all g* types in racing.h to keep some kind of consistency. And, since racing.h works with gsize AND mono_stats has this guint64 value anyways, I thought that (again talking about consistency) it would be nice to have those affected fields defined as gsize in mono_stats as well.
- introduce the `RacingIncrement* ()` functions - test the `RacingIncrement* ()` functions with races of `mono_stats` in class.c - add racing.h to Makefile.am, libmonoutils.vcxproj and msvc/libmonoutils.vcxproj.filters
7d30a0c to
a72b665
Compare
|
Can we call this something other than racing ? Like Unlocked or something ? |
|
@vargaz Yeah sure, I like that idea; I'll change it to |
- rename racing.h to unlocked.h - update new file name in Makefile.am and *.vcxproj* files - rename the functions from Racing* to Unlocked* - update the macro logic
[TSan] Unlocking MonoStats, GCStats and JITGCStats As the `Unlocked* ()` functions have been approved in #5310, I used them to blacklist some of the most obvious counting variables whose data races should be ignored: `MonoStats`, `GCStats` and `JITGCStats` (more to follow if approved). Please find details about all changes within the commit messages.
* Introduce racing.h - introduce the `RacingIncrement* ()` functions - test the `RacingIncrement* ()` functions with races of `mono_stats` in class.c - add racing.h to Makefile.am, libmonoutils.vcxproj and msvc/libmonoutils.vcxproj.filters * [fixup!] Rename "racing" to "unlocked" - rename racing.h to unlocked.h - update new file name in Makefile.am and *.vcxproj* files - rename the functions from Racing* to Unlocked* - update the macro logic Commit migrated from mono/mono@bc84302
[TSan] Unlocking MonoStats, GCStats and JITGCStats As the `Unlocked* ()` functions have been approved in mono/mono#5310, I used them to blacklist some of the most obvious counting variables whose data races should be ignored: `MonoStats`, `GCStats` and `JITGCStats` (more to follow if approved). Please find details about all changes within the commit messages. Commit migrated from mono/mono@787faec
I would like to propose another idea about how to deal with the instrumentation of data races. Inspired by atomic.h and the
G_UNLIKELYmacro, a (maybe the) solution might be to useinlinefunctions that wrap around increments, additions, ...The Main Problem:
mono_statsin class-internals.h).The Idea:
Using inline functions that follow the exact same interface like the functions in atomic.h.
RacingIncrement ()can be quickly changed toInterlockedIncrement (), should the need arise.To demonstrate the idea, I used
mono_statsin class.c as a specimen. I also tested proper function inlining on Fedora 26 withgcc 7.1.1andclang 4.0.0(both with-O2) and all results were as expected: The code was exactly the same - withRacingIncrementSize (&mono_stats.foo)and with++mono_stats.foo.I really hope that this idea gets accepted by the community since I would love to finally have the possibility of blacklisting single racy instructions. Detecting actual (harmuful) data races would be a lot more precise and reliable. If accepted, I would of course expand these function family (we will need things like
RacingExchange (),RacingAdd (),RacingSub ()and more) to tackle all races that are connected to debugging / reporting.As we talked about this topic before, I would kindly ask at least @luhenry, @vargaz, @alexrp and @lambdageek about thoughts and opinions.