LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 08-02-2017, 03:45 AM   #1
David PREVOT
LQ Newbie
 
Registered: Aug 2017
Posts: 1

Rep: Reputation: Disabled
Adding times from "top" command doesn't match uptime minus sleep time


Hi all,

I'm running top on an atom N270 cpu (single core).
When the uptime reaches 10 hours
1) I run "top -b -n 1 -c -S" to get all the cpu time used by all processes ... Assuming that "init" receives gets the time spent by all dead processes (due to the "cumulative mode ON" option).
2) I run "cat /proc/uptime" to get the uptime and the sleep time

When I add the cumulative time and the sleep time I get (more or less) 9 hours.

I believe that the "lost time" is used by the kernel itself (task scheduling, IP forwarding, ... can't be attributed to userspace processes). But it's only a feeling
Am I wrong in my deduction ?
Is there a tool like "top" that works for the kernel ?

Thanks in advance,
Best regards,
David.
 
Old 08-02-2017, 05:33 PM   #2
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
Those figures are approximate. /proc/uptime does not specify time sleeping. It specifies time idle. What exactly constitutes idle I don't know.
 
Old 08-04-2017, 12:50 PM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,672
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
"idle" is the time spent when the dispatcher has no work of any kind to dispatch.

All of the statistics are approximate and are calculated in different ways which are not intended to "add up."

The init process ("process #1" by any name) does not receive all unallocated time. Instead, if there's nothing for the CPU to do, the CPU generally halts, so that it gets off of the DMA bus.

Interrupt-processing time may or may not be fully accounted for but is ordinarily comparatively slight.
 
Old 08-06-2017, 04:03 PM   #4
rigor
Member
 
Registered: Sep 2003
Location: 19th moon ................. ................Planet Covid ................Another Galaxy;............. ................Not Yours
Posts: 705

Rep: Reputation: Disabled
If you just run top without command line arguments and look at the top outline line labeled "%Cpu" you can see a breakdown of some of the specific categories about where time was spent, including to some extent, in the kernel. For me, they usually add up reasonably well, but they can be rounded before being displayed, so they can add up to somewhat more than 100%.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How could a computer technician use the "top" command with "ps" and "kill" to investigate how a system is misbehaving? geckono1 Linux - Newbie 13 07-03-2016 07:51 AM
What "xload" sees which "top" doesn't? kaza Linux - General 3 12-08-2012 01:25 AM
[SOLVED] Adding user "me" to group "you" doesn't take effect for a while. Why not? Le Beastie Linux - Newbie 1 12-09-2009 04:13 AM
Data transfer online is slow "at times" or "stops at times" Balarabay1 SUSE / openSUSE 14 04-30-2006 10:00 AM
Where to download precompiled bash binaries, such as "time" and "top"? elinuxqs Linux - Newbie 12 11-14-2005 08:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 07:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration