WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED INVALID
199832
[bmalloc] Add option to use pthread mutex instead of spin lock.
https://bugs.webkit.org/show_bug.cgi?id=199832
Summary
[bmalloc] Add option to use pthread mutex instead of spin lock.
Basuke Suzuki
Reported
2019-07-16 10:42:02 PDT
Our platform prefer using actual mutex.
Attachments
PATCH
(3.12 KB, patch)
2019-07-16 11:12 PDT
,
Basuke Suzuki
keith_miller
: review-
keith_miller
: commit-queue-
Details
Formatted Diff
Diff
PATCH
(3.40 KB, patch)
2019-07-16 12:27 PDT
,
Basuke Suzuki
no flags
Details
Formatted Diff
Diff
TRY WITH NO constexpr
(3.36 KB, patch)
2019-07-16 12:35 PDT
,
Basuke Suzuki
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Basuke Suzuki
Comment 1
2019-07-16 11:12:00 PDT
Created
attachment 374222
[details]
PATCH
Keith Miller
Comment 2
2019-07-16 11:24:16 PDT
Comment on
attachment 374222
[details]
PATCH If we are going to support this we should try to minimize the usage of #if BUSE(PTHREAD_MUTEX). e.g. The constructor should exist everywhere but only do things for pthreads, try_lock could be pthread_mutex_trylock, etc.
Basuke Suzuki
Comment 3
2019-07-16 12:27:42 PDT
Created
attachment 374230
[details]
PATCH
Basuke Suzuki
Comment 4
2019-07-16 12:29:09 PDT
(In reply to Keith Miller from
comment #2
)
> Comment on
attachment 374222
[details]
> PATCH > > If we are going to support this we should try to minimize the usage of #if > BUSE(PTHREAD_MUTEX). e.g. The constructor should exist everywhere but only > do things for pthreads, try_lock could be pthread_mutex_trylock, etc.
Do you mean like this? I removed the differences between both implementation as much as possible. For constructor, we need a non constexpr version so that I kept that difference as is.
EWS Watchlist
Comment 5
2019-07-16 12:29:23 PDT
Attachment 374230
[details]
did not pass style-queue: ERROR: Source/bmalloc/bmalloc/Mutex.h:111: Mutex::try_lock is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] Total errors found: 1 in 4 files If any of these errors are false positives, please file a bug against check-webkit-style.
Yusuke Suzuki
Comment 6
2019-07-16 12:31:29 PDT
Comment on
attachment 374230
[details]
PATCH View in context:
https://bugs.webkit.org/attachment.cgi?id=374230&action=review
> Source/bmalloc/bmalloc/Mutex.h:46 > +#if BUSE(PTHREAD_MUTEX) > + Mutex(); > +#else
This is not necessary. PTHREAD_MUTEX_INITIALIZER can initialize it under the constexpr context.
> Source/bmalloc/bmalloc/Mutex.h:92 > +#if BUSE(PTHREAD_MUTEX) > +inline Mutex::Mutex() > { > - return !m_flag.exchange(true, std::memory_order_acquire); > + pthread_mutex_init(&m_mutex, nullptr); > +} > +#endif
pthread_mutex_init and Mutex constructor is not necessary because we initialize it via PTHREAD_MUTEX_INITIALIZER.
Basuke Suzuki
Comment 7
2019-07-16 12:35:11 PDT
Created
attachment 374232
[details]
TRY WITH NO constexpr
Basuke Suzuki
Comment 8
2019-07-16 12:43:34 PDT
(In reply to Yusuke Suzuki from
comment #6
)
> Comment on
attachment 374230
[details]
> PATCH > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=374230&action=review
> > > Source/bmalloc/bmalloc/Mutex.h:46 > > +#if BUSE(PTHREAD_MUTEX) > > + Mutex(); > > +#else > > This is not necessary. PTHREAD_MUTEX_INITIALIZER can initialize it under the > constexpr context. > > > Source/bmalloc/bmalloc/Mutex.h:92 > > +#if BUSE(PTHREAD_MUTEX) > > +inline Mutex::Mutex() > > { > > - return !m_flag.exchange(true, std::memory_order_acquire); > > + pthread_mutex_init(&m_mutex, nullptr); > > +} > > +#endif > > pthread_mutex_init and Mutex constructor is not necessary because we > initialize it via PTHREAD_MUTEX_INITIALIZER.
Ah, okay, that's good to know. But we do still need destructor for cleanup, right? I thought the error below was caused by that. /Volumes/Data/EWS/WebKit/Source/bmalloc/bmalloc/CryptoRandom.cpp:79:1: error: declaration requires a global destructor [-Werror,-Wglobal-constructors] In file included from /Volumes/Data/EWS/WebKit/Source/bmalloc/bmalloc/CryptoRandom.cpp:36: /Volumes/Data/EWS/WebKit/Source/bmalloc/bmalloc/StaticPerProcess.h:103:57: note: expanded from macro 'DEFINE_STATIC_PER_PROCESS_STORAGE' Mutex StaticPerProcessStorageTraits<Type>::Storage::s_mutex { }; \ ^
EWS Watchlist
Comment 9
2019-07-16 12:59:39 PDT
Attachment 374232
[details]
did not pass style-queue: ERROR: Source/bmalloc/bmalloc/Mutex.h:107: Mutex::try_lock is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] Total errors found: 1 in 4 files If any of these errors are false positives, please file a bug against check-webkit-style.
Yusuke Suzuki
Comment 10
2019-07-16 13:01:31 PDT
Comment on
attachment 374230
[details]
PATCH View in context:
https://bugs.webkit.org/attachment.cgi?id=374230&action=review
>>> Source/bmalloc/bmalloc/Mutex.h:46 >>> +#else >> >> This is not necessary. PTHREAD_MUTEX_INITIALIZER can initialize it under the constexpr context. > > Ah, okay, that's good to know. But we do still need destructor for cleanup, right? I thought the error below was caused by that. > > /Volumes/Data/EWS/WebKit/Source/bmalloc/bmalloc/CryptoRandom.cpp:79:1: error: declaration requires a global destructor [-Werror,-Wglobal-constructors] > In file included from /Volumes/Data/EWS/WebKit/Source/bmalloc/bmalloc/CryptoRandom.cpp:36: > /Volumes/Data/EWS/WebKit/Source/bmalloc/bmalloc/StaticPerProcess.h:103:57: note: expanded from macro 'DEFINE_STATIC_PER_PROCESS_STORAGE' > Mutex StaticPerProcessStorageTraits<Type>::Storage::s_mutex { }; \ > ^
Yes, but this error is related to existence of destructor, not related to constexpr constructor.
Geoffrey Garen
Comment 11
2019-07-16 14:49:47 PDT
Comment on
attachment 374232
[details]
TRY WITH NO constexpr Why should we do this? Modes are bad, so we should only add a mode if we have a really good reason.
Basuke Suzuki
Comment 12
2019-07-16 14:57:57 PDT
(In reply to Geoffrey Garen from
comment #11
)
> Comment on
attachment 374232
[details]
> TRY WITH NO constexpr > > Why should we do this? Modes are bad, so we should only add a mode if we > have a really good reason.
Well, I cannot tell the detail..., please guess. Any way, we didn't notice there're exit-time-destructor issues on our patch and it should be solved anyway. We'll think about that later and invalidate this bug at this moment. Thanks.
Geoffrey Garen
Comment 13
2019-07-16 15:08:20 PDT
If you do choose to re-upload this change, I think we will need some way to discuss its benefits and consider alternatives, even if some of the specifics need to be confidential.
Basuke Suzuki
Comment 14
2019-07-16 15:18:47 PDT
Thanks, Geoffrey.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug