Difference between revisions of "BC proc entries"

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search
m (Categorized)
m (Reverted edits by StevenCook (talk) to last revision by Kir)
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This page describes proc interface of [UBC] subsystem.
+
{{UBC toc}}
 +
This page describes proc interface of [[UBC]] subsystem.
  
 
== Old interface ==
 
== Old interface ==
Old interface consisted of 2 (optionally 3) files
+
The [[Proc/user_beancounters|old interface]] consisted of 2 (optionally 3) files:
; <code>user_beancounters</code>
+
; <code>/proc/user_beancounters</code>
: reveals an overall information about resource consumption of each beancounter in system
+
: reveals an overall information about resource consumption of each beancounter in system; described [[Proc/user_beancounters|here]];
; <code>user_beancounters_sub</code>
+
; <code>/proc/user_beancounters_sub</code>
: reveals information about all beancounters and sub-beancounters in system
+
: reveals information about all beancounters and sub-beancounters in system;
; <code>user_beancounters_debug</code>
+
; <code>/proc/user_beancounters_debug</code>
: this files is shown if <code>CONFIG_UBC_DEBUG_KMEM</code> option is turned on and shows debugging information about each beancounter. This includes the numbers of
+
: shows debugging information about each beancounter. Available if <code>CONFIG_UBC_DEBUG_KMEM</code> option is turned on. Information revealed includes the numbers of
# objects charged from each slab
+
:# objects charged from each slab;
# pages charged
+
:# pages charged;
# vmalloc-ed pages
+
:# vmalloc-ed pages;
# page beancounters
+
:# page beancounters;
# etc
+
:# etc.
  
 
== New interface ==
 
== New interface ==
In new interface only <code>user_beancounters</code> entry is left for compatibility with old tools. New entries reside in <code>/proc/bc</code> directory. This directory also contains subdirectories for each beancounter in the system. E.g.
+
In new interface only <code>/proc/user_beancounters</code> entry is left for compatibility with old tools. New entries reside in <code>/proc/bc</code> directory. This directory also contains subdirectories for each beancounter in the system. E.g.
 
<pre>
 
<pre>
 
# ls /proc/bc/
 
# ls /proc/bc/
Line 32: Line 33:
 
=== Existing general entries ===
 
=== Existing general entries ===
 
; <code>/proc/bc/resources</code>
 
; <code>/proc/bc/resources</code>
: This entry looks like old <code>user_beancounters</code> entry but
+
: This entry looks like old <code>/proc/user_beancounters</code> entry but
# it doesn't contain “dummy” resources
+
:# it doesn't contain “dummy” resources
# if new resource is added to BC it will appear in this entry only
+
:# if new resource is added to BC it will appear in this entry only
 
; <code>/proc/bc/$BCID/resources</code>
 
; <code>/proc/bc/$BCID/resources</code>
: This entry shows the same as <code>bc/resources</code> does but for <code>$BCID</code> beancounter only.
+
: This entry shows the same as <code>/proc/bc/resources</code> does but for <code>$BCID</code> beancounter only.
 
; <code>/proc/bc/$BCID/vmaux</code>
 
; <code>/proc/bc/$BCID/vmaux</code>
 
: This entry shows auxiliary resources used in VM accounting.
 
: This entry shows auxiliary resources used in VM accounting.
 
; <code>/proc/bc/$BCID/kmem_debug</code>
 
; <code>/proc/bc/$BCID/kmem_debug</code>
 
: This entry is available with <code>CONFIG_UBC_DEBUG_KMEM</code> option set and shows per-beancounter info that was in <code>/proc/user_beancounters_debug</code> before.
 
: This entry is available with <code>CONFIG_UBC_DEBUG_KMEM</code> option set and shows per-beancounter info that was in <code>/proc/user_beancounters_debug</code> before.
 +
 +
=== Other entries ===
 +
The following subsystems add their own entries in <code>/proc/bc</code> and <code>/proc/bc/$BCID</code>:
 +
* [[IO accounting]]
  
 
=== Kernel API ===
 
=== Kernel API ===
Line 48: Line 53:
 
; <code>struct bc_proc_entry;</code>
 
; <code>struct bc_proc_entry;</code>
 
: This describes an entry that may show per-beancounter info. This looks like this:
 
: This describes an entry that may show per-beancounter info. This looks like this:
<pre>
+
<source lang="c">
 
struct bc_proc_entry {
 
struct bc_proc_entry {
 
         char *name;
 
         char *name;
Line 54: Line 59:
 
         struct bc_proc_entry *next;
 
         struct bc_proc_entry *next;
 
};
 
};
</pre>
+
</source>
 
* <code>name</code> is the entry name as it will appear in <code>/proc/bc/$BCID</code>
 
* <code>name</code> is the entry name as it will appear in <code>/proc/bc/$BCID</code>
 
* <code>show</code> is a callback that is to fill info about particulat beancounter
 
* <code>show</code> is a callback that is to fill info about particulat beancounter
Line 60: Line 65:
 
: This call registers an entry that shows per-beancounter info.
 
: This call registers an entry that shows per-beancounter info.
  
The code that fills info about BC must look like this
+
The code that fills info about BC must look like this:
<pre>
+
<source lang="c">
 
static int bc_my_show(struct seq_file *f, void *v)
 
static int bc_my_show(struct seq_file *f, void *v)
 
{
 
{
Line 83: Line 88:
  
 
late_initcall(bc_my_init);
 
late_initcall(bc_my_init);
</pre>
+
</source>
 
{{note|Due to limitations in <code>single_open</code> the <code>struct user_beancounter</code> pointer is not passed as <code>void *v</code> into showing function but must be obtained from <code>seq_file</code> with <code>seq_beancounter</code>}}
 
{{note|Due to limitations in <code>single_open</code> the <code>struct user_beancounter</code> pointer is not passed as <code>void *v</code> into showing function but must be obtained from <code>seq_file</code> with <code>seq_beancounter</code>}}
 
[[Category:UBC]]
 

Latest revision as of 20:46, 4 August 2012

User Beancounters
Definition
/proc/user_beancounters
/proc/bc/
General information
Units of measurement
VSwap
Parameters description
Primary parameters
numproc, numtcpsock, numothersock, vmguarpages
Secondary parameters
kmemsize, tcpsndbuf, tcprcvbuf, othersockbuf, dgramrcvbuf, oomguarpages, privvmpages
Auxiliary parameters
lockedpages, shmpages, physpages, numfile, numflock, numpty, numsiginfo, dcachesize, numiptent, swappages
Internals
User pages accounting
RSS fractions accounting
On-demand accounting
UBC consistency
Consistency formulae
System-wide configuration
vzubc(8)
Configuration examples
Basic
Derived
Intermediate configurations
Tables
List of parameters
Parameter properties
Consistency
Config examples

This page describes proc interface of UBC subsystem.

Old interface[edit]

The old interface consisted of 2 (optionally 3) files:

/proc/user_beancounters
reveals an overall information about resource consumption of each beancounter in system; described here;
/proc/user_beancounters_sub
reveals information about all beancounters and sub-beancounters in system;
/proc/user_beancounters_debug
shows debugging information about each beancounter. Available if CONFIG_UBC_DEBUG_KMEM option is turned on. Information revealed includes the numbers of
  1. objects charged from each slab;
  2. pages charged;
  3. vmalloc-ed pages;
  4. page beancounters;
  5. etc.

New interface[edit]

In new interface only /proc/user_beancounters entry is left for compatibility with old tools. New entries reside in /proc/bc directory. This directory also contains subdirectories for each beancounter in the system. E.g.

# ls /proc/bc/
0  ioacct_debug  resources
# vzctl  start 101
...
# ls /proc/bc
0  101  ioacct_debug  resources
# ls /proc/bc/101/
ioacct  kmem_debug  resources  vmaux

All new entries that are in /proc/bc shows some overall information about BC subsystem, while entries in /proc/bc/$BCID show per-beancounter info.

Existing general entries[edit]

/proc/bc/resources
This entry looks like old /proc/user_beancounters entry but
  1. it doesn't contain “dummy” resources
  2. if new resource is added to BC it will appear in this entry only
/proc/bc/$BCID/resources
This entry shows the same as /proc/bc/resources does but for $BCID beancounter only.
/proc/bc/$BCID/vmaux
This entry shows auxiliary resources used in VM accounting.
/proc/bc/$BCID/kmem_debug
This entry is available with CONFIG_UBC_DEBUG_KMEM option set and shows per-beancounter info that was in /proc/user_beancounters_debug before.

Other entries[edit]

The following subsystems add their own entries in /proc/bc and /proc/bc/$BCID:

Kernel API[edit]

Subsystems may add its own entries in /proc/bc or /proc/bc/$BCID. To facilitate this the following API is used in BC sybsystem (declared in include/ub/proc.h).

struct proc_dir_entry *bc_proc_root
This is an entry that corresponds to /proc/bc directory. If a subsystem wishes to report some information that is not per-beancounter it may create entry using this as a parent.
struct bc_proc_entry;
This describes an entry that may show per-beancounter info. This looks like this:
struct bc_proc_entry {
        char *name;
        int (*show)(struct seq_file *, void *);
        struct bc_proc_entry *next;
};
  • name is the entry name as it will appear in /proc/bc/$BCID
  • show is a callback that is to fill info about particulat beancounter
void bc_register_proc_entry(struct bc_proc_entry *);
This call registers an entry that shows per-beancounter info.

The code that fills info about BC must look like this:

static int bc_my_show(struct seq_file *f, void *v)
{
        struct user_beancounter *ub;

        ub = seq_beancounter(f);
        /* dump info into f here */
        return 0;
}
...
static struct bc_proc_entry my_entry = {
        .name = "my_entry",
        .show = bc_my_show,
};

static int __init bc_my_init(void)
{
        bc_register_proc_entry(&my_entry);
        return 0;
}

late_initcall(bc_my_init);
Yellowpin.svg Note: Due to limitations in single_open the struct user_beancounter pointer is not passed as void *v into showing function but must be obtained from seq_file with seq_beancounter