From 76c3e4b72e2d451b812db4ccd7de83d82f8e96e7 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 7 Nov 2024 12:41:45 +0100 Subject: [PATCH 1/3] Remove x86-specific instructions from telnet server telnetsrv uses the Intel/AMD-specific "cpuid" instruction, which is not available on ARM machines. Remove the call. The previous code was checking for the number of cores, which is retained by a call to get_nprocs(). I did not find an equivalent for the number of threads in C. In C++, there would be https://en.cppreference.com/w/cpp/thread/thread/hardware_concurrency, in case it's relevant for anybody. --- common/utils/telnetsrv/telnetsrv_proccmd.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/common/utils/telnetsrv/telnetsrv_proccmd.c b/common/utils/telnetsrv/telnetsrv_proccmd.c index 4255b20956..f081bb66a1 100644 --- a/common/utils/telnetsrv/telnetsrv_proccmd.c +++ b/common/utils/telnetsrv/telnetsrv_proccmd.c @@ -32,6 +32,7 @@ #define _GNU_SOURCE #include #include +#include #include #include #include @@ -222,11 +223,8 @@ char aname[256]; tdata->numlines = 0; } - unsigned int eax = 11, ebx = 0, ecx = 1, edx = 0; - - asm volatile("cpuid" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "0"(eax), "2"(ecx) :); - - prnt("System has %d cores %d threads %d Actual threads", eax, ebx, edx); + int nprocs = get_nprocs(); + prnt("System has %d cores", nprocs); prnt("\n id name state USRmod KRNmod prio nice vsize proc pol \n\n"); snprintf(aname, sizeof(aname), "/proc/%d/stat", getpid()); From 2204fc13db87d5347d46d9e183c4d14ce78cc8b0 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 7 Nov 2024 12:44:26 +0100 Subject: [PATCH 2/3] Compile telnetsrv in cross-compilation pipeline --- docker/Dockerfile.build.ubuntu22.cross-arm64 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile.build.ubuntu22.cross-arm64 b/docker/Dockerfile.build.ubuntu22.cross-arm64 index 7b145fdc5b..97dbee50e8 100644 --- a/docker/Dockerfile.build.ubuntu22.cross-arm64 +++ b/docker/Dockerfile.build.ubuntu22.cross-arm64 @@ -36,7 +36,7 @@ RUN /bin/sh oaienv && \ cd cmake_targets && \ mkdir -p log ran_build/build ran_build/build-cross && \ cd ran_build/build && \ - cmake ../../.. -GNinja && \ + cmake ../../.. -GNinja -DENABLE_TELNETSRV=ON && \ echo "====== Start of log for host-tools ======" && \ ninja ldpc_generators generate_T > ../../log/host-tools.txt 2>&1 && \ echo "====== End of log for host-tools ======" && \ @@ -48,7 +48,7 @@ RUN /bin/sh oaienv && \ -DCMAKE_C_FLAGS="-Werror" -DCMAKE_CXX_FLAGS="-Werror" && \ echo "====== Start of log for cross-build executables ======" && \ # making always passing so we can analyze the all.txt file - ninja dlsim ulsim ldpctest polartest smallblocktest nr_pbchsim nr_dlschsim nr_ulschsim nr_dlsim nr_ulsim nr_pucchsim nr_prachsim lte-softmodem nr-softmodem nr-cuup oairu lte-uesoftmodem nr-uesoftmodem params_libconfig coding rfsimulator > ../../log/all.txt 2>&1; \ + ninja dlsim ulsim ldpctest polartest smallblocktest nr_pbchsim nr_dlschsim nr_ulschsim nr_dlsim nr_ulsim nr_pucchsim nr_prachsim lte-softmodem nr-softmodem nr-cuup oairu lte-uesoftmodem nr-uesoftmodem params_libconfig coding rfsimulator telnetsrv > ../../log/all.txt 2>&1; \ # displaying errors and warnings grep -E -A3 "warning:|error:" ../../log/all.txt || true && \ # will fail only if string "errors:" is found From 49584e6cb3a85863787980829c6fd14eb7eefcf4 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 7 Nov 2024 13:17:21 +0100 Subject: [PATCH 3/3] fixup --- docker/Dockerfile.build.ubuntu22.cross-arm64 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile.build.ubuntu22.cross-arm64 b/docker/Dockerfile.build.ubuntu22.cross-arm64 index 97dbee50e8..91b53ff6b4 100644 --- a/docker/Dockerfile.build.ubuntu22.cross-arm64 +++ b/docker/Dockerfile.build.ubuntu22.cross-arm64 @@ -36,14 +36,14 @@ RUN /bin/sh oaienv && \ cd cmake_targets && \ mkdir -p log ran_build/build ran_build/build-cross && \ cd ran_build/build && \ - cmake ../../.. -GNinja -DENABLE_TELNETSRV=ON && \ + cmake ../../.. -GNinja && \ echo "====== Start of log for host-tools ======" && \ ninja ldpc_generators generate_T > ../../log/host-tools.txt 2>&1 && \ echo "====== End of log for host-tools ======" && \ cd ../build-cross/ && \ # install missing libyaml-cpp-dev for arm64 apt install -y libyaml-cpp-dev:arm64 && \ - cmake ../../.. -GNinja \ + cmake ../../.. -GNinja -DENABLE_TELNETSRV=ON \ -DCMAKE_TOOLCHAIN_FILE=../../../cmake_targets/cross-arm.cmake -DNATIVE_DIR=../build \ -DCMAKE_C_FLAGS="-Werror" -DCMAKE_CXX_FLAGS="-Werror" && \ echo "====== Start of log for cross-build executables ======" && \