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.

selftests/proc: Remove idle time monotonicity assertions

Due to broken iowait task counting design (cf: comments above
get_cpu_idle_time_us() and nr_iowait()), it is not possible to provide
the guarantee that /proc/stat or /proc/uptime display monotonic idle
time values.

Remove the assertions that verify the related wrong assumption so that
testers and maintainers don't spend more time on that.

Reported-by: Yu Liao <liaoyu15@huawei.com>
Reported-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20230222144649.624380-8-frederic@kernel.org

authored by

Frederic Weisbecker and committed by
Thomas Gleixner
270b2a67 9a1d4b8a

+14 -27
+6 -6
tools/testing/selftests/proc/proc-uptime-001.c
··· 13 13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 15 */ 16 - // Test that values in /proc/uptime increment monotonically. 16 + // Test that boottime value in /proc/uptime increments monotonically. 17 + // We don't test idle time monotonicity due to broken iowait task 18 + // counting, cf: comment above get_cpu_idle_time_us() 17 19 #undef NDEBUG 18 20 #include <assert.h> 19 21 #include <stdint.h> ··· 27 25 28 26 int main(void) 29 27 { 30 - uint64_t start, u0, u1, i0, i1; 28 + uint64_t start, u0, u1; 31 29 int fd; 32 30 33 31 fd = open("/proc/uptime", O_RDONLY); 34 32 assert(fd >= 0); 35 33 36 - proc_uptime(fd, &u0, &i0); 34 + u0 = proc_uptime(fd); 37 35 start = u0; 38 36 do { 39 - proc_uptime(fd, &u1, &i1); 37 + u1 = proc_uptime(fd); 40 38 assert(u1 >= u0); 41 - assert(i1 >= i0); 42 39 u0 = u1; 43 - i0 = i1; 44 40 } while (u1 - start < 100); 45 41 46 42 return 0;
+6 -7
tools/testing/selftests/proc/proc-uptime-002.c
··· 13 13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 15 */ 16 - // Test that values in /proc/uptime increment monotonically 17 - // while shifting across CPUs. 16 + // Test that boottime value in /proc/uptime increments monotonically 17 + // while shifting across CPUs. We don't test idle time monotonicity 18 + // due to broken iowait task counting, cf: comment above get_cpu_idle_time_us() 18 19 #undef NDEBUG 19 20 #include <assert.h> 20 21 #include <errno.h> ··· 46 45 unsigned int len; 47 46 unsigned long *m; 48 47 unsigned int cpu; 49 - uint64_t u0, u1, i0, i1; 48 + uint64_t u0, u1; 50 49 int fd; 51 50 52 51 /* find out "nr_cpu_ids" */ ··· 61 60 fd = open("/proc/uptime", O_RDONLY); 62 61 assert(fd >= 0); 63 62 64 - proc_uptime(fd, &u0, &i0); 63 + u0 = proc_uptime(fd); 65 64 for (cpu = 0; cpu < len * 8; cpu++) { 66 65 memset(m, 0, len); 67 66 m[cpu / (8 * sizeof(unsigned long))] |= 1UL << (cpu % (8 * sizeof(unsigned long))); ··· 69 68 /* CPU might not exist, ignore error */ 70 69 sys_sched_setaffinity(0, len, m); 71 70 72 - proc_uptime(fd, &u1, &i1); 71 + u1 = proc_uptime(fd); 73 72 assert(u1 >= u0); 74 - assert(i1 >= i0); 75 73 u0 = u1; 76 - i0 = i1; 77 74 } 78 75 79 76 return 0;
+2 -14
tools/testing/selftests/proc/proc-uptime.h
··· 22 22 23 23 #include "proc.h" 24 24 25 - static void proc_uptime(int fd, uint64_t *uptime, uint64_t *idle) 25 + static uint64_t proc_uptime(int fd) 26 26 { 27 27 uint64_t val1, val2; 28 28 char buf[64], *p; ··· 43 43 assert(p[3] == ' '); 44 44 45 45 val2 = (p[1] - '0') * 10 + p[2] - '0'; 46 - *uptime = val1 * 100 + val2; 47 46 48 - p += 4; 49 - 50 - val1 = xstrtoull(p, &p); 51 - assert(p[0] == '.'); 52 - assert('0' <= p[1] && p[1] <= '9'); 53 - assert('0' <= p[2] && p[2] <= '9'); 54 - assert(p[3] == '\n'); 55 - 56 - val2 = (p[1] - '0') * 10 + p[2] - '0'; 57 - *idle = val1 * 100 + val2; 58 - 59 - assert(p + 4 == buf + rv); 47 + return val1 * 100 + val2; 60 48 }