lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130816144704.GA25904@redhat.com>
Date:	Fri, 16 Aug 2013 16:47:04 +0200
From:	Oleg Nesterov <oleg@...hat.com>
To:	Jaromir Capik <jcapik@...hat.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Michal Hocko <mhocko@...e.cz>,
	Martin Schwidefsky <schwidefsky@...ibm.com>,
	Ingo Molnar <mingo@...nel.org>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Thomas Gleixner <tglx@...utronix.de>
Cc:	Ania Honess <ahoness@...hat.com>, atomlin@...hat.com,
	asolanas@...hat.com, linux-kernel@...r.kernel.org
Subject: proc/stat: idle goes backward

Hello.

Out customer reports that "idle" field is not monotonic. So far this
is all I know. I do not know how to reproduce, etc.

But when I look at this code, this looks really possible even
ignoring drivers/cpuidle/ which plays with update_ts_time_stats().

So, get_cpu_idle_time_us(last_update_time => NULL) does:

	if (ts->idle_active && !nr_iowait_cpu(cpu)) {
		ktime_t delta = ktime_sub(now, ts->idle_entrytime);

		idle = ktime_add(ts->idle_sleeptime, delta);
	} else {
		idle = ts->idle_sleeptime;
	}


Suppose that ts->idle_active == T. By the time we calculate

	idle = ktime_add(ts->idle_sleeptime, delta);

this cpu can be already non-idle and ->idle_sleeptime can be already
updated by tick_nohz_stop_idle(), we return the wrong value.

If user-space reads /proc/stat again after that, "idle" can obviously
go back.

get_cpu_iowait_time_us() has the same problem.

Plus nr_iowait_cpu() can change in between even if cpu stays idle,
io_schedule() can return on another CPU.

Questions:

	- Any other reason why it can be non-monotonic?

	- Should we fix this or should we document that userspace
	  should handle this itself?

	  IOW, is this is bug or not?

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ