xref: /illumos-gate/usr/src/uts/common/sys/mem_cage.h (revision 2d6eb4a5)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
55d07b933Sdp78419  * Common Development and Distribution License (the "License").
65d07b933Sdp78419  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*d94ffb28Sjmcp  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*d94ffb28Sjmcp  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SYS_MEM_CAGE_H
277c478bd9Sstevel@tonic-gate #define	_SYS_MEM_CAGE_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #include <sys/types.h>
307c478bd9Sstevel@tonic-gate #include <sys/memlist.h>
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate /*
337c478bd9Sstevel@tonic-gate  * Memory caging interfaces.
347c478bd9Sstevel@tonic-gate  */
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
377c478bd9Sstevel@tonic-gate extern "C" {
387c478bd9Sstevel@tonic-gate #endif
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #ifdef _KERNEL
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #define	KCT_FAILURE	0
437c478bd9Sstevel@tonic-gate #define	KCT_CRIT	1
447c478bd9Sstevel@tonic-gate #define	KCT_NONCRIT	2
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate extern int kernel_cage_enable;
477c478bd9Sstevel@tonic-gate extern int kcage_on;
487c478bd9Sstevel@tonic-gate extern kthread_id_t kcage_cageout_thread;
497c478bd9Sstevel@tonic-gate extern pgcnt_t kcage_freemem;
507c478bd9Sstevel@tonic-gate extern pgcnt_t kcage_needfree;
517c478bd9Sstevel@tonic-gate extern pgcnt_t kcage_lotsfree;
527c478bd9Sstevel@tonic-gate extern pgcnt_t kcage_desfree;
537c478bd9Sstevel@tonic-gate extern pgcnt_t kcage_minfree;
547c478bd9Sstevel@tonic-gate extern pgcnt_t kcage_throttlefree;
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate extern void kcage_freemem_add(pgcnt_t);
577c478bd9Sstevel@tonic-gate extern void kcage_freemem_sub(pgcnt_t);
587c478bd9Sstevel@tonic-gate extern int kcage_create_throttle(pgcnt_t, int);
597c478bd9Sstevel@tonic-gate 
6085f58038Sdp78419 /*
6185f58038Sdp78419  * Control direction of growth: 0: increasing pfns, 1: decreasing.
6285f58038Sdp78419  */
6385f58038Sdp78419 typedef enum {KCAGE_UP, KCAGE_DOWN} kcage_dir_t;
6485f58038Sdp78419 extern void kcage_range_init(struct memlist *, kcage_dir_t, pgcnt_t);
6585f58038Sdp78419 extern int kcage_range_add(pfn_t, pgcnt_t, kcage_dir_t);
6685f58038Sdp78419 
677c478bd9Sstevel@tonic-gate extern int kcage_current_pfn(pfn_t *);
687c478bd9Sstevel@tonic-gate extern int kcage_range_delete(pfn_t, pgcnt_t);
697c478bd9Sstevel@tonic-gate extern int kcage_range_delete_post_mem_del(pfn_t, pgcnt_t);
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate extern void kcage_recalc_thresholds(void);
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate /* Called from vm_pageout.c */
747c478bd9Sstevel@tonic-gate extern void kcage_cageout_init(void);
757c478bd9Sstevel@tonic-gate extern void kcage_cageout_wakeup(void);
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate /* Called from clock thread in clock.c */
787c478bd9Sstevel@tonic-gate extern void kcage_tick(void);
797c478bd9Sstevel@tonic-gate 
805d07b933Sdp78419 /* Called from vm_pagelist.c */
815d07b933Sdp78419 extern int kcage_next_range(int incage,
825d07b933Sdp78419     pfn_t lo, pfn_t hi, pfn_t *nlo, pfn_t *nhi);
835d07b933Sdp78419 
845832075cSsetje extern kcage_dir_t kcage_startup_dir;
855832075cSsetje 
867c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
897c478bd9Sstevel@tonic-gate }
907c478bd9Sstevel@tonic-gate #endif
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate #endif	/* _SYS_MEM_CAGE_H */
93