Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'linux_kselftest-next-6.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull kselftest updates from Shuah Khan:
"resctrl test:
- fix division by zero error on Hygon
- fix non-contiguous CBM check for Hygon
- define CPU vendor IDs as bits to match usage
- add CPU vendor detection for Hygon

misc:
- coredeump test: use __builtin_trap() instead of a null pointer
- anon_inode: replace null pointers with empty arrays
- kublk: include message in _Static_assert for C11 compatibility
- run_kselftest.sh: add `--skip` argument option
- pidfd: fix typo in comment"

* tag 'linux_kselftest-next-6.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
selftests/pidfd: fix typo in comment
selftests/run_kselftest.sh: Add `--skip` argument option
selftests/resctrl: Fix non-contiguous CBM check for Hygon
selftests/resctrl: Add CPU vendor detection for Hygon
selftests/resctrl: Define CPU vendor IDs as bits to match usage
selftests/resctrl: Fix a division by zero error on Hygon
kselftest/kublk: include message in _Static_assert for C11 compatibility
kselftest/anon_inode: replace null pointers with empty arrays
kselftest/coredump: use __builtin_trap() instead of null pointer

+57 -17
+1 -1
tools/testing/selftests/coredump/coredump_test_helpers.c
··· 56 56 pthread_create(&thread, NULL, do_nothing, NULL); 57 57 58 58 /* crash on purpose */ 59 - i = *(int *)NULL; 59 + __builtin_trap(); 60 60 } 61 61 62 62 int create_detached_tmpfs(void)
+4 -1
tools/testing/selftests/filesystems/anon_inode_test.c
··· 42 42 fd_context = sys_fsopen("tmpfs", 0); 43 43 ASSERT_GE(fd_context, 0); 44 44 45 - ASSERT_LT(execveat(fd_context, "", NULL, NULL, AT_EMPTY_PATH), 0); 45 + char *const empty_argv[] = {NULL}; 46 + char *const empty_envp[] = {NULL}; 47 + 48 + ASSERT_LT(execveat(fd_context, "", empty_argv, empty_envp, AT_EMPTY_PATH), 0); 46 49 ASSERT_EQ(errno, EACCES); 47 50 48 51 EXPECT_EQ(close(fd_context), 0);
+1 -1
tools/testing/selftests/pidfd/pidfd_info_test.c
··· 229 229 230 230 close(ipc_socket); 231 231 232 - /* Sleep untill we're killed. */ 232 + /* Sleep until we're killed. */ 233 233 pause(); 234 234 return NULL; 235 235 }
+4 -2
tools/testing/selftests/resctrl/cat_test.c
··· 290 290 291 291 static bool arch_supports_noncont_cat(const struct resctrl_test *test) 292 292 { 293 - /* AMD always supports non-contiguous CBM. */ 294 - if (get_vendor() == ARCH_AMD) 293 + unsigned int vendor_id = get_vendor(); 294 + 295 + /* AMD and Hygon always support non-contiguous CBM. */ 296 + if (vendor_id == ARCH_AMD || vendor_id == ARCH_HYGON) 295 297 return true; 296 298 297 299 #if defined(__i386__) || defined(__x86_64__) /* arch */
+5 -3
tools/testing/selftests/resctrl/resctrl.h
··· 23 23 #include <asm/unistd.h> 24 24 #include <linux/perf_event.h> 25 25 #include <linux/compiler.h> 26 + #include <linux/bits.h> 26 27 #include "kselftest.h" 27 28 28 29 #define MB (1024 * 1024) ··· 37 36 * Define as bits because they're used for vendor_specific bitmask in 38 37 * the struct resctrl_test. 39 38 */ 40 - #define ARCH_INTEL 1 41 - #define ARCH_AMD 2 39 + #define ARCH_INTEL BIT(0) 40 + #define ARCH_AMD BIT(1) 41 + #define ARCH_HYGON BIT(2) 42 42 43 43 #define END_OF_TESTS 1 44 44 ··· 165 163 extern char llc_occup_path[1024]; 166 164 167 165 int snc_nodes_per_l3_cache(void); 168 - int get_vendor(void); 166 + unsigned int get_vendor(void); 169 167 bool check_resctrlfs_support(void); 170 168 int filter_dmesg(void); 171 169 int get_domain_id(const char *resource, int cpu_no, int *domain_id);
+20 -8
tools/testing/selftests/resctrl/resctrl_tests.c
··· 23 23 &l2_noncont_cat_test, 24 24 }; 25 25 26 - static int detect_vendor(void) 26 + static unsigned int detect_vendor(void) 27 27 { 28 - FILE *inf = fopen("/proc/cpuinfo", "r"); 29 - int vendor_id = 0; 28 + static unsigned int vendor_id; 29 + static bool initialized; 30 30 char *s = NULL; 31 + FILE *inf; 31 32 char *res; 32 33 33 - if (!inf) 34 + if (initialized) 34 35 return vendor_id; 36 + 37 + inf = fopen("/proc/cpuinfo", "r"); 38 + if (!inf) { 39 + vendor_id = 0; 40 + initialized = true; 41 + return vendor_id; 42 + } 35 43 36 44 res = fgrep(inf, "vendor_id"); 37 45 ··· 50 42 vendor_id = ARCH_INTEL; 51 43 else if (s && !strcmp(s, ": AuthenticAMD\n")) 52 44 vendor_id = ARCH_AMD; 45 + else if (s && !strcmp(s, ": HygonGenuine\n")) 46 + vendor_id = ARCH_HYGON; 53 47 54 48 fclose(inf); 55 49 free(res); 50 + 51 + initialized = true; 56 52 return vendor_id; 57 53 } 58 54 59 - int get_vendor(void) 55 + unsigned int get_vendor(void) 60 56 { 61 - static int vendor = -1; 57 + unsigned int vendor; 62 58 63 - if (vendor == -1) 64 - vendor = detect_vendor(); 59 + vendor = detect_vendor(); 60 + 65 61 if (vendor == 0) 66 62 ksft_print_msg("Can not get vendor info...\n"); 67 63
+10
tools/testing/selftests/resctrl/resctrlfs.c
··· 243 243 } 244 244 snc_mode = cache_cpus / node_cpus; 245 245 246 + /* 247 + * On some platforms (e.g. Hygon), 248 + * cache_cpus < node_cpus, the calculated snc_mode is 0. 249 + * 250 + * Set snc_mode = 1 to indicate that SNC mode is not 251 + * supported on the platform. 252 + */ 253 + if (!snc_mode) 254 + snc_mode = 1; 255 + 246 256 if (snc_mode > 1) 247 257 ksft_print_msg("SNC-%d mode discovered.\n", snc_mode); 248 258 }
+11
tools/testing/selftests/run_kselftest.sh
··· 30 30 -s | --summary Print summary with detailed log in output.log (conflict with -p) 31 31 -p | --per-test-log Print test log in /tmp with each test name (conflict with -s) 32 32 -t | --test COLLECTION:TEST Run TEST from COLLECTION 33 + -S | --skip COLLECTION:TEST Skip TEST from COLLECTION 33 34 -c | --collection COLLECTION Run all tests from COLLECTION 34 35 -l | --list List the available collection:test entries 35 36 -d | --dry-run Don't actually run any tests ··· 44 43 45 44 COLLECTIONS="" 46 45 TESTS="" 46 + SKIP="" 47 47 dryrun="" 48 48 kselftest_override_timeout="" 49 49 ERROR_ON_FAIL=true ··· 59 57 shift ;; 60 58 -t | --test) 61 59 TESTS="$TESTS $2" 60 + shift 2 ;; 61 + -S | --skip) 62 + SKIP="$SKIP $2" 62 63 shift 2 ;; 63 64 -c | --collection) 64 65 COLLECTIONS="$COLLECTIONS $2" ··· 113 108 valid="$valid $found" 114 109 done 115 110 available="$(echo "$valid" | sed -e 's/ /\n/g')" 111 + fi 112 + # Remove tests to be skipped from available list 113 + if [ -n "$SKIP" ]; then 114 + for skipped in $SKIP ; do 115 + available="$(echo "$available" | grep -v "^${skipped}$")" 116 + done 116 117 fi 117 118 118 119 kselftest_failures_file="$(mktemp --tmpdir kselftest-failures-XXXXXX)"
+1 -1
tools/testing/selftests/ublk/kublk.h
··· 223 223 unsigned tgt_data, unsigned q_id, unsigned is_target_io) 224 224 { 225 225 /* we only have 7 bits to encode q_id */ 226 - _Static_assert(UBLK_MAX_QUEUES_SHIFT <= 7); 226 + _Static_assert(UBLK_MAX_QUEUES_SHIFT <= 7, "UBLK_MAX_QUEUES_SHIFT must be <= 7"); 227 227 assert(!(tag >> 16) && !(op >> 8) && !(tgt_data >> 16) && !(q_id >> 7)); 228 228 229 229 return tag | (op << 16) | (tgt_data << 24) |