MCS queued lock implementation
cover MCS queued lock implementation
This patch set added MCS lock library and its unit test.
The MCS lock (proposed by JOHN M. MELLOR-CRUMMEY and MICHAEL L. SCOTT) provides scalability by spinning on a CPU/thread local variable which avoids expensive cache bouncings. It provides fairness by maintaining a list of acquirers and passing the lock to each CPU/thread in the order they acquired the lock.
References:
1. http://web.mit.edu/6.173/www/currentsemester/readings/R06-scalable-synchronization-1991.pdf
2. https://lwn.net/Articles/590243/
Mirco-benchmarking result:
------------------------------------------------------------------------------------------------
MCS lock | spinlock | ticket lock
------------------------------+--------------------------------+--------------------------------
Test with lock on 13 cores... | Test with lock on 14 cores... | Test with lock on 14 cores...
Core [15] Cost Time = 22426 us| Core [14] Cost Time = 47974 us| Core [14] cost time = 66761 us
Core [16] Cost Time = 22382 us| Core [15] Cost Time = 46979 us| Core [15] cost time = 66766 us
Core [17] Cost Time = 22294 us| Core [16] Cost Time = 46044 us| Core [16] cost time = 66761 us
Core [18] Cost Time = 22412 us| Core [17] Cost Time = 28793 us| Core [17] cost time = 66767 us
Core [19] Cost Time = 22407 us| Core [18] Cost Time = 48349 us| Core [18] cost time = 66758 us
Core [20] Cost Time = 22436 us| Core [19] Cost Time = 19381 us| Core [19] cost time = 66766 us
Core [21] Cost Time = 22414 us| Core [20] Cost Time = 47914 us| Core [20] cost time = 66763 us
Core [22] Cost Time = 22405 us| Core [21] Cost Time = 48333 us| Core [21] cost time = 66766 us
Core [23] Cost Time = 22435 us| Core [22] Cost Time = 38900 us| Core [22] cost time = 66749 us
Core [24] Cost Time = 22401 us| Core [23] Cost Time = 45374 us| Core [23] cost time = 66765 us
Core [25] Cost Time = 22408 us| Core [24] Cost Time = 16121 us| Core [24] cost time = 66762 us
Core [26] Cost Time = 22380 us| Core [25] Cost Time = 42731 us| Core [25] cost time = 66768 us
Core [27] Cost Time = 22395 us| Core [26] Cost Time = 29439 us| Core [26] cost time = 66768 us
| Core [27] Cost Time = 38071 us| Core [27] cost time = 66767 us------------------------------+--------------------------------+--------------------------------
Total Cost Time = 291195 us | Total Cost Time = 544403 us | Total cost time = 934687 us
------------------------------------------------------------------------------------------------
Phil Yang (3):
eal/mcslock: add mcs queued lock implementation eal/mcslock: use generic msc queued lock on all arch test/mcslock: add mcs queued lock unit test
MAINTAINERS | 5 + app/test/Makefile | 1 + app/test/autotest_data.py | 6 + app/test/autotest_test_funcs.py | 32 +++ app/test/meson.build | 2 + app/test/test_mcslock.c | 248 +++++++++++++++++++++ doc/api/doxy-api-index.md | 1 + doc/guides/rel_notes/release_19_08.rst | 6 + lib/librte_eal/common/Makefile | 2 +- .../common/include/arch/arm/rte_mcslock.h | 23 ++ .../common/include/arch/ppc_64/rte_mcslock.h | 19 ++ .../common/include/arch/x86/rte_mcslock.h | 19 ++ .../common/include/generic/rte_mcslock.h | 169 ++++++++++++++ lib/librte_eal/common/meson.build | 1 + 14 files changed, 533 insertions(+), 1 deletion(-) create mode 100644 app/test/test_mcslock.c create mode 100644 lib/librte_eal/common/include/arch/arm/rte_mcslock.h create mode 100644 lib/librte_eal/common/include/arch/ppc_64/rte_mcslock.h create mode 100644 lib/librte_eal/common/include/arch/x86/rte_mcslock.h create mode 100644 lib/librte_eal/common/include/generic/rte_mcslock.h
Signature · 1 line
2.7.4
PATCH 1/3 eal/mcslock: add mcs queued lock implementation
If there are multiple threads contending, they all attempt to take the spinlock lock at the same time once it is released. This results in a huge amount of processor bus traffic, which is a huge performance killer. Thus, if we somehow order the lock-takers so that they know who is next in line for the resource we can vastly reduce the amount of bus traffic.
This patch added MCS lock library. It provides scalability by spinning on a CPU/thread local variable which avoids expensive cache bouncings. It provides fairness by maintaining a list of acquirers and passing the lock to each CPU/thread in the order they acquired the lock.
--- MAINTAINERS | 4 + doc/api/doxy-api-index.md | 1 + doc/guides/rel_notes/release_19_08.rst | 6 + lib/librte_eal/common/Makefile | 2 +- .../common/include/generic/rte_mcslock.h | 169 +++++++++++++++++++++ lib/librte_eal/common/meson.build | 1 + 6 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 lib/librte_eal/common/include/generic/rte_mcslock.h
MAINTAINERS +4 -0
@@ -222,6 +222,10 @@ M: Joyce Kong <[email protected]> F: lib/librte_eal/common/include/generic/rte_ticketlock.h F: app/test/test_ticketlock.c +MCSlock - EXPERIMENTAL +M: Phil Yang <[email protected]> +F: lib/librte_eal/common/include/generic/rte_mcslock.h + ARM v7 M: Jan Viktorin <[email protected]> M: Gavin Hu <[email protected]>
doc/api/doxy-api-index.md +1 -0
@@ -63,6 +63,7 @@ The public API headers are grouped by topics: - **locks**: [atomic] (@ref rte_atomic.h), + [mcslock] (@ref rte_mcslock.h), [rwlock] (@ref rte_rwlock.h), [spinlock] (@ref rte_spinlock.h), [ticketlock] (@ref rte_ticketlock.h),
doc/guides/rel_notes/release_19_08.rst +6 -0
@@ -54,6 +54,12 @@ New Features Also, make sure to start the actual text at the margin. ========================================================= +* **Added MCS lock library.** + + Added MCS lock library. It provides scalability by spinning on a + CPU/thread local variable which avoids expensive cache bouncings. + It provides fairness by maintaining a list of acquirers and passing + the lock to each CPU/thread in the order they acquired the lock. Removed Items -------------
lib/librte_eal/common/Makefile +1 -1
@@ -21,7 +21,7 @@ INC += rte_reciprocal.h rte_fbarray.h rte_uuid.h GENERIC_INC := rte_atomic.h rte_byteorder.h rte_cycles.h rte_prefetch.h GENERIC_INC += rte_memcpy.h rte_cpuflags.h -GENERIC_INC += rte_spinlock.h rte_rwlock.h rte_ticketlock.h +GENERIC_INC += rte_mcslock.h rte_spinlock.h rte_rwlock.h rte_ticketlock.h GENERIC_INC += rte_vect.h rte_pause.h rte_io.h # defined in mk/arch/$(RTE_ARCH)/rte.vars.mk
lib/librte_eal/common/include/generic/rte_mcslock.h new file +169 -0
169 lines not on this page · raw message
lib/librte_eal/common/meson.build +1 -0
@@ -94,6 +94,7 @@ generic_headers = files( 'include/generic/rte_cpuflags.h', 'include/generic/rte_cycles.h', 'include/generic/rte_io.h', + 'include/generic/rte_mcslock.h', 'include/generic/rte_memcpy.h', 'include/generic/rte_pause.h', 'include/generic/rte_prefetch.h',
Signature · 1 line
2.7.4
v2 cover MCS queued lock implementation
This patch set added MCS lock library and its unit test.
The MCS lock (proposed by John M. Mellor-Crummey and Michael L. Scott) provides scalability by spinning on a CPU/thread local variable which avoids expensive cache bouncings. It provides fairness by maintaining a list of acquirers and passing the lock to each CPU/thread in the order they acquired the lock.
References:
1. http://web.mit.edu/6.173/www/currentsemester/readings/R06-scalable-synchronization-1991.pdf
2. https://lwn.net/Articles/590243/
Micro benchmark (1M iterations):
---------------------------------------------------------------------------------------------------------
MCS lock | spinlock | ticket lock
---------------------------------------------------------------------------------------------------------
Test with lock on 20 cores... | Test with lock on 20 cores... | Test with lock on 20 cores... Core [0] Cost Time = 4221256 us | Core [0] Cost Time = 1948341 us | Core [0] cost time = 25388253 us Core [14] Cost Time = 4221260 us | Core [14] Cost Time = 5136122 us | Core [14] cost time = 25389593 us Core [28] Cost Time = 4221239 us | Core [28] Cost Time = 4849188 us | Core [28] cost time = 25387857 us Core [29] Cost Time = 4221190 us | Core [29] Cost Time = 3424137 us | Core [29] cost time = 25387625 us Core [30] Cost Time = 4221249 us | Core [30] Cost Time = 3455813 us | Core [30] cost time = 25387662 us Core [31] Cost Time = 4221090 us | Core [31] Cost Time = 4742221 us | Core [31] cost time = 25387968 us Core [32] Cost Time = 4221169 us | Core [32] Cost Time = 4955011 us | Core [32] cost time = 25387991 us Core [33] Cost Time = 4221192 us | Core [33] Cost Time = 3807345 us | Core [33] cost time = 25387679 us Core [34] Cost Time = 4221209 us | Core [34] Cost Time = 5011178 us | Core [34] cost time = 25389370 us Core [35] Cost Time = 4221232 us | Core [35] Cost Time = 4983119 us | Core [35] cost time = 25387899 us Core [36] Cost Time = 4221260 us | Core [36] Cost Time = 5178121 us | Core [36] cost time = 25389593 us Core [37] Cost Time = 4221203 us | Core [37] Cost Time = 5148525 us | Core [37] cost time = 25389347 us Core [38] Cost Time = 4221229 us | Core [38] Cost Time = 5186183 us | Core [38] cost time = 25389363 us Core [39] Cost Time = 4221253 us | Core [39] Cost Time = 4650058 us | Core [39] cost time = 25387948 us Core [40] Cost Time = 4221121 us | Core [40] Cost Time = 4682572 us | Core [40] cost time = 25387857 us Core [41] Cost Time = 4221238 us | Core [41] Cost Time = 4327049 us | Core [41] cost time = 25389261 us Core [42] Cost Time = 4221234 us | Core [42] Cost Time = 5141807 us | Core [42] cost time = 25389284 us Core [43] Cost Time = 4221218 us | Core [43] Cost Time = 3346939 us | Core [43] cost time = 25387967 us Core [44] Cost Time = 4221220 us | Core [44] Cost Time = 2768786 us | Core [44] cost time = 25387771 us Core [45] Cost Time = 4221221 us | Core [45] Cost Time = 3525078 us | Core [45] cost time = 25389044 us
---------------------------------------------------------------------------------------------------------
Total Cost Time = 84424283 us | Total Cost Time = 86267593 us | Total cost time = 507769332 us
---------------------------------------------------------------------------------------------------------
Summary:
1. In the lock contention scenario, MCS lock and ticket lock can grantee the fairness for each lock acquirers. MCS lock has better performance than ticket lock.
2. Spinlock is fast, however spinlock has the unfairness issue in the lock contention case. This will make some lock acquirers got starved. MCS lock is fast and fair comparing with spinlock.
v2
1. Lowercase the algrithom author's name; (David Marchand)
2. Add the load test on master core to align with other locks test; (David Marchand)
3. Enlarge the test iterations from 10K to 1M; (Ananyev Konstantin)
4. Fixed potential deadlock issues.
v1
Initial version.
Phil Yang (3):
eal/mcslock: add mcs queued lock implementation eal/mcslock: use generic msc queued lock on all arch test/mcslock: add mcs queued lock unit test
MAINTAINERS | 5 + app/test/Makefile | 1 + app/test/autotest_data.py | 6 + app/test/autotest_test_funcs.py | 32 +++ app/test/meson.build | 2 + app/test/test_mcslock.c | 251 +++++++++++++++++++++ doc/api/doxy-api-index.md | 1 + doc/guides/rel_notes/release_19_08.rst | 6 + lib/librte_eal/common/Makefile | 2 +- .../common/include/arch/arm/rte_mcslock.h | 23 ++ .../common/include/arch/ppc_64/rte_mcslock.h | 19 ++ .../common/include/arch/x86/rte_mcslock.h | 19 ++ .../common/include/generic/rte_mcslock.h | 175 ++++++++++++++ lib/librte_eal/common/meson.build | 1 + 14 files changed, 542 insertions(+), 1 deletion(-) create mode 100644 app/test/test_mcslock.c create mode 100644 lib/librte_eal/common/include/arch/arm/rte_mcslock.h create mode 100644 lib/librte_eal/common/include/arch/ppc_64/rte_mcslock.h create mode 100644 lib/librte_eal/common/include/arch/x86/rte_mcslock.h create mode 100644 lib/librte_eal/common/include/generic/rte_mcslock.h
Signature · 1 line
2.7.4
PATCH v2 1/3 eal/mcslock: add mcs queued lock implementation
If there are multiple threads contending, they all attempt to take the spinlock lock at the same time once it is released. This results in a huge amount of processor bus traffic, which is a huge performance killer. Thus, if we somehow order the lock-takers so that they know who is next in line for the resource we can vastly reduce the amount of bus traffic.
This patch added MCS lock library. It provides scalability by spinning on a CPU/thread local variable which avoids expensive cache bouncings. It provides fairness by maintaining a list of acquirers and passing the lock to each CPU/thread in the order they acquired the lock.
--- MAINTAINERS | 4 + doc/api/doxy-api-index.md | 1 + doc/guides/rel_notes/release_19_08.rst | 6 + lib/librte_eal/common/Makefile | 2 +- .../common/include/generic/rte_mcslock.h | 175 +++++++++++++++++++++ lib/librte_eal/common/meson.build | 1 + 6 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 lib/librte_eal/common/include/generic/rte_mcslock.h
MAINTAINERS +4 -0
@@ -234,6 +234,10 @@ F: lib/librte_eal/common/include/rte_random.h F: lib/librte_eal/common/rte_random.c F: app/test/test_rand_perf.c +MCSlock - EXPERIMENTAL +M: Phil Yang <[email protected]> +F: lib/librte_eal/common/include/generic/rte_mcslock.h + ARM v7 M: Jan Viktorin <[email protected]> M: Gavin Hu <[email protected]>
doc/api/doxy-api-index.md +1 -0
@@ -63,6 +63,7 @@ The public API headers are grouped by topics: - **locks**: [atomic] (@ref rte_atomic.h), + [mcslock] (@ref rte_mcslock.h), [rwlock] (@ref rte_rwlock.h), [spinlock] (@ref rte_spinlock.h), [ticketlock] (@ref rte_ticketlock.h),
doc/guides/rel_notes/release_19_08.rst +6 -0
@@ -139,6 +139,12 @@ New Features Added telemetry mode to l3fwd-power application to report application level busyness, empty and full polls of rte_eth_rx_burst(). +* **Added MCS lock library.** + + Added MCS lock library. It provides scalability by spinning on a + CPU/thread local variable which avoids expensive cache bouncings. + It provides fairness by maintaining a list of acquirers and passing + the lock to each CPU/thread in the order they acquired the lock. Removed Items -------------
lib/librte_eal/common/Makefile +1 -1
@@ -21,7 +21,7 @@ INC += rte_reciprocal.h rte_fbarray.h rte_uuid.h GENERIC_INC := rte_atomic.h rte_byteorder.h rte_cycles.h rte_prefetch.h GENERIC_INC += rte_memcpy.h rte_cpuflags.h -GENERIC_INC += rte_spinlock.h rte_rwlock.h rte_ticketlock.h +GENERIC_INC += rte_mcslock.h rte_spinlock.h rte_rwlock.h rte_ticketlock.h GENERIC_INC += rte_vect.h rte_pause.h rte_io.h # defined in mk/arch/$(RTE_ARCH)/rte.vars.mk
lib/librte_eal/common/include/generic/rte_mcslock.h new file +175 -0
175 lines not on this page · raw message
lib/librte_eal/common/meson.build +1 -0
@@ -95,6 +95,7 @@ generic_headers = files( 'include/generic/rte_cpuflags.h', 'include/generic/rte_cycles.h', 'include/generic/rte_io.h', + 'include/generic/rte_mcslock.h', 'include/generic/rte_memcpy.h', 'include/generic/rte_pause.h', 'include/generic/rte_prefetch.h',
Signature · 1 line
2.7.4
PATCH v2 2/3 eal/mcslock: use generic msc queued lock on all arch
In reply to Phil YangLet all architectures use generic MCS queued lock implementation.
--- .../common/include/arch/arm/rte_mcslock.h | 23 ++++++++++++++++++++++ .../common/include/arch/ppc_64/rte_mcslock.h | 19 ++++++++++++++++++ .../common/include/arch/x86/rte_mcslock.h | 19 ++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 lib/librte_eal/common/include/arch/arm/rte_mcslock.h create mode 100644 lib/librte_eal/common/include/arch/ppc_64/rte_mcslock.h create mode 100644 lib/librte_eal/common/include/arch/x86/rte_mcslock.h
lib/librte_eal/common/include/arch/arm/rte_mcslock.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +*/ + +#ifndef _RTE_MCSLOCK_ARM_H_ +#define _RTE_MCSLOCK_ARM_H_ + +#ifndef RTE_FORCE_INTRINSICS +# error Platform must be built with CONFIG_RTE_FORCE_INTRINSICS +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_mcslock.h" + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_MCSLOCK_ARM_H_ */ +
lib/librte_eal/common/include/arch/ppc_64/rte_mcslock.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +*/ + +#ifndef _RTE_MCSLOCK_PPC_64_H_ +#define _RTE_MCSLOCK_PPC_64_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_mcslock.h" + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_MCSLOCK_PPC_64_H_ */ +
lib/librte_eal/common/include/arch/x86/rte_mcslock.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +*/ + +#ifndef _RTE_MCSLOCK_X86_64_H_ +#define _RTE_MCSLOCK_X86_64_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_mcslock.h" + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_MCSLOCK_X86_64_H_ */ +
Signature · 1 line
2.7.4
PATCH v2 3/3 test/mcslock: add mcs queued lock unit test
In reply to Phil YangUnit test and perf test for MCS queued lock.
--- MAINTAINERS | 1 + app/test/Makefile | 1 + app/test/autotest_data.py | 6 + app/test/autotest_test_funcs.py | 32 +++++ app/test/meson.build | 2 + app/test/test_mcslock.c | 251 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 293 insertions(+) create mode 100644 app/test/test_mcslock.c
MAINTAINERS +1 -0
@@ -237,6 +237,7 @@ F: app/test/test_rand_perf.c MCSlock - EXPERIMENTAL M: Phil Yang <[email protected]> F: lib/librte_eal/common/include/generic/rte_mcslock.h +F: app/test/test_mcslock.c ARM v7 M: Jan Viktorin <[email protected]>
app/test/Makefile +1 -0
@@ -64,6 +64,7 @@ SRCS-y += test_atomic.c SRCS-y += test_barrier.c SRCS-y += test_malloc.c SRCS-y += test_cycles.c +SRCS-y += test_mcslock.c SRCS-y += test_spinlock.c SRCS-y += test_ticketlock.c SRCS-y += test_memory.c
app/test/autotest_data.py +6 -0
@@ -177,6 +177,12 @@ "Report": None, }, { + "Name": "MCSlock autotest", + "Command": "mcslock_autotest", + "Func": mcslock_autotest, + "Report": None, + }, + { "Name": "Byte order autotest", "Command": "byteorder_autotest", "Func": default_autotest,
app/test/autotest_test_funcs.py +32 -0
@@ -164,6 +164,38 @@ def ticketlock_autotest(child, test_name): return 0, "Success" +def mcslock_autotest(child, test_name): + i = 0 + ir = 0 + child.sendline(test_name) + while True: + index = child.expect(["Test OK", + "Test Failed", + "lcore ([0-9]*) state: ([0-1])" + "MCS lock taken on core ([0-9]*)", + "MCS lock released on core ([0-9]*)", + pexpect.TIMEOUT], timeout=5) + # ok + if index == 0: + break + + # message, check ordering + elif index == 2: + if int(child.match.groups()[0]) < i: + return -1, "Fail [Bad order]" + i = int(child.match.groups()[0]) + elif index == 3: + if int(child.match.groups()[0]) < ir: + return -1, "Fail [Bad order]" + ir = int(child.match.groups()[0]) + + # fail + elif index == 4: + return -1, "Fail [Timeout]" + elif index == 1: + return -1, "Fail" + + return 0, "Success" def logs_autotest(child, test_name): child.sendline(test_name)
app/test/meson.build +2 -0
@@ -80,6 +80,7 @@ test_sources = files('commands.c', 'test_memzone.c', 'test_meter.c', 'test_metrics.c', + 'test_mcslock.c', 'test_mp_secondary.c', 'test_pdump.c', 'test_per_lcore.c',
@@ -185,6 +186,7 @@ fast_test_names = [ 'lpm6_autotest', 'malloc_autotest', 'mbuf_autotest', + 'mcslock_autotest', 'memcpy_autotest', 'memory_autotest', 'mempool_autotest',
app/test/test_mcslock.c new file +251 -0
251 lines not on this page · raw message
Signature · 1 line
2.7.4
v3 cover MCS queued lock implementation
In reply to Phil YangThis patch set added MCS lock library and its unit test.
The MCS lock (proposed by John M. Mellor-Crummey and Michael L. Scott) provides scalability by spinning on a CPU/thread local variable which avoids expensive cache bouncings. It provides fairness by maintaining a list of acquirers and passing the lock to each CPU/thread in the order they acquired the lock.
References:
1. http://web.mit.edu/6.173/www/currentsemester/readings/R06-scalable-synchronization-1991.pdf
2. https://lwn.net/Articles/590243/
Micro benchmark (1M iterations):
---------------------------------------------------------------------------------------------------------
MCS lock | spinlock | ticket lock
---------------------------------------------------------------------------------------------------------
Test with lock on 20 cores... | Test with lock on 20 cores... | Test with lock on 20 cores... Core [0] Cost Time = 4221256 us | Core [0] Cost Time = 1948341 us | Core [0] cost time = 25388253 us Core [14] Cost Time = 4221260 us | Core [14] Cost Time = 5136122 us | Core [14] cost time = 25389593 us Core [28] Cost Time = 4221239 us | Core [28] Cost Time = 4849188 us | Core [28] cost time = 25387857 us Core [29] Cost Time = 4221190 us | Core [29] Cost Time = 3424137 us | Core [29] cost time = 25387625 us Core [30] Cost Time = 4221249 us | Core [30] Cost Time = 3455813 us | Core [30] cost time = 25387662 us Core [31] Cost Time = 4221090 us | Core [31] Cost Time = 4742221 us | Core [31] cost time = 25387968 us Core [32] Cost Time = 4221169 us | Core [32] Cost Time = 4955011 us | Core [32] cost time = 25387991 us Core [33] Cost Time = 4221192 us | Core [33] Cost Time = 3807345 us | Core [33] cost time = 25387679 us Core [34] Cost Time = 4221209 us | Core [34] Cost Time = 5011178 us | Core [34] cost time = 25389370 us Core [35] Cost Time = 4221232 us | Core [35] Cost Time = 4983119 us | Core [35] cost time = 25387899 us Core [36] Cost Time = 4221260 us | Core [36] Cost Time = 5178121 us | Core [36] cost time = 25389593 us Core [37] Cost Time = 4221203 us | Core [37] Cost Time = 5148525 us | Core [37] cost time = 25389347 us Core [38] Cost Time = 4221229 us | Core [38] Cost Time = 5186183 us | Core [38] cost time = 25389363 us Core [39] Cost Time = 4221253 us | Core [39] Cost Time = 4650058 us | Core [39] cost time = 25387948 us Core [40] Cost Time = 4221121 us | Core [40] Cost Time = 4682572 us | Core [40] cost time = 25387857 us Core [41] Cost Time = 4221238 us | Core [41] Cost Time = 4327049 us | Core [41] cost time = 25389261 us Core [42] Cost Time = 4221234 us | Core [42] Cost Time = 5141807 us | Core [42] cost time = 25389284 us Core [43] Cost Time = 4221218 us | Core [43] Cost Time = 3346939 us | Core [43] cost time = 25387967 us Core [44] Cost Time = 4221220 us | Core [44] Cost Time = 2768786 us | Core [44] cost time = 25387771 us Core [45] Cost Time = 4221221 us | Core [45] Cost Time = 3525078 us | Core [45] cost time = 25389044 us
---------------------------------------------------------------------------------------------------------
Total Cost Time = 84424283 us | Total Cost Time = 86267593 us | Total cost time = 507769332 us
---------------------------------------------------------------------------------------------------------
Summary:
1. In the lock contention scenario, MCS lock and ticket lock can grantee the fairness for each lock acquirers. MCS lock has better performance than ticket lock.
2. Spinlock is fast, however spinlock has the unfairness issue in the lock contention case. This will make some lock acquirers got starved. MCS lock is fast and fair comparing with spinlock.
v3
Fix __rte_experimental coding style warning.
v2
1. Lowercase the algrithom author's name; (David Marchand)
2. Add the load test on master core to align with other locks test; (David Marchand)
3. Enlarge the test iterations from 10K to 1M; (Ananyev Konstantin)
4. Fixed potential deadlock issues.
v1
Initial version.
Phil Yang (3):
eal/mcslock: add mcs queued lock implementation eal/mcslock: use generic msc queued lock on all arch test/mcslock: add mcs queued lock unit test
MAINTAINERS | 5 + app/test/Makefile | 1 + app/test/autotest_data.py | 6 + app/test/autotest_test_funcs.py | 32 +++ app/test/meson.build | 2 + app/test/test_mcslock.c | 251 +++++++++++++++++++++ doc/api/doxy-api-index.md | 1 + doc/guides/rel_notes/release_19_08.rst | 6 + lib/librte_eal/common/Makefile | 2 +- .../common/include/arch/arm/rte_mcslock.h | 23 ++ .../common/include/arch/ppc_64/rte_mcslock.h | 19 ++ .../common/include/arch/x86/rte_mcslock.h | 19 ++ .../common/include/generic/rte_mcslock.h | 179 +++++++++++++++ lib/librte_eal/common/meson.build | 1 + 14 files changed, 546 insertions(+), 1 deletion(-) create mode 100644 app/test/test_mcslock.c create mode 100644 lib/librte_eal/common/include/arch/arm/rte_mcslock.h create mode 100644 lib/librte_eal/common/include/arch/ppc_64/rte_mcslock.h create mode 100644 lib/librte_eal/common/include/arch/x86/rte_mcslock.h create mode 100644 lib/librte_eal/common/include/generic/rte_mcslock.h
Signature · 1 line
2.7.4
PATCH v3 1/3 eal/mcslock: add mcs queued lock implementation
If there are multiple threads contending, they all attempt to take the spinlock lock at the same time once it is released. This results in a huge amount of processor bus traffic, which is a huge performance killer. Thus, if we somehow order the lock-takers so that they know who is next in line for the resource we can vastly reduce the amount of bus traffic.
This patch added MCS lock library. It provides scalability by spinning on a CPU/thread local variable which avoids expensive cache bouncings. It provides fairness by maintaining a list of acquirers and passing the lock to each CPU/thread in the order they acquired the lock.
--- MAINTAINERS | 4 + doc/api/doxy-api-index.md | 1 + doc/guides/rel_notes/release_19_08.rst | 6 + lib/librte_eal/common/Makefile | 2 +- .../common/include/generic/rte_mcslock.h | 179 +++++++++++++++++++++ lib/librte_eal/common/meson.build | 1 + 6 files changed, 192 insertions(+), 1 deletion(-) create mode 100644 lib/librte_eal/common/include/generic/rte_mcslock.h
MAINTAINERS +4 -0
@@ -234,6 +234,10 @@ F: lib/librte_eal/common/include/rte_random.h F: lib/librte_eal/common/rte_random.c F: app/test/test_rand_perf.c +MCSlock - EXPERIMENTAL +M: Phil Yang <[email protected]> +F: lib/librte_eal/common/include/generic/rte_mcslock.h + ARM v7 M: Jan Viktorin <[email protected]> M: Gavin Hu <[email protected]>
doc/api/doxy-api-index.md +1 -0
@@ -63,6 +63,7 @@ The public API headers are grouped by topics: - **locks**: [atomic] (@ref rte_atomic.h), + [mcslock] (@ref rte_mcslock.h), [rwlock] (@ref rte_rwlock.h), [spinlock] (@ref rte_spinlock.h), [ticketlock] (@ref rte_ticketlock.h),
doc/guides/rel_notes/release_19_08.rst +6 -0
@@ -139,6 +139,12 @@ New Features Added telemetry mode to l3fwd-power application to report application level busyness, empty and full polls of rte_eth_rx_burst(). +* **Added MCS lock library.** + + Added MCS lock library. It provides scalability by spinning on a + CPU/thread local variable which avoids expensive cache bouncings. + It provides fairness by maintaining a list of acquirers and passing + the lock to each CPU/thread in the order they acquired the lock. Removed Items -------------
lib/librte_eal/common/Makefile +1 -1
@@ -21,7 +21,7 @@ INC += rte_reciprocal.h rte_fbarray.h rte_uuid.h GENERIC_INC := rte_atomic.h rte_byteorder.h rte_cycles.h rte_prefetch.h GENERIC_INC += rte_memcpy.h rte_cpuflags.h -GENERIC_INC += rte_spinlock.h rte_rwlock.h rte_ticketlock.h +GENERIC_INC += rte_mcslock.h rte_spinlock.h rte_rwlock.h rte_ticketlock.h GENERIC_INC += rte_vect.h rte_pause.h rte_io.h # defined in mk/arch/$(RTE_ARCH)/rte.vars.mk
lib/librte_eal/common/include/generic/rte_mcslock.h new file +179 -0
179 lines not on this page · raw message
lib/librte_eal/common/meson.build +1 -0
@@ -95,6 +95,7 @@ generic_headers = files( 'include/generic/rte_cpuflags.h', 'include/generic/rte_cycles.h', 'include/generic/rte_io.h', + 'include/generic/rte_mcslock.h', 'include/generic/rte_memcpy.h', 'include/generic/rte_pause.h', 'include/generic/rte_prefetch.h',
Signature · 1 line
2.7.4
PATCH v3 2/3 eal/mcslock: use generic msc queued lock on all arch
In reply to Phil YangLet all architectures use generic MCS queued lock implementation.
--- .../common/include/arch/arm/rte_mcslock.h | 23 ++++++++++++++++++++++ .../common/include/arch/ppc_64/rte_mcslock.h | 19 ++++++++++++++++++ .../common/include/arch/x86/rte_mcslock.h | 19 ++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 lib/librte_eal/common/include/arch/arm/rte_mcslock.h create mode 100644 lib/librte_eal/common/include/arch/ppc_64/rte_mcslock.h create mode 100644 lib/librte_eal/common/include/arch/x86/rte_mcslock.h
lib/librte_eal/common/include/arch/arm/rte_mcslock.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +*/ + +#ifndef _RTE_MCSLOCK_ARM_H_ +#define _RTE_MCSLOCK_ARM_H_ + +#ifndef RTE_FORCE_INTRINSICS +# error Platform must be built with CONFIG_RTE_FORCE_INTRINSICS +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_mcslock.h" + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_MCSLOCK_ARM_H_ */ +
lib/librte_eal/common/include/arch/ppc_64/rte_mcslock.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +*/ + +#ifndef _RTE_MCSLOCK_PPC_64_H_ +#define _RTE_MCSLOCK_PPC_64_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_mcslock.h" + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_MCSLOCK_PPC_64_H_ */ +
lib/librte_eal/common/include/arch/x86/rte_mcslock.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +*/ + +#ifndef _RTE_MCSLOCK_X86_64_H_ +#define _RTE_MCSLOCK_X86_64_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_mcslock.h" + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_MCSLOCK_X86_64_H_ */ +
Signature · 1 line
2.7.4
PATCH v3 3/3 test/mcslock: add mcs queued lock unit test
In reply to Phil YangUnit test and perf test for MCS queued lock.
--- MAINTAINERS | 1 + app/test/Makefile | 1 + app/test/autotest_data.py | 6 + app/test/autotest_test_funcs.py | 32 +++++ app/test/meson.build | 2 + app/test/test_mcslock.c | 251 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 293 insertions(+) create mode 100644 app/test/test_mcslock.c
MAINTAINERS +1 -0
@@ -237,6 +237,7 @@ F: app/test/test_rand_perf.c MCSlock - EXPERIMENTAL M: Phil Yang <[email protected]> F: lib/librte_eal/common/include/generic/rte_mcslock.h +F: app/test/test_mcslock.c ARM v7 M: Jan Viktorin <[email protected]>
app/test/Makefile +1 -0
@@ -64,6 +64,7 @@ SRCS-y += test_atomic.c SRCS-y += test_barrier.c SRCS-y += test_malloc.c SRCS-y += test_cycles.c +SRCS-y += test_mcslock.c SRCS-y += test_spinlock.c SRCS-y += test_ticketlock.c SRCS-y += test_memory.c
app/test/autotest_data.py +6 -0
@@ -177,6 +177,12 @@ "Report": None, }, { + "Name": "MCSlock autotest", + "Command": "mcslock_autotest", + "Func": mcslock_autotest, + "Report": None, + }, + { "Name": "Byte order autotest", "Command": "byteorder_autotest", "Func": default_autotest,
app/test/autotest_test_funcs.py +32 -0
@@ -164,6 +164,38 @@ def ticketlock_autotest(child, test_name): return 0, "Success" +def mcslock_autotest(child, test_name): + i = 0 + ir = 0 + child.sendline(test_name) + while True: + index = child.expect(["Test OK", + "Test Failed", + "lcore ([0-9]*) state: ([0-1])" + "MCS lock taken on core ([0-9]*)", + "MCS lock released on core ([0-9]*)", + pexpect.TIMEOUT], timeout=5) + # ok + if index == 0: + break + + # message, check ordering + elif index == 2: + if int(child.match.groups()[0]) < i: + return -1, "Fail [Bad order]" + i = int(child.match.groups()[0]) + elif index == 3: + if int(child.match.groups()[0]) < ir: + return -1, "Fail [Bad order]" + ir = int(child.match.groups()[0]) + + # fail + elif index == 4: + return -1, "Fail [Timeout]" + elif index == 1: + return -1, "Fail" + + return 0, "Success" def logs_autotest(child, test_name): child.sendline(test_name)
app/test/meson.build +2 -0
@@ -80,6 +80,7 @@ test_sources = files('commands.c', 'test_memzone.c', 'test_meter.c', 'test_metrics.c', + 'test_mcslock.c', 'test_mp_secondary.c', 'test_pdump.c', 'test_per_lcore.c',
@@ -185,6 +186,7 @@ fast_test_names = [ 'lpm6_autotest', 'malloc_autotest', 'mbuf_autotest', + 'mcslock_autotest', 'memcpy_autotest', 'memory_autotest', 'mempool_autotest',
app/test/test_mcslock.c new file +251 -0
251 lines not on this page · raw message
Signature · 1 line
2.7.4
Thomas Monjalon
Applied05/07/2019 12:27, Phil Yang:
Quoted 4 lines
Phil Yang (3):
eal/mcslock: add mcs queued lock implementation eal/mcslock: use generic msc queued lock on all arch test/mcslock: add mcs queued lock unit test
Applied, thanks
PATCH 2/3 eal/mcslock: use generic msc queued lock on all arch
In reply to Phil YangLet all architectures use generic MCS queued lock implementation.
--- .../common/include/arch/arm/rte_mcslock.h | 23 ++++++++++++++++++++++ .../common/include/arch/ppc_64/rte_mcslock.h | 19 ++++++++++++++++++ .../common/include/arch/x86/rte_mcslock.h | 19 ++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 lib/librte_eal/common/include/arch/arm/rte_mcslock.h create mode 100644 lib/librte_eal/common/include/arch/ppc_64/rte_mcslock.h create mode 100644 lib/librte_eal/common/include/arch/x86/rte_mcslock.h
lib/librte_eal/common/include/arch/arm/rte_mcslock.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +*/ + +#ifndef _RTE_MCSLOCK_ARM_H_ +#define _RTE_MCSLOCK_ARM_H_ + +#ifndef RTE_FORCE_INTRINSICS +# error Platform must be built with CONFIG_RTE_FORCE_INTRINSICS +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_mcslock.h" + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_MCSLOCK_ARM_H_ */ +
lib/librte_eal/common/include/arch/ppc_64/rte_mcslock.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +*/ + +#ifndef _RTE_MCSLOCK_PPC_64_H_ +#define _RTE_MCSLOCK_PPC_64_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_mcslock.h" + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_MCSLOCK_PPC_64_H_ */ +
lib/librte_eal/common/include/arch/x86/rte_mcslock.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +*/ + +#ifndef _RTE_MCSLOCK_X86_64_H_ +#define _RTE_MCSLOCK_X86_64_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_mcslock.h" + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_MCSLOCK_X86_64_H_ */ +
Signature · 1 line
2.7.4
PATCH 3/3 test/mcslock: add mcs queued lock unit test
In reply to Phil YangUnit test and perf test for MCS queued lock.
--- MAINTAINERS | 1 + app/test/Makefile | 1 + app/test/autotest_data.py | 6 + app/test/autotest_test_funcs.py | 32 ++++++ app/test/meson.build | 2 + app/test/test_mcslock.c | 248 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 290 insertions(+) create mode 100644 app/test/test_mcslock.c
MAINTAINERS +1 -0
@@ -225,6 +225,7 @@ F: app/test/test_ticketlock.c MCSlock - EXPERIMENTAL M: Phil Yang <[email protected]> F: lib/librte_eal/common/include/generic/rte_mcslock.h +F: app/test/test_mcslock.c ARM v7 M: Jan Viktorin <[email protected]>
app/test/Makefile +1 -0
@@ -64,6 +64,7 @@ SRCS-y += test_atomic.c SRCS-y += test_barrier.c SRCS-y += test_malloc.c SRCS-y += test_cycles.c +SRCS-y += test_mcslock.c SRCS-y += test_spinlock.c SRCS-y += test_ticketlock.c SRCS-y += test_memory.c
app/test/autotest_data.py +6 -0
@@ -177,6 +177,12 @@ "Report": None, }, { + "Name": "MCSlock autotest", + "Command": "mcslock_autotest", + "Func": mcslock_autotest, + "Report": None, + }, + { "Name": "Byte order autotest", "Command": "byteorder_autotest", "Func": default_autotest,
app/test/autotest_test_funcs.py +32 -0
@@ -164,6 +164,38 @@ def ticketlock_autotest(child, test_name): return 0, "Success" +def mcslock_autotest(child, test_name): + i = 0 + ir = 0 + child.sendline(test_name) + while True: + index = child.expect(["Test OK", + "Test Failed", + "lcore ([0-9]*) state: ([0-1])" + "MCS lock taken on core ([0-9]*)", + "MCS lock released on core ([0-9]*)", + pexpect.TIMEOUT], timeout=5) + # ok + if index == 0: + break + + # message, check ordering + elif index == 2: + if int(child.match.groups()[0]) < i: + return -1, "Fail [Bad order]" + i = int(child.match.groups()[0]) + elif index == 3: + if int(child.match.groups()[0]) < ir: + return -1, "Fail [Bad order]" + ir = int(child.match.groups()[0]) + + # fail + elif index == 4: + return -1, "Fail [Timeout]" + elif index == 1: + return -1, "Fail" + + return 0, "Success" def logs_autotest(child, test_name): child.sendline(test_name)
app/test/meson.build +2 -0
@@ -75,6 +75,7 @@ test_sources = files('commands.c', 'test_memzone.c', 'test_meter.c', 'test_metrics.c', + 'test_mcslock.c', 'test_mp_secondary.c', 'test_pdump.c', 'test_per_lcore.c',
@@ -167,6 +168,7 @@ fast_parallel_test_names = [ 'lpm6_autotest', 'malloc_autotest', 'mbuf_autotest', + 'mcslock_autotest', 'memcpy_autotest', 'memory_autotest', 'mempool_autotest',
app/test/test_mcslock.c new file +248 -0
248 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v1 3/3] test/mcslock: add mcs queued lock unit test
Hi,
Quoted 2 lines
Unit test and perf test for MCS queued lock.
Perf test is important of course, but first I think we need
more robust functional test to make sure that lock does work properly. At least something like ticketlock test but probably with bigger number of iterations. 10K seems quite small here.
In fact with this one we'll have 3 lock methods, I think it makes sense to have one united UT framework for them, so only actual lock/unlock would be different. Konstantin
Quoted 375 lines
Signed-off-by Phil Yang <[email protected]>Reviewed-by Gavin Hu <[email protected]>Reviewed-by Honnappa Nagarahalli <[email protected]>--- MAINTAINERS | 1 + app/test/Makefile | 1 + app/test/autotest_data.py | 6 + app/test/autotest_test_funcs.py | 32 ++++++ app/test/meson.build | 2 + app/test/test_mcslock.c | 248 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 290 insertions(+) create mode 100644 app/test/test_mcslock.cMAINTAINERS +1
-0@@ -225,6 +225,7 @@ F: app/test/test_ticketlock.c MCSlock - EXPERIMENTAL M: Phil Yang <[email protected]> F: lib/librte_eal/common/include/generic/rte_mcslock.h +F: app/test/test_mcslock.c ARM v7 M: Jan Viktorin <[email protected]>app/test/Makefile +1
-0@@ -64,6 +64,7 @@ SRCS-y += test_atomic.c SRCS-y += test_barrier.c SRCS-y += test_malloc.c SRCS-y += test_cycles.c +SRCS-y += test_mcslock.c SRCS-y += test_spinlock.c SRCS-y += test_ticketlock.c SRCS-y += test_memory.capp/test/autotest_data.py +6
-0@@ -177,6 +177,12 @@ "Report": None, }, { + "Name": "MCSlock autotest", + "Command": "mcslock_autotest", + "Func": mcslock_autotest, + "Report": None, + }, + { "Name": "Byte order autotest", "Command": "byteorder_autotest", "Func": default_autotest,app/test/autotest_test_funcs.py +32
-0@@ -164,6 +164,38 @@ def ticketlock_autotest(child, test_name): return 0, "Success" +def mcslock_autotest(child, test_name): + i = 0 + ir = 0 + child.sendline(test_name) + while True: + index = child.expect(["Test OK", + "Test Failed", + "lcore ([0-9]*) state: ([0-1])" + "MCS lock taken on core ([0-9]*)", + "MCS lock released on core ([0-9]*)", + pexpect.TIMEOUT], timeout=5) + # ok + if index == 0: + break + + # message, check ordering + elif index == 2: + if int(child.match.groups()[0]) < i: + return -1, "Fail [Bad order]" + i = int(child.match.groups()[0]) + elif index == 3: + if int(child.match.groups()[0]) < ir: + return -1, "Fail [Bad order]" + ir = int(child.match.groups()[0]) + + # fail + elif index == 4: + return -1, "Fail [Timeout]" + elif index == 1: + return -1, "Fail" + + return 0, "Success" def logs_autotest(child, test_name): child.sendline(test_name)app/test/meson.build +2
-0@@ -75,6 +75,7 @@ test_sources = files('commands.c', 'test_memzone.c', 'test_meter.c', 'test_metrics.c', + 'test_mcslock.c', 'test_mp_secondary.c', 'test_pdump.c', 'test_per_lcore.c',@@ -167,6 +168,7 @@ fast_parallel_test_names = [ 'lpm6_autotest', 'malloc_autotest', 'mbuf_autotest', + 'mcslock_autotest', 'memcpy_autotest', 'memory_autotest', 'mempool_autotest',app/test/test_mcslock.c new file +248
-1@@ -0,0 +1,248 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +*/ + +#include <stdio.h> +#include <stdint.h> +#include <inttypes.h> +#include <string.h> +#include <unistd.h> +#include <sys/queue.h> + +#include <rte_common.h> +#include <rte_memory.h> +#include <rte_per_lcore.h> +#include <rte_launch.h> +#include <rte_eal.h> +#include <rte_lcore.h> +#include <rte_cycles.h> +#include <rte_mcslock.h> +#include <rte_atomic.h> + +#include "test.h" + +/* +* RTE MCS lock test +* ================= +* +* These tests are derived from spin lock test cases. +* +* - The functional test takes all of these locks and launches the +* ''test_mcslock_per_core()'' function on each core (except the master). +* +* - The function takes the global lock, display something, then releases +* the global lock on each core. +* +* - A load test is carried out, with all cores attempting to lock a single +* lock multiple times. +*/ +#include <rte_per_lcore.h> + +RTE_DEFINE_PER_LCORE (rte_mcslock_t, _ml_me); +RTE_DEFINE_PER_LCORE (rte_mcslock_t, _ml_try_me); +RTE_DEFINE_PER_LCORE (rte_mcslock_t, _ml_perf_me); + +rte_mcslock_t *p_ml; +rte_mcslock_t *p_ml_try; +rte_mcslock_t *p_ml_perf; + +static unsigned int count; + +static rte_atomic32_t synchro; + +static int +test_mcslock_per_core (__attribute__((unused))void *arg) +{ +/* Per core me node. */ +rte_mcslock_t ml_me =RTE_PER_LCORE (_ml_me); + +rte_mcslock_lock (&p_ml, &ml_me); +printf ("MCS lock taken on core %u\n" ,rte_lcore_id ()); +rte_mcslock_unlock (&p_ml, &ml_me); +printf ("MCS lock released on core %u\n" ,rte_lcore_id ()); + +return 0 ; +} + +static uint64_t time_count[RTE_MAX_LCORE ] = {0 }; + +#define MAX_LOOP 10000 + +static int +load_loop_fn (void *func_param) +{ +uint64_t time_diff =0 , begin; +uint64_t hz =rte_get_timer_hz (); +volatile uint64_t lcount =0 ; +const int use_lock = *(int *)func_param; +const unsigned int lcore =rte_lcore_id (); + +/**< Per core me node. */ +rte_mcslock_t ml_perf_me =RTE_PER_LCORE (_ml_perf_me); + +/* wait synchro */ +while (rte_atomic32_read (&synchro) ==0 ) + ; + + begin =rte_get_timer_cycles (); +while (lcount <MAX_LOOP ) { +if (use_lock) +rte_mcslock_lock (&p_ml_perf, &ml_perf_me); + + lcount++; +if (use_lock) +rte_mcslock_unlock (&p_ml_perf, &ml_perf_me); + } + time_diff =rte_get_timer_cycles () - begin; + time_count[lcore] = time_diff *1000000 / hz; +return 0 ; +} + +static int +test_mcslock_perf (void ) +{ +unsigned int i; +uint64_t total =0 ; +int lock =0 ; +const unsigned int lcore =rte_lcore_id (); + +printf ("\nTest with no lock on single core...\n" ); +rte_atomic32_set (&synchro,1 ); +load_loop_fn (&lock); +printf ("Core [%u] Cost Time = %" PRIu64" us\n" , + lcore, time_count[lcore]); +memset (time_count,0 ,sizeof (time_count)); + +printf ("\nTest with lock on single core...\n" ); + lock =1 ; +rte_atomic32_set (&synchro,1 ); +load_loop_fn (&lock); +printf ("Core [%u] Cost Time = %" PRIu64" us\n" , + lcore, time_count[lcore]); +memset (time_count,0 ,sizeof (time_count)); + +printf ("\nTest with lock on %u cores...\n" , (rte_lcore_count ()-1 )); + +rte_atomic32_set (&synchro,0 ); +rte_eal_mp_remote_launch (load_loop_fn, &lock,SKIP_MASTER ); +rte_atomic32_set (&synchro,1 ); + +rte_eal_mp_wait_lcore (); + +RTE_LCORE_FOREACH_SLAVE (i) { +printf ("Core [%u] Cost Time = %" PRIu64" us\n" , + i, time_count[i]); + total += time_count[i]; + } + +printf ("Total Cost Time = %" PRIu64" us\n" , total); + +return 0 ; +} + +/* +* Use rte_mcslock_trylock() to trylock a mcs lock object, +* If it could not lock the object successfully, it would +* return immediately. +*/ +static int +test_mcslock_try (__attribute__((unused))void *arg) +{ +/**< Per core me node. */ +rte_mcslock_t ml_me =RTE_PER_LCORE (_ml_me); +rte_mcslock_t ml_try_me =RTE_PER_LCORE (_ml_try_me); + +/* Locked ml_try in the master lcore, so it should fail +* when trying to lock it in the slave lcore. +*/ +if (rte_mcslock_trylock (&p_ml_try, &ml_try_me) ==0 ) { +rte_mcslock_lock (&p_ml, &ml_me); + count++; +rte_mcslock_unlock (&p_ml, &ml_me); + } + +return 0 ; +} + + +/* +* Test rte_eal_get_lcore_state() in addition to mcs locks +* as we have "waiting" then "running" lcores. +*/ +static int +test_mcslock (void ) +{ +int ret =0 ; +int i; + +/* Define per core me node. */ +rte_mcslock_t ml_me =RTE_PER_LCORE (_ml_me); +rte_mcslock_t ml_try_me =RTE_PER_LCORE (_ml_try_me); + +/* +* Test mcs lock & unlock on each core +*/ + +/* slave cores should be waiting: print it */ +RTE_LCORE_FOREACH_SLAVE (i) { +printf ("lcore %d state: %d\n" , i, + (int )rte_eal_get_lcore_state (i)); + } + +rte_mcslock_lock (&p_ml, &ml_me); + +RTE_LCORE_FOREACH_SLAVE (i) { +rte_eal_remote_launch (test_mcslock_per_core,NULL , i); + } + +/* slave cores should be busy: print it */ +RTE_LCORE_FOREACH_SLAVE (i) { +printf ("lcore %d state: %d\n" , i, + (int )rte_eal_get_lcore_state (i)); + } + +rte_mcslock_unlock (&p_ml, &ml_me); + +rte_eal_mp_wait_lcore (); + +/* +* Test if it could return immediately from try-locking a locked object. +* Here it will lock the mcs lock object first, then launch all the +* slave lcores to trylock the same mcs lock object. +* All the slave lcores should give up try-locking a locked object and +* return immediately, and then increase the "count" initialized with +* zero by one per times. +* We can check if the "count" is finally equal to the number of all +* slave lcores to see if the behavior of try-locking a locked +* mcslock object is correct. +*/ +if (rte_mcslock_trylock (&p_ml_try, &ml_try_me) ==0 ) +return -1 ; + + count =0 ; +RTE_LCORE_FOREACH_SLAVE (i) { +rte_eal_remote_launch (test_mcslock_try,NULL , i); + } +rte_mcslock_unlock (&p_ml_try, &ml_try_me); +rte_eal_mp_wait_lcore (); + +/* Test is_locked API */ +if (rte_mcslock_is_locked (p_ml)) { +printf ("mcslock is locked but it should not be\n" ); +return -1 ; + } + +/* Counting the locked times in each core */ +rte_mcslock_lock (&p_ml, &ml_me); +if (count != (rte_lcore_count () -1 )) + ret =-1 ; +rte_mcslock_unlock (&p_ml, &ml_me); + +/* mcs lock perf test */ +if (test_mcslock_perf () <0 ) +return -1 ; + +return ret; +} + +REGISTER_TEST_COMMAND (mcslock_autotest, test_mcslock); --2.7.4
Re: [dpdk-dev] [PATCH v1 3/3] test/mcslock: add mcs queued lock unit test
Quoted 5 lines
Hi,
Quoted 2 lines
Unit test and perf test for MCS queued lock.
Quoted 8 lines
Perf test is important of course, but first I think we need more robust functional test to make sure that lock does work properly.
At least something like ticketlock test but probably with bigger number of iterations.
10K seems quite small here.
In fact with this one we'll have 3 lock methods, I think it makes sense to have one united UT framework for them, so only actual lock/unlock would be different.
+1
Quoted 3 lines
Konstantin
Quoted 1 line
<snip>
Re: [dpdk-dev] [PATCH v1 3/3] test/mcslock: add mcs queued lock unit test
Hi,
Quoted 21 lines
-----Original Message-----
From: Honnappa Nagarahalli <[email protected]>
Sent: Friday, June 7, 2019 1:27 PM
To: Ananyev, Konstantin <[email protected]>; Phil Yang (Arm Technology China) <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; Gavin Hu (Arm Technology China) <[email protected]>; nd <[email protected]>; nd <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v1 3/3] test/mcslock: add mcs queued lock unit testQuoted 10 lines
Hi,
Quoted 2 lines
Unit test and perf test for MCS queued lock.
Perf test is important of course, but first I think we need more robust functional test to make sure that lock does work properly. At least something like ticketlock test but probably with bigger number of iterations.
10K seems quite small here.
Yes. I agree. I think we should also consider the total time consuming of the test. As more cores are involved in the lock contention, more time is required to complete the test.
Quoted 3 lines
Quoted 3 lines
In fact with this one we'll have 3 lock methods, I think it makes sense to have one united UT framework for them, so only actual lock/unlock would be different.
+1.
Since the APIs of MCS lock is different with spinlock and ticket lock, so I am wondering that what will this united UT framework look like? Will it be the same test case that integrates 3 sets of lock tests running with different cmd line?
Quoted 7 lines
+1
Quoted 3 lines
Konstantin
Quoted 1 line
<snip>
Thanks,
Phil Yang
Quoted 50 lines · Phil Yang
This patch set added MCS lock library and its unit test.
The MCS lock (proposed by JOHN M. MELLOR-CRUMMEY and MICHAEL L. SCOTT) provides
scalability by spinning on a CPU/thread local variable which avoids expensive
cache bouncings. It provides fairness by maintaining a list of acquirers and
passing the lock to each CPU/thread in the order they acquired the lock.References:
1.
http://web.mit.edu/6.173/www/currentsemester/readings/R06-scalable-synchronization-1991.pdf
2. https://lwn.net/Articles/590243/Mirco-benchmarking result:
------------------------------------------------------------------------------------------------
MCS lock | spinlock | ticket
lock------------------------------+--------------------------------+--------------------------------
Test with lock on 13 cores... | Test with lock on 14 cores... | Test with lock on 14 cores...
Core [15] Cost Time = 22426 us| Core [14] Cost Time = 47974 us| Core
[14] cost time = 66761 us
Core [16] Cost Time = 22382 us| Core [15] Cost Time = 46979 us| Core
[15] cost time = 66766 us
Core [17] Cost Time = 22294 us| Core [16] Cost Time = 46044 us| Core
[16] cost time = 66761 us
Core [18] Cost Time = 22412 us| Core [17] Cost Time = 28793 us| Core
[17] cost time = 66767 us
Core [19] Cost Time = 22407 us| Core [18] Cost Time = 48349 us| Core
[18] cost time = 66758 us
Core [20] Cost Time = 22436 us| Core [19] Cost Time = 19381 us| Core
[19] cost time = 66766 us
Core [21] Cost Time = 22414 us| Core [20] Cost Time = 47914 us| Core
[20] cost time = 66763 us
Core [22] Cost Time = 22405 us| Core [21] Cost Time = 48333 us| Core
[21] cost time = 66766 us
Core [23] Cost Time = 22435 us| Core [22] Cost Time = 38900 us| Core
[22] cost time = 66749 us
Core [24] Cost Time = 22401 us| Core [23] Cost Time = 45374 us| Core
[23] cost time = 66765 us
Core [25] Cost Time = 22408 us| Core [24] Cost Time = 16121 us| Core
[24] cost time = 66762 us
Core [26] Cost Time = 22380 us| Core [25] Cost Time = 42731 us| Core
[25] cost time = 66768 us
Core [27] Cost Time = 22395 us| Core [26] Cost Time = 29439 us| Core
[26] cost time = 66768 us
Quoted 9 lines
| Core [27] Cost Time = 38071 us| Core[27] cost time = 66767 us
------------------------------+--------------------------------+--------------------------------
Total Cost Time = 291195 us | Total Cost Time = 544403 us | Total
cost time = 934687 us------------------------------------------------------------------------------------------------
Had a quick look, interesting.
Quick comments:
- your numbers are for 13 cores, while the other are for 14, what is the reason?
- do we need per architecture header? all I can see is generic code, we might as well directly put rte_mcslock.h in the common/include directory.
- could we replace the current spinlock with this approach? is this more expensive than spinlock on lowly contended locks? is there a reason we want to keep all these approaches? we could have now 3 lock implementations.
- do we need to write the authors names in full capitalized version? it seems like you are shouting :-)
Signature · 1 line
David Marchand
On Wed, Jun 5, 2019 at 6:00 PM Phil Yang <[email protected]<mailto:[email protected]>> wrote:
This patch set added MCS lock library and its unit test.
The MCS lock (proposed by JOHN M. MELLOR-CRUMMEY and MICHAEL L. SCOTT) provides scalability by spinning on a CPU/thread local variable which avoids expensive cache bouncings. It provides fairness by maintaining a list of acquirers and passing the lock to each CPU/thread in the order they acquired the lock.
References:
1. http://web.mit.edu/6.173/www/currentsemester/readings/R06-scalable-synchronization-1991.pdf
2. https://lwn.net/Articles/590243/
Mirco-benchmarking result:
------------------------------------------------------------------------------------------------
MCS lock | spinlock | ticket lock
------------------------------+--------------------------------+--------------------------------
Test with lock on 13 cores... | Test with lock on 14 cores... | Test with lock on 14 cores...
Core [15] Cost Time = 22426 us| Core [14] Cost Time = 47974 us| Core [14] cost time = 66761 us
Core [16] Cost Time = 22382 us| Core [15] Cost Time = 46979 us| Core [15] cost time = 66766 us
Core [17] Cost Time = 22294 us| Core [16] Cost Time = 46044 us| Core [16] cost time = 66761 us
Core [18] Cost Time = 22412 us| Core [17] Cost Time = 28793 us| Core [17] cost time = 66767 us
Core [19] Cost Time = 22407 us| Core [18] Cost Time = 48349 us| Core [18] cost time = 66758 us
Core [20] Cost Time = 22436 us| Core [19] Cost Time = 19381 us| Core [19] cost time = 66766 us
Core [21] Cost Time = 22414 us| Core [20] Cost Time = 47914 us| Core [20] cost time = 66763 us
Core [22] Cost Time = 22405 us| Core [21] Cost Time = 48333 us| Core [21] cost time = 66766 us
Core [23] Cost Time = 22435 us| Core [22] Cost Time = 38900 us| Core [22] cost time = 66749 us
Core [24] Cost Time = 22401 us| Core [23] Cost Time = 45374 us| Core [23] cost time = 66765 us
Core [25] Cost Time = 22408 us| Core [24] Cost Time = 16121 us| Core [24] cost time = 66762 us
Core [26] Cost Time = 22380 us| Core [25] Cost Time = 42731 us| Core [25] cost time = 66768 us
Core [27] Cost Time = 22395 us| Core [26] Cost Time = 29439 us| Core [26] cost time = 66768 us
| Core [27] Cost Time = 38071 us| Core [27] cost time = 66767 us------------------------------+--------------------------------+--------------------------------
Total Cost Time = 291195 us | Total Cost Time = 544403 us | Total cost time = 934687 us
------------------------------------------------------------------------------------------------
Had a quick look, interesting.
Quick comments:
- your numbers are for 13 cores, while the other are for 14, what is the reason?
- do we need per architecture header? all I can see is generic code, we might as well directly put rte_mcslock.h in the common/include directory.
- could we replace the current spinlock with this approach? is this more expensive than spinlock on lowly contended locks? is there a reason we want to keep all these approaches? we could have now 3 lock implementations.
- do we need to write the authors names in full capitalized version? it seems like you are shouting :-)
[Honnappa] IMO, writing full names is a cultural thing? I do not see any harm. But, I do think, we do not need to capitalize everything.
--
David Marchand
[Honnappa] This mail is appearing as HTML, would be good to change to text mode. It is much easier to add inline comments.
From: David Marchand <[email protected]>
Sent: Thursday, June 6, 2019 12:30 AM
To: Phil Yang (Arm Technology China) <[email protected]>
Cc: dev <[email protected]>; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Gavin Hu (Arm Technology China) <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v1 0/3] MCS queued lock implementation
On Wed, Jun 5, 2019 at 6:00 PM Phil Yang <[email protected]<mailto:[email protected]>> wrote:
This patch set added MCS lock library and its unit test.
The MCS lock (proposed by JOHN M. MELLOR-CRUMMEY and MICHAEL L. SCOTT) provides scalability by spinning on a CPU/thread local variable which avoids expensive cache bouncings. It provides fairness by maintaining a list of acquirers and passing the lock to each CPU/thread in the order they acquired the lock.
References:
1. http://web.mit.edu/6.173/www/currentsemester/readings/R06-scalable-synchronization-1991.pdf
2. https://lwn.net/Articles/590243/
Mirco-benchmarking result:
------------------------------------------------------------------------------------------------
MCS lock | spinlock | ticket lock
------------------------------+--------------------------------+--------------------------------
Test with lock on 13 cores... | Test with lock on 14 cores... | Test with lock on 14 cores...
Core [15] Cost Time = 22426 us| Core [14] Cost Time = 47974 us| Core [14] cost time = 66761 us
Core [16] Cost Time = 22382 us| Core [15] Cost Time = 46979 us| Core [15] cost time = 66766 us
Core [17] Cost Time = 22294 us| Core [16] Cost Time = 46044 us| Core [16] cost time = 66761 us
Core [18] Cost Time = 22412 us| Core [17] Cost Time = 28793 us| Core [17] cost time = 66767 us
Core [19] Cost Time = 22407 us| Core [18] Cost Time = 48349 us| Core [18] cost time = 66758 us
Core [20] Cost Time = 22436 us| Core [19] Cost Time = 19381 us| Core [19] cost time = 66766 us
Core [21] Cost Time = 22414 us| Core [20] Cost Time = 47914 us| Core [20] cost time = 66763 us
Core [22] Cost Time = 22405 us| Core [21] Cost Time = 48333 us| Core [21] cost time = 66766 us
Core [23] Cost Time = 22435 us| Core [22] Cost Time = 38900 us| Core [22] cost time = 66749 us
Core [24] Cost Time = 22401 us| Core [23] Cost Time = 45374 us| Core [23] cost time = 66765 us
Core [25] Cost Time = 22408 us| Core [24] Cost Time = 16121 us| Core [24] cost time = 66762 us
Core [26] Cost Time = 22380 us| Core [25] Cost Time = 42731 us| Core [25] cost time = 66768 us
Core [27] Cost Time = 22395 us| Core [26] Cost Time = 29439 us| Core [26] cost time = 66768 us
| Core [27] Cost Time = 38071 us| Core [27] cost time = 66767 us------------------------------+--------------------------------+--------------------------------
Total Cost Time = 291195 us | Total Cost Time = 544403 us | Total cost time = 934687 us
------------------------------------------------------------------------------------------------
Had a quick look, interesting.
Hi David,
Thanks for your comments.
Quick comments:
- your numbers are for 13 cores, while the other are for 14, what is the reason?
[Phil]The test case skipped the master thread while doing the load test. The master thread just controls the trigger. So all the other threads acquiring the lock and running the same workload at the same time. Actually, there is no difference on per core performance when it involved the master thread in the load test.
- do we need per architecture header? all I can see is generic code, we might as well directly put rte_mcslock.h in the common/include directory. [Phil] I just trying to leave it for architecture specific optimization.
- could we replace the current spinlock with this approach? is this more expensive than spinlock on lowly contended locks? is there a reason we want to keep all these approaches? we could have now 3 lock implementations. [Phil] Under the high lock contention scenarios, MCS is much better than spinlock. However, MCS lock is more complicated than spinlock and more expensive than spinlock in the single thread scenario. E.g:
Test with lock on single core..
MCS lock :
Core [14] Cost Time = 327 us
Spinlock:
Core [14] Cost Time = 258 us
ticket lock:
Core [14] cost time = 195 us
I think in low-contention scenarios but you still need mutual exclusion you can use spinlock. It is lighter. I think that all depends on the application.
- do we need to write the authors names in full capitalized version? it seems like you are shouting :-) [Phil] :-) I will modify it in the next version. Thanks.
--
David Marchand
Thanks,
Phil Yang
Quoted 30 lines · On Wed, 5 Jun 2019 23:58:45 +0800 Phil Yang <[email protected]> wrote:
This patch set added MCS lock library and its unit test.
The MCS lock (proposed by JOHN M. MELLOR-CRUMMEY and MICHAEL L. SCOTT) provides scalability by spinning on a CPU/thread local variable which avoids expensive cache bouncings. It provides fairness by maintaining a list of acquirers and passing the lock to each CPU/thread in the order they acquired the lock.
References:
1. http://web.mit.edu/6.173/www/currentsemester/readings/R06-scalable-synchronization-1991.pdf
2. https://lwn.net/Articles/590243/Mirco-benchmarking result:
------------------------------------------------------------------------------------------------
MCS lock | spinlock | ticket lock
------------------------------+--------------------------------+--------------------------------Test with lock on 13 cores... | Test with lock on 14 cores... | Test with lock on 14 cores... Core [15] Cost Time = 22426 us| Core [14] Cost Time = 47974 us| Core [14] cost time = 66761 us Core [16] Cost Time = 22382 us| Core [15] Cost Time = 46979 us| Core [15] cost time = 66766 us Core [17] Cost Time = 22294 us| Core [16] Cost Time = 46044 us| Core [16] cost time = 66761 us Core [18] Cost Time = 22412 us| Core [17] Cost Time = 28793 us| Core [17] cost time = 66767 us Core [19] Cost Time = 22407 us| Core [18] Cost Time = 48349 us| Core [18] cost time = 66758 us Core [20] Cost Time = 22436 us| Core [19] Cost Time = 19381 us| Core [19] cost time = 66766 us Core [21] Cost Time = 22414 us| Core [20] Cost Time = 47914 us| Core [20] cost time = 66763 us Core [22] Cost Time = 22405 us| Core [21] Cost Time = 48333 us| Core [21] cost time = 66766 us Core [23] Cost Time = 22435 us| Core [22] Cost Time = 38900 us| Core [22] cost time = 66749 us Core [24] Cost Time = 22401 us| Core [23] Cost Time = 45374 us| Core [23] cost time = 66765 us Core [25] Cost Time = 22408 us| Core [24] Cost Time = 16121 us| Core [24] cost time = 66762 us Core [26] Cost Time = 22380 us| Core [25] Cost Time = 42731 us| Core [25] cost time = 66768 us Core [27] Cost Time = 22395 us| Core [26] Cost Time = 29439 us| Core [26] cost time = 66768 us | Core [27] Cost Time = 38071 us| Core [27] cost time = 66767 us
Quoted 3 lines
------------------------------+--------------------------------+--------------------------------
Total Cost Time = 291195 us | Total Cost Time = 544403 us | Total cost time = 934687 us
------------------------------------------------------------------------------------------------
From the user point of view there needs to be clear recommendations on which lock type to use.
And if one of the lock types is always slower it should be deprecated long term.
+David
(had similar questions)
Quoted 66 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Wednesday, June 5, 2019 11:48 AM
To: Phil Yang (Arm Technology China) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Gavin Hu (Arm Technology China) <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v1 0/3] MCS queued lock implementationQuoted 3 lines · On Wed, 5 Jun 2019 23:58:45 +0800 Phil Yang <[email protected]> wrote:
This patch set added MCS lock library and its unit test.
The MCS lock (proposed by JOHN M. MELLOR-CRUMMEY and MICHAEL L.
SCOTT)
Quoted 3 lines
provides scalability by spinning on a CPU/thread local variable which avoids expensive cache bouncings. It provides fairness by maintaining a list of acquirers and passing the lock to each CPU/thread in the order they
acquired the lock.
Quoted 7 lines
References:
1.
http://web.mit.edu/6.173/www/currentsemester/readings/R06-scalable-syn
chronization-1991.pdf
2. https://lwn.net/Articles/590243/Quoted 10 lines
Mirco-benchmarking result:
------------------------------------------------------------------------------------------------
MCS lock | spinlock | ticket lock
------------------------------+--------------------------------+------
------------------------------+--------------------------------+------
------------------------------+--------------------------------+------
------------------------------+--------------------------------+------
------------------------------+--------------------------------+------
------------------------------+--------------------------------+--
Test with lock on 13 cores... | Test with lock on 14 cores... | Test with lockon 14 cores...
Quoted 5 lines
Core [15] Cost Time = 22426 us| Core [14] Cost Time = 47974 us| Core
[14] cost time = 66761 us Core [16] Cost Time = 22382 us| Core [15] Cost Time = 46979 us| Core [15] cost time = 66766 us Core [17] Cost Time = 22294 us| Core [16] Cost Time = 46044 us| Core [16] cost time = 66761 us Core [18] Cost Time = 22412 us| Core [17] Cost Time =Quoted 8 lines
28793 us| Core [17] cost time = 66767 us Core [19] Cost Time = 22407 us| Core [18] Cost Time = 48349 us| Core [18] cost time = 66758 us Core [20] Cost Time = 22436 us| Core [19] Cost Time = 19381 us| Core
[19] cost time = 66766 us Core [21] Cost Time = 22414 us| Core [20] Cost Time = 47914 us| Core [20] cost time = 66763 us Core [22] Cost Time = 22405 us| Core [21] Cost Time = 48333 us| Core [21] cost time = 66766 us Core [23] Cost Time = 22435 us| Core [22] Cost Time = 38900 us| Core [22] cost time = 66749 us Core [24] Cost Time = 22401 us|Core [23] Cost Time = 45374 us| Core [23] cost time = 66765 us Core [25] Cost Time = 22408 us| Core [24] Cost Time = 16121 us| Core [24] cost time = 66762 us Core [26] Cost Time = 22380 us| Core [25] Cost Time = 42731 us| Core [25] cost time = 66768 us Core [27] Cost Time = 22395 us| Core [26] Cost Time = 29439 us| Core [26] cost time = 66768 us
Quoted 9 lines
| Core [27] Cost Time = 38071 us| Core[27] cost time = 66767 us
------------------------------+--------------------------------+------
------------------------------+--------------------------------+------
------------------------------+--------------------------------+------
------------------------------+--------------------------------+------
------------------------------+--------------------------------+------
------------------------------+--------------------------------+--
Total Cost Time = 291195 us | Total Cost Time = 544403 us | Total cost
Quoted 6 lines
time = 934687 us
Quoted 2 lines
----------------------------------------------------------------------
--------------------------From the user point of view there needs to be clear recommendations on which lock type to use.
I think the data about fairness needs to be added to this - especially for ticket lock. IMO, we should consider fairness and space (cache lines) along with cycles.
Quoted 2 lines
And if one of the lock types is always slower it should be deprecated long term.
The ticket lock can be a drop-in replacement for spinlock. Gavin is working on a patch which will make ticket lock as the backend for spinlock through a configuration. But the performance needs to be considered.
05/06/2019 17:58, Phil Yang:
Quoted 1 line
This patch set added MCS lock library and its unit test.
It seems this patch is targetting 19.08, however it missed the proposal deadline by 2 days.
+Cc techboard for a decision.
05/06/2019 17:58, Phil Yang:
Quoted 6 lines
This patch set added MCS lock library and its unit test.
The MCS lock (proposed by JOHN M. MELLOR-CRUMMEY and MICHAEL L. SCOTT) provides scalability by spinning on a CPU/thread local variable which avoids expensive cache bouncings. It provides fairness by maintaining a list of acquirers and passing the lock to each CPU/thread in the order they acquired the lock.
What is the plan for this patch?
Do we try to get more reviews for a merge in 19.08-rc2? Or we target 19.11?
Quoted 12 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Friday, July 5, 2019 4:12 AM
To: Phil Yang (Arm Technology China) <[email protected]>; Honnappa Nagarahalli <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Gavin Hu (Arm Technology China) <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v1 0/3] MCS queued lock implementation05/06/2019 17:58, Phil Yang:
Quoted 2 lines
This patch set added MCS lock library and its unit test.
Quoted 8 lines
Quoted 1 line
The MCS lock (proposed by JOHN M. MELLOR-CRUMMEY and MICHAEL L.
SCOTT) provides
Quoted 1 line
scalability by spinning on a CPU/thread local variable which avoids
expensive
Quoted 2 lines
cache bouncings. It provides fairness by maintaining a list of acquirers and passing the lock to each CPU/thread in the order they acquired the lock.
What is the plan for this patch?
I have reworked this patch and addressed all the comments in the previous version. Please review the v3.
Quoted 3 lines
Do we try to get more reviews for a merge in 19.08-rc2? Or we target 19.11?
Thank,
Phil