ezylinux
ลินุกซ์ง่ายนิดเดียว

10
Oct

หลายคนคงจะรู้จัก Hyperthreading (HT) หรือชื่ออีกชื่อหนึ่งคือ Symmetric Multi-Threading (SMT) กันเป็นอย่างดี ซึ่งเป็น feature หนึ่งของ CPU intel ตระกูล x86 มีอยู่ใน cpu รุ่นเก่าๆอย่าง Pentium4, Xeon processors บางรุ่น และยังมี CPU ที่มีรหัส codename ว่า “Nehalem” ก็มี Hyperthreading (HT) แต่ CPU รุ่นปัจจุบันนี้ที่มีการผลิตแบบ Core microarchitecture เช่น Core2Duo, Core2Quad ไม่ได้มี Hyperthreading (HT) แล้วเราจะทราบได้อย่างไรละว่า CPU รุ่นที่ใช้งานอยู่นี้ เป็นแบบ multi-processor, multi-core แล้วมี hyperthreading ด้วยหรือปล่าว

ใน linux มีวิธีการตรวจสอบว่า CPU ของเราเป็นแบบใด ซึ่งวิธีการตรวจสอบก็ไม่ยากอะไรมากมาย เพียงแค่ดูข้อมูลในไฟล์ /proc/cpuinfo แต่มีข้อแม้ว่าจะต้องไม่ใช้งาน Xen-kernel เมื่อเราจะได้ใช้คำสั่ง เนื่องจากว่า kernel-xen จะไม่แสดงค่าของ CPU ที่(แสดงเป็น single-core processor)

#cat /proc/cpuinfo

ในบรรทัดด้านล่างนี้จะเป็นตัวอย่างของการอ่านค่าใน CPU แบบต่างๆ เรามาดูกันเลยว่า CPU ในแบบต่างๆจะมีข้อมูลอะไรแสดงออกมาบ้างดังตัวอย่างด้านล่าง

**ค่าที่เกี่ยวข้อง

“physical id” คือค่าของ processor socket เอาไว้ใช้ดูว่ามีกี่ processor

“siblings” คือค่า logical processors (ค่าจะเท่ากัน)

“cpu cores” คือค่า physical cores ของแต่ละ physical processor

Single-processor, Single-core, HT

processor	    0 1
physical id	0 0
siblings	    2 2
core id 	    0 0
cpu cores	    1 1  

จากตัวอย่างนี้จะเห็นว่า physical id มีเลข 0 อย่างเดียวแสดงว่าเป็น Single-processor , siblings มีค่า 2 แสดงว่ามี 2 logical processors และสุดท้าย cpu core มีเลข 1 อย่างเดียวแสดงว่ามี 1 core เป็น HT เพราะว่า siblings หาร cpu cores แล้วผลลัพธ์ได้ค่าเท่ากับ 2 (2 เท่าของ processor จริง)

Single-processor, Dual-core, non-HT

processor	    0 1
physical id	0 0
siblings	    2 2
core id 	    0 1
cpu cores	    2 2   

จากตัวอย่างนี้จะเห็นว่า physical id มีเลข 0 อย่างเดียวแสดงว่าเป็น Single-processor , siblings มีค่า 2 แสดงว่ามี 2 logical processors และสุดท้าย cpu core มีเลข 2 อย่างเดียวแสดงว่ามี 2 core เป็น non-HT เพราะว่า siblings หาร cpu cores แล้วผลลัพธ์ได้ค่าเท่ากับ 1

Dual-processor, Single-core, HT

processor	0 1 2 3
physical id	0 3 0 3
siblings	2 2 2 2
core id 	0 3 0 3
cpu cores	1 1 1 1  

จากตัวอย่างนี้จะเห็นว่า physical id มีเลข 0,3 อย่างเดียวแสดงว่าเป็น Dual-processor , siblings มีค่า 2 แสดงว่ามี 2 logical processors และสุดท้าย cpu core มีเลข 1 อย่างเดียวแสดงว่ามี 1 core เป็น HT เพราะว่า siblings หาร cpu cores แล้วผลลัพธ์ได้ค่าเท่ากับ 2

จากตัวอย่างอื่นๆด้านล่างให้ลองฝึกดูนะครับ จะได้ชำนาญในการดูว่า CPU ที่ใช้อยู่เป็นแบบไหน

Dual-processor, Dual-core, HT

processor	0 1 2 3 4 5 6 7
physical id	0 0 0 0 1 1 1 1
siblings	4 4 4 4 4 4 4 4
core id 	0 0 1 1 0 0 1 1
cpu cores	2 2 2 2 2 2 2 2    

Single-processor, Quad-core, non-HT

processor	0 1 2 3
physical id	0 0 0 0
siblings	4 4 4 4
core id 	0 2 1 3
cpu cores	4 4 4 4  

Dual-processor, Quad-core, non-HT

processor	0 1 2 3 4 5 6 7
physical id	0 1 0 1 0 1 0 1
siblings	4 4 4 4 4 4 4 4
core id 	0 0 1 1 2 2 3 3
cpu cores	4 4 4 4 4 4 4 4  

Dual-processor, Quad-core, HT

processor	0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
physical id	0  0  0  0  0  0  0  0  1  1  1  1  1  1  1  1
siblings	8  8  8  8  8  8  8  8  8  8  8  8  8  8  8  8
core id		0  0  1  1  2  2  3  3  0  0  1  1  2  2  3  3
cpu cores	4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  

Related posts:

  1. Controlling Core Dump Files in Linux Core dump อีกแล้ว!! คำพูดนี้เกิดขึ้นหลังจากที่เพื่อนคนหนึ่งได้โทรมาถามปัญหาเรื่องการใช้ rpm เสร็จ ตอนแรกก็งงๆ core dump คือไรหว่า มันขึ้น error ตรงไหน แล้วรู้ได้ไง ผมเลยลองค้นๆดูปรากฏว่าปัญหานี้เราเคยเจอแล้วนี้ เจอที่ blog ของเราเองด้วย แต่ตอนนั้นไม่ได้หาสาเหตุว่าเกิดจากอะไรกันแน่เพราะว่าไม่มีสิทธิแก้ไขอะไรมาก...
  2. Enable Core Dumps for Daemons or Services in Red Hat Enterprise Linux โดยทั่วไปแล้ว daemon เป็นการทำงานในรูปแบบ background process การสั่งให้ deamond ทำงานสามารถทำได้โดยใช้ service command หรือ ใช้ init script การเปิดใช้งาน core dump (ดูรายละเอียดของ core...
  3. Non-Uniform Memory Access Non-Uniform Memory Access or Non-Uniform Memory Architecture (NUMA) is a computer memory design used in multiprocessors, where the memory...
  4. How large is the virtual address space for a process ใน linux การเลือกใช้งาน CPU และ kernel ให้ถูกต้องตามความต้องการของ application นั้นจะทำให้ระบบทำงานได้อย่างมีเสถียรภาพ ในความเป็นจริงแล้ว processor ที่เป็น x86_64 (AMD64, EM64T) คือ 64 bit processor...

Category : Knowledge

Sorry, the comment form is closed at this time.