ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • AMD Ryzen CPU 와 CentOS 리눅스
    Linux 2020. 3. 11. 15:12

    AMD Ryzen CPU 와 CentOS 리눅스

    최초 작성일: 2020년 3월 11일

    최종 수정일: 2020년 4월  3일

    0. 레퍼런스


    컴퓨터 사양 및 운영환경

     운영체제

     CentOS 7 + Windows 10 Pro - (U)EFI Multi Booting

     CPU

     AMD Ryzen Threadripper 1950X 16-Core Processor

     메인보드

     GIGABYTE X399 AORUS Gaming 7

     저장장치

     HDD (8T x 2)  Raid 1 [+ 8T]

     메모리

     128G ( 16G x 8 )


    1. 경고 메시지

     그동안 무심하게 컴퓨터를 끄고, 부팅하고 원격에서 접속해서 사용하다가, 우연히 부팅화면을 보게 되었다.
    아래와 같이 경고 메시지가 뜨고 있었다.

    Mar  4 22:17:36 localhost kernel: Booting paravirtualized kernel on bare hardware

    Mar  4 22:17:36 localhost kernel: Detected CPU family 17h model 1

    Mar  4 22:17:36 localhost kernel: Warning: AMD Processor - this hardware has not undergone upstream testing. Please consult http://wiki.centos.org/FAQ for more information


    AMD 프로세서가 제대로 테스트되지 않은 상위 하드웨어라는 뭐 대충의 그런 메시지다.

    즉, 현재 리눅스 커널이 이 CPU 를 제대로 테스트하지 않은 이전 버전이라는 의미이기도 하다.


    [xxxx@localhost ~]$ lscpu

    Architecture:          x86_64

    CPU op-mode(s):        32-bit, 64-bit

    Byte Order:            Little Endian

    CPU(s):                32

    On-line CPU(s) list:   0-31

    Thread(s) per core:    2

    Core(s) per socket:    16

    Socket(s):             1

    NUMA node(s):          1

    Vendor ID:             AuthenticAMD

    CPU family:            23

    Model:                 1

    Model name:            AMD Ryzen Threadripper 1950X 16-Core Processor

    Stepping:              1

    CPU MHz:               2200.000

    CPU max MHz:           3400.0000

    CPU min MHz:           2200.0000

    BogoMIPS:              6786.39

    Virtualization:        AMD-V

    L1d cache:             32K

    L1i cache:             64K

    L2 cache:              512K

    L3 cache:              8192K

    NUMA node0 CPU(s):     0-31

    Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc art rep_good nopl nonstop_tsc extd_apicid amd_dcm aperfmperf eagerfpu pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_l2 hw_pstate sme retpoline_amd ssbd ibpb vmmcall fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap clflushopt sha_ni xsaveopt xsavec xgetbv1 clzero irperf xsaveerptr arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif overflow_recov succor smca


    2. 커널 소스

    그래서, 커널 소스를 대충 훑어본다.
    linux-3.10.0-1062.12.1.el7.x86_64/arch/x86/kernel/setup.c
            if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) {
                    if (!valid_amd_processor(boot_cpu_data.x86,
                                             boot_cpu_data.x86_model_id, guest)) {
                            pr_crit("Detected CPU family %xh model %d\n",
                                    boot_cpu_data.x86,
                                    boot_cpu_data.x86_model);
                            mark_hardware_unsupported("AMD Processor");
                    }
            }

    지원하지 않는 AMD Processor 로 표시한다.
    낯설다. 

    그래서, 인터넷 검색을 한다.

    리눅스 커널 4.10 이 AMD Ryzen 아키텍처의 멀티쓰레드를 지원한다는 이야기다.
    그렇다면, CentOS7 의 기본 커널에서 그동안, AMD Ryzen 쓰레드리퍼를 제대로 사용하고 있지 못했다는 이야기다.

    하지만,
    CentOS 7 의 최신 코드에는 Zen SMT topology 가 적용되어 있다.
    linux-3.10.0-1062.12.1.el7.x86_64/arch/x86/kernel/cpu/amd.c
                    if (c->x86 == 0x15)
                            c->cu_id = ebx & 0xff;

                    if (c->x86 >= 0x17) {
                            c->cpu_core_id = ebx & 0xff;

                            if (smp_num_siblings > 1)
                                    c->x86_max_cores /= smp_num_siblings;
                    }


    CentOS 7 의 RPM SPEC ChangeLog 를 살펴본다.
    * Wed Apr 25 2018 Bruno E. O. Meneguele <bmeneg@redhat.com> [3.10.0-878.el7]
    - [hwmon] (k10temp) Add temperature offset for Ryzen 1900X (David Arcari) [1446653]

    * Sat Apr 29 2017 Rafael Aquini <aquini@redhat.com> [3.10.0-660.el7]
    - [x86] Mark AMD Naples/Ryzen as unsupported (David Arcari) [1444841]


    2017년에 AMD Ryzen 을 지원하지 않는 것으로 표시하고, 2018년에는 1900x CPU 의 temperature offset 에 대한 변경정도만 보인다.

    RHEL 은 AMD Ryzen 을 지원하지 않는 것으로 보인다.


    다시 또 구글링을 해 본다,


    젠투펭귄이  Ryzen ThreadRipper 1950x 는 4.19.52+ 커널부터 지원된다는 글이 있다.

    그런데, https://cdn.kernel.org/pub/linux/kernel/v4.x/ChangeLog-4.19.52 딱히 AMD CPU 관련된 ChangeLog 는 보이지 않는다.


    귀챦다. 감도 떨어졌고...


    어찌되었건, 4.10 이후 버전부터 지원된다.


    그냥, CentOS7 용 최신 리눅스 커널을 설치하도록 하자.

    3. ElRepo

    ElRepo 는 엔터프라이즈 리눅스, 즉 RHEL 과 RHEL 을 베이스로 만든 CentOS, Scientific Linux 등을 위한 RPM 저장소다.


    ElRepo  저장소 KEY 추가하기

    # rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org


    CentOS 7 용 저장소 추가하기

    # yum install https://www.elrepo.org/elrepo-release-7.0-4.el7.elrepo.noarch.rpm


    ElRepo 는 다음 4개의 채널로 구성된다.

    • elrepo - 메인 채널.
    • elrepo-extras - RHEL 대체 패키지를 제공한다.
    • elrepo-testing - 아직 메인 채널에 릴리스되지 않은 패키지를 제공한다.
    • elrepo-kernel - 장기 지원 커널을 제공한다.

    일단, kernel 채널을 제외한 다른 채널은 disable 시킨다.

    # yum-config-manager --disable elrepo  [ 이건 옵션 ]

    # yum-config-manager --enable elrepo-kernel


    또는 /etc/yum.repos.d/elrepo.repo 파일을 직접 수정한다.

    [elrepo-kernel]

    name=ELRepo.org Community Enterprise Linux Kernel Repository - el7

    baseurl=http://elrepo.org/linux/kernel/el7/$basearch/

            http://mirrors.coreix.net/elrepo/kernel/el7/$basearch/

            http://mirror.rackspace.com/elrepo/kernel/el7/$basearch/

            http://repos.lax-noc.com/elrepo/kernel/el7/$basearch/

    mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-kernel.el7

    enabled=1

    gpgcheck=1

    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org

    protect=0


    kernel-ml  (kernel-mainline) 패키지를 설치한다.

    kernel-ml 은 최신 리눅스 커널을 RHEL 의 설정으로 적용한 패키지라고 생각하면 된다.

    # yum search kernel-ml

    ...

    ======================== N/S matched: kernel-ml ==========================================

    kernel-ml.x86_64 : The Linux kernel. (The core of any Linux-based operating system.)

    kernel-ml-devel.x86_64 : Development package for building kernel modules to match the kernel.

    kernel-ml-doc.noarch : Various bits of documentation found in the kernel sources.

    kernel-ml-headers.x86_64 : Header files of the kernel, for use by glibc.

    kernel-ml-tools.x86_64 : Assortment of tools for the kernel.

    kernel-ml-tools-libs.x86_64 : Libraries for the kernel tools.

    kernel-ml-tools-libs-devel.x86_64 : Development package for the kernel tools libraries.


      Name and summary matches only, use "search all" for everything.


    # yum install kernel-ml 
    ...
    ====================================================================================
     Package                     Arch               Version                         Repository                 Size
    ====================================================================================
    Installing:
     kernel-ml-devel             x86_64             5.5.8-1.el7.elrepo              elrepo-kernel              13 M

    Transaction Summary
    =====================================================================================
    Install  1 Package


    devel 패키지도 함께 설치해둔다.

    # yum install kernel-ml-devel


    4. AMD Raid Expert (rcraid)  패치


    물론 RAID 를 사용하지 않는다면,  이 패치는 할 필요가 없다.

    최신 커널로 부팅하면, raid 로 설치해둔 디스크를 마운트하지 못한다.

    최신 커널도 x399 의 raid 기능은 지원하지 않는다.

    이전에 작성한 글[Linux (CentOS) Hardware RAID 설치하기] 을 바탕으로 리눅스 커널 5.5 에 x399 raid 패치를 적용한다.

    # git clone https://github.com/thopiekar/rcraid-dkms.git

    # cd rcraid-dkms

    # chmod +x installl


    [root@localhost rcraid-dkms]# ./install 5.5.8-1.el7.elrepo.x86_64

    rm -f -f *.o *.ko vers.c .*.cmd .*.d

    rm -f -f rcraid.mod.c Module.symvers Modules.symvers

    rm -f -rf .tmp_versions Module.markers modules.order

    make -C /lib/modules/5.5.8-1.el7.elrepo.x86_64/build M=/root/x399/rcraid-dkms/src

    make[1]: Entering directory `/usr/src/kernels/5.5.8-1.el7.elrepo.x86_64'

    ln -sf `basename /root/x399/rcraid-dkms/src/rcblob.x86_64.o .o` /root/x399/rcraid-dkms/src/rcblob.x86_64.o

      AR      /root/x399/rcraid-dkms/src/built-in.a

      CC [M]  /root/x399/rcraid-dkms/src/rc_init.o

    /root/x399/rcraid-dkms/src/rc_init.c: In function ‘rcraid_resume_one’:

    /root/x399/rcraid-dkms/src/rc_init.c:1105:26: warning: ignoring return value of ‘pci_enable_device’, declared with attribute warn_unused_result [-Wunused-result]

             pci_enable_device(adapter->pdev);

                              ^

    /root/x399/rcraid-dkms/src/rc_init.c:1130:23: warning: ignoring return value of ‘pcim_enable_device’, declared with attribute warn_unused_result [-Wunused-result]

         pcim_enable_device(pdev);

                           ^

      CC [M]  /root/x399/rcraid-dkms/src/rc_msg.o

      CC [M]  /root/x399/rcraid-dkms/src/rc_mem_ops.o

      CC [M]  /root/x399/rcraid-dkms/src/rc_event.o

      CC [M]  /root/x399/rcraid-dkms/src/rc_config.o

      CC [M]  /root/x399/rcraid-dkms/src/vers.o

      LD [M]  /root/x399/rcraid-dkms/src/rcraid.o

      Building modules, stage 2.

      MODPOST 1 modules

      CC [M]  /root/x399/rcraid-dkms/src/rcraid.mod.o

      LD [M]  /root/x399/rcraid-dkms/src/rcraid.ko

    make[1]: Leaving directory `/usr/src/kernels/5.5.8-1.el7.elrepo.x86_64'

    SWL option: "ahci,lsi1068,lsi2008"

    Installing rcraid.ko driver for 5.5.8-1.el7.elrepo.x86_64


    ### initramfs 에 rcraid 드라이버를 추가한다.
    [root@localhost rcraid-dkms]# dracut --add-drivers rcraid --force --kver 5.5.8-1.el7.elrepo.x86_64


    /etc/modprobe.d/rcraid.conf

    blacklist ahci

    alias scsi_hostadapter rcraid

    options rcraid use_swl=15

    설치된 kernel-ml 은 기본 부팅으로 설정되지 않는다. 부팅에 이상이 없으면, 다음과 같이 기본 부팅 운영체제로 설정한다.

    부팅순서 바꾸기

    # grub2-set-default 0

    **) Linux Kernel 5.6 대응

    리눅스 커널 5.6은 2038년 문제를 수정한 첫 번째 리눅스 커널이다.
    이 커널은 2038년 후에도 32비트 리눅스를 운영할 수 있게 해 준다.


    커널 5.6 이상에서 rcraid 패치를 적용하면 다음과 같은 오류가 발생한다.

    (오류가 없으면, 이미 패치가 적용된 버전으로 생각하면 된다. 아래는 생략한다.)


      CC [M]  /root/x399/rcraid-dkms/src/rc_msg.o

    /root/x399/rcraid-dkms/src/rc_msg.c: In function ‘rc_vprintf’:

    /root/x399/rcraid-dkms/src/rc_msg.c:211:17: error: storage size of ‘tv’ isn’t known

      struct timeval tv;

                     ^

    /root/x399/rcraid-dkms/src/rc_msg.c:213:18: error: storage size of ‘ts’ isn’t known

      struct timespec ts;

                      ^

    /root/x399/rcraid-dkms/src/rc_msg.c:222:3: error: implicit declaration of function ‘getnstimeofday’ [-Werror=implicit-function-declaration]

       getnstimeofday(&ts);

       ^

    /root/x399/rcraid-dkms/src/rc_msg.c:213:18: warning: unused variable ‘ts’ [-Wunused-variable]



    컴파일시에 위와 같은 오류가 발생하면, 아래의 패치를 적용한 후 컴파일한다.

    5. 컴파일 비교

    간단하게 컴파일속도등을 비교하기 위해 RPM 으로 커널 패키지를 생성해본다.


    Linux Kernel 3.10.0-1062.12.1

    $ time rpmbuild -ba kernel.spec

    ...

    작성: /home/respiro/rpmbuild/SRPMS/kernel-3.10.0-1062.12.1.el7.src.rpm

    작성: /home/respiro/rpmbuild/RPMS/x86_64/kernel-3.10.0-1062.12.1.el7.x86_64.rpm

    작성: /home/respiro/rpmbuild/RPMS/x86_64/kernel-headers-3.10.0-1062.12.1.el7.x86_64.rpm

    작성: /home/respiro/rpmbuild/RPMS/x86_64/kernel-debuginfo-common-x86_64-3.10.0-1062.12.1.el7.x86_64.rpm

    작성: /home/respiro/rpmbuild/RPMS/x86_64/perf-3.10.0-1062.12.1.el7.x86_64.rpm

    작성: /home/respiro/rpmbuild/RPMS/x86_64/perf-debuginfo-3.10.0-1062.12.1.el7.x86_64.rpm

    작성: /home/respiro/rpmbuild/RPMS/x86_64/python-perf-3.10.0-1062.12.1.el7.x86_64.rpm

    작성: /home/respiro/rpmbuild/RPMS/x86_64/python-perf-debuginfo-3.10.0-1062.12.1.el7.x86_64.rpm

    작성: /home/respiro/rpmbuild/RPMS/x86_64/kernel-tools-3.10.0-1062.12.1.el7.x86_64.rpm

    작성: /home/respiro/rpmbuild/RPMS/x86_64/kernel-tools-libs-3.10.0-1062.12.1.el7.x86_64.rpm

    작성: /home/respiro/rpmbuild/RPMS/x86_64/kernel-tools-libs-devel-3.10.0-1062.12.1.el7.x86_64.rpm

    작성: /home/respiro/rpmbuild/RPMS/x86_64/kernel-tools-debuginfo-3.10.0-1062.12.1.el7.x86_64.rpm

    작성: /home/respiro/rpmbuild/RPMS/x86_64/bpftool-3.10.0-1062.12.1.el7.x86_64.rpm

    작성: /home/respiro/rpmbuild/RPMS/x86_64/bpftool-debuginfo-3.10.0-1062.12.1.el7.x86_64.rpm

    작성: /home/respiro/rpmbuild/RPMS/x86_64/kernel-devel-3.10.0-1062.12.1.el7.x86_64.rpm

    작성: /home/respiro/rpmbuild/RPMS/x86_64/kernel-debuginfo-3.10.0-1062.12.1.el7.x86_64.rpm

    작성: /home/respiro/rpmbuild/RPMS/x86_64/kernel-debug-3.10.0-1062.12.1.el7.x86_64.rpm

    작성: /home/respiro/rpmbuild/RPMS/x86_64/kernel-debug-devel-3.10.0-1062.12.1.el7.x86_64.rpm

    작성: /home/respiro/rpmbuild/RPMS/x86_64/kernel-debug-debuginfo-3.10.0-1062.12.1.el7.x86_64.rpm

    실행 중(%clean): /bin/sh -e /var/tmp/rpm-tmp.CAEqGK

    + umask 022

    + cd /home/respiro/rpmbuild/BUILD

    + cd kernel-3.10.0-1062.12.1.el7

    + rm -rf /home/respiro/rpmbuild/BUILDROOT/kernel-3.10.0-1062.12.1.el7.x86_64

    + exit 0


    real    30m2.942s

    user    243m42.035s

    sys     43m13.747s


    Linux Kernel 5.5.8-1

    ...

    실행 중(%clean): /bin/sh -e /var/tmp/rpm-tmp.R7ez3L

    + umask 022

    + cd /home/respiro/rpmbuild/BUILD

    + cd kernel-3.10.0-1062.12.1.el7

    + rm -rf /home/respiro/rpmbuild/BUILDROOT/kernel-3.10.0-1062.12.1.el7.x86_64

    + exit 0


    real    28m26.299s

    user    249m16.163s

    sys     38m53.185s


    기대했던것 만큼 크게 향상되거나 하지는 않는 것 같다.


     

     3.10.0-1062.12.1

     5.5.8-1

     Real

     30분 2.942 초

      28분 26.299초

     User

     243분 42.035 초

     249분 16.163초 

     Sys

     43분 13.747 초  

      38분 53.185초 


    • Real is wall clock time - time from start to finish of the call. This is all elapsed time including time slices used by other processes and time the process spends blocked (for example if it is waiting for I/O to complete).

    • User is the amount of CPU time spent in user-mode code (outside the kernel) within the process. This is only actual CPU time used in executing the process. Other processes and time the process spends blocked do not count towards this figure.

    • Sys is the amount of CPU time spent in the kernel within the process. This means executing CPU time spent in system calls within the kernel, as opposed to library code, which is still running in user-space. Like 'user', this is only CPU time used by the process. See below for a brief description of kernel mode (also known as 'supervisor' mode) and the system call mechanism.


    User+Sys will tell you how much actual CPU time your process used. Note that this is across all CPUs, so if the process has multiple threads (and this process is running on a computer with more than one processor) it could potentially exceed the wall clock time reported by Real (which usually occurs). Note that in the output these figures include the User and Sys time of all child processes (and their descendants) as well when they could have been collected, e.g. by wait(2) or waitpid(2), although the underlying system calls return the statistics for the process and its children separately


    출처: https://stackoverflow.com/questions/556405/what-do-real-user-and-sys-mean-in-the-output-of-time1


    6. LuxMark 테스트

    LuxMark 는 OpenCL 벤치마크 도구다.

    GUI 에서 CPU 혹은 GPU 렌더링 벤치마크를 수행할 수 있다.


    LuxMark 소스 내려받기

    $ git clone https://github.com/LuxCoreRender/LuxMark.git

    $ cd LuxMark

    $ mkdir build

    $ cd build

    $ cmake ../

    ...

    CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:138 (message):


    ..


    $ sudo yum install OpenImageIO-devel

    $ cmake ../

    ..

    CMake Error at cmake/Dependencies.cmake:177 (MESSAGE):

      LuxRays not found.


    $ cd ..
    $ git clone https://github.com/scollinson/luxrays.git


    귀챦아졌다. 

    바이너리 다운받자.


    'Linux' 카테고리의 다른 글

    PDFium 라이브러리 삽질기 - 5  (0) 2019.12.16
    PDFium 라이브러리 삽질기 - 4  (0) 2019.12.13
    PDFium 라이브러리 삽질기 - 3  (0) 2019.12.11
    PDFium 라이브러리 삽질기 - 2  (0) 2019.12.10
    PDFium 라이브러리 삽질기 - 1  (0) 2019.12.10

    댓글

Designed by Tistory.