The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/racct.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2010 The FreeBSD Foundation
    3  * All rights reserved.
    4  *
    5  * This software was developed by Edward Tomasz Napierala under sponsorship
    6  * from the FreeBSD Foundation.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27  * SUCH DAMAGE.
   28  *
   29  * $FreeBSD: releng/9.0/sys/sys/racct.h 226092 2011-10-07 06:46:46Z trasz $
   30  */
   31 
   32 /*
   33  * Resource accounting.
   34  */
   35 
   36 #ifndef _RACCT_H_
   37 #define _RACCT_H_
   38 
   39 #include <sys/cdefs.h>
   40 #include <sys/queue.h>
   41 #include <sys/types.h>
   42 
   43 struct proc;
   44 struct rctl_rule_link;
   45 struct ucred;
   46 
   47 /*
   48  * Resources.
   49  */
   50 #define RACCT_UNDEFINED         -1
   51 #define RACCT_CPU               0
   52 #define RACCT_DATA              1
   53 #define RACCT_STACK             2
   54 #define RACCT_CORE              3
   55 #define RACCT_RSS               4
   56 #define RACCT_MEMLOCK           5
   57 #define RACCT_NPROC             6
   58 #define RACCT_NOFILE            7
   59 #define RACCT_VMEM              8
   60 #define RACCT_NPTS              9
   61 #define RACCT_SWAP              10
   62 #define RACCT_NTHR              11
   63 #define RACCT_MSGQQUEUED        12
   64 #define RACCT_MSGQSIZE          13
   65 #define RACCT_NMSGQ             14
   66 #define RACCT_NSEM              15
   67 #define RACCT_NSEMOP            16
   68 #define RACCT_NSHM              17
   69 #define RACCT_SHMSIZE           18
   70 #define RACCT_WALLCLOCK         19
   71 #define RACCT_MAX               RACCT_WALLCLOCK
   72 
   73 /*
   74  * Resource properties.
   75  */
   76 #define RACCT_IN_MILLIONS       0x01
   77 #define RACCT_RECLAIMABLE       0x02
   78 #define RACCT_INHERITABLE       0x04
   79 #define RACCT_DENIABLE          0x08
   80 #define RACCT_SLOPPY            0x10
   81 
   82 extern int racct_types[];
   83 
   84 /*
   85  * Amount stored in c_resources[] is 10**6 times bigger than what's
   86  * visible to the userland.  It gets fixed up when retrieving resource
   87  * usage or adding rules.
   88  */
   89 #define RACCT_IS_IN_MILLIONS(X) (racct_types[X] & RACCT_IN_MILLIONS)
   90 
   91 /*
   92  * Resource usage can drop, as opposed to only grow.
   93  */
   94 #define RACCT_IS_RECLAIMABLE(X) (racct_types[X] & RACCT_RECLAIMABLE)
   95 
   96 /*
   97  * Children inherit resource usage.
   98  */
   99 #define RACCT_IS_INHERITABLE(X) (racct_types[X] & RACCT_INHERITABLE)
  100 
  101 /*
  102  * racct_{add,set}(9) can actually return an error and not update resource
  103  * usage counters.  Note that even when resource is not deniable, allocating
  104  * resource might cause signals to be sent by RCTL code.
  105  */
  106 #define RACCT_IS_DENIABLE(X)            (racct_types[X] & RACCT_DENIABLE)
  107 
  108 /*
  109  * Per-process resource usage information makes no sense, but per-credential
  110  * one does.  This kind of resources are usually allocated for process, but
  111  * freed using credentials.
  112  */
  113 #define RACCT_IS_SLOPPY(X)              (racct_types[X] & RACCT_SLOPPY)
  114 
  115 /*
  116  * The 'racct' structure defines resource consumption for a particular
  117  * subject, such as process or jail.
  118  *
  119  * This structure must be filled with zeroes initially.
  120  */
  121 struct racct {
  122         int64_t                         r_resources[RACCT_MAX + 1];
  123         LIST_HEAD(, rctl_rule_link)     r_rule_links;
  124 };
  125 
  126 int     racct_add(struct proc *p, int resource, uint64_t amount);
  127 void    racct_add_cred(struct ucred *cred, int resource, uint64_t amount);
  128 void    racct_add_force(struct proc *p, int resource, uint64_t amount);
  129 int     racct_set(struct proc *p, int resource, uint64_t amount);
  130 void    racct_set_force(struct proc *p, int resource, uint64_t amount);
  131 void    racct_sub(struct proc *p, int resource, uint64_t amount);
  132 void    racct_sub_cred(struct ucred *cred, int resource, uint64_t amount);
  133 uint64_t        racct_get_limit(struct proc *p, int resource);
  134 uint64_t        racct_get_available(struct proc *p, int resource);
  135 
  136 void    racct_create(struct racct **racctp);
  137 void    racct_destroy(struct racct **racctp);
  138 
  139 int     racct_proc_fork(struct proc *parent, struct proc *child);
  140 void    racct_proc_fork_done(struct proc *child);
  141 void    racct_proc_exit(struct proc *p);
  142 
  143 void    racct_proc_ucred_changed(struct proc *p, struct ucred *oldcred,
  144             struct ucred *newcred);
  145 
  146 #endif /* !_RACCT_H_ */

Cache object: e84423b252b1443144a419a45fe0cf93


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.