加速Linux程序:Intel TSX事务同步扩展

0 下载量 21 浏览量 更新于2024-07-14 收藏 133KB PDF 举报
"Adding Lock Elision to Linux - Slides (2012)" by Andi Kleen 这篇演讲是关于在Linux系统中引入锁消除技术的讨论,由Andi Kleen在2012年的Linux Plumbers Conference上发表。锁消除是一种优化技术,旨在提升现有使用锁的程序性能,而不是引导开发者采用全新的事务性内存编程模型。 **事务性内存(Transactional Memory)编程模型** 事务性内存编程提供了一种新的编程范式,它允许可预测性和并发性的提升,而无需像传统锁定机制那样处理同步问题。然而,该演讲并不专注于介绍TM编程模型,而是关注如何利用这种技术来加速已有锁定机制的程序。 **Intel的Transactional Synchronization Extensions (Intel TSX)** Intel TSX是Intel处理器的一个特性,它提供了硬件支持的事务性同步扩展,使得程序员可以在指定的临界区执行事务性操作。如果事务成功,会原子性地提交;如果失败,则回滚状态并丢弃更新。Intel TSX的目标是通过锁消除技术实现细粒度的性能提升,而只需要粗粒度的努力。它超越了仅仅降低锁延迟的优化,进一步发掘隐藏的并行性。 **接口与关键区域识别** 为了实现锁消除,Intel TSX使用了XACQUIRE和XRELEASE前缀。这两个前缀是向后兼容的提示,在非TSX系统上会被忽略。它们使得代码可以推测性地执行临界区,而不需要实际获取锁。硬件会缓冲加载和存储操作,并保存寄存器的状态。然后,硬件尝试进行提交,如果在事务期间没有冲突,就会成功;若有冲突,事务则会失败并回滚。 **锁消除的意义** 锁消除技术的核心在于,它可以避免因等待锁而产生的上下文切换和竞争开销,从而提高多线程程序的效率。通过将事务性编程的概念应用于已有的锁机制,开发者可以在不完全重构代码的情况下,享受到事务性内存的潜在性能优势。 总结来说,这篇演讲探讨了如何在Linux中利用Intel TSX硬件特性来改进锁的性能,通过锁消除技术实现更高效的数据访问和并发控制,以提升系统的整体吞吐量。这一技术对于优化多线程和多核环境下的软件性能具有重要意义。
2023-06-11 上传

make for plat=atlas310 cross=aarch64-ascend310-linux-gnu- LDFLAGS=-Wl,--gc-sections -static -L/home/257916/server/test/v1.1/Trunk/build/../src/thirdpart/libs/atlas310 -L/home/257916/server/test/v1.1/Trunk/build/../lib/atlas310 -ldw -lbs -lpthread -lm EXTRA_CFLAGS=-DSVN_VERSION="\"64670"\" -I /net -DOSA_MODULE_NAME=Spectrum-Convert@64670 -DBUILD_DATE="\"Mon, 24 Jul 2023 19:48:54 +0800"\" CFLAGS=-D_GNU_SOURCE -I/home/257916/server/test/v1.1/Trunk/build/../include -I/home/257916/server/test/v1.1/Trunk/build/../src/base/include -I/home/257916/server/test/v1.1/Trunk/build/../src/base/test/include -I/home/257916/server/test/v1.1/Trunk/build/../src/decode/include -I/home/257916/server/test/v1.1/Trunk/build/../src/decode/test/include -I/home/257916/server/test/v1.1/Trunk/build/../src/fourier/include -I/home/257916/server/test/v1.1/Trunk/build/../src/fourier/test/include -I/home/257916/server/test/v1.1/Trunk/build/../src/include -I/home/257916/server/test/v1.1/Trunk/build/../src/service/include -I/home/257916/server/test/v1.1/Trunk/build/../src/service/test/include -I/home/257916/server/test/v1.1/Trunk/build/../src/draw/include -I/home/257916/server/test/v1.1/Trunk/build/../src/draw/test/include -I/home/257916/server/test/v1.1/Trunk/build/../tools/include -fPIC -ffunction-sections -fdata-sections -g -Wall -O1 -c -o ############################################################ mkdir -p /home/257916/server/test/v1.1/Trunk/build/../bin/atlas310 aarch64-ascend310-linux-gnu-g++ -o draw test/src/draw_pic_test.o -Wl,--gc-sections -static -L/home/257916/server/test/v1.1/Trunk/build/../src/thirdpart/libs/atlas310 -L/home/257916/server/test/v1.1/Trunk/build/../lib/atlas310 -ldw -lbs -lpthread -lm /opt/Atlas310-ascend/toolkit/toolchain/hcc/bin/../lib64/gcc/aarch64-target-linux-gnu/7.3.0/../../../../aarch64-target-linux-gnu/bin/ld: test/src/draw_pic_test.o: Relocations in generic ELF (EM: 62) /opt/Atlas310-ascend/toolkit/toolchain/hcc/bin/../lib64/gcc/aarch64-target-linux-gnu/7.3.0/../../../../aarch64-target-linux-gnu/bin/ld: test/src/draw_pic_test.o: Relocations in generic ELF (EM: 62) /opt/Atlas310-ascend/toolkit/toolchain/hcc/bin/../lib64/gcc/aarch64-target-linux-gnu/7.3.0/../../../../aarch64-target-linux-gnu/bin/ld: test/src/draw_pic_test.o: Relocations in generic ELF (EM: 62) /opt/Atlas310-ascend/toolkit/toolchain/hcc/bin/../lib64/gcc/aarch64-target-linux-gnu/7.3.0/../../../../aarch64-target-linux-gnu/bin/ld: test/src/draw_pic_test.o: Relocations in generic ELF (EM: 62) /opt/Atlas310-ascend/toolkit/toolchain/hcc/bin/../lib64/gcc/aarch64-target-linux-gnu/7.3.0/../../../../aarch64-target-linux-gnu/bin/ld: test/src/draw_pic_test.o: Relocations in generic ELF (EM: 62) /opt/Atlas310-ascend/toolkit/toolchain/hcc/bin/../lib64/gcc/aarch64-target-linux-gnu/7.3.0/../../../../aarch64-target-linux-gnu/bin/ld: test/src/draw_pic_test.o: Relocations in generic ELF (EM: 62) /opt/Atlas310-ascend/toolkit/toolchain/hcc/bin/../lib64/gcc/aarch64-target-linux-gnu/7.3.0/../../../../aarch64-target-linux-gnu/bin/ld: test/src/draw_pic_test.o: Relocations in generic ELF (EM: 62) /opt/Atlas310-ascend/toolkit/toolchain/hcc/bin/../lib64/gcc/aarch64-target-linux-gnu/7.3.0/../../../../aarch64-target-linux-gnu/bin/ld: test/src/draw_pic_test.o: Relocations in generic ELF (EM: 62) /opt/Atlas310-ascend/toolkit/toolchain/hcc/bin/../lib64/gcc/aarch64-target-linux-gnu/7.3.0/../../../../aarch64-target-linux-gnu/bin/ld: test/src/draw_pic_test.o: error adding symbols: file in wrong format collect2: error: ld returned 1 exit status make[1]: *** [draw] Error 1 make[1]: Leaving directory `/home/257916/server/test/v1.1/Trunk/src/draw' make: *** [draw] Error 2

2023-07-25 上传