Bug #97228 rwlock: refine lock->lock_word with C11 atomics

Submitted: 15 Oct 2019 10:40 Modified: 25 Oct 2019 10:41
Reporter: Cai Yibo (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S5 (Performance)
Version:8.0 OS:Any
Assigned to: CPU Architecture:ARM
Tags: Contribution

[15 Oct 2019 10:40] Cai Yibo
Description:
This is followup patch of Bug #96504(Refine atomics and barriers for weak memory order platform). It depends on the patch for Bug #97150.

lock_word is core of rwlock implementation. It's a signed integer
reflecting current locking status(S, SX, X).

The most important changes of this patch are locking and unlocking
code. Refine locking(rw_lock_lock_word_decr) with acquire order,
and unlocking(rw_lock_lock_word_incr) with release order.

Unlocking is followed by lock->waiters checking to signal waiting
threads. Incrementing lock->word must happen before checking
lock->waiters. After changing unlocking to release order, this
sequence is not guaranteed. So adding an explicit acquire fence
before loading lock->waiters to fix the problem.

Another improvement comes from removing of "volatile" definition,
which eliminates some unnecessary memory accesses in code.

How to repeat:
NA
[15 Oct 2019 10:41] Cai Yibo
patch

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: 0002-rwlock-refine-lock-lock_word-with-C-11-atomics.patch (text/x-patch), 17.74 KiB.

[15 Oct 2019 10:45] Cai Yibo
Better to review together with Bug #97230.
[15 Oct 2019 12:47] MySQL Verification Team
Hi Mr. Yibo,

Thank you for your bug report and contribution for improving our performance on the ARM CPU family.

Verified as reported.
[25 Oct 2019 10:41] Cai Yibo
Hi Sinisa,

Thanks for reviewing. Is there anything I need to improve for this patch?

Yibo
[25 Oct 2019 12:07] MySQL Verification Team
Hi Mr. Yibo,

We shall contact you as soon as we get some feedback from our Engineering.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.060 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.