Skip to content

Commit

Permalink
Merge pull request #777 from intel/push-2024-07-06
Browse files Browse the repository at this point in the history
Push 2024 07 06
  • Loading branch information
rdementi authored Jul 6, 2024
2 parents 761c2bf + 5ced9e2 commit cd7342b
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 129 deletions.
44 changes: 0 additions & 44 deletions .github/workflows/ci-gcc48.yml

This file was deleted.

49 changes: 0 additions & 49 deletions .github/workflows/ci-gcc5.yml

This file was deleted.

24 changes: 7 additions & 17 deletions .github/workflows/ci-gcc7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:
jobs:
build:

runs-on: ci-gcc7
runs-on: ci-gcc9
if: ${{ github.repository != 'intel/pcm' }}

steps:
Expand All @@ -21,26 +21,16 @@ jobs:
with:
egress-policy: audit

- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: install simdjson
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: simdjson/simdjson
path: src/simdjson
submodules: recursive
- name: Configure CMake
run: |
cmake --version
rm -rf ${{ github.workspace }}/build && mkdir ${{ github.workspace }}/build
cd ${{ github.workspace }}/build
cmake -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/build ..
- name: Build
run: |
g++ --version
cd ${{ github.workspace }}/build
make -j$(nproc)
- name: Install
rm -rf ${{ github.workspace }}/build
CXX=g++-7 CC=gcc-7 cmake -B ${{ github.workspace }}/build -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/build
- name: Build and Install
run: |
g++-7 --version
cd ${{ github.workspace }}/build
make install -j$(nproc)
- name: Diagnostic
run: date
19 changes: 14 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ if(UNIX) # LINUX, FREE_BSD, APPLE
add_subdirectory(MacMSRDriver)
include_directories("${CMAKE_SOURCE_DIR}/src/MacMSRDriver") # target_include_directories doesn't work
target_link_libraries(PCM_SHARED PRIVATE PCM_STATIC_SILENT PcmMsr Threads::Threads)
elseif(LINUX)
target_link_libraries(PCM_SHARED PRIVATE PCM_STATIC_SILENT Threads::Threads asan)
else()
target_link_libraries(PCM_SHARED PRIVATE PCM_STATIC_SILENT Threads::Threads)
endif()
Expand All @@ -66,14 +64,21 @@ if(MSVC)
file(GLOB WINDOWS_SOURCES winpmem/winpmem.cpp windows/stdafx.cpp freegetopt/getopt.cpp)
add_library(PCM_STATIC STATIC ${COMMON_SOURCES} ${WINDOWS_SOURCES})
target_compile_definitions(PCM_STATIC PRIVATE UNICODE _UNICODE _CONSOLE)
target_compile_options(PCM_STATIC PRIVATE "/MT$<$<CONFIG:Debug>:d>")
if (NO_STATIC_MSVC_RUNTIME_LIBRARY)
set(PCM_MSVC_RUNTIME_LIBRARY_OPTIONS "")
else()
set(PCM_MSVC_RUNTIME_LIBRARY_OPTIONS "/MT$<$<CONFIG:Debug>:d>")
message(STATUS "Using static MSVC runtime library")
message(STATUS "To use default/dynamic MSVC runtime library, use -DNO_STATIC_MSVC_RUNTIME_LIBRARY=1 option")
endif()
target_compile_options(PCM_STATIC PRIVATE "${PCM_MSVC_RUNTIME_LIBRARY_OPTIONS}")

# Graphical perfmon front-end: pcm-lib, pcm-service
# Files: COMMON_FILES() + pcm-lib.cpp winpmem\winpmem.cpp dllmain.cpp
file(GLOB PCM_LIB_SOURCES winpmem/winpmem.cpp dllmain.cpp pcm-lib.cpp )
add_library(pcm-lib SHARED ${COMMON_SOURCES} ${PCM_LIB_SOURCES})
target_compile_definitions(pcm-lib PRIVATE _WINDOWS _USRDLL PCM_EXPORTS _WINDLL _UNICODE UNICODE)
target_compile_options(pcm-lib PRIVATE "/MT$<$<CONFIG:Debug>:d>")
target_compile_options(pcm-lib PRIVATE "${PCM_MSVC_RUNTIME_LIBRARY_OPTIONS}")

# Pcm-service files: PCM_SHARED + AssemblyInfo.cpp PCMInstaller.cpp PCMService.cpp
file(GLOB PCM_SERVICE_SOURCES windows/PCMInstaller.cpp windows/PCMService.cpp windows/AssemblyInfo.cpp winddows/utils.cpp)
Expand Down Expand Up @@ -139,9 +144,13 @@ foreach(PROJECT_NAME ${PROJECT_NAMES})
add_executable(${PROJECT_NAME} ${PROJECT_FILE})

if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE "/MT$<$<CONFIG:Debug>:d>")
target_compile_options(${PROJECT_NAME} PRIVATE "${PCM_MSVC_RUNTIME_LIBRARY_OPTIONS}")
endif(MSVC)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-static-libasan")
endif()

# specific file for pcm-raw project
if(${PROJECT_NAME} STREQUAL pcm-raw)
set(LIBS ${LIBS} PCM_SIMDJSON)
Expand Down
19 changes: 10 additions & 9 deletions src/cpucounters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8712,27 +8712,28 @@ void ServerUncorePMUs::programServerUncoreMemoryMetrics(const ServerUncoreMemory
std::cerr << "PCM Error: invalid rankA value: " << rankA << "\n";
return;
}
if (rankB < 0 || rankB > 7)
{
std::cerr << "PCM Error: invalid rankB value: " << rankB << "\n";
return;
}
switch(cpu_model)
{
case PCM::IVYTOWN:
MCCntConfig[EventPosition::READ_RANK_A] = MC_CH_PCI_PMON_CTL_EVENT((0xb0 + rankA)) + MC_CH_PCI_PMON_CTL_UMASK(0xff); // RD_CAS_RANK(rankA) all banks
MCCntConfig[EventPosition::WRITE_RANK_A] = MC_CH_PCI_PMON_CTL_EVENT((0xb8 + rankA)) + MC_CH_PCI_PMON_CTL_UMASK(0xff); // WR_CAS_RANK(rankA) all banks
MCCntConfig[EventPosition::READ_RANK_B] = MC_CH_PCI_PMON_CTL_EVENT((0xb0 + rankB)) + MC_CH_PCI_PMON_CTL_UMASK(0xff); // RD_CAS_RANK(rankB) all banks
MCCntConfig[EventPosition::WRITE_RANK_B] = MC_CH_PCI_PMON_CTL_EVENT((0xb8 + rankB)) + MC_CH_PCI_PMON_CTL_UMASK(0xff); // WR_CAS_RANK(rankB) all banks
if (rankB >= 0 && rankB <= 7)
{
MCCntConfig[EventPosition::READ_RANK_B] = MC_CH_PCI_PMON_CTL_EVENT((0xb0 + rankB)) + MC_CH_PCI_PMON_CTL_UMASK(0xff); // RD_CAS_RANK(rankB) all banks
MCCntConfig[EventPosition::WRITE_RANK_B] = MC_CH_PCI_PMON_CTL_EVENT((0xb8 + rankB)) + MC_CH_PCI_PMON_CTL_UMASK(0xff); // WR_CAS_RANK(rankB) all banks
}
break;
case PCM::HASWELLX:
case PCM::BDX_DE:
case PCM::BDX:
case PCM::SKX:
MCCntConfig[EventPosition::READ_RANK_A] = MC_CH_PCI_PMON_CTL_EVENT((0xb0 + rankA)) + MC_CH_PCI_PMON_CTL_UMASK(16); // RD_CAS_RANK(rankA) all banks
MCCntConfig[EventPosition::WRITE_RANK_A] = MC_CH_PCI_PMON_CTL_EVENT((0xb8 + rankA)) + MC_CH_PCI_PMON_CTL_UMASK(16); // WR_CAS_RANK(rankA) all banks
MCCntConfig[EventPosition::READ_RANK_B] = MC_CH_PCI_PMON_CTL_EVENT((0xb0 + rankB)) + MC_CH_PCI_PMON_CTL_UMASK(16); // RD_CAS_RANK(rankB) all banks
MCCntConfig[EventPosition::WRITE_RANK_B] = MC_CH_PCI_PMON_CTL_EVENT((0xb8 + rankB)) + MC_CH_PCI_PMON_CTL_UMASK(16); // WR_CAS_RANK(rankB) all banks
if (rankB >= 0 && rankB <= 7)
{
MCCntConfig[EventPosition::READ_RANK_B] = MC_CH_PCI_PMON_CTL_EVENT((0xb0 + rankB)) + MC_CH_PCI_PMON_CTL_UMASK(16); // RD_CAS_RANK(rankB) all banks
MCCntConfig[EventPosition::WRITE_RANK_B] = MC_CH_PCI_PMON_CTL_EVENT((0xb8 + rankB)) + MC_CH_PCI_PMON_CTL_UMASK(16); // WR_CAS_RANK(rankB) all banks
}
break;
case PCM::KNL:
MCCntConfig[EventPosition::READ] = MC_CH_PCI_PMON_CTL_EVENT(0x03) + MC_CH_PCI_PMON_CTL_UMASK(1); // monitor reads on counter 0: CAS.RD
Expand Down
1 change: 1 addition & 0 deletions src/pcm-sensor-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,7 @@ class basic_socketbuf : public std::basic_streambuf<CharT> {
bytesReceived = SSL_read( ssl_, static_cast<void*>(inputBuffer_), SIZE * sizeof( char_type ) );
if ( 0 >= bytesReceived ) {
int sslError = SSL_get_error( ssl_, bytesReceived );
ERR_print_errors_fp(stderr);
switch ( sslError ) {
case SSL_ERROR_WANT_READ:
case SSL_ERROR_WANT_WRITE:
Expand Down
8 changes: 7 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@ if(UNIX)
endif(UNIX)

if(FUZZ)
find_package(OpenSSL REQUIRED)
set(SSL_LIBS OpenSSL::SSL OpenSSL::Crypto)
add_executable(urltest-fuzz urltest-fuzz.cpp)
add_executable(pcm-sensor-server-fuzz pcm-sensor-server-fuzz.cpp)
add_executable(pcm-sensor-server-ssl-fuzz pcm-sensor-server-fuzz.cpp)
target_compile_options(pcm-sensor-server-fuzz PRIVATE -DUSE_SSL=1)
target_compile_options(pcm-sensor-server-ssl-fuzz PRIVATE -DUSE_SSL=1 -DFUZZ_USE_SSL=1)
add_executable(pcm-fuzz pcm-fuzz.cpp)
add_executable(pcm-memory-fuzz pcm-memory-fuzz.cpp)
target_link_libraries(urltest-fuzz Threads::Threads PCM_STATIC)
target_link_libraries(pcm-sensor-server-fuzz Threads::Threads PCM_STATIC)
target_link_libraries(pcm-sensor-server-fuzz Threads::Threads PCM_STATIC ${SSL_LIBS})
target_link_libraries(pcm-sensor-server-ssl-fuzz Threads::Threads PCM_STATIC ${SSL_LIBS})
target_link_libraries(pcm-fuzz Threads::Threads PCM_STATIC)
target_link_libraries(pcm-memory-fuzz Threads::Threads PCM_STATIC)
endif()
29 changes: 29 additions & 0 deletions tests/fuzz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ if [ "$#" -eq 1 ]; then
factor=$1
fi

# Suppress leaks in libcrypto
# Below is caused by openssl leaks
# similar to https://github.com/spdk/spdk/issues/2947
echo leak:libcrypto.so >> pcm_asan_suppression_file
export LSAN_OPTIONS=suppressions="pcm_asan_suppression_file"

echo "Running fuzz tests with running time multiplier $factor"

CC=`which clang` CXX=`which clang++` cmake .. -DCMAKE_BUILD_TYPE=Debug -DFUZZ=1 && mkdir -p corpus &&
make urltest-fuzz \
pcm-fuzz \
pcm-memory-fuzz \
pcm-sensor-server-fuzz \
pcm-sensor-server-ssl-fuzz \
-j &&
rm -rf corpus/* &&
printf '%b' "GET / HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/1 &&
Expand All @@ -34,6 +41,26 @@ printf '%b' "GET /dashboard/prometheus HTTP/1.1\r\nHost: localhost\r\nAccept: */
printf '%b' "GET /dashboard/prometheus/default HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/10 &&
printf '%b' "GET /dashboard HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/11 &&
printf '%b' "GET /favicon.ico HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/12 &&
LLVM_PROFILE_FILE="pcm-sensor-server-ssl.profraw" bin/tests/pcm-sensor-server-ssl-fuzz -detect_leaks=0 -max_total_time=$((10 * $factor)) -rss_limit_mb=10000 corpus > /dev/null &&
rm -rf corpus/* &&
printf '%b' "GET / HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/1 &&
printf '%b' "GET /metrics HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/2 &&
printf '%b' "GET /persecond HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/3 &&
printf '%b' "GET /persecond HTTP/1.1\r\nHost: localhost\r\nAccept: application/json\r\n\r\n" > corpus/3.1 &&
printf '%b' "GET /persecond HTTP/1.1\r\nHost: localhost\r\nAccept: text/plain; version=0.0.4\r\n\r\n" > corpus/3.2 &&
printf '%b' "GET /persecond/1 HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/4 &&
printf '%b' "GET /persecond/1 HTTP/1.1\r\nHost: localhost\r\nAccept: application/json\r\n\r\n" > corpus/4.1 &&
printf '%b' "GET /persecond/1 HTTP/1.1\r\nHost: localhost\r\nAccept: text/plain; version=0.0.4\r\n\r\n" > corpus/4.2 &&
printf '%b' "GET /persecond/10 HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/5 &&
printf '%b' "GET /persecond/10 HTTP/1.1\r\nHost: localhost\r\nAccept: application/json\r\n\r\n" > corpus/5.1 &&
printf '%b' "GET /persecond/10 HTTP/1.1\r\nHost: localhost\r\nAccept: text/plain; version=0.0.4\r\n\r\n" > corpus/5.2 &&
printf '%b' "GET /persecond/100 HTTP/1.1\r\nHost: localhost\r\nAccept: application/json\r\n\r\n" > corpus/6 &&
printf '%b' "GET /metrics HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/7 &&
printf '%b' "GET /dashboard/influxdb HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/8 &&
printf '%b' "GET /dashboard/prometheus HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/9 &&
printf '%b' "GET /dashboard/prometheus/default HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/10 &&
printf '%b' "GET /dashboard HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/11 &&
printf '%b' "GET /favicon.ico HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/12 &&
LLVM_PROFILE_FILE="pcm-sensor-server.profraw" bin/tests/pcm-sensor-server-fuzz -detect_leaks=0 -rss_limit_mb=10000 -max_total_time=$((10 * $factor)) corpus > /dev/null &&
rm -rf corpus/* &&
printf '%b' "http://otto:test@www.intel.com/~otto/file1.txt" > corpus/1 &&
Expand Down Expand Up @@ -71,11 +98,13 @@ llvm-profdata merge -sparse \
pcm.nmi_watchdog.profraw \
pcm-memory.profraw \
pcm-sensor-server.profraw \
pcm-sensor-server-ssl.profraw \
-o all.profdata &&
llvm-cov report --summary-only \
-object ./bin/tests/pcm-fuzz \
-object ./bin/tests/urltest-fuzz \
-object ./bin/tests/pcm-memory-fuzz \
-object ./bin/tests/pcm-sensor-server-fuzz \
-object ./bin/tests/pcm-sensor-server-ssl-fuzz \
-instr-profile=all.profdata | tee report.txt

Loading

0 comments on commit cd7342b

Please sign in to comment.