public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: Steve Sakoman <steve@sakoman.com>
To: openembedded-core@lists.openembedded.org
Subject: [OE-core][kirkstone 30/31] ltp: backport clock_gettime04 fix from upstream
Date: Thu,  3 Nov 2022 17:01:05 -1000	[thread overview]
Message-ID: <f5d737a02a41ccfd040367228c85e438b59d63ab.1667530733.git.steve@sakoman.com> (raw)
In-Reply-To: <cover.1667530733.git.steve@sakoman.com>

From: Xiangyu Chen <xiangyu.chen@windriver.com>

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.

Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
---
 ...set-threshold-based-on-the-clock-res.patch | 89 +++++++++++++++++++
 meta/recipes-extended/ltp/ltp_20220121.bb     |  1 +
 2 files changed, 90 insertions(+)
 create mode 100644 meta/recipes-extended/ltp/ltp/0001-clock_gettime04-set-threshold-based-on-the-clock-res.patch

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 @@
+From 9851deb86ef257a98d7433280161d8ca685aa669 Mon Sep 17 00:00:00 2001
+From: Li Wang <liwang@redhat.com>
+Date: Tue, 29 Mar 2022 13:03:51 +0800
+Subject: [PATCH] clock_gettime04: set threshold based on the clock resolution
+
+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.
+
+Error log:
+  clock_gettime04.c:163: TFAIL: CLOCK_REALTIME_COARSE(syscall with old kernel spec):
+        Difference between successive readings greater than 5 ms (1): 10
+  clock_gettime04.c:163: TFAIL: CLOCK_MONOTONIC_COARSE(vDSO with old kernel spec):
+	Difference between successive readings greater than 5 ms (2): 10
+
+From Waiman Long:
+  That failure happens for CLOCK_REALTIME_COARSE which is a faster but less
+  precise version of CLOCK_REALTIME. The time resolution is actually a clock
+  tick. Since arm64 has a HZ rate of 100. That means each tick is 10ms. So a
+  CLOCK_REALTIME_COARSE threshold of 5ms is probably not enough. I would say
+  in the case of CLOCK_REALTIME_COARSE, we have to increase the threshold based
+  on the clock tick rate of the system. This is more a test failure than is
+  an inherent problem in the kernel.
+
+Fixes #898
+
+Upstream-Status: Backport
+[https://github.com/linux-test-project/ltp/commit/9851deb86ef257a98d7433280161d8ca685aa669]
+
+Reported-by: Eirik Fuller <efuller@redhat.com>
+Signed-off-by: Li Wang <liwang@redhat.com>
+Cc: Waiman Long <llong@redhat.com>
+Cc: Viresh Kumar <viresh.kumar@linaro.org>
+Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
+Acked-by: Waiman Long <longman@redhat.com>
+Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com>
+---
+ .../syscalls/clock_gettime/clock_gettime04.c   | 18 ++++++++++++++++--
+ 1 file changed, 16 insertions(+), 2 deletions(-)
+
+diff --git a/testcases/kernel/syscalls/clock_gettime/clock_gettime04.c b/testcases/kernel/syscalls/clock_gettime/clock_gettime04.c
+index a8d2c5b38..c279da79e 100644
+--- a/testcases/kernel/syscalls/clock_gettime/clock_gettime04.c
++++ b/testcases/kernel/syscalls/clock_gettime/clock_gettime04.c
+@@ -35,7 +35,7 @@ clockid_t clks[] = {
+ };
+ 
+ static gettime_t ptr_vdso_gettime, ptr_vdso_gettime64;
+-static long long delta = 5;
++static long long delta, precise_delta, coarse_delta;
+ 
+ static inline int do_vdso_gettime(gettime_t vdso, clockid_t clk_id, void *ts)
+ {
+@@ -92,9 +92,18 @@ static struct time64_variants variants[] = {
+ 
+ static void setup(void)
+ {
++	struct timespec res;
++
++	clock_getres(CLOCK_REALTIME, &res);
++	precise_delta = 5 + res.tv_nsec / 1000000;
++
++	clock_getres(CLOCK_REALTIME_COARSE, &res);
++	coarse_delta = 5 + res.tv_nsec / 1000000;
++
+ 	if (tst_is_virt(VIRT_ANY)) {
+ 		tst_res(TINFO, "Running in a virtual machine, multiply the delta by 10.");
+-		delta *= 10;
++		precise_delta *= 10;
++		coarse_delta *= 10;
+ 	}
+ 
+ 	find_clock_gettime_vdso(&ptr_vdso_gettime, &ptr_vdso_gettime64);
+@@ -108,6 +117,11 @@ static void run(unsigned int i)
+ 	int count = 10000, ret;
+ 	unsigned int j;
+ 
++	if (clks[i] == CLOCK_REALTIME_COARSE || clks[i] == CLOCK_MONOTONIC_COARSE)
++		delta = coarse_delta;
++	else
++		delta = precise_delta;
++
+ 	do {
+ 		for (j = 0; j < ARRAY_SIZE(variants); j++) {
+ 			/* Refresh time in start */
+-- 
+2.34.1
+
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
            file://0001-metadata-parse.sh-sort-filelist-for-reproducibility.patch \
            file://disable_hanging_tests.patch \
            file://0001-syscalls-pread02-extend-buffer-to-avoid-glibc-overflow-detection.patch \
+           file://0001-clock_gettime04-set-threshold-based-on-the-clock-res.patch \
            "
 
 S = "${WORKDIR}/git"
-- 
2.25.1



  parent reply	other threads:[~2022-11-04  3:02 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-04  3:00 [OE-core][kirkstone 00/31] Patch review Steve Sakoman
2022-11-04  3:00 ` [OE-core][kirkstone 01/31] openssl: export necessary env vars in SDK Steve Sakoman
2022-11-04  3:00 ` [OE-core][kirkstone 02/31] openssl: Fix SSL_CERT_FILE to match ca-certs location Steve Sakoman
2022-11-04  3:00 ` [OE-core][kirkstone 03/31] openssl: CVE-2022-3358 Using a Custom Cipher with NID_undef may lead to NULL encryption Steve Sakoman
2022-11-04  3:00 ` [OE-core][kirkstone 04/31] openssl: Upgrade 3.0.5 -> 3.0.7 Steve Sakoman
2022-11-04  3:00 ` [OE-core][kirkstone 05/31] lighttpd: fix CVE-2022-41556 Steve Sakoman
2022-11-04  3:00 ` [OE-core][kirkstone 06/31] tiff: fix CVE-2022-2953 Steve Sakoman
2022-11-07  9:10   ` Shubham Kulkarni
2022-11-07 14:19     ` Steve Sakoman
2022-11-09 10:27       ` Shubham Kulkarni
2022-11-04  3:00 ` [OE-core][kirkstone 07/31] expat: backport the fix for CVE-2022-43680 Steve Sakoman
2022-11-04  3:00 ` [OE-core][kirkstone 08/31] wayland: fix CVE-2021-3782 Steve Sakoman
2022-11-04  3:00 ` [OE-core][kirkstone 09/31] cve-update-db-native: add timeout to urlopen() calls Steve Sakoman
2022-11-04  3:00 ` [OE-core][kirkstone 10/31] vim: Upgrade 9.0.0598 -> 9.0.0614 Steve Sakoman
2022-11-04  3:00 ` [OE-core][kirkstone 11/31] vim: upgrade 9.0.0614 -> 9.0.0820 Steve Sakoman
2022-11-04  3:00 ` [OE-core][kirkstone 12/31] ifupdown: upgrade 0.8.37 -> 0.8.39 Steve Sakoman
2022-11-04  3:00 ` [OE-core][kirkstone 13/31] scripts/oe-check-sstate: cleanup Steve Sakoman
2022-11-04  3:00 ` [OE-core][kirkstone 14/31] scripts/oe-check-sstate: force build to run for all targets, specifically populate_sysroot Steve Sakoman
2022-11-04  3:00 ` [OE-core][kirkstone 15/31] psplash: add psplash-default in rdepends Steve Sakoman
2022-11-04  3:00 ` [OE-core][kirkstone 16/31] opkg-utils: use a git clone, not a dynamic snapshot Steve Sakoman
2022-11-04  3:00 ` [OE-core][kirkstone 17/31] insane.bbclass: Allow hashlib version that only accepts on parameter Steve Sakoman
2022-11-04  3:00 ` [OE-core][kirkstone 18/31] oe/packagemanager/rpm: don't leak file objects Steve Sakoman
2022-11-04  3:00 ` [OE-core][kirkstone 19/31] u-boot: Remove duplicate inherit of cml1 Steve Sakoman
2022-11-04  3:00 ` [OE-core][kirkstone 20/31] bluez5: add dbus to RDEPENDS Steve Sakoman
2022-11-04  3:00 ` [OE-core][kirkstone 21/31] glib-2.0: fix rare GFileInfo test case failure Steve Sakoman
2022-11-04  3:00 ` [OE-core][kirkstone 22/31] gnutls: Unified package names to lower-case Steve Sakoman
2022-11-04  3:00 ` [OE-core][kirkstone 23/31] meson: make wrapper options sub-command specific Steve Sakoman
2022-11-04  3:00 ` [OE-core][kirkstone 24/31] buildtools-tarball: export certificates to python and curl Steve Sakoman
2022-11-04  3:01 ` [OE-core][kirkstone 25/31] qemu-native: Add PACKAGECONFIG option for jack Steve Sakoman
2022-11-04  3:01 ` [OE-core][kirkstone 26/31] runqemu: Do not perturb script environment Steve Sakoman
2022-11-04  3:01 ` [OE-core][kirkstone 27/31] runqemu: Fix gl-es argument from causing other arguments to be ignored Steve Sakoman
2022-11-04  3:01 ` [OE-core][kirkstone 28/31] overlayfs: Allow not used mount points Steve Sakoman
2022-11-04  3:01 ` [OE-core][kirkstone 29/31] cmake-native: Fix host tool contamination (Bug: 14951) Steve Sakoman
2022-11-04  3:01 ` Steve Sakoman [this message]
2022-11-04  3:01 ` [OE-core][kirkstone 31/31] perf: Depend on native setuptools3 Steve Sakoman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f5d737a02a41ccfd040367228c85e438b59d63ab.1667530733.git.steve@sakoman.com \
    --to=steve@sakoman.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox