2014-11-27 23:02:52 +00:00
|
|
|
#ifndef HEADER_LinuxProcessList
|
|
|
|
#define HEADER_LinuxProcessList
|
|
|
|
/*
|
|
|
|
htop - LinuxProcessList.h
|
|
|
|
(C) 2014 Hisham H. Muhammad
|
|
|
|
Released under the GNU GPL, see the COPYING file
|
|
|
|
in the source distribution for its full text.
|
|
|
|
*/
|
|
|
|
|
2018-02-26 14:44:00 +00:00
|
|
|
#ifdef MAJOR_IN_MKDEV
|
2018-12-15 13:06:00 +00:00
|
|
|
#elif defined(MAJOR_IN_SYSMACROS)
|
2018-02-26 14:44:00 +00:00
|
|
|
#endif
|
|
|
|
|
2017-12-04 02:15:29 +00:00
|
|
|
#ifdef HAVE_DELAYACCT
|
|
|
|
#endif
|
|
|
|
|
2014-11-27 23:02:52 +00:00
|
|
|
|
|
|
|
#include "ProcessList.h"
|
2019-07-07 23:27:00 +00:00
|
|
|
#include "zfs/ZfsArcStats.h"
|
2014-11-27 23:02:52 +00:00
|
|
|
|
2018-08-19 04:29:03 +00:00
|
|
|
extern long long btime;
|
|
|
|
|
2015-01-22 01:27:31 +00:00
|
|
|
typedef struct CPUData_ {
|
|
|
|
unsigned long long int totalTime;
|
|
|
|
unsigned long long int userTime;
|
|
|
|
unsigned long long int systemTime;
|
|
|
|
unsigned long long int systemAllTime;
|
|
|
|
unsigned long long int idleAllTime;
|
|
|
|
unsigned long long int idleTime;
|
|
|
|
unsigned long long int niceTime;
|
|
|
|
unsigned long long int ioWaitTime;
|
|
|
|
unsigned long long int irqTime;
|
|
|
|
unsigned long long int softIrqTime;
|
|
|
|
unsigned long long int stealTime;
|
|
|
|
unsigned long long int guestTime;
|
2019-10-31 16:39:12 +00:00
|
|
|
|
2015-01-22 01:27:31 +00:00
|
|
|
unsigned long long int totalPeriod;
|
|
|
|
unsigned long long int userPeriod;
|
|
|
|
unsigned long long int systemPeriod;
|
|
|
|
unsigned long long int systemAllPeriod;
|
|
|
|
unsigned long long int idleAllPeriod;
|
|
|
|
unsigned long long int idlePeriod;
|
|
|
|
unsigned long long int nicePeriod;
|
|
|
|
unsigned long long int ioWaitPeriod;
|
|
|
|
unsigned long long int irqPeriod;
|
|
|
|
unsigned long long int softIrqPeriod;
|
|
|
|
unsigned long long int stealPeriod;
|
|
|
|
unsigned long long int guestPeriod;
|
2019-08-11 05:19:32 +00:00
|
|
|
|
|
|
|
double frequency;
|
2015-01-22 01:27:31 +00:00
|
|
|
} CPUData;
|
|
|
|
|
2016-10-01 06:09:04 +00:00
|
|
|
typedef struct TtyDriver_ {
|
|
|
|
char* path;
|
|
|
|
unsigned int major;
|
|
|
|
unsigned int minorFrom;
|
|
|
|
unsigned int minorTo;
|
|
|
|
} TtyDriver;
|
|
|
|
|
2015-01-22 01:27:31 +00:00
|
|
|
typedef struct LinuxProcessList_ {
|
|
|
|
ProcessList super;
|
2019-10-31 16:39:12 +00:00
|
|
|
|
2015-01-22 01:27:31 +00:00
|
|
|
CPUData* cpus;
|
2016-10-01 06:09:04 +00:00
|
|
|
TtyDriver* ttyDrivers;
|
2018-10-16 18:08:23 +00:00
|
|
|
bool haveSmapsRollup;
|
2019-10-31 16:39:12 +00:00
|
|
|
|
2017-12-04 02:15:29 +00:00
|
|
|
#ifdef HAVE_DELAYACCT
|
|
|
|
struct nl_sock *netlink_socket;
|
|
|
|
int netlink_family;
|
|
|
|
#endif
|
2019-07-07 02:37:02 +00:00
|
|
|
|
2019-07-07 23:27:00 +00:00
|
|
|
ZfsArcStats zfs;
|
2015-01-22 01:27:31 +00:00
|
|
|
} LinuxProcessList;
|
|
|
|
|
2014-11-27 23:02:52 +00:00
|
|
|
#ifndef PROCDIR
|
|
|
|
#define PROCDIR "/proc"
|
|
|
|
#endif
|
|
|
|
|
2019-08-11 05:19:32 +00:00
|
|
|
#ifndef PROCCPUINFOFILE
|
|
|
|
#define PROCCPUINFOFILE PROCDIR "/cpuinfo"
|
|
|
|
#endif
|
|
|
|
|
2014-11-27 23:02:52 +00:00
|
|
|
#ifndef PROCSTATFILE
|
|
|
|
#define PROCSTATFILE PROCDIR "/stat"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef PROCMEMINFOFILE
|
|
|
|
#define PROCMEMINFOFILE PROCDIR "/meminfo"
|
|
|
|
#endif
|
|
|
|
|
2019-07-07 02:37:02 +00:00
|
|
|
#ifndef PROCARCSTATSFILE
|
|
|
|
#define PROCARCSTATSFILE PROCDIR "/spl/kstat/zfs/arcstats"
|
|
|
|
#endif
|
|
|
|
|
2016-10-01 06:09:04 +00:00
|
|
|
#ifndef PROCTTYDRIVERSFILE
|
|
|
|
#define PROCTTYDRIVERSFILE PROCDIR "/tty/drivers"
|
|
|
|
#endif
|
|
|
|
|
2015-12-14 15:27:11 +00:00
|
|
|
#ifndef PROC_LINE_LENGTH
|
2018-08-19 04:29:03 +00:00
|
|
|
#define PROC_LINE_LENGTH 4096
|
2015-12-14 15:27:11 +00:00
|
|
|
#endif
|
|
|
|
|
Introduce CLAMP macro. Unify all MIN(MAX(a,b),c) uses.
With the CLAMP macro replacing the combination of MIN and MAX, we will
have at least two advantages:
1. It's more obvious semantically.
2. There are no more mixes of confusing uses like MIN(MAX(a,b),c) and
MAX(MIN(a,b),c) and MIN(a,MAX(b,c)) appearing everywhere. We unify
the 'clamping' with a single macro.
Note that the behavior of this CLAMP macro is different from
the combination `MAX(low,MIN(x,high))`.
* This CLAMP macro expands to two comparisons instead of three from
MAX and MIN combination. In theory, this makes the code slightly
smaller, in case that (low) or (high) or both are computed at
runtime, so that compilers cannot optimize them. (The third
comparison will matter if (low)>(high); see below.)
* CLAMP has a side effect, that if (low)>(high) it will produce weird
results. Unlike MIN & MAX which will force either (low) or (high) to
win. No assertion of ((low)<=(high)) is done in this macro, for now.
This CLAMP macro is implemented like described in glib
<http://developer.gnome.org/glib/stable/glib-Standard-Macros.html>
and does not handle weird uses like CLAMP(a++, low++, high--) .
2016-01-15 12:26:01 +00:00
|
|
|
|
|
|
|
#ifndef CLAMP
|
|
|
|
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
|
|
|
|
#endif
|
2016-10-01 06:09:04 +00:00
|
|
|
|
2017-12-04 02:15:29 +00:00
|
|
|
#ifdef HAVE_DELAYACCT
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2020-09-02 07:38:44 +00:00
|
|
|
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId);
|
2014-11-27 23:02:52 +00:00
|
|
|
|
2020-09-02 07:38:44 +00:00
|
|
|
void ProcessList_delete(ProcessList* pl);
|
2014-11-27 23:02:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_TASKSTATS
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_OPENVZ
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_CGROUP
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_VSERVER
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2017-12-04 02:15:29 +00:00
|
|
|
#ifdef HAVE_DELAYACCT
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2020-09-02 07:38:44 +00:00
|
|
|
void ProcessList_goThroughEntries(ProcessList* super);
|
2014-11-27 23:02:52 +00:00
|
|
|
|
|
|
|
#endif
|