diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-04-08 16:01:18 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-04-08 16:01:18 +0000 |
commit | 88be01fe5f129a7ab8020e5d4c9cdd01666a6291 (patch) | |
tree | 8b9c4dfc348ca5779ee6b944325581e97c78b78a | |
parent | 12402f59cc24dc1b3b0bf0ceaaa1993681b54c00 (diff) | |
parent | 4273e3bca33cf3fa696512945c85033862f3856a (diff) | |
download | ltp-88be01fe5f129a7ab8020e5d4c9cdd01666a6291.tar.gz |
Snap for 8426163 from 4273e3bca33cf3fa696512945c85033862f3856a to mainline-tzdata2-releaseandroid-mainline-12.0.0_r112aml_tz2_305400500aml_tz2_305400300aml_tz2_305400100aml_tz2_304500300aml_tz2_303900110aml_tz2_303900102aml_tz2_303800002aml_tz2_303800001aml_tz2_303200001android12-mainline-tzdata2-releaseaml_tz2_305400100
Change-Id: Iee7734bd8e41ec8ccc7fe7d9a1e47d2fcff80f52
28 files changed, 177 insertions, 349 deletions
diff --git a/Android.bp b/Android.bp index 03821b6c9..8b7f2e75c 100644 --- a/Android.bp +++ b/Android.bp @@ -15,63 +15,13 @@ // // Include the generated rules -// *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS. PLEASE -// CONSULT THE OWNERS AND opensource-licensing@google.com BEFORE -// DEPENDING ON IT IN YOUR PROJECT. *** -package { - default_applicable_licenses: ["external_ltp_license"], -} - -// Added automatically by a large-scale-change that took the approach of -// 'apply every license found to every target'. While this makes sure we respect -// every license restriction, it may not be entirely correct. -// -// e.g. GPL in an MIT project might only apply to the contrib/ directory. -// -// Please consider splitting the single license below into multiple licenses, -// taking care not to lose any license_kind information, and overriding the -// default license using the 'licenses: [...]' property on targets as needed. -// -// For unused files, consider creating a 'fileGroup' with "//visibility:private" -// to attach the license to, and including a comment whether the files may be -// used in the current project. -// -// large-scale-change included anything that looked like it might be a license -// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc. -// -// Please consider removing redundant or irrelevant files from 'license_text:'. -// See: http://go/android-license-faq -license { - name: "external_ltp_license", - visibility: [":__subpackages__"], - license_kinds: [ - "SPDX-license-identifier-APSL-1.1", - "SPDX-license-identifier-Apache-2.0", - "SPDX-license-identifier-BSD", - "SPDX-license-identifier-BSD-2-Clause", - "SPDX-license-identifier-BSD-3-Clause", - "SPDX-license-identifier-GFDL", // by exception only - "SPDX-license-identifier-GPL", - "SPDX-license-identifier-GPL-2.0", - "SPDX-license-identifier-GPL-3.0", - "SPDX-license-identifier-ISC", - "SPDX-license-identifier-LGPL", - ], - license_text: [ - "COPYING", - "NOTICE", - ], -} - build = ["gen.bp"] genrule { name: "ltp_syscalls_h", - tool_files: [ - "include/lapi/syscalls/regen.sh", - "include/lapi/syscalls/*.in", - ], + tool_files: ["include/lapi/syscalls/regen.sh"], cmd: "$(location) $(genDir)/lapi/syscalls.h", + srcs: ["include/lapi/syscalls/*.in"], out: ["lapi/syscalls.h"], } diff --git a/METADATA b/METADATA deleted file mode 100644 index d15c65dcc..000000000 --- a/METADATA +++ /dev/null @@ -1,8 +0,0 @@ -# *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS. PLEASE -# CONSULT THE OWNERS AND opensource-licensing@google.com BEFORE -# DEPENDING ON IT IN YOUR PROJECT. *** -third_party { - # would be RESTRICTED save for GFDL in: - # testcases/kernel/device-drivers/v4l/user_space/doc/spec/*.htm* - license_type: BY_EXCEPTION_ONLY -} diff --git a/android/Android.mk b/android/Android.mk index c627356b7..8db2c0370 100644 --- a/android/Android.mk +++ b/android/Android.mk @@ -23,9 +23,6 @@ ltp_build_prebuilt := include $(CLEAR_VARS) LOCAL_MODULE := ltp -LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-GPL-2.0 -LOCAL_LICENSE_CONDITIONS := notice restricted -LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../COPYING $(LOCAL_PATH)/../NOTICE LOCAL_MODULE_STEM := disabled_tests.txt LOCAL_PREBUILT_MODULE_FILE := $(LOCAL_PATH)/tools/disabled_tests.txt LOCAL_MODULE_RELATIVE_PATH := ltp diff --git a/android/Android.prebuilt.mk b/android/Android.prebuilt.mk index 5fa2e4b58..2fb5daa3c 100644 --- a/android/Android.prebuilt.mk +++ b/android/Android.prebuilt.mk @@ -18,9 +18,6 @@ module_stem := $(notdir $(module_prebuilt)) module_path := $(patsubst %/,%,$(dir $(module_prebuilt))) LOCAL_MODULE := $(module_name) -LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-GPL-2.0 -LOCAL_LICENSE_CONDITIONS := notice restricted -LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../COPYING $(LOCAL_PATH)/../NOTICE LOCAL_INSTALLED_MODULE_STEM := $(module_stem) LOCAL_PREBUILT_MODULE_FILE := $(local_ltp_root)/$(module_src_files) LOCAL_MODULE_RELATIVE_PATH := ltp/$(module_path) diff --git a/android/include/config.h b/android/include/config.h index bb216469e..49a64e3e4 100644 --- a/android/include/config.h +++ b/android/include/config.h @@ -262,7 +262,7 @@ #define HAVE_PIDFD_OPEN 1 /* Define to 1 if you have the `pidfd_send_signal' function. */ -#define HAVE_PIDFD_SEND_SIGNAL 1 +/* #undef HAVE_PIDFD_SEND_SIGNAL */ /* Define to 1 if you have the `pkey_mprotect' function. */ /* #undef HAVE_PKEY_MPROTECT */ diff --git a/include/tst_cpu.h b/include/tst_cpu.h index 2e21384f9..1aacf8593 100644 --- a/include/tst_cpu.h +++ b/include/tst_cpu.h @@ -22,10 +22,8 @@ long tst_ncpus(void); long tst_ncpus_conf(void); long tst_ncpus_max(void); -#define VIRT_ANY 0 /* catch-all argument for tst_is_virt() */ #define VIRT_XEN 1 /* xen dom0/domU */ #define VIRT_KVM 2 /* only default virtual CPU */ -#define VIRT_OTHER 0xffff /* unrecognized hypervisor */ int tst_is_virt(int virt_type); diff --git a/lib/tst_timer_test.c b/lib/tst_timer_test.c index 196c51272..13e9deff2 100644 --- a/lib/tst_timer_test.c +++ b/lib/tst_timer_test.c @@ -26,7 +26,6 @@ static long long *samples; static unsigned int cur_sample; static unsigned int monotonic_resolution; static unsigned int timerslack; -static int virt_env; static char *print_frequency_plot; static char *file_name; @@ -307,10 +306,7 @@ void do_timer_test(long long usec, unsigned int nsamples) samples[nsamples-1], samples[0], median, 1.00 * trunc_mean / keep_samples, discard); - if (virt_env) { - tst_res(TINFO, - "Virtualisation detected, skipping oversleep checks"); - } else if (trunc_mean > (nsamples - discard) * usec + threshold) { + if (trunc_mean > (nsamples - discard) * usec + threshold) { tst_res(TFAIL, "%s slept for too long", scall); if (!print_frequency_plot) @@ -347,11 +343,6 @@ static void timer_setup(void) if (setup) setup(); - /* - * Running tests in VM may cause timing issues, disable upper bound - * checks if any hypervisor is detected. - */ - virt_env = tst_is_virt(VIRT_ANY); tst_clock_getres(CLOCK_MONOTONIC, &t); tst_res(TINFO, "CLOCK_MONOTONIC resolution %lins", (long)t.tv_nsec); diff --git a/lib/tst_virt.c b/lib/tst_virt.c index d21f74c1c..e95cf5e70 100644 --- a/lib/tst_virt.c +++ b/lib/tst_virt.c @@ -23,20 +23,9 @@ */ #include <unistd.h> -#include <sys/stat.h> #include "test.h" #include "safe_macros.h" -static int file_exist(const char *path) -{ - struct stat st; - - if (!access(path, R_OK) && !stat(path, &st)) - return 1; - - return 0; -} - static int is_kvm(void) { FILE *cpuinfo; @@ -55,16 +44,12 @@ static int is_kvm(void) } SAFE_FCLOSE(NULL, cpuinfo); - - if (file_exist("/dev/vda") || file_exist("/dev/block/vda")) - found = 1; - return found; } static int is_xen(void) { - char hypervisor_type[4]; + char hypervisor_type[3]; if (access("/proc/xen", F_OK) == 0) return 1; @@ -105,41 +90,30 @@ static int try_systemd_detect_virt(void) * systemd-detect-virt not found by shell or no virtualization detected * (systemd-detect-virt returns non-zero) */ - if (ret < 0 || (WIFEXITED(ret) && WEXITSTATUS(ret) == 127)) - return -1; - if (ret) return 0; - if (!strncmp("kvm", virt_type, 3)) + if (strncmp("kvm", virt_type, 3)) return VIRT_KVM; - if (!strncmp("xen", virt_type, 3)) + if (strncmp("xen", virt_type, 3)) return VIRT_XEN; - return VIRT_OTHER; + return 0; } int tst_is_virt(int virt_type) { int ret = try_systemd_detect_virt(); - if (ret >= 0) { - if (virt_type == VIRT_ANY) - return ret != 0; - else - return ret == virt_type; - } + if (ret) + return ret == virt_type; switch (virt_type) { - case VIRT_ANY: - return is_xen() || is_kvm(); case VIRT_XEN: return is_xen(); case VIRT_KVM: return is_kvm(); - case VIRT_OTHER: - return 0; } tst_brkm(TBROK, NULL, "invalid virt_type flag: %d", virt_type); diff --git a/testcases/kernel/sched/eas/eas_big_to_small.c b/testcases/kernel/sched/eas/eas_big_to_small.c index d1e14378f..36f9598cd 100644 --- a/testcases/kernel/sched/eas/eas_big_to_small.c +++ b/testcases/kernel/sched/eas/eas_big_to_small.c @@ -35,7 +35,7 @@ static void *task_fn(void *arg LTP_ATTRIBUTE_UNUSED) burn(BURN_SEC * USEC_PER_SEC, 0); printf("Changing to small task...\n"); - tracefs_write("trace_marker", "SMALL TASK"); + SAFE_FILE_PRINTF(TRACING_DIR "trace_marker", "SMALL TASK"); burn(BURN_SEC * USEC_PER_SEC, 1); return NULL; @@ -50,7 +50,6 @@ static int parse_results(void) unsigned long long big_task_us = 0; unsigned long long small_task_us = 0; unsigned long long smalltask_ts_usec = 0; - unsigned long long smalltask_tm_usec = 0; unsigned long long downmigrate_ts_usec = 0; unsigned long long downmigrate_latency_usec = 0; cpu_set_t cpuset; @@ -63,11 +62,10 @@ static int parse_results(void) for (i = 0; i < num_trace_records; i++) { unsigned long long segment_us; struct trace_sched_switch *t = trace[i].event_data; - unsigned long long trace_ts_usec = TS_TO_USEC(trace[i].ts); if (trace[i].event_type == TRACE_RECORD_TRACING_MARK_WRITE && !strcmp(trace[i].event_data, "SMALL TASK")) { - smalltask_tm_usec = trace_ts_usec; + smalltask_ts_usec = TS_TO_USEC(trace[i].ts); continue; } @@ -75,15 +73,12 @@ static int parse_results(void) continue; if (t->next_pid == task_tid) { - if (!smalltask_ts_usec && smalltask_tm_usec && - trace_ts_usec > smalltask_tm_usec) - smalltask_ts_usec = trace_ts_usec; /* Start of task execution segment. */ if (exec_start_us) { printf("Trace parse fail: double exec start\n"); return -1; } - exec_start_us = trace_ts_usec; + exec_start_us = TS_TO_USEC(trace[i].ts); if (smalltask_ts_usec && !downmigrate_ts_usec && CPU_ISSET(trace[i].cpu, &cpuset)) downmigrate_ts_usec = exec_start_us; @@ -92,7 +87,7 @@ static int parse_results(void) if (t->prev_pid != task_tid) continue; /* End of task execution segment. */ - segment_us = trace_ts_usec; + segment_us = TS_TO_USEC(trace[i].ts); segment_us -= exec_start_us; exec_start_us = 0; if (CPU_ISSET(trace[i].cpu, &cpuset)) { @@ -151,17 +146,17 @@ static void run(void) MAX_DOWNMIGRATE_LATENCY_US); /* configure and enable tracing */ - tracefs_write("tracing_on", "0"); - tracefs_write("buffer_size_kb", "16384"); - tracefs_write("set_event", TRACE_EVENTS); - tracefs_write("trace", "\n"); - tracefs_write("tracing_on", "1"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "buffer_size_kb", "16384"); + SAFE_FILE_PRINTF(TRACING_DIR "set_event", TRACE_EVENTS); + SAFE_FILE_PRINTF(TRACING_DIR "trace", "\n"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "1"); SAFE_PTHREAD_CREATE(&task_thread, NULL, task_fn, NULL); SAFE_PTHREAD_JOIN(task_thread, NULL); /* disable tracing */ - tracefs_write("tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); LOAD_TRACE(); if (parse_results()) @@ -174,6 +169,5 @@ static void run(void) static struct tst_test test = { .test_all = run, - .setup = trace_setup, .cleanup = trace_cleanup, }; diff --git a/testcases/kernel/sched/eas/eas_one_big_task.c b/testcases/kernel/sched/eas/eas_one_big_task.c index ab066f51a..5886e9e49 100644 --- a/testcases/kernel/sched/eas/eas_one_big_task.c +++ b/testcases/kernel/sched/eas/eas_one_big_task.c @@ -111,17 +111,17 @@ static void run(void) MAX_UPMIGRATE_LATENCY_US); /* configure and enable tracing */ - tracefs_write("tracing_on", "0"); - tracefs_write("buffer_size_kb", "16384"); - tracefs_write("set_event", TRACE_EVENTS); - tracefs_write("trace", "\n"); - tracefs_write("tracing_on", "1"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "buffer_size_kb", "16384"); + SAFE_FILE_PRINTF(TRACING_DIR "set_event", TRACE_EVENTS); + SAFE_FILE_PRINTF(TRACING_DIR "trace", "\n"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "1"); SAFE_PTHREAD_CREATE(&task_thread, NULL, task_fn, NULL); SAFE_PTHREAD_JOIN(task_thread, NULL); /* disable tracing */ - tracefs_write("tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); LOAD_TRACE(); if (parse_results()) @@ -134,6 +134,5 @@ static void run(void) static struct tst_test test = { .test_all = run, - .setup = trace_setup, .cleanup = trace_cleanup, }; diff --git a/testcases/kernel/sched/eas/eas_one_small_task.c b/testcases/kernel/sched/eas/eas_one_small_task.c index 3885d60bb..74b3a93f8 100644 --- a/testcases/kernel/sched/eas/eas_one_small_task.c +++ b/testcases/kernel/sched/eas/eas_one_small_task.c @@ -94,17 +94,17 @@ static void run(void) MIN_CORRECT_CLUSTER_PCT); /* configure and enable tracing */ - tracefs_write("tracing_on", "0"); - tracefs_write("buffer_size_kb", "16384"); - tracefs_write("set_event", TRACE_EVENTS); - tracefs_write("trace", "\n"); - tracefs_write("tracing_on", "1"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "buffer_size_kb", "16384"); + SAFE_FILE_PRINTF(TRACING_DIR "set_event", TRACE_EVENTS); + SAFE_FILE_PRINTF(TRACING_DIR "trace", "\n"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "1"); SAFE_PTHREAD_CREATE(&task_thread, NULL, task_fn, NULL); SAFE_PTHREAD_JOIN(task_thread, NULL); /* disable tracing */ - tracefs_write("tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); LOAD_TRACE(); if (parse_results()) @@ -115,6 +115,5 @@ static void run(void) static struct tst_test test = { .test_all = run, - .setup = trace_setup, .cleanup = trace_cleanup, }; diff --git a/testcases/kernel/sched/eas/eas_small_big_toggle.c b/testcases/kernel/sched/eas/eas_small_big_toggle.c index 760949ff1..c0d98b021 100644 --- a/testcases/kernel/sched/eas/eas_small_big_toggle.c +++ b/testcases/kernel/sched/eas/eas_small_big_toggle.c @@ -36,10 +36,10 @@ static void *task_fn(void *arg LTP_ATTRIBUTE_UNUSED) task_tid = gettid(); while (loops--) { - tracefs_write("trace_marker", "SMALL TASK"); + SAFE_FILE_PRINTF(TRACING_DIR "trace_marker", "SMALL TASK"); burn(BURN_SEC * USEC_PER_SEC, 1); - tracefs_write("trace_marker", "CPU HOG"); + SAFE_FILE_PRINTF(TRACING_DIR "trace_marker", "CPU HOG"); burn(BURN_SEC * USEC_PER_SEC, 0); } @@ -204,17 +204,17 @@ static void run(void) BURN_SEC * NUM_LOOPS * 2); /* configure and enable tracing */ - tracefs_write("tracing_on", "0"); - tracefs_write("buffer_size_kb", "16384"); - tracefs_write("set_event", TRACE_EVENTS); - tracefs_write("trace", "\n"); - tracefs_write("tracing_on", "1"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "buffer_size_kb", "16384"); + SAFE_FILE_PRINTF(TRACING_DIR "set_event", TRACE_EVENTS); + SAFE_FILE_PRINTF(TRACING_DIR "trace", "\n"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "1"); SAFE_PTHREAD_CREATE(&task_thread, NULL, task_fn, NULL); SAFE_PTHREAD_JOIN(task_thread, NULL); /* disable tracing */ - tracefs_write("tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); LOAD_TRACE(); if (parse_results()) @@ -227,6 +227,5 @@ static void run(void) static struct tst_test test = { .test_all = run, - .setup = trace_setup, .cleanup = trace_cleanup, }; diff --git a/testcases/kernel/sched/eas/eas_small_to_big.c b/testcases/kernel/sched/eas/eas_small_to_big.c index dd194d5d1..0e2c04a1a 100644 --- a/testcases/kernel/sched/eas/eas_small_to_big.c +++ b/testcases/kernel/sched/eas/eas_small_to_big.c @@ -36,7 +36,7 @@ static void *task_fn(void *arg LTP_ATTRIBUTE_UNUSED) burn(BURN_SEC * USEC_PER_SEC, 1); printf("Changing to big task...\n"); - tracefs_write("trace_marker", "CPU HOG"); + SAFE_FILE_PRINTF(TRACING_DIR "trace_marker", "CPU HOG"); burn(BURN_SEC * USEC_PER_SEC, 0); return NULL; @@ -146,17 +146,17 @@ static void run(void) MAX_UPMIGRATE_LATENCY_US); /* configure and enable tracing */ - tracefs_write("tracing_on", "0"); - tracefs_write("buffer_size_kb", "16384"); - tracefs_write("set_event", TRACE_EVENTS); - tracefs_write("trace", "\n"); - tracefs_write("tracing_on", "1"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "buffer_size_kb", "16384"); + SAFE_FILE_PRINTF(TRACING_DIR "set_event", TRACE_EVENTS); + SAFE_FILE_PRINTF(TRACING_DIR "trace", "\n"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "1"); SAFE_PTHREAD_CREATE(&task_thread, NULL, task_fn, NULL); SAFE_PTHREAD_JOIN(task_thread, NULL); /* disable tracing */ - tracefs_write("tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); LOAD_TRACE(); if (parse_results()) @@ -169,6 +169,5 @@ static void run(void) static struct tst_test test = { .test_all = run, - .setup = trace_setup, .cleanup = trace_cleanup, }; diff --git a/testcases/kernel/sched/eas/eas_two_big_three_small.c b/testcases/kernel/sched/eas/eas_two_big_three_small.c index e6149b1af..000b9425b 100644 --- a/testcases/kernel/sched/eas/eas_two_big_three_small.c +++ b/testcases/kernel/sched/eas/eas_two_big_three_small.c @@ -116,11 +116,11 @@ static void run(void) printf("Tasks running for %d sec\n", BURN_SEC); /* configure and enable tracing */ - tracefs_write("tracing_on", "0"); - tracefs_write("buffer_size_kb", "16384"); - tracefs_write("set_event", TRACE_EVENTS); - tracefs_write("trace", "\n"); - tracefs_write("tracing_on", "1"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "buffer_size_kb", "16384"); + SAFE_FILE_PRINTF(TRACING_DIR "set_event", TRACE_EVENTS); + SAFE_FILE_PRINTF(TRACING_DIR "trace", "\n"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "1"); for (i = 0; i < NUM_TASKS; i++) SAFE_PTHREAD_CREATE(&tasks[i], NULL, task_fn, &task_tids[i]); @@ -128,7 +128,7 @@ static void run(void) SAFE_PTHREAD_JOIN(tasks[i], NULL); /* disable tracing */ - tracefs_write("tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); LOAD_TRACE(); if (parse_results()) @@ -139,6 +139,5 @@ static void run(void) static struct tst_test test = { .test_all = run, - .setup = trace_setup, .cleanup = trace_cleanup, }; diff --git a/testcases/kernel/sched/eas/sched_boost.c b/testcases/kernel/sched/eas/sched_boost.c index 6554a42da..26a72ae66 100644 --- a/testcases/kernel/sched/eas/sched_boost.c +++ b/testcases/kernel/sched/eas/sched_boost.c @@ -78,7 +78,7 @@ static void *test_fn(void *arg LTP_ATTRIBUTE_UNUSED) // give time for utilization to track real task usage do_work(); // start measuring - tracefs_write("tracing_on", "1"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "1"); do_work(); sem_post(&result_sem); tests_done++; @@ -110,10 +110,10 @@ static void run_test(void) { SAFE_FILE_PRINTF(STUNE_TEST_PATH "/schedtune.boost", "%d", test_boost[test_index]); - tracefs_write("trace", "\n"); + SAFE_FILE_PRINTF(TRACING_DIR "trace", "\n"); sem_post(&test_sem); sem_wait(&result_sem); - tracefs_write("tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); LOAD_TRACE(); parse_results(); test_index++; @@ -182,9 +182,9 @@ static void run(void) SAFE_PTHREAD_CREATE(&test_thread, NULL, test_fn, NULL); - tracefs_write("tracing_on", "0"); - tracefs_write("buffer_size_kb", "16384"); - tracefs_write("set_event", TRACE_EVENTS); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "buffer_size_kb", "16384"); + SAFE_FILE_PRINTF(TRACING_DIR "set_event", TRACE_EVENTS); while (test_index < NUM_TESTS) run_test(); @@ -196,6 +196,5 @@ static void run(void) static struct tst_test test = { .test_all = run, - .setup = trace_setup, .cleanup = trace_cleanup, }; diff --git a/testcases/kernel/sched/eas/sched_cfs_prio.c b/testcases/kernel/sched/eas/sched_cfs_prio.c index b54d0d5b5..92d2dced6 100644 --- a/testcases/kernel/sched/eas/sched_cfs_prio.c +++ b/testcases/kernel/sched/eas/sched_cfs_prio.c @@ -181,11 +181,11 @@ static void run(void) NUM_TASKS, TEST_TASK_SECONDS); /* configure and enable tracing */ - tracefs_write("tracing_on", "0"); - tracefs_write("buffer_size_kb", "16384"); - tracefs_write("set_event", TRACE_EVENTS); - tracefs_write("trace", "\n"); - tracefs_write("tracing_on", "1"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "buffer_size_kb", "16384"); + SAFE_FILE_PRINTF(TRACING_DIR "set_event", TRACE_EVENTS); + SAFE_FILE_PRINTF(TRACING_DIR "trace", "\n"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "1"); for (i = 0; i < NUM_TASKS; i++) SAFE_PTHREAD_CREATE(&tasks[i], NULL, task_fn, @@ -194,7 +194,7 @@ static void run(void) SAFE_PTHREAD_JOIN(tasks[i], NULL); /* disable tracing */ - tracefs_write("tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); LOAD_TRACE(); if (parse_results()) @@ -207,6 +207,5 @@ static void run(void) static struct tst_test test = { .test_all = run, - .setup = trace_setup, .cleanup = trace_cleanup, }; diff --git a/testcases/kernel/sched/eas/sched_dl_runtime.c b/testcases/kernel/sched/eas/sched_dl_runtime.c index 18fadea9e..27f0564d4 100644 --- a/testcases/kernel/sched/eas/sched_dl_runtime.c +++ b/testcases/kernel/sched/eas/sched_dl_runtime.c @@ -49,7 +49,7 @@ static void *dl_fn(void *arg LTP_ATTRIBUTE_UNUSED) attr.sched_period = 20000000; attr.sched_deadline = 10000000; - tracefs_write("trace_marker", "DL START"); + SAFE_FILE_PRINTF(TRACING_DIR "trace_marker", "DL START"); ERROR_CHECK(sched_setattr(0, &attr, 0)); dl_task_tid = gettid(); @@ -126,7 +126,6 @@ static int parse_results(void) periods_parsed++; next_deadline_ts_us += 20000; next_period_ts_us += 20000; - period_exec_time_us = 0; } if (trace[i].event_type == TRACE_RECORD_SCHED_SWITCH) { struct trace_sched_switch *t = trace[i].event_data; @@ -174,17 +173,17 @@ static void run(void) &dl_thread_sched_params)); /* configure and enable tracing */ - tracefs_write("tracing_on", "0"); - tracefs_write("buffer_size_kb", "16384"); - tracefs_write("set_event", TRACE_EVENTS); - tracefs_write("trace", "\n"); - tracefs_write("tracing_on", "1"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "buffer_size_kb", "16384"); + SAFE_FILE_PRINTF(TRACING_DIR "set_event", TRACE_EVENTS); + SAFE_FILE_PRINTF(TRACING_DIR "trace", "\n"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "1"); SAFE_PTHREAD_CREATE(&dl_thread, NULL, dl_fn, NULL); SAFE_PTHREAD_JOIN(dl_thread, NULL); /* disable tracing */ - tracefs_write("tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); LOAD_TRACE(); if (parse_results()) @@ -194,7 +193,6 @@ static void run(void) } static struct tst_test test = { - .setup = trace_setup, .test_all = run, .cleanup = trace_cleanup, }; diff --git a/testcases/kernel/sched/eas/sched_latency_dl.c b/testcases/kernel/sched/eas/sched_latency_dl.c index e66fc21f7..486c4cf4d 100644 --- a/testcases/kernel/sched/eas/sched_latency_dl.c +++ b/testcases/kernel/sched/eas/sched_latency_dl.c @@ -61,7 +61,7 @@ static void *dl_fn(void *arg LTP_ATTRIBUTE_UNUSED) static void *cfs_fn(void *arg LTP_ATTRIBUTE_UNUSED) { usleep(5000); - tracefs_write("trace_marker", "WAKING"); + SAFE_FILE_PRINTF(TRACING_DIR "trace_marker", "WAKING"); sem_post(&sem); burn(USEC_PER_SEC, 0); @@ -135,11 +135,11 @@ static void run(void) sem_init(&sem, 0, 0); /* configure and enable tracing */ - tracefs_write("tracing_on", "0"); - tracefs_write("buffer_size_kb", "16384"); - tracefs_write("set_event", TRACE_EVENTS); - tracefs_write("trace", "\n"); - tracefs_write("tracing_on", "1"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "buffer_size_kb", "16384"); + SAFE_FILE_PRINTF(TRACING_DIR "set_event", TRACE_EVENTS); + SAFE_FILE_PRINTF(TRACING_DIR "trace", "\n"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "1"); SAFE_PTHREAD_CREATE(&cfs_thread, &cfs_thread_attrs, cfs_fn, NULL); SAFE_PTHREAD_CREATE(&dl_thread, &dl_thread_attrs, dl_fn, NULL); @@ -147,7 +147,7 @@ static void run(void) SAFE_PTHREAD_JOIN(dl_thread, NULL); /* disable tracing */ - tracefs_write("tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); LOAD_TRACE(); if (parse_results()) @@ -160,6 +160,5 @@ static void run(void) static struct tst_test test = { .test_all = run, - .setup = trace_setup, .cleanup = trace_cleanup, }; diff --git a/testcases/kernel/sched/eas/sched_latency_rt.c b/testcases/kernel/sched/eas/sched_latency_rt.c index 68fb45a26..3a5a91fde 100644 --- a/testcases/kernel/sched/eas/sched_latency_rt.c +++ b/testcases/kernel/sched/eas/sched_latency_rt.c @@ -43,7 +43,7 @@ static void *cfs_fn(void *arg LTP_ATTRIBUTE_UNUSED) affine(0); usleep(5000); - tracefs_write("trace_marker", "WAKING"); + SAFE_FILE_PRINTF(TRACING_DIR "trace_marker", "WAKING"); sem_post(&sem); burn(USEC_PER_SEC, 0); @@ -117,11 +117,11 @@ static void run(void) sem_init(&sem, 0, 0); /* configure and enable tracing */ - tracefs_write("tracing_on", "0"); - tracefs_write("buffer_size_kb", "16384"); - tracefs_write("set_event", TRACE_EVENTS); - tracefs_write("trace", "\n"); - tracefs_write("tracing_on", "1"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "buffer_size_kb", "16384"); + SAFE_FILE_PRINTF(TRACING_DIR "set_event", TRACE_EVENTS); + SAFE_FILE_PRINTF(TRACING_DIR "trace", "\n"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "1"); SAFE_PTHREAD_CREATE(&cfs_thread, &cfs_thread_attrs, cfs_fn, NULL); SAFE_PTHREAD_CREATE(&rt_thread, &rt_thread_attrs, rt_fn, NULL); @@ -129,7 +129,7 @@ static void run(void) SAFE_PTHREAD_JOIN(rt_thread, NULL); /* disable tracing */ - tracefs_write("tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); LOAD_TRACE(); if (parse_results()) @@ -142,6 +142,5 @@ static void run(void) static struct tst_test test = { .test_all = run, - .setup = trace_setup, .cleanup = trace_cleanup, }; diff --git a/testcases/kernel/sched/eas/sched_prio_3_fifo.c b/testcases/kernel/sched/eas/sched_prio_3_fifo.c index 29f704f92..4244f17c0 100644 --- a/testcases/kernel/sched/eas/sched_prio_3_fifo.c +++ b/testcases/kernel/sched/eas/sched_prio_3_fifo.c @@ -225,7 +225,7 @@ static void *rt_low_fn_a(void *arg LTP_ATTRIBUTE_UNUSED) fixup_expected_events(); - tracefs_write("trace_marker", "TEST START"); + SAFE_FILE_PRINTF(TRACING_DIR "trace_marker", "TEST START"); /* Wake up rt_low_fn_b. We should continue to run though. */ sem_post(&sem_low_b); @@ -353,11 +353,11 @@ static void run(void) sem_init(&sem_low_a, 0, 0); /* configure and enable tracing */ - tracefs_write("tracing_on", "0"); - tracefs_write("buffer_size_kb", "16384"); - tracefs_write("set_event", TRACE_EVENTS); - tracefs_write("trace", "\n"); - tracefs_write("tracing_on", "1"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "buffer_size_kb", "16384"); + SAFE_FILE_PRINTF(TRACING_DIR "set_event", TRACE_EVENTS); + SAFE_FILE_PRINTF(TRACING_DIR "trace", "\n"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "1"); create_rt_thread(70, rt_low_fn_a, &rt_low_a); create_rt_thread(70, rt_low_fn_b, &rt_low_b); @@ -374,7 +374,7 @@ static void run(void) SAFE_PTHREAD_JOIN(rt_high_b, NULL); /* disable tracing */ - tracefs_write("tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); LOAD_TRACE(); if (parse_results()) @@ -387,6 +387,5 @@ static void run(void) static struct tst_test test = { .test_all = run, - .setup = trace_setup, .cleanup = trace_cleanup, }; diff --git a/testcases/kernel/sched/eas/sched_prio_3_rr.c b/testcases/kernel/sched/eas/sched_prio_3_rr.c index 43bcce7a7..8403da5fe 100644 --- a/testcases/kernel/sched/eas/sched_prio_3_rr.c +++ b/testcases/kernel/sched/eas/sched_prio_3_rr.c @@ -24,7 +24,7 @@ #define TRACE_EVENTS "sched_wakeup sched_switch sched_process_exit" -#define EXEC_MIN_PCT 32 +#define EXEC_MIN_PCT 33 #define EXEC_MAX_PCT 34 static sem_t sem; @@ -58,7 +58,7 @@ static void *rt_a_fn(void *arg LTP_ATTRIBUTE_UNUSED) affine(0); /* Give all other tasks a chance to affine and block. */ usleep(3000); - tracefs_write("trace_marker", "TEST START"); + SAFE_FILE_PRINTF(TRACING_DIR "trace_marker", "TEST START"); sem_post(&sem); sem_post(&sem); burn(BUSY_WAIT_USECS, 0); @@ -147,11 +147,11 @@ static void run(void) printf("Running %d RT RR tasks for 10 seconds...\n", NUM_TASKS); /* configure and enable tracing */ - tracefs_write("tracing_on", "0"); - tracefs_write("buffer_size_kb", "16384"); - tracefs_write("set_event", TRACE_EVENTS); - tracefs_write("trace", "\n"); - tracefs_write("tracing_on", "1"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "buffer_size_kb", "16384"); + SAFE_FILE_PRINTF(TRACING_DIR "set_event", TRACE_EVENTS); + SAFE_FILE_PRINTF(TRACING_DIR "trace", "\n"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "1"); create_rt_thread(70, rt_a_fn, &rt_a); create_rt_thread(70, rt_b_fn, &rt_b); @@ -162,7 +162,7 @@ static void run(void) SAFE_PTHREAD_JOIN(rt_c, NULL); /* disable tracing */ - tracefs_write("tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); LOAD_TRACE(); if (parse_results()) @@ -175,6 +175,5 @@ static void run(void) static struct tst_test test = { .test_all = run, - .setup = trace_setup, .cleanup = trace_cleanup, }; diff --git a/testcases/kernel/sched/eas/sugov_latency.c b/testcases/kernel/sched/eas/sugov_latency.c index 35154d83b..923948edc 100644 --- a/testcases/kernel/sched/eas/sugov_latency.c +++ b/testcases/kernel/sched/eas/sugov_latency.c @@ -65,9 +65,9 @@ static void *burn_fn(void *arg LTP_ATTRIBUTE_UNUSED) return NULL; } - tracefs_write("trace_marker", "affined"); + SAFE_FILE_PRINTF(TRACING_DIR "trace_marker", "affined"); burn(BURN_MSEC * 1000, 0); - tracefs_write("trace_marker", "small task"); + SAFE_FILE_PRINTF(TRACING_DIR "trace_marker", "small task"); burn(BURN_MSEC * 1000, 1); return NULL; @@ -205,17 +205,17 @@ static void run(void) printf("CPU hog will be bound to CPU %d.\n", test_cpu); /* configure and enable tracing */ - tracefs_write("tracing_on", "0"); - tracefs_write("buffer_size_kb", "16384"); - tracefs_write("set_event", TRACE_EVENTS); - tracefs_write("trace", "\n"); - tracefs_write("tracing_on", "1"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "buffer_size_kb", "16384"); + SAFE_FILE_PRINTF(TRACING_DIR "set_event", TRACE_EVENTS); + SAFE_FILE_PRINTF(TRACING_DIR "trace", "\n"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "1"); SAFE_PTHREAD_CREATE(&burn_thread, NULL, burn_fn, NULL); SAFE_PTHREAD_JOIN(burn_thread, NULL); /* disable tracing */ - tracefs_write("tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); LOAD_TRACE(); if (parse_results()) @@ -226,6 +226,5 @@ static void run(void) static struct tst_test test = { .test_all = run, - .setup = trace_setup, .cleanup = trace_cleanup, }; diff --git a/testcases/kernel/sched/eas/sugov_stale_util.c b/testcases/kernel/sched/eas/sugov_stale_util.c index b02882c93..685d1bd19 100644 --- a/testcases/kernel/sched/eas/sugov_stale_util.c +++ b/testcases/kernel/sched/eas/sugov_stale_util.c @@ -53,9 +53,11 @@ static void *event_fn(void *arg LTP_ATTRIBUTE_UNUSED) sem_wait(&sem); - tracefs_write("trace_marker", "event task sleep"); + SAFE_FILE_PRINTF(TRACING_DIR "trace_marker", + "event task sleep"); usleep(MAX_STALE_USEC); - tracefs_write("trace_marker", "event task wake"); + SAFE_FILE_PRINTF(TRACING_DIR "trace_marker", + "event task wake"); /* * Waking up should be sufficient to get the cpufreq policy to * re-evaluate. @@ -81,7 +83,7 @@ static void *burn_fn(void *arg LTP_ATTRIBUTE_UNUSED) * Sleep. The next sugov update after TICK_NSEC should not include * this task's contribution. */ - tracefs_write("trace_marker", "sleeping"); + SAFE_FILE_PRINTF(TRACING_DIR "trace_marker", "sleeping"); /* * Wake up task on another CPU in the same policy which will sleep @@ -203,11 +205,11 @@ static void run(void) sem_init(&sem, 0, 0); /* configure and enable tracing */ - tracefs_write("tracing_on", "0"); - tracefs_write("buffer_size_kb", "16384"); - tracefs_write("set_event", TRACE_EVENTS); - tracefs_write("trace", "\n"); - tracefs_write("tracing_on", "1"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "buffer_size_kb", "16384"); + SAFE_FILE_PRINTF(TRACING_DIR "set_event", TRACE_EVENTS); + SAFE_FILE_PRINTF(TRACING_DIR "trace", "\n"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "1"); SAFE_PTHREAD_CREATE(&burn_thread, NULL, burn_fn, NULL); SAFE_PTHREAD_CREATE(&event_thread, NULL, event_fn, NULL); @@ -216,7 +218,7 @@ static void run(void) SAFE_PTHREAD_JOIN(event_thread, NULL); /* disable tracing */ - tracefs_write("tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); LOAD_TRACE(); if (parse_results()) @@ -229,6 +231,5 @@ static void run(void) static struct tst_test test = { .test_all = run, - .setup = trace_setup, .cleanup = trace_cleanup, }; diff --git a/testcases/kernel/sched/eas/sugov_wakeups.c b/testcases/kernel/sched/eas/sugov_wakeups.c index b068b1fe9..c1f6f2f08 100644 --- a/testcases/kernel/sched/eas/sugov_wakeups.c +++ b/testcases/kernel/sched/eas/sugov_wakeups.c @@ -34,16 +34,16 @@ static void run(void) "%d wakeups allowed\n", SLEEP_SEC, MAX_WAKEUPS); /* configure and enable tracing */ - tracefs_write("tracing_on", "0"); - tracefs_write("buffer_size_kb", "16384"); - tracefs_write("set_event", TRACE_EVENTS); - tracefs_write("trace", "\n"); - tracefs_write("tracing_on", "1"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "buffer_size_kb", "16384"); + SAFE_FILE_PRINTF(TRACING_DIR "set_event", TRACE_EVENTS); + SAFE_FILE_PRINTF(TRACING_DIR "trace", "\n"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "1"); sleep(SLEEP_SEC); /* disable tracing */ - tracefs_write("tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); LOAD_TRACE(); for (i = 0; i < num_trace_records; i++) { @@ -64,6 +64,5 @@ static void run(void) static struct tst_test test = { .test_all = run, - .setup = trace_setup, .cleanup = trace_cleanup, }; diff --git a/testcases/kernel/sched/eas/trace_parse.c b/testcases/kernel/sched/eas/trace_parse.c index 46bc0bdb4..a4c158a1b 100644 --- a/testcases/kernel/sched/eas/trace_parse.c +++ b/testcases/kernel/sched/eas/trace_parse.c @@ -20,18 +20,12 @@ #include "trace_parse.h" -#define TRACEFS_MAX_PATH_LEN 512 - int num_trace_records = 0; struct trace_record *trace = NULL; static int trace_fd = -1; static char *trace_buffer = NULL; -const char *tracefs_root = "/sys/kernel/tracing/"; -const char *debugfs_tracefs_root = "/sys/kernel/debug/tracing/"; -char *ftrace_root_dir; - static int parse_event_type(char *event_name) { if (!strcmp(event_name, "sched_process_exit")) @@ -92,28 +86,9 @@ void print_trace_record(struct trace_record *tr) printf("(other)\n"); } -void trace_setup(void) -{ - struct stat buf; - - if (stat("/sys/kernel/tracing/trace", &buf) == 0) - ftrace_root_dir = tracefs_root; - else - ftrace_root_dir = debugfs_tracefs_root; - -} - -void tracefs_write(const char *file_name, const char *value) -{ - char buf[TRACEFS_MAX_PATH_LEN]; - - snprintf(buf, sizeof(buf), "%s%s", ftrace_root_dir, file_name); - SAFE_FILE_PRINTF(buf, value); -} - void trace_cleanup(void) { - tracefs_write("tracing_on", "0"); + SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0"); } @@ -256,15 +231,15 @@ static void *parse_event_data(unsigned int event_type, char *data) * First 16 chars are the currently running thread name. Drop leading spaces. * Next char is a dash * Next 5 chars are PID. Drop trailing spaces. - * Next is some number of spaces. + * Next char is a space. * Next five chars are the CPU, i.e. [001]. - * Next is some number of spaces. + * Next char is a space. * Next letter is whether IRQs are off. * Next letter is if NEED_RESCHED is set. * Next letter is if this is in hard or soft IRQ context. * Next letter is the preempt disable depth. - * Next is some number of spaces. - * Next twelve letters are the timestamp. + * Next char is a space. + * Next twelve letters are the timestamp. Drop leading spaces. * Next char is colon. * Next char is space. * Next twelve letters are the event name. @@ -272,7 +247,7 @@ static void *parse_event_data(unsigned int event_type, char *data) * Rest of line is string specific to event. */ static int parse_trace_record(struct trace_record *tr, char *line) { - unsigned int field_start, idx = 0; + unsigned int idx = 0; char *found; /* Skip leading spaces in the task name. */ @@ -291,100 +266,83 @@ static int parse_trace_record(struct trace_record *tr, char *line) { return -1; } idx = 17; - while(line[idx] && line[idx] != '[') idx++; - if (!line[idx]) { - printf("Malformatted trace record, no open bracket for" - "CPU after pid:\n"); + if (line[22] != ' ') { + printf("Malformatted trace record, no space between" + "pid and CPU:\n"); printf("%s", line); return -1; } - line[idx-1] = 0; + line[22] = 0; if (sscanf(&line[17], "%hd", &tr->pid) != 1) { printf("Malformatted trace record, error parsing" "pid:\n"); printf("%s", line); return -1; } - field_start = idx; - while(line[idx] && line[idx] != ']') idx++; - if (!line[idx]) { - printf("Malformatted trace record, no closing bracket for" - "CPU:\n"); - printf("%s", line); - return -1; - } - idx++; - if (line[idx] != ' ') { - printf("Malformatted trace record, no space following CPU:\n"); + if (line[28] != ' ') { + printf("Malformatted trace record, no space between" + "CPU and flags:\n"); printf("%s", line); return -1; } - line[idx] = 0; - idx++; - if (sscanf(&line[field_start], "[%hd]", &tr->cpu) != 1) { + line[28] = 0; + if (sscanf(&line[23], "[%hd]", &tr->cpu) != 1) { printf("Malformatted trace record, error parsing CPU:\n"); printf("%s", line); return -1; } - - if (line[idx] == 'd') { + if (line[29] == 'd') { tr->flags |= TRACE_RECORD_IRQS_OFF; - } else if (line[idx] != '.') { + } else if (line[29] != '.') { printf("Malformatted trace record, error parsing irqs-off:\n"); printf("%s", line); return -1; } - idx++; - if (line[idx] == 'N') { + if (line[30] == 'N') { tr->flags |= TRACE_RECORD_TIF_NEED_RESCHED; tr->flags |= TRACE_RECORD_PREEMPT_NEED_RESCHED; - } else if (line[idx] == 'n') { + } else if (line[30] == 'n') { tr->flags |= TRACE_RECORD_TIF_NEED_RESCHED; - } else if (line[idx] == 'p') { + } else if (line[30] == 'p') { tr->flags |= TRACE_RECORD_PREEMPT_NEED_RESCHED; - } else if (line[idx] != '.') { + } else if (line[30] != '.') { printf("Malformatted trace record, error parsing " "need-resched:\n"); printf("%s", line); return -1; } - idx++; - if (line[idx] != IRQ_CONTEXT_NORMAL && line[idx] != IRQ_CONTEXT_SOFT && - line[idx] != IRQ_CONTEXT_HARD && - line[idx] != IRQ_CONTEXT_HARD_IN_SOFT && - line[idx] != IRQ_CONTEXT_NMI && line[idx] != IRQ_CONTEXT_NMI_IN_HARD) { + if (line[31] != IRQ_CONTEXT_NORMAL && line[31] != IRQ_CONTEXT_SOFT && + line[31] != IRQ_CONTEXT_HARD && + line[31] != IRQ_CONTEXT_HARD_IN_SOFT && + line[31] != IRQ_CONTEXT_NMI && line[31] != IRQ_CONTEXT_NMI_IN_HARD) { printf("Malformatted trace record, error parsing irq " "context:\n"); printf("%s", line); return -1; } - tr->irq_context = line[idx]; - idx++; + tr->irq_context = line[31]; - if (line[idx+1] != ' ') { + if (line[33] != ' ') { printf("Malformatted trace record, no space between" "flags and timestamp:\n"); printf("%s", line); return -1; } - line[idx+1] = 0; - if (line[idx] == '.') { + line[33] = 0; + if (line[32] == '.') { tr->preempt_depth = 0; - } else if (sscanf(&line[idx], "%hx", &tr->preempt_depth) != 1) { + } else if (sscanf(&line[32], "%hx", &tr->preempt_depth) != 1) { printf("Malformatted trace record, error parsing " "preempt-depth:\n"); printf("%s", line); return -1; } - idx += 2; - while (line[idx] && line[idx] == ' ') idx++; - if (!line[idx]) { - printf("Malformatted trace record, missing timestamp:\n"); - printf("%s", line); - return -1; - } + /* timestamp starts as early as line[34], skip leading spaces */ + idx = 34; + while (idx < 38 && line[idx] == ' ') + idx++; if (sscanf(&line[idx], "%d.%d: ", &tr->ts.sec, &tr->ts.usec) != 2) { printf("Malformatted trace record, error parsing " @@ -422,15 +380,12 @@ static int refill_buffer(char *buffer, char *idx) int bytes_to_read; int bytes_read = 0; int rv; - char buf[256]; bytes_in_buffer = TRACE_BUFFER_SIZE - (idx - buffer) - 1; bytes_to_read = TRACE_BUFFER_SIZE - bytes_in_buffer - 1; if (trace_fd == -1) { - snprintf(buf, sizeof(buf), "%strace", ftrace_root_dir); - - trace_fd = open(buf, O_RDONLY); + trace_fd = open(TRACING_DIR "trace", O_RDONLY); if (trace_fd == -1) { printf("Could not open trace file!\n"); return 0; diff --git a/testcases/kernel/sched/eas/trace_parse.h b/testcases/kernel/sched/eas/trace_parse.h index afce586a9..436b6d7d8 100644 --- a/testcases/kernel/sched/eas/trace_parse.h +++ b/testcases/kernel/sched/eas/trace_parse.h @@ -7,6 +7,10 @@ #ifndef _LTP_TRACE_PARSE_H_ #define _LTP_TRACE_PARSE_H_ +/* + * It is necessary to define TRACE_EVENTS to communicate the events to trace. */ +#define TRACING_DIR "/sys/kernel/debug/tracing/" + enum { TRACE_RECORD_OTHER = 0, TRACE_RECORD_SCHED_PROCESS_EXIT, @@ -87,10 +91,7 @@ struct trace_record { extern int num_trace_records; extern struct trace_record *trace; -extern char *ftrace_root_dir; -void tracefs_write(const char *file_name, const char *value); -void trace_setup(void); void trace_cleanup(void); void print_trace_record(struct trace_record *tr); struct trace_record *load_trace(void); diff --git a/testcases/kernel/sched/eas/util.h b/testcases/kernel/sched/eas/util.h index 7108dcbe9..2433a53d6 100644 --- a/testcases/kernel/sched/eas/util.h +++ b/testcases/kernel/sched/eas/util.h @@ -13,7 +13,7 @@ #define USEC_PER_SEC 1000000 -#define TS_TO_USEC(x) (x.usec + (unsigned long long)x.sec * USEC_PER_SEC) +#define TS_TO_USEC(x) (x.usec + x.sec * USEC_PER_SEC) #ifndef SCHED_DEADLINE #define SCHED_DEADLINE 6 diff --git a/testcases/kernel/syscalls/getrlimit/getrlimit03.c b/testcases/kernel/syscalls/getrlimit/getrlimit03.c index 604082ccf..319bc494a 100644 --- a/testcases/kernel/syscalls/getrlimit/getrlimit03.c +++ b/testcases/kernel/syscalls/getrlimit/getrlimit03.c @@ -35,20 +35,14 @@ * The underlying syscall names vary across architectures, depending on whether * the architecture predates the "new" handler. For clarity, this test * will call them getrlimit_long and getlimit_ulong internally. - * - * __NR_getrlimit has been deprecated from arm EABI and moved to OABI_COMPAT, - * so the syscall on arm may or may not be available even if __NR_ugetrlimit - * exists. */ -#if __NR_ugetrlimit != __LTP__NR_INVALID_SYSCALL -# if !defined(__arm__) || __NR_getrlimit != __LTP__NR_INVALID_SYSCALL -# define SIGNED_GETRLIMIT -# endif -# define __NR_getrlimit_ulong __NR_ugetrlimit -# define __NR_getrlimit_ulong_str "__NR_ugetrlimit" +#define SIGNED_GETRLIMIT (__NR_ugetrlimit != __LTP__NR_INVALID_SYSCALL) +#if SIGNED_GETRLIMIT +#define __NR_getrlimit_ulong __NR_ugetrlimit +#define __NR_getrlimit_ulong_str "__NR_ugetrlimit" #else -# define __NR_getrlimit_ulong __NR_getrlimit -# define __NR_getrlimit_ulong_str "__NR_getrlimit" +#define __NR_getrlimit_ulong __NR_getrlimit +#define __NR_getrlimit_ulong_str "__NR_getrlimit" #endif #ifndef HAVE_STRUCT_RLIMIT64 @@ -80,13 +74,12 @@ static int getrlimit_ulong(int resource, struct rlimit_ulong *rlim) return syscall(__NR_getrlimit_ulong, resource, rlim); } -const long RLIM_INFINITY_L = LONG_MAX; - -#ifdef SIGNED_GETRLIMIT +#if SIGNED_GETRLIMIT struct rlimit_long { long rlim_cur; long rlim_max; }; +const long RLIM_INFINITY_L = LONG_MAX; static int getrlimit_long(int resource, struct rlimit_long *rlim) { @@ -123,7 +116,7 @@ static int compare_u64_ulong(int resource, uint64_t val_u64, return 0; } -#ifdef SIGNED_GETRLIMIT +#if SIGNED_GETRLIMIT static int compare_u64_long(int resource, uint64_t val_u64, long val_l, const char *kind) { @@ -149,7 +142,7 @@ static void run(unsigned int resource) int ret_ul; int errno_ul; -#ifdef SIGNED_GETRLIMIT +#if SIGNED_GETRLIMIT struct rlimit_long rlim_l; int ret_l; int errno_l; @@ -174,7 +167,7 @@ static void run(unsigned int resource) tst_res(TPASS, "__NR_prlimit64(%d) and %s(%d) gave consistent results", resource, __NR_getrlimit_ulong_str, resource); -#ifdef SIGNED_GETRLIMIT +#if SIGNED_GETRLIMIT errno = 0; ret_l = getrlimit_long(resource, &rlim_l); errno_l = errno; |