turbostat와 lm-sensors의 CPU 온도

1.
오버클락서버를 판매합니다. 고객에게 출고하기 전에 이런저런 시험을 합니다. 최초 바이오스 설정할 때 한번하고 OS를 설치하고 커널을 튜닝한 후 한번더 합니다. 그래도 부품의 불량으로 인해 문제가 발생합니다. 문제가 발생한 서버는 다시 입고를 해서 원인을 찾습니다. 지금까지 입고받아서 확인한 서버들은 대부분 두가지 문제에서 출발하였습니다.

첫째 CPU불량
둘째 CPU쿨러 불량

어느 경우나 무상교체를 진행합니다. 다만 트레이더는 매매 중지를 하여야 하기 때문에 이런저런 미안함이 듭니다.

이번에 원인이 정확하지 않는 서버를 받았습니다. 고객이 개발한 프로그램을 운용하는데 CPU온도가 너무 높다는 요청이었습니다. 이 때문에 서버가 먹통이 되는 듯 하다고 합니다. 혹시나 해서 coredump가 발생했는지 문의했지만 없다고 합니다. 제가 확인했던 서버들은 Coredump를 확인했는데 이점에 차이가 있었습니다.

서버를 받아서 확인하니까 CPU온도가 최초 시험했을 때보다 높아서 CPU쿨러를 교체하였습니다. 이후 시험을 해보니까 적정한 수준의 온도가 나왔습니다.

2.
테스트프로그램을 실행하고 온도측정을 위한 프로그램을 실행하였습니다. 고객이 사용하는 lm-sensors와 제가 사용하는 turbostat를 각각 실행하였습니다. 아래가 실행한 값입니다.

위 이미지를 보시면 sensor의 출력값과 turbostat의 출력값이 다릅니다. 왜 다른가 궁금해서 확인을 했습니다.

먼저, MSR(Machine specific registers)입니다. 인털이 CPU의 온도값을 모니터링하기 위하여 제공하는 CPU내부에 있는 센서입니다.

The temperature readings are very accurate as the data is collected directly from a Digital Thermal Sensor (or DTS) which is located in each individual processing core*, near the hottest part. This sensor is digital, which means it doesn’t rely on an external circuit located on the motherboard to report temperature, its value is stored in a special register in the processor so that software can access and read it. This eliminates any inaccuracies that can be introduced by external motherboard circuits and sensors.
Alcpu – How does it work?중에서

그리고 CPU의 MSR값을 읽기 위한 CPU 명령어가 rdmsr과 wrmsr입니다.

Reading and writing to these registers is handled by the rdmsr and wrmsr instructions

인텔이 제공하는 가이드입니다.

Model-specific registers (MSR) are control registers provided by the processor implementation so that system software can interact with a variety of features, including performance monitoring, checking processor status, debugging, program tracing or toggling specific CPU features.
Reading and Writing Model Specific Registers (MSRs) in Linux중에서

Turbostat는 MSR이 제공하는 값을 직접적으로 이용합니다. turbostat를 실행할 때 나오는 첫화면입니다.

위 값중 MSR_IA32_PACKAGE_THERM_STATUS이 CPU온도값입니다.

turbotat 소스코드를 보면 msr과 관련한 코드가 대부분입니다.

3.
다음은 lm-sensors입니다. coretmep를 이용합니다. coretemp는 커널드라이버입니다. 커널문서의 내용입니다.

This driver permits reading the DTS (Digital Temperature Sensor) embedded inside Intel CPUs. This driver can read both the per-core and per-package temperature using the appropriate sensors. The per-package sensor is new; as of now, it is present only in the SandyBridge platform. The driver will show the temperature of all cores inside a package under a single device directory inside hwmon.

Temperature is measured in degrees Celsius and measurement resolution is 1 degree C. Valid temperatures are from 0 to TjMax degrees C, because the actual value of temperature register is in fact a delta from TjMax.

Temperature known as TjMax is the maximum junction temperature of processor, which depends on the CPU model. At this temperature, protection mechanism will perform actions to forcibly cool down the processor. Alarm may be raised, if the temperature grows enough (more than TjMax) to trigger the Out-Of-Spec bit.
Kernel driver coretemp중에서

Coretemp는 lm-sensors가 CPU를 표시할 때 사용하는 커널모듈입니다. DTS를 읽어서 데이타를 수집한다고 하는데 인텔이 소개하는 DTS입니다.

Each processor has multiple on-die Digital Thermal Sensor (DTS) that detects the processor IA, GT and other areas of interest instantaneous temperature.

Temperature values from the DTS can be retrieved through:

A software interface using processor Model Specific Register (MSR).
A processor hardware interface.


When the temperature is retrieved by the processor MSR, it is the instantaneous temperature of the given DTS. When the temperature is retrieved using PECI, it is the average of the highest DTS temperature in the package over a 256 ms time window. Intel recommends using the PECI reported temperature for platform thermal control that benefits from averaging, such as fan speed control. The average DTS temperature may not be a good indicator of package Adaptive Thermal Monitor activation or rapid increases in temperature that triggers the Out of Specification status bit within the PACKAGE_​THERM_​STATUS (0x1B1) MSR and IA32_​THERM_​STATUS (0x19C) MSR.

Code execution is halted in C1 or deeper C-states. Package temperature can still be monitored through PECI in lower C-states.

Unlike traditional thermal devices, the DTS outputs a temperature relative to the maximum supported operating temperature of the processor (TjMAX), regardless of TCC activation offset. It is the responsibility of software to convert the relative temperature to an absolute temperature. The absolute reference temperature is readable in the TEMPERATURE_​TARGET (0x1A2) MSR. The temperature returned by the DTS is an implied negative integer indicating the relative offset from TjMAX. The DTS does not report temperatures greater than TjMAX. The DTS-relative temperature readout directly impacts the Adaptive Thermal Monitor trigger point. When a package DTS indicates that it has reached the TCC activation (a reading of 0x0, except when the TCC activation offset is changed), the TCC will activate and indicate an Adaptive Thermal Monitor event. A TCC activation will lower both processor IA core and graphics core frequency, voltage, or both. Changes to the temperature can be detected using two programmable thresholds located in the processor thermal MSRs. These thresholds have the capability of generating interrupts using the processor IA core’s local APIC. Refer to the Intel 64 Architectures Software Developer’s Manual for specific register and programming details.
Digital Thermal Sensor중에서

DTS와 MSR은 서로 밀접한 관계를 가지고 있습니다. 커널 모듈인 msr와 coretmp는 비슷한 기능을 합니다만 포괄하는 범위가 다른 듯 합니다.

대략 흐름은 이해하겠는데 왜 다른 값을 보여주는지, 확실하지 않네요.. 좀더 시간이 필요할 듯 합니다.

4.
오버클락서버의 경우 냉각이 중요합니다. 공냉식이든 수냉식이든 공기흐름이 무척이나 중요합니다. 그렇기 때문에 서버내부의 케이블링도 중요합고 냉각팬도 중요합니다. 공장에서 나오는 서버케이스는 같습니다. 케이스 내부에 팬을 설치하기 때문에 위치정도만 다릅니다. 그런데 냉각효율을 높히려고 외부에 팬을 다는 작업을 하였습니다. 케이스에 구멍을 뚫는 작업이라 문래동에서 관련한 업체를 수소문하였습니다 35년만에 문래동을 다시 찾았습니다. 88년부터 몇 년동안 문래동에서 선반노동자로 일을 했기때문입니다. 성수동처럼 문래동도 카페촌으로 많이 바뀌는 듯 합니다. ㅠㅠ

아래는 작업전후입니다.

Leave a Comment

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

이 사이트는 Akismet을 사용하여 스팸을 줄입니다. 댓글 데이터가 어떻게 처리되는지 알아보세요.