2002-12-09 12:30:07 +05:30
|
|
|
#ifndef PROC_SYSINFO_H
|
|
|
|
#define PROC_SYSINFO_H
|
2003-05-31 06:08:55 +05:30
|
|
|
#include <sys/types.h>
|
2014-07-06 19:51:01 +05:30
|
|
|
#include <dirent.h>
|
2002-11-25 15:46:33 +05:30
|
|
|
#include "procps.h"
|
|
|
|
|
2002-12-09 12:30:07 +05:30
|
|
|
EXTERN_C_BEGIN
|
|
|
|
|
2002-05-28 09:48:55 +05:30
|
|
|
extern unsigned long long Hertz; /* clock tick frequency */
|
2011-07-14 16:46:02 +05:30
|
|
|
extern long smp_num_cpus; /* number of CPUs */
|
|
|
|
extern int have_privs; /* boolean, true if setuid or similar */
|
2014-07-17 21:41:11 +05:30
|
|
|
extern long page_bytes; /* this architecture's bytes per page */
|
2002-02-02 04:17:29 +05:30
|
|
|
|
2003-09-08 07:09:49 +05:30
|
|
|
#if 0
|
2002-02-02 04:17:29 +05:30
|
|
|
#define JT double
|
2006-06-25 07:45:36 +05:30
|
|
|
extern void eight_cpu_numbers(JT *uret, JT *nret, JT *sret, JT *iret, JT *wret, JT *xret, JT *yret, JT *zret);
|
2002-02-02 04:17:29 +05:30
|
|
|
#undef JT
|
2003-09-08 07:09:49 +05:30
|
|
|
#endif
|
2002-02-02 04:17:29 +05:30
|
|
|
|
|
|
|
extern int uptime (double *uptime_secs, double *idle_secs);
|
2010-12-16 15:00:39 +05:30
|
|
|
extern unsigned long getbtime(void);
|
2002-02-02 04:17:29 +05:30
|
|
|
extern void loadavg(double *av1, double *av5, double *av15);
|
|
|
|
|
library: properly handle memory used by tmpfs
tmpfs has become much more widely used since distributions use it for
/tmp (Fedora 18+). In /proc/meminfo, memory used by tmpfs is accounted
into "Cached" (aka "NR_FILE_PAGES",
http://lxr.free-electrons.com/source/mm/shmem.c#L301 ).
The tools just pass it on, so what top, free and vmstat report as
"cached" is the sum of page cache and tmpfs.
free has the extremely useful "-/+ buffers/cache" output. However, now
that tmpfs is accounted into "cached", those numbers are way off once
you have big files in /tmp.
Fortunately, kernel 2.6.32 introduces "Shmem", which makes tmpfs memory
usage accessible from userspace (
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=4b02108ac1b3354a22b0d83c684797692efdc395 ).
This patch substracts Shmem from Cached to get the actual page cache
memory. This makes both issues mentioned above disappear. For older
kernels, Shmem is not available (hence zero) and this patch is no-op.
Additionally:
* Update the man pages of free and vmstat to explain what is happening
* Finally drop "MemShared" from the /proc/meminfo parser, it has been
dead for 10+ years and is only causing confusion ( removed in kernel
2.5.54, see
https://git.kernel.org/cgit/linux/kernel/git/tglx/history.git/commit/?id=fe04e9451e5a159247cf9f03c615a4273ac0c571 )
2014-02-19 02:42:21 +05:30
|
|
|
/* Shmem in 2.6.32+ */
|
2003-01-23 11:18:27 +05:30
|
|
|
extern unsigned long kb_main_shared;
|
2002-02-02 04:17:29 +05:30
|
|
|
/* old but still kicking -- the important stuff */
|
2003-01-23 11:18:27 +05:30
|
|
|
extern unsigned long kb_main_buffers;
|
|
|
|
extern unsigned long kb_main_cached;
|
|
|
|
extern unsigned long kb_main_free;
|
|
|
|
extern unsigned long kb_main_total;
|
|
|
|
extern unsigned long kb_swap_free;
|
|
|
|
extern unsigned long kb_swap_total;
|
2002-02-02 04:17:29 +05:30
|
|
|
/* recently introduced */
|
2003-01-23 11:18:27 +05:30
|
|
|
extern unsigned long kb_high_free;
|
|
|
|
extern unsigned long kb_high_total;
|
|
|
|
extern unsigned long kb_low_free;
|
|
|
|
extern unsigned long kb_low_total;
|
2014-07-12 02:04:06 +05:30
|
|
|
extern unsigned long kb_main_available;
|
2002-02-02 04:17:29 +05:30
|
|
|
/* 2.4.xx era */
|
2003-01-23 11:18:27 +05:30
|
|
|
extern unsigned long kb_active;
|
|
|
|
extern unsigned long kb_inact_laundry; // grrr...
|
|
|
|
extern unsigned long kb_inact_dirty;
|
|
|
|
extern unsigned long kb_inact_clean;
|
|
|
|
extern unsigned long kb_inact_target;
|
|
|
|
extern unsigned long kb_swap_cached; /* late 2.4+ */
|
2002-02-02 04:17:29 +05:30
|
|
|
/* derived values */
|
2003-01-23 11:18:27 +05:30
|
|
|
extern unsigned long kb_swap_used;
|
|
|
|
extern unsigned long kb_main_used;
|
2002-10-06 22:16:06 +05:30
|
|
|
/* 2.5.41+ */
|
2003-01-23 11:18:27 +05:30
|
|
|
extern unsigned long kb_writeback;
|
|
|
|
extern unsigned long kb_slab;
|
|
|
|
extern unsigned long nr_reversemaps;
|
|
|
|
extern unsigned long kb_committed_as;
|
|
|
|
extern unsigned long kb_dirty;
|
|
|
|
extern unsigned long kb_inactive;
|
|
|
|
extern unsigned long kb_mapped;
|
|
|
|
extern unsigned long kb_pagetables;
|
2002-02-02 04:17:29 +05:30
|
|
|
|
2005-10-30 05:44:16 +05:30
|
|
|
#define BUFFSIZE (64*1024)
|
2003-05-31 06:08:55 +05:30
|
|
|
typedef unsigned long long jiff;
|
2012-01-09 16:14:51 +05:30
|
|
|
extern void getstat(jiff *__restrict cuse, jiff *__restrict cice, jiff *__restrict csys, jiff *__restrict cide, jiff *__restrict ciow, jiff *__restrict cxxx, jiff *__restrict cyyy, jiff *__restrict czzz,
|
|
|
|
unsigned long *__restrict pin, unsigned long *__restrict pout, unsigned long *__restrict s_in, unsigned long *__restrict sout,
|
|
|
|
unsigned *__restrict intr, unsigned *__restrict ctxt,
|
|
|
|
unsigned int *__restrict running, unsigned int *__restrict blocked,
|
|
|
|
unsigned int *__restrict btime, unsigned int *__restrict processes);
|
2003-05-31 06:08:55 +05:30
|
|
|
|
2002-02-02 04:17:29 +05:30
|
|
|
extern void meminfo(void);
|
|
|
|
|
2002-10-06 22:16:06 +05:30
|
|
|
|
2003-01-23 11:18:27 +05:30
|
|
|
extern unsigned long vm_nr_dirty;
|
|
|
|
extern unsigned long vm_nr_writeback;
|
|
|
|
extern unsigned long vm_nr_pagecache;
|
|
|
|
extern unsigned long vm_nr_page_table_pages;
|
|
|
|
extern unsigned long vm_nr_reverse_maps;
|
|
|
|
extern unsigned long vm_nr_mapped;
|
|
|
|
extern unsigned long vm_nr_slab;
|
2014-07-15 22:47:02 +05:30
|
|
|
extern unsigned long vm_nr_slab_reclaimable;
|
|
|
|
extern unsigned long vm_nr_slab_unreclaimable;
|
|
|
|
extern unsigned long vm_nr_active_file;
|
|
|
|
extern unsigned long vm_nr_inactive_file;
|
|
|
|
extern unsigned long vm_nr_free_pages;
|
2003-01-23 11:18:27 +05:30
|
|
|
extern unsigned long vm_pgpgin;
|
|
|
|
extern unsigned long vm_pgpgout;
|
|
|
|
extern unsigned long vm_pswpin;
|
|
|
|
extern unsigned long vm_pswpout;
|
|
|
|
extern unsigned long vm_pgalloc;
|
|
|
|
extern unsigned long vm_pgfree;
|
|
|
|
extern unsigned long vm_pgactivate;
|
|
|
|
extern unsigned long vm_pgdeactivate;
|
|
|
|
extern unsigned long vm_pgfault;
|
|
|
|
extern unsigned long vm_pgmajfault;
|
|
|
|
extern unsigned long vm_pgscan;
|
|
|
|
extern unsigned long vm_pgrefill;
|
|
|
|
extern unsigned long vm_pgsteal;
|
|
|
|
extern unsigned long vm_kswapd_steal;
|
|
|
|
extern unsigned long vm_pageoutrun;
|
|
|
|
extern unsigned long vm_allocstall;
|
2002-10-06 22:16:06 +05:30
|
|
|
|
|
|
|
extern void vminfo(void);
|
|
|
|
|
2003-06-08 22:58:06 +05:30
|
|
|
typedef struct disk_stat{
|
|
|
|
unsigned long long reads_sectors;
|
|
|
|
unsigned long long written_sectors;
|
2016-06-30 21:59:50 +05:30
|
|
|
char disk_name [32];
|
2003-06-08 22:58:06 +05:30
|
|
|
unsigned inprogress_IO;
|
2003-08-11 07:29:53 +05:30
|
|
|
unsigned merged_reads;
|
|
|
|
unsigned merged_writes;
|
|
|
|
unsigned milli_reading;
|
2003-06-08 22:58:06 +05:30
|
|
|
unsigned milli_spent_IO;
|
2003-08-11 07:29:53 +05:30
|
|
|
unsigned milli_writing;
|
2003-08-11 05:10:41 +05:30
|
|
|
unsigned partitions;
|
2003-08-11 07:29:53 +05:30
|
|
|
unsigned reads;
|
|
|
|
unsigned weighted_milli_spent_IO;
|
|
|
|
unsigned writes;
|
2003-06-08 22:58:06 +05:30
|
|
|
}disk_stat;
|
|
|
|
|
|
|
|
typedef struct partition_stat{
|
2016-06-30 21:59:50 +05:30
|
|
|
char partition_name [35];
|
2004-02-24 01:01:00 +05:30
|
|
|
unsigned long long reads_sectors;
|
2004-05-05 04:59:40 +05:30
|
|
|
unsigned parent_disk; // index into a struct disk_stat array
|
2003-06-08 22:58:06 +05:30
|
|
|
unsigned reads;
|
|
|
|
unsigned writes;
|
2011-11-27 17:17:17 +05:30
|
|
|
unsigned long long requested_writes;
|
2003-06-08 22:58:06 +05:30
|
|
|
}partition_stat;
|
|
|
|
|
2003-08-11 05:10:41 +05:30
|
|
|
extern unsigned int getpartitions_num(struct disk_stat *disks, int ndisks);
|
2003-06-08 22:58:06 +05:30
|
|
|
extern unsigned int getdiskstat (struct disk_stat**,struct partition_stat**);
|
|
|
|
|
|
|
|
typedef struct slab_cache{
|
|
|
|
char name[48];
|
|
|
|
unsigned active_objs;
|
|
|
|
unsigned num_objs;
|
|
|
|
unsigned objsize;
|
|
|
|
unsigned objperslab;
|
|
|
|
}slab_cache;
|
|
|
|
|
|
|
|
extern unsigned int getslabinfo (struct slab_cache**);
|
|
|
|
|
2003-07-03 10:50:19 +05:30
|
|
|
extern unsigned get_pid_digits(void) FUNCTION;
|
|
|
|
|
2011-07-14 16:46:02 +05:30
|
|
|
extern void cpuinfo (void);
|
|
|
|
|
2002-12-09 12:30:07 +05:30
|
|
|
EXTERN_C_END
|
2002-02-02 04:17:29 +05:30
|
|
|
#endif /* SYSINFO_H */
|