Transactional Synchronization Extensions
Transactional Synchronization Extensions (TSX), also called Transactional Synchronization Extensions New Instructions (TSX-NI), is an extension to the x86instruction set architecture (ISA) that adds hardware transactional memory support, speeding up execution of multi-threaded software through lock elision. According to different benchmarks, TSX/TSX-NI can provide around 40% faster applications execution in specific workloads, and 4–5 times more database transactions per second (TPS).[1][2][3][4]
TSX/TSX-NI was documented by Intel in February 2012, and debuted in June 2013 on selected Intel microprocessors based on the Haswell microarchitecture.[5][6][7] Haswell processors below 45xx as well as R-series and K-series (with unlocked multiplier) SKUs do not support TSX/TSX-NI.[8] In August 2014, Intel announced a bug in the TSX/TSX-NI implementation on current steppings of Haswell, Haswell-E, Haswell-EP and early Broadwell CPUs, which resulted in disabling the TSX/TSX-NI feature on affected CPUs via a microcode update.[9][10]
In 2016, a side-channeltiming attack was found by abusing the way TSX/TSX-NI handles transactional faults (i.e. page faults) in order to break kernel address space layout randomization (KASLR) on all major operating systems.[11] In 2021, Intel released a microcode update that disabled the TSX/TSX-NI feature on CPU generations from Skylake to Coffee Lake, as a mitigation for discovered security issues.[12]
While TSX/TSX-NI is not supported anymore in desktop-class processors, it remains supported in the Xeon line of processors (at least on specific models, as of the 6th generation).[13]
Support for TSX/TSX-NI emulation is provided as part of the Intel Software Development Emulator.[14] There is also experimental support for TSX/TSX-NI emulation in a QEMU fork.[15]
Features
TSX/TSX-NI provides two software interfaces for designating code regions for transactional execution. Hardware Lock Elision (HLE) is an instruction prefix-based interface designed to be backward compatible with processors without TSX/TSX-NI support. Restricted Transactional Memory (RTM) is a new instruction set interface that provides greater flexibility for programmers.[16]
TSX/TSX-NI enables optimistic execution of transactional code regions. The hardware monitors multiple threads for conflicting memory accesses, while aborting and rolling back transactions that cannot be successfully completed. Mechanisms are provided for software to detect and handle failed transactions.[16]
Hardware Lock Elision
Hardware Lock Elision (HLE) adds two new instruction prefixes, XACQUIRE and XRELEASE. These two prefixes reuse the opcodes of the existing REPNE / REPE prefixes (F2H / F3H). On processors that do not support HLE, REPNE / REPE prefixes are ignored on instructions for which the XACQUIRE / XRELEASE are valid, thus enabling backward compatibility.[17]
The XACQUIRE prefix hint can only be used with the following instructions with an explicit LOCK prefix: ADD, ADC, AND, BTC, BTR, BTS, CMPXCHG, CMPXCHG8B, DEC, INC, NEG, NOT, OR, SBB, SUB, XOR, XADD, and XCHG. The XCHG instruction can be used without the LOCK prefix as well.
The XRELEASE prefix hint can be used both with the instructions listed above, and with the MOV mem, reg and MOV mem, imm instructions.
HLE allows optimistic execution of a critical section by skipping the write to a lock, so that the lock appears to be free to other threads. A failed transaction results in execution restarting from the XACQUIRE-prefixed instruction, but treating the instruction as if the XACQUIRE prefix were not present.
In other words, lock elision through transactional execution uses memory transactions as a fast path where possible, while the slow (fallback) path is still a normal lock.
Restricted Transactional Memory
Restricted Transactional Memory (RTM) is an alternative implementation to HLE which gives the programmer the flexibility to specify a fallback code path that is executed when a transaction cannot be successfully executed. Unlike HLE, RTM is not backward compatible with processors that do not support it. For backward compatibility, programs are required to detect support for RTM in the CPU before using the new instructions.
يُضيف RTM ثلاث تعليمات جديدة: XBEGINو XENDو و XABORT. تُشير التعليمات XBEGINو XENDإلى بداية ونهاية منطقة التعليمات البرمجية الخاصة بالمعاملات؛ XABORTبينما تُنهي التعليمات صراحةً المعاملة. يُعيد فشل المعاملة توجيه المعالج إلى مسار التعليمات البرمجية الاحتياطي المُحدد بواسطة XBEGINالتعليمات ، مع إرجاع حالة الإلغاء في EAXالسجل.
| موضع بت سجل EAX | معنى |
|---|---|
| 0 | قم بتعيين هذا الخيار إذا كان الإجهاض ناتجًا عن XABORTالتعليمات. |
| 1 | إذا تم ضبط هذا الخيار، فقد تنجح العملية عند إعادة المحاولة. ويكون هذا الخيار غير مُفعّل دائمًا إذا تم ضبط البت 0. |
| 2 | يتم تعيينه إذا تعارض معالج منطقي آخر مع عنوان ذاكرة كان جزءًا من المعاملة التي تم إلغاؤها. |
| 3 | يتم تعيين هذا الخيار في حالة تجاوز سعة المخزن المؤقت الداخلي. |
| 4 | قم بتعيين هذا الخيار إذا تم الوصول إلى نقطة توقف التصحيح. |
| 5 | يتم تعيين هذا الخيار في حالة حدوث إجهاض أثناء تنفيذ معاملة متداخلة. |
| 23:6 | محجوز. |
| 31:24 | XABORTالوسيط (صالح فقط إذا تم تعيين البت 0، وإلا فهو محجوز). |
XTESTتعليمات
يُقدّم TSX/TSX-NI تعليمة جديدة XTESTتُحدّد ما إذا كان المعالج يُنفّذ منطقة معاملات. يدعم المعالج هذه التعليمة إذا كان يدعم HLE أو RTM أو كليهما.
تتبع عنوان التحميل المعلق في بورصة تورنتو
تُعدّ خاصية تعليق تتبع عناوين التحميل في TSX/TSX-NI (TSXLDTRK) امتدادًا لمجموعة التعليمات يسمح بتعطيل تتبع التحميلات من الذاكرة مؤقتًا في جزء من التعليمات البرمجية ضمن منطقة المعاملات. تُوسّع هذه الخاصية نطاقي HLE وRTM، ويجب اكتشاف دعمها في المعالج بشكل منفصل.
يُقدّم TSXLDTRK تعليمتين جديدتين، XSUSLDTRKوهما و XRESLDTRK، لتعليق واستئناف تتبّع عناوين التحميل، على التوالي. أثناء تعليق التتبّع، لن تُضاف أي عمليات تحميل من الذاكرة إلى مجموعة قراءة المعاملة. هذا يعني أنه ما لم تُضَف مواقع الذاكرة هذه إلى مجموعات قراءة أو كتابة المعاملة خارج منطقة التعليق، فلن تتسبب عمليات الكتابة في هذه المواقع بواسطة سلاسل عمليات أخرى في إجهاض المعاملة. يسمح تعليق تتبّع عناوين التحميل لجزء من التعليمات البرمجية داخل منطقة المعاملة بتقليل كمية الذاكرة التي يجب تتبّعها لتجنّب تعارضات القراءة والكتابة، وبالتالي زيادة احتمالية إتمام المعاملة بنجاح.
تطبيق
تُحدد مواصفات TSX/TSX-NI من إنتل كيفية إتاحة الوصول إلى الذاكرة التفاعلية للمبرمجين، لكنها لا تُفصّل آلية تنفيذها. [ 18 ] تُشير إنتل في أدلة المطورين والتحسين إلى أن معالجات Haswell تحتفظ بمجموعات القراءة والكتابة بدقة سطر التخزين المؤقت، متتبعةً العناوين في ذاكرة التخزين المؤقت للبيانات من المستوى الأول (L1) للمعالج. [ 19 ] [ 20 ] [ 21 ] [ 22 ] كما تُوضح إنتل أن تعارضات البيانات تُكتشف من خلال بروتوكول تماسك ذاكرة التخزين المؤقت . [ 20 ]
تتمتع ذاكرة التخزين المؤقت للبيانات من المستوى الأول (L1) في معالجات Haswell بترابطية ثمانية. هذا يعني أنه في هذا التطبيق، سيؤدي تنفيذ عملية كتابة إلى تسعة مواقع مختلفة مرتبطة بنفس مجموعة ذاكرة التخزين المؤقت إلى الإجهاض. مع ذلك، ونظرًا لتطبيقات البنية الدقيقة، لا يضمن هذا عدم حدوث إجهاض عند تقليل عدد مرات الوصول إلى نفس المجموعة. إضافةً إلى ذلك، في تكوينات وحدة المعالجة المركزية المزودة بتقنية Hyper-Threading ، تتم مشاركة ذاكرة التخزين المؤقت L1 بين خيطي المعالجة على نفس النواة، لذا قد تتسبب العمليات في معالج منطقي شقيق لنفس النواة في حدوث عمليات إخلاء. [ 20 ]
تشير الأبحاث المستقلة إلى أن ذاكرة المعاملات في معالجات هاسويل تعتمد على الأرجح على نظام تحديث مؤجل، باستخدام ذاكرات التخزين المؤقت لكل نواة لبيانات المعاملات ونقاط التحقق من السجلات. [ 18 ] بعبارة أخرى، من المرجح أن تستخدم هاسويل نظام ذاكرة المعاملات القائم على ذاكرة التخزين المؤقت، لأنه خيار تنفيذي أقل مخاطرة. من ناحية أخرى، قد تجمع معالجات سكاي ليك من إنتل أو ما بعدها بين هذا النهج القائم على ذاكرة التخزين المؤقت ومخزن ترتيب الذاكرة (MOB) للغرض نفسه، وربما توفر أيضًا ذاكرة معاملات متعددة الإصدارات أكثر ملاءمة للمعالجة المتعددة التخمينية . [ 23 ]
التاريخ والأخطاء
هاسويل وبرودويل باغ (2014)
في أغسطس 2014، أعلنت شركة إنتل عن وجود خلل في تطبيق TSX/TSX-NI على معالجات Haswell وHaswell-E وHaswell-EP ومعالجات Broadwell المبكرة، مما أدى إلى تعطيل ميزة TSX/TSX-NI على المعالجات المتأثرة عبر تحديث للبرنامج الثابت. [ 9 ] [ 10 ] [ 24 ] تم إصلاح هذا الخلل في الإصدارات F-0 من معالج Core M-5Y70 Broadwell المزود بتقنية vPro في نوفمبر 2014. [ 25 ]
تم اكتشاف الخلل والإبلاغ عنه أثناء إعداد أطروحة دبلوم في كلية الهندسة الكهربائية وهندسة الحاسوب بالجامعة التقنية الوطنية في أثينا . [ 26 ]
خطأ سكايليك (2018)
في أكتوبر 2018، كشفت إنتل عن مشكلة في ترتيب ذاكرة TSX/TSX-NI في بعض معالجات Skylake . [ 27 ] نتيجةً لتحديث الشفرة البرمجية الدقيقة، تم تعطيل دعم HLE في وحدات المعالجة المركزية المتأثرة، وتم التخفيف من تأثير RTM عن طريق التضحية بأحد عدادات الأداء عند استخدامه خارج وضع Intel SGX أو وضع إدارة النظام ( SMM ). كان على برامج النظام إما تعطيل RTM فعليًا أو تحديث أدوات مراقبة الأداء بحيث لا تستخدم عداد الأداء المتأثر.
ثغرة أمنية في برنامج TAA (2021)
In June 2021, Intel published a microcode update that further disables TSX/TSX-NI on various Xeon and Core processor models from Skylake through Coffee Lake and Whiskey Lake as a mitigation for TSX Asynchronous Abort (TAA) vulnerability. Earlier mitigation for memory ordering issue was removed.[28] By default, with the updated microcode, the processor would still indicate support for RTM but would always abort the transaction. System software is able to detect this mode of operation and mask support for TSX/TSX-NI from the CPUID instruction, preventing detection of TSX/TSX-NI by applications. System software may also enable the "Unsupported Software Development Mode", where RTM is fully active, but in this case RTM usage may be subject to the issues described earlier, and therefore this mode should not be enabled on production systems. On some systems RTM can't be re-enabled when SGX is active. HLE is always disabled.
Current status
According to Intel 64 and IA-32 Architectures Software Developer's Manual from May 2020, Volume 1, Chapter 2.5 Intel Instruction Set Architecture And Features Removed,[19] HLE has been removed from Intel products released in 2019 and later. RTM is not documented as removed. However, Intel 10th generation Comet Lake and Ice Lake client processors, which were released in 2020, do not support TSX/TSX-NI,[29][30][31][32][33] including both HLE and RTM. Engineering versions of Comet Lake processors were still retaining TSX/TSX-NI support.
In Intel Architecture Instruction Set Extensions Programming Reference revision 41 from October 2020,[34] a new TSXLDTRK instruction set extension was documented. It was first included in Sapphire Rapids processors released in January 2023.
See also
- Advanced Synchronization Facility – AMD's competing technology
References
- ↑Richard M. Yoo; Christopher J. Hughes; Konrad Lai; Ravi Rajwar (November 2013). "Performance Evaluation of Intel Transactional Synchronization Extensions for High-Performance Computing"(PDF). intel-research.net. Archived from the original(PDF) on 2016-10-24. Retrieved 2013-11-14.
- ↑ توماس كارناجل؛ رومان ديمينتييف؛ رافي راجوار؛ كونراد لاي؛ توماس ليجلر؛ بنيامين شليجل؛ فولفغانغ لينر (فبراير 2014). "تحسين أداء فهرسة قواعد البيانات في الذاكرة باستخدام ملحقات مزامنة المعاملات من إنتل" (ملف PDF) . software.intel.com . تاريخ الاسترجاع: 3 مارس 2014 .
- ↑ "تقييم أداء ملحقات مزامنة المعاملات من إنتل للحوسبة عالية الأداء" . supercomputing.org . نوفمبر 2013. مؤرشف من الأصل بتاريخ 29 أكتوبر 2013. تم الاطلاع عليه بتاريخ 14 نوفمبر 2013 .
- ↑ "معايير الأداء: معدل نقل البيانات عبر TSX والذاكرة في معالجات Haswell (HLE وRTM)" . sisoftware.co.uk . تاريخ الاسترجاع: 14 نوفمبر 2013 .
- ↑ "مزامنة المعاملات في معالجات هاسويل" . Software.intel.com. مؤرشف من الأصل بتاريخ 23 فبراير 2020. تم الاطلاع عليه بتاريخ 7 فبراير 2012 .
- ↑ "الذاكرة التفاعلية تنتشر على نطاق واسع مع معالجات إنتل هاسويل" . آرس تكنيكا . 8 فبراير 2012. تاريخ الاسترجاع: 9 فبراير 2012 .
- ↑ "مراجعة معالج Core i7-4770K" . موقع Tom's Hardware. 1 يونيو 2013. تاريخ الاطلاع: 3 يونيو 2012 .
- ↑ "جدول مقارنة معالجات إنتل من طرازات Haswell Pentium و i3 و i5 و i7" . intel.com . تم الاطلاع عليه بتاريخ 11 فبراير 2014 .
- 1 2 سكوت واسون (12 أغسطس 2014). "تصحيح يدفع إنتل إلى تعطيل TSX في معالجات Haswell و Broadwell المبكرة" . techreport.com . تم الاطلاع عليه بتاريخ 12 أغسطس 2014 .
- 1 2 "معالجات Intel Core من الجيل الرابع لأجهزة سطح المكتب، ومعالجات Intel Pentium لأجهزة سطح المكتب، ومعالجات Intel Celeron لأجهزة سطح المكتب: تحديث المواصفات (مراجعة 014)" (ملف PDF) . Intel . يونيو 2014. ص 46. تاريخ الاسترجاع : 13 أغسطس 2014.
في ظل مجموعة معقدة من ظروف التوقيت الداخلي وأحداث النظام، قد يلاحظ البرنامج الذي يستخدم تعليمات Intel TSX/TSX-NI (ملحقات مزامنة المعاملات) سلوكًا غير متوقع للنظام.
- ↑ "كسر عشوائية تخطيط مساحة عناوين النواة باستخدام Intel TSX" (ملف PDF) . 2016.
- ↑ غاريث هالفكري (29 يونيو 2021). "إنتل تدق مسمارًا آخر في نعش TSX بتحديث برمجي دقيق يعطل بعض الميزات" . ذا ريجستر . تاريخ الاسترجاع: 17 أكتوبر 2012 .
- ↑"Compare Products". Intel. Retrieved 2025-03-10.
- ↑Wooyoung Kim (2013-07-25). "Fun with Intel Transactional Synchronization Extensions". Intel. Retrieved 2013-11-12.
- ↑Sebastien Dabdoub; Stephen Tu. "Supporting Intel Transactional Synchronization Extensions in QEMU"(PDF). mit.edu. Retrieved 2013-11-12.
- 12Johan De Gelas (2012-09-20). "Making Sense of the Intel Haswell Transactional Synchronization eXtensions". AnandTech. Archived from the original on September 22, 2012. Retrieved 2013-10-20.
- ↑"Hardware Lock Elision Overview". intel.com. Archived from the original on 2013-10-29. Retrieved 2013-10-27.
- 12David Kanter (2012-08-21). "Analysis of Haswell's Transactional Memory". Real World Technologies. Retrieved 2013-11-19.
- 12"Intel 64 and IA-32 Architectures Software Developer's Manual Combined Volumes: 1, 2A, 2B, 2C, 3A, 3B, and 3C"(PDF). Intel. September 2013. p. 342. Retrieved 2013-11-19.
- 123"Intel 64 and IA-32 Architectures Optimization Reference Manual"(PDF). Intel. September 2013. p. 446. Retrieved 2013-11-19.
- ↑"Intel TSX implementation properties". Intel. 2013. Retrieved 2013-11-14.
The processor tracks both the read-set addresses and the write-set addresses in the first level data cache (L1 cache) of the processor.
- ↑De Gelas, Johan (September 20, 2012). "Making Sense of the Intel Haswell Transactional Synchronization eXtensions". AnandTech. Retrieved 23 December 2013.
The whole "CPU does the fine grained locks" is based upon tagging the L1 (64 B) cachelines and there are 512 of them to be specific (64 x 512 = 32 KB). There is only one "lock tag" per cacheline.
{{cite web}}: CS1 maint: deprecated archival service (link) - ↑David Kanter (2012-08-21). "Haswell Transactional Memory Alternatives". Real World Technologies. Retrieved 2013-11-14.
- ↑Ian Cutress (2014-08-12). "Intel Disables TSX Instructions: Erratum Found in Haswell, Haswell-E/EP, Broadwell-Y". AnandTech. Archived from the original on August 14, 2014. Retrieved 2014-08-30.
- ↑"Intel Core M Processor Family. Specification Update. December 2014. Revision 003. 330836-003"(PDF). Intel. December 2014. p. 10. Retrieved 2014-12-28.
BDM53 1 E-0: X, F-0:, Status: Fixed ERRATA: Intel TSX Instructions Not Available. 1. Applies to Intel Core M-5Y70 processor. Intel TSX is supported on Intel Core M-5Y70 processor with Intel vPro Technology. Intel TSX is not supported on other processor SKUs.
- ↑"HiPEAC info"(PDF). p. 12. Archived from the original(PDF) on 2017-03-05.
- ↑"Performance Monitoring Impact of Intel® Transactional Synchronization Extension Memory Ordering Issue White Paper, June 2021, Revision 1.4"(PDF). Intel. 2021-06-12. p. 5.
The October 2018 microcode update also disabled the HLE instruction prefix of Intel TSX and force all RTM transactions to abort when operating in Intel SGX mode or System Management Mode (SMM).
- ↑"Intel® Transactional Synchronization Extensions (Intel® TSX) Memory and Performance Monitoring Update for Intel® Processors". Intel. 2021-06-12.
- ↑"Intel® Core™ i9-10900K Processor specifications". Intel. 2020. Retrieved 2020-10-10.
- ↑"Intel® Core™ i9-10980HK Processor specifications". Intel. 2020. Retrieved 2020-10-10.
- ↑"Intel® Core™ i7-10810U Processor specifications". Intel. 2020. Retrieved 2020-10-10.
- ↑"Intel® Xeon® W-1290P Processor specifications". Intel. 2020. Retrieved 2020-10-10.
- ↑"Intel® Core™ i7-1068NG7 Processor specifications". Intel. 2020. Retrieved 2020-10-10.
- ↑"Intel® Architecture Instruction Set Extensions Programming Reference"(PDF). Intel. 2020. Retrieved 2020-10-21.
Further reading
- أفيك، ي.؛ ليفي، أ.؛ موريسون، أ. (2014). وقائع ندوة ACM لعام 2014 حول مبادئ الحوسبة الموزعة - PODC '14 . تحسين برمجيات إلغاء قفل الأجهزة، ص 212. doi : 10.1145/2611462.2611482 . ISBN 9781450329446. S2CID 16645370 . . تحسينات برمجية لتقنية إلغاء قفل الأجهزة في Intel TSX.
روابط خارجية
- عرض تقديمي من مؤتمر الاتحاد الدولي للرجبي 2012 (ملف PDF)
- إضافة خاصية حذف القفل إلى نظام لينكس ، مؤتمر لينكس للسباكين 2012 (ملف PDF)
- قفل الحذف في مكتبة GNU C ، LWN.net ، 30 يناير 2013، بقلم آندي كلين
- دليل تحسين بورصة تورنتو ، الفصل 12 (ملف PDF)
- دليل مطوري البرامج ، المجلد 1، الفصل 2.5 (ملف PDF)
- موارد الويب حول ملحقات مزامنة المعاملات من إنتل
- x86، الشفرة الدقيقة: خطأ: تحديث الشفرة الدقيقة الذي يغير x86_capability ، LKML ، سبتمبر 2014 (يوجد أيضًا تقرير خطأ مشابه آخر )
- شفرة Intel الدقيقة ، Gentoo، 19 سبتمبر 2015
- مقدمات متعلقة بالحاسوب في عام 2012
- تعليمات X86
- الحوسبة المتوازية
- الذاكرة التفاعلية
- معالجة المعاملات
- التحكم في التزامن
- أعطال الأجهزة
- امتدادات مجموعة التعليمات
