xref: /titanic_51/usr/src/uts/common/sys/mem_cage.h (revision bbaa8b60dd95d714741fc474adad3cf710ef4efd)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_MEM_CAGE_H
27 #define	_SYS_MEM_CAGE_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/types.h>
32 #include <sys/memlist.h>
33 
34 /*
35  * Memory caging interfaces.
36  */
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 #ifdef _KERNEL
43 
44 #define	KCT_FAILURE	0
45 #define	KCT_CRIT	1
46 #define	KCT_NONCRIT	2
47 
48 extern int kernel_cage_enable;
49 extern int kcage_on;
50 extern kthread_id_t kcage_cageout_thread;
51 extern pgcnt_t kcage_freemem;
52 extern pgcnt_t kcage_needfree;
53 extern pgcnt_t kcage_lotsfree;
54 extern pgcnt_t kcage_desfree;
55 extern pgcnt_t kcage_minfree;
56 extern pgcnt_t kcage_throttlefree;
57 
58 extern void kcage_freemem_add(pgcnt_t);
59 extern void kcage_freemem_sub(pgcnt_t);
60 extern int kcage_create_throttle(pgcnt_t, int);
61 
62 /*
63  * Control direction of growth: 0: increasing pfns, 1: decreasing.
64  */
65 typedef enum {KCAGE_UP, KCAGE_DOWN} kcage_dir_t;
66 extern void kcage_range_init(struct memlist *, kcage_dir_t, pgcnt_t);
67 extern int kcage_range_add(pfn_t, pgcnt_t, kcage_dir_t);
68 
69 extern int kcage_current_pfn(pfn_t *);
70 extern int kcage_range_delete(pfn_t, pgcnt_t);
71 extern int kcage_range_delete_post_mem_del(pfn_t, pgcnt_t);
72 
73 extern void kcage_recalc_thresholds(void);
74 
75 /* Called from vm_pageout.c */
76 extern void kcage_cageout_init(void);
77 extern void kcage_cageout_wakeup(void);
78 
79 /* Called from clock thread in clock.c */
80 extern void kcage_tick(void);
81 
82 /* Called from vm_pagelist.c */
83 extern int kcage_next_range(int incage,
84     pfn_t lo, pfn_t hi, pfn_t *nlo, pfn_t *nhi);
85 
86 extern kcage_dir_t kcage_startup_dir;
87 
88 #endif /* _KERNEL */
89 
90 #ifdef	__cplusplus
91 }
92 #endif
93 
94 #endif	/* _SYS_MEM_CAGE_H */
95