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 29*d94ffb28Sjmcp #pragma ident "%Z%%M% %I% %E% SMI" 30*d94ffb28Sjmcp 317c478bd9Sstevel@tonic-gate #include <sys/types.h> 327c478bd9Sstevel@tonic-gate #include <sys/memlist.h> 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate /* 357c478bd9Sstevel@tonic-gate * Memory caging interfaces. 367c478bd9Sstevel@tonic-gate */ 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #ifdef __cplusplus 397c478bd9Sstevel@tonic-gate extern "C" { 407c478bd9Sstevel@tonic-gate #endif 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate #ifdef _KERNEL 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate #define KCT_FAILURE 0 457c478bd9Sstevel@tonic-gate #define KCT_CRIT 1 467c478bd9Sstevel@tonic-gate #define KCT_NONCRIT 2 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate extern int kernel_cage_enable; 497c478bd9Sstevel@tonic-gate extern int kcage_on; 507c478bd9Sstevel@tonic-gate extern kthread_id_t kcage_cageout_thread; 517c478bd9Sstevel@tonic-gate extern pgcnt_t kcage_freemem; 527c478bd9Sstevel@tonic-gate extern pgcnt_t kcage_needfree; 537c478bd9Sstevel@tonic-gate extern pgcnt_t kcage_lotsfree; 547c478bd9Sstevel@tonic-gate extern pgcnt_t kcage_desfree; 557c478bd9Sstevel@tonic-gate extern pgcnt_t kcage_minfree; 567c478bd9Sstevel@tonic-gate extern pgcnt_t kcage_throttlefree; 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate extern void kcage_freemem_add(pgcnt_t); 597c478bd9Sstevel@tonic-gate extern void kcage_freemem_sub(pgcnt_t); 607c478bd9Sstevel@tonic-gate extern int kcage_create_throttle(pgcnt_t, int); 617c478bd9Sstevel@tonic-gate 6285f58038Sdp78419 /* 6385f58038Sdp78419 * Control direction of growth: 0: increasing pfns, 1: decreasing. 6485f58038Sdp78419 */ 6585f58038Sdp78419 typedef enum {KCAGE_UP, KCAGE_DOWN} kcage_dir_t; 6685f58038Sdp78419 extern void kcage_range_init(struct memlist *, kcage_dir_t, pgcnt_t); 6785f58038Sdp78419 extern int kcage_range_add(pfn_t, pgcnt_t, kcage_dir_t); 6885f58038Sdp78419 697c478bd9Sstevel@tonic-gate extern int kcage_current_pfn(pfn_t *); 707c478bd9Sstevel@tonic-gate extern int kcage_range_delete(pfn_t, pgcnt_t); 717c478bd9Sstevel@tonic-gate extern int kcage_range_delete_post_mem_del(pfn_t, pgcnt_t); 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate extern void kcage_recalc_thresholds(void); 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate /* Called from vm_pageout.c */ 767c478bd9Sstevel@tonic-gate extern void kcage_cageout_init(void); 777c478bd9Sstevel@tonic-gate extern void kcage_cageout_wakeup(void); 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate /* Called from clock thread in clock.c */ 807c478bd9Sstevel@tonic-gate extern void kcage_tick(void); 817c478bd9Sstevel@tonic-gate 825d07b933Sdp78419 /* Called from vm_pagelist.c */ 835d07b933Sdp78419 extern int kcage_next_range(int incage, 845d07b933Sdp78419 pfn_t lo, pfn_t hi, pfn_t *nlo, pfn_t *nhi); 855d07b933Sdp78419 865832075cSsetje extern kcage_dir_t kcage_startup_dir; 875832075cSsetje 887c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate #ifdef __cplusplus 917c478bd9Sstevel@tonic-gate } 927c478bd9Sstevel@tonic-gate #endif 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate #endif /* _SYS_MEM_CAGE_H */ 95