diff options
| author | Xiangyu Chen <xiangyu.chen@windriver.com> | 2022-11-02 10:51:45 +0800 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-11-09 17:42:08 +0000 |
| commit | a8b7298d407b7633e5772e3c446e31b5a73d9985 (patch) | |
| tree | 069555cc01e92aee801086e8a31296a2f57e40d8 /meta | |
| parent | 994831eac1ab925da85914a10221ac63a79a4028 (diff) | |
| download | poky-a8b7298d407b7633e5772e3c446e31b5a73d9985.tar.gz | |
ltp: backport clock_gettime04 fix from upstream
This is to get rid of the intermittent failures in clock_gettime04,
which are likely caused by different clock tick rates on platforms.
Here give two thresholds (in milliseconds) for comparison, one for
COARSE clock and one for the rest.
(From OE-Core rev: 9452efd99299a5bf23cc6518e8900e58b3a2fff9)
Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
| -rw-r--r-- | meta/recipes-extended/ltp/ltp/0001-clock_gettime04-set-threshold-based-on-the-clock-res.patch | 89 | ||||
| -rw-r--r-- | meta/recipes-extended/ltp/ltp_20220121.bb | 1 |
2 files changed, 90 insertions, 0 deletions
diff --git a/meta/recipes-extended/ltp/ltp/0001-clock_gettime04-set-threshold-based-on-the-clock-res.patch b/meta/recipes-extended/ltp/ltp/0001-clock_gettime04-set-threshold-based-on-the-clock-res.patch new file mode 100644 index 0000000000..b4879221ad --- /dev/null +++ b/meta/recipes-extended/ltp/ltp/0001-clock_gettime04-set-threshold-based-on-the-clock-res.patch | |||
| @@ -0,0 +1,89 @@ | |||
| 1 | From 9851deb86ef257a98d7433280161d8ca685aa669 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Li Wang <liwang@redhat.com> | ||
| 3 | Date: Tue, 29 Mar 2022 13:03:51 +0800 | ||
| 4 | Subject: [PATCH] clock_gettime04: set threshold based on the clock resolution | ||
| 5 | |||
| 6 | This is to get rid of the intermittent failures in clock_gettime04, | ||
| 7 | which are likely caused by different clock tick rates on platforms. | ||
| 8 | Here give two thresholds (in milliseconds) for comparison, one for | ||
| 9 | COARSE clock and one for the rest. | ||
| 10 | |||
| 11 | Error log: | ||
| 12 | clock_gettime04.c:163: TFAIL: CLOCK_REALTIME_COARSE(syscall with old kernel spec): | ||
| 13 | Difference between successive readings greater than 5 ms (1): 10 | ||
| 14 | clock_gettime04.c:163: TFAIL: CLOCK_MONOTONIC_COARSE(vDSO with old kernel spec): | ||
| 15 | Difference between successive readings greater than 5 ms (2): 10 | ||
| 16 | |||
| 17 | From Waiman Long: | ||
| 18 | That failure happens for CLOCK_REALTIME_COARSE which is a faster but less | ||
| 19 | precise version of CLOCK_REALTIME. The time resolution is actually a clock | ||
| 20 | tick. Since arm64 has a HZ rate of 100. That means each tick is 10ms. So a | ||
| 21 | CLOCK_REALTIME_COARSE threshold of 5ms is probably not enough. I would say | ||
| 22 | in the case of CLOCK_REALTIME_COARSE, we have to increase the threshold based | ||
| 23 | on the clock tick rate of the system. This is more a test failure than is | ||
| 24 | an inherent problem in the kernel. | ||
| 25 | |||
| 26 | Fixes #898 | ||
| 27 | |||
| 28 | Upstream-Status: Backport | ||
| 29 | [https://github.com/linux-test-project/ltp/commit/9851deb86ef257a98d7433280161d8ca685aa669] | ||
| 30 | |||
| 31 | Reported-by: Eirik Fuller <efuller@redhat.com> | ||
| 32 | Signed-off-by: Li Wang <liwang@redhat.com> | ||
| 33 | Cc: Waiman Long <llong@redhat.com> | ||
| 34 | Cc: Viresh Kumar <viresh.kumar@linaro.org> | ||
| 35 | Reviewed-by: Cyril Hrubis <chrubis@suse.cz> | ||
| 36 | Acked-by: Waiman Long <longman@redhat.com> | ||
| 37 | Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com> | ||
| 38 | --- | ||
| 39 | .../syscalls/clock_gettime/clock_gettime04.c | 18 ++++++++++++++++-- | ||
| 40 | 1 file changed, 16 insertions(+), 2 deletions(-) | ||
| 41 | |||
| 42 | diff --git a/testcases/kernel/syscalls/clock_gettime/clock_gettime04.c b/testcases/kernel/syscalls/clock_gettime/clock_gettime04.c | ||
| 43 | index a8d2c5b38..c279da79e 100644 | ||
| 44 | --- a/testcases/kernel/syscalls/clock_gettime/clock_gettime04.c | ||
| 45 | +++ b/testcases/kernel/syscalls/clock_gettime/clock_gettime04.c | ||
| 46 | @@ -35,7 +35,7 @@ clockid_t clks[] = { | ||
| 47 | }; | ||
| 48 | |||
| 49 | static gettime_t ptr_vdso_gettime, ptr_vdso_gettime64; | ||
| 50 | -static long long delta = 5; | ||
| 51 | +static long long delta, precise_delta, coarse_delta; | ||
| 52 | |||
| 53 | static inline int do_vdso_gettime(gettime_t vdso, clockid_t clk_id, void *ts) | ||
| 54 | { | ||
| 55 | @@ -92,9 +92,18 @@ static struct time64_variants variants[] = { | ||
| 56 | |||
| 57 | static void setup(void) | ||
| 58 | { | ||
| 59 | + struct timespec res; | ||
| 60 | + | ||
| 61 | + clock_getres(CLOCK_REALTIME, &res); | ||
| 62 | + precise_delta = 5 + res.tv_nsec / 1000000; | ||
| 63 | + | ||
| 64 | + clock_getres(CLOCK_REALTIME_COARSE, &res); | ||
| 65 | + coarse_delta = 5 + res.tv_nsec / 1000000; | ||
| 66 | + | ||
| 67 | if (tst_is_virt(VIRT_ANY)) { | ||
| 68 | tst_res(TINFO, "Running in a virtual machine, multiply the delta by 10."); | ||
| 69 | - delta *= 10; | ||
| 70 | + precise_delta *= 10; | ||
| 71 | + coarse_delta *= 10; | ||
| 72 | } | ||
| 73 | |||
| 74 | find_clock_gettime_vdso(&ptr_vdso_gettime, &ptr_vdso_gettime64); | ||
| 75 | @@ -108,6 +117,11 @@ static void run(unsigned int i) | ||
| 76 | int count = 10000, ret; | ||
| 77 | unsigned int j; | ||
| 78 | |||
| 79 | + if (clks[i] == CLOCK_REALTIME_COARSE || clks[i] == CLOCK_MONOTONIC_COARSE) | ||
| 80 | + delta = coarse_delta; | ||
| 81 | + else | ||
| 82 | + delta = precise_delta; | ||
| 83 | + | ||
| 84 | do { | ||
| 85 | for (j = 0; j < ARRAY_SIZE(variants); j++) { | ||
| 86 | /* Refresh time in start */ | ||
| 87 | -- | ||
| 88 | 2.34.1 | ||
| 89 | |||
diff --git a/meta/recipes-extended/ltp/ltp_20220121.bb b/meta/recipes-extended/ltp/ltp_20220121.bb index 4ae54492f3..51e8db4f1e 100644 --- a/meta/recipes-extended/ltp/ltp_20220121.bb +++ b/meta/recipes-extended/ltp/ltp_20220121.bb | |||
| @@ -29,6 +29,7 @@ SRC_URI = "git://github.com/linux-test-project/ltp.git;branch=master;protocol=ht | |||
| 29 | file://0001-metadata-parse.sh-sort-filelist-for-reproducibility.patch \ | 29 | file://0001-metadata-parse.sh-sort-filelist-for-reproducibility.patch \ |
| 30 | file://disable_hanging_tests.patch \ | 30 | file://disable_hanging_tests.patch \ |
| 31 | file://0001-syscalls-pread02-extend-buffer-to-avoid-glibc-overflow-detection.patch \ | 31 | file://0001-syscalls-pread02-extend-buffer-to-avoid-glibc-overflow-detection.patch \ |
| 32 | file://0001-clock_gettime04-set-threshold-based-on-the-clock-res.patch \ | ||
| 32 | " | 33 | " |
| 33 | 34 | ||
| 34 | S = "${WORKDIR}/git" | 35 | S = "${WORKDIR}/git" |
