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 5c6402783Sakolb * Common Development and Distribution License (the "License"). 6c6402783Sakolb * 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 */ 21c6402783Sakolb 227c478bd9Sstevel@tonic-gate /* 23*d5d7cf4eSJonathan Chew * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _LGRP_H 287c478bd9Sstevel@tonic-gate #define _LGRP_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate /* 317c478bd9Sstevel@tonic-gate * locality group definitions for kernel 327c478bd9Sstevel@tonic-gate */ 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #include <sys/types.h> 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #ifdef __cplusplus 377c478bd9Sstevel@tonic-gate extern "C" { 387c478bd9Sstevel@tonic-gate #endif 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #define LGRP_NONE (-1) /* non-existent lgroup ID */ 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate #if (!defined(_KERNEL) && !defined(_KMEMUSER)) 437c478bd9Sstevel@tonic-gate typedef struct lgrp_mem_policy_info { int opaque[2]; } lgrp_mem_policy_info_t; 447c478bd9Sstevel@tonic-gate #endif /* !_KERNEL && !_KMEMUSER */ 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate #if (defined(_KERNEL) || defined(_KMEMUSER)) 477c478bd9Sstevel@tonic-gate #include <sys/cpuvar.h> 487c478bd9Sstevel@tonic-gate #include <sys/bitmap.h> 497c478bd9Sstevel@tonic-gate #include <sys/vnode.h> 507c478bd9Sstevel@tonic-gate #include <vm/anon.h> 517c478bd9Sstevel@tonic-gate #include <vm/seg.h> 527c478bd9Sstevel@tonic-gate #include <sys/lgrp_user.h> 537c478bd9Sstevel@tonic-gate #include <sys/param.h> 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate typedef uint32_t lgrp_load_t; /* lgrp_loadavg type */ 567c478bd9Sstevel@tonic-gate typedef uintptr_t lgrp_handle_t; /* lgrp handle */ 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate #define LGRP_NONE_SUCH LGRP_NONE /* non-existent lgroup ID */ 597c478bd9Sstevel@tonic-gate /* null platform handle */ 607c478bd9Sstevel@tonic-gate #define LGRP_NULL_HANDLE ((lgrp_handle_t)0xbadbad) 617c478bd9Sstevel@tonic-gate #define LGRP_DEFAULT_HANDLE ((lgrp_handle_t)0xbabecafe) /* uma handle */ 627c478bd9Sstevel@tonic-gate #define LGRP_ROOTID (0) /* root lgroup ID */ 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate /* 657c478bd9Sstevel@tonic-gate * Maximum number of lgrps a platform may define. 667c478bd9Sstevel@tonic-gate */ 677c478bd9Sstevel@tonic-gate #define NLGRPS_MAX 64 687c478bd9Sstevel@tonic-gate #define LGRP_LOADAVG_MAX UINT32_MAX 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate /* 717c478bd9Sstevel@tonic-gate * The load-average we expect for one cpu-bound thread's worth of load 727c478bd9Sstevel@tonic-gate */ 737c478bd9Sstevel@tonic-gate #define LGRP_LOADAVG_THREAD_MAX 65516 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate /* 767c478bd9Sstevel@tonic-gate * The input to the load-average generating function for one cpu-bound thread's 777c478bd9Sstevel@tonic-gate * worth of load 787c478bd9Sstevel@tonic-gate */ 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate #define LGRP_LOADAVG_IN_THREAD_MAX 128 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate /* 837c478bd9Sstevel@tonic-gate * LPL actions 847c478bd9Sstevel@tonic-gate */ 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate typedef enum { 877c478bd9Sstevel@tonic-gate LPL_INCREMENT, 887c478bd9Sstevel@tonic-gate LPL_DECREMENT 897c478bd9Sstevel@tonic-gate } lpl_act_t; 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate /* 927c478bd9Sstevel@tonic-gate * lgroup statistics. Most of these are counters that are updated 937c478bd9Sstevel@tonic-gate * dynamically so they are hashed to CPU buckets to reduce cache 947c478bd9Sstevel@tonic-gate * interference. The remaining statistics are snapshots of kernel 957c478bd9Sstevel@tonic-gate * data, so they aren't stored in the array of counter stats. 967c478bd9Sstevel@tonic-gate * 977c478bd9Sstevel@tonic-gate * For the hashed stats to make sense, you have to sum all the buckets for 987c478bd9Sstevel@tonic-gate * that stat, hence macros are provided to read the stats. 997c478bd9Sstevel@tonic-gate */ 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate #define LGRP_NUM_CPU_BUCKETS 8 /* must be power of 2 */ 1027c478bd9Sstevel@tonic-gate #define LGRP_CPU_BUCKET_MASK (LGRP_NUM_CPU_BUCKETS - 1) 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate /* 1057c478bd9Sstevel@tonic-gate * Flags for what to do with lgroup memory policy 1067c478bd9Sstevel@tonic-gate * Used for heap and stack where policy is extended to new segments added to 1077c478bd9Sstevel@tonic-gate * the end 1087c478bd9Sstevel@tonic-gate */ 1097c478bd9Sstevel@tonic-gate #define LGRP_MP_FLAG_EXTEND_UP 0x1 /* policy should extend up */ 1107c478bd9Sstevel@tonic-gate #define LGRP_MP_FLAG_EXTEND_DOWN 0x2 /* policy should extend down */ 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate #define LGRP_STAT(stats, bucket, whichstat) \ 1137c478bd9Sstevel@tonic-gate ((stats)->ls_data[bucket][whichstat]) 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate /* Return a pointer suitable for an atomic 64-bit op on the bucket */ 1167c478bd9Sstevel@tonic-gate #define LGRP_STAT_WRITE_PTR(stats, whichstat) \ 1177c478bd9Sstevel@tonic-gate (&LGRP_STAT(stats, (CPU->cpu_id) & LGRP_CPU_BUCKET_MASK, \ 1187c478bd9Sstevel@tonic-gate whichstat)) 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate /* Sum up all the buckets and return the value in 'val' */ 1217c478bd9Sstevel@tonic-gate #define LGRP_STAT_READ(stats, whichstat, val) { \ 1227c478bd9Sstevel@tonic-gate int bkt; \ 1237c478bd9Sstevel@tonic-gate for (val = 0, bkt = 0; bkt < LGRP_NUM_CPU_BUCKETS; bkt++) \ 1247c478bd9Sstevel@tonic-gate val += LGRP_STAT(stats, bkt, whichstat); \ 1257c478bd9Sstevel@tonic-gate } 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate /* Reset all buckets for the stat to 0 */ 1287c478bd9Sstevel@tonic-gate #define LGRP_STAT_RESET(stats, stat) { \ 1297c478bd9Sstevel@tonic-gate int i; \ 1307c478bd9Sstevel@tonic-gate for (i = 0; i < LGRP_NUM_CPU_BUCKETS; i++) \ 1317c478bd9Sstevel@tonic-gate LGRP_STAT(stats, i, stat) = 0; \ 1327c478bd9Sstevel@tonic-gate } 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate /* 1357c478bd9Sstevel@tonic-gate * Define all of the statistics that are kept for lgrp kstats, 1367c478bd9Sstevel@tonic-gate * and their corresponding text names. 1377c478bd9Sstevel@tonic-gate */ 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate typedef enum lgrp_stat_types { 1407c478bd9Sstevel@tonic-gate LGRP_NUM_MIGR, /* # migrations away from this lgrp */ 1417c478bd9Sstevel@tonic-gate LGRP_NUM_ALLOC_FAIL, /* # times alloc fails for chosen lgrp */ 1427c478bd9Sstevel@tonic-gate LGRP_PM_SRC_PGS, /* # pages migrated from this lgrp */ 1437c478bd9Sstevel@tonic-gate LGRP_PM_DEST_PGS, /* # pages migrated to this lgrp */ 1447c478bd9Sstevel@tonic-gate LGRP_PM_FAIL_ALLOC_PGS, /* # pages failed to migrate to this lgrp */ 1457c478bd9Sstevel@tonic-gate LGRP_PM_FAIL_LOCK_PGS, /* # pages failed to migrate from this lgrp */ 1467c478bd9Sstevel@tonic-gate LGRP_PMM_PGS, /* # pages marked to migrate from this lgrp */ 1477c478bd9Sstevel@tonic-gate LGRP_PMM_FAIL_PGS, /* # pages marked to migrate from this lgrp */ 1487c478bd9Sstevel@tonic-gate LGRP_NUM_DEFAULT, /* # of times default policy applied */ 1497c478bd9Sstevel@tonic-gate LGRP_NUM_NEXT, /* # of times next touch policy applied */ 1507c478bd9Sstevel@tonic-gate LGRP_NUM_RANDOM, /* # of times random policy applied */ 1517c478bd9Sstevel@tonic-gate LGRP_NUM_RANDOM_PROC, /* # of times random proc policy applied */ 1527c478bd9Sstevel@tonic-gate LGRP_NUM_RANDOM_PSET, /* # of times random pset policy applied */ 1537c478bd9Sstevel@tonic-gate LGRP_NUM_ROUNDROBIN, /* # of times round robin policy applied */ 1542cb27123Saguzovsk LGRP_NUM_NEXT_SEG, /* # of times next to seg policy applied */ 1557c478bd9Sstevel@tonic-gate LGRP_NUM_COUNTER_STATS, /* always last */ 1567c478bd9Sstevel@tonic-gate LGRP_CTR_STATS_ALLOC = 16 /* cache-align pad - multiple of 8 */ 1577c478bd9Sstevel@tonic-gate /* always keep >= LGRP_NUM_COUNTER_STATS */ 1587c478bd9Sstevel@tonic-gate } lgrp_stat_t; 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate typedef enum lgrp_snap_stat_types { 1617c478bd9Sstevel@tonic-gate LGRP_NUM_CPUS, /* number of CPUs */ 1627c478bd9Sstevel@tonic-gate LGRP_NUM_PG_FREE, /* # of free pages */ 1637c478bd9Sstevel@tonic-gate LGRP_NUM_PG_AVAIL, /* # of allocatable physical pages */ 1647c478bd9Sstevel@tonic-gate LGRP_NUM_PG_INSTALL, /* # of installed physical pages */ 165c6402783Sakolb LGRP_LOADAVG, /* unscaled load average of this lgrp */ 166c6402783Sakolb LGRP_LOADAVG_SCALE, /* load unit of one CPU bound thread */ 1677c478bd9Sstevel@tonic-gate LGRP_NUM_SNAPSHOT_STATS /* always last */ 1687c478bd9Sstevel@tonic-gate } lgrp_snap_stat_t; 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate #define LGRP_KSTAT_NAMES \ 1717c478bd9Sstevel@tonic-gate static char *lgrp_kstat_names[] = { \ 1727c478bd9Sstevel@tonic-gate \ 1737c478bd9Sstevel@tonic-gate /* Counter stats */ \ 1747c478bd9Sstevel@tonic-gate "lwp migrations", \ 1757c478bd9Sstevel@tonic-gate "alloc fail", \ 1767c478bd9Sstevel@tonic-gate "pages migrated from", \ 1777c478bd9Sstevel@tonic-gate "pages migrated to", \ 1787c478bd9Sstevel@tonic-gate "pages failed to migrate to", \ 1797c478bd9Sstevel@tonic-gate "pages failed to migrate from", \ 1807c478bd9Sstevel@tonic-gate "pages marked for migration", \ 1817c478bd9Sstevel@tonic-gate "pages failed to mark", \ 1827c478bd9Sstevel@tonic-gate "default policy", \ 1837c478bd9Sstevel@tonic-gate "next-touch policy", \ 1847c478bd9Sstevel@tonic-gate "random policy", \ 1857c478bd9Sstevel@tonic-gate "span process policy", \ 1867c478bd9Sstevel@tonic-gate "span psrset policy", \ 1877c478bd9Sstevel@tonic-gate "round robin policy", \ 1882cb27123Saguzovsk "next-seg policy", \ 1897c478bd9Sstevel@tonic-gate \ 1907c478bd9Sstevel@tonic-gate /* Snapshot stats */ \ 1917c478bd9Sstevel@tonic-gate "cpus", \ 1927c478bd9Sstevel@tonic-gate "pages free", \ 1937c478bd9Sstevel@tonic-gate "pages avail", \ 1947c478bd9Sstevel@tonic-gate "pages installed", \ 195c6402783Sakolb "load average", \ 196c6402783Sakolb "loadscale" \ 1977c478bd9Sstevel@tonic-gate } 1987c478bd9Sstevel@tonic-gate 1997c478bd9Sstevel@tonic-gate #define LGRP_NUM_STATS ((int)LGRP_NUM_COUNTER_STATS + \ 2007c478bd9Sstevel@tonic-gate (int)LGRP_NUM_SNAPSHOT_STATS) 2017c478bd9Sstevel@tonic-gate 2027c478bd9Sstevel@tonic-gate /* 2037c478bd9Sstevel@tonic-gate * The contents of this structure are opaque and should only be 2047c478bd9Sstevel@tonic-gate * accessed through the LGRP_STAT macro. 2057c478bd9Sstevel@tonic-gate */ 2067c478bd9Sstevel@tonic-gate struct lgrp_stats { 2077c478bd9Sstevel@tonic-gate int64_t ls_data[LGRP_NUM_CPU_BUCKETS][LGRP_CTR_STATS_ALLOC]; 2087c478bd9Sstevel@tonic-gate }; 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate /* The kernel's version of a bitmap of lgroups */ 2117c478bd9Sstevel@tonic-gate typedef uint64_t klgrpset_t; 2127c478bd9Sstevel@tonic-gate 2137c478bd9Sstevel@tonic-gate /* 2147c478bd9Sstevel@tonic-gate * This really belongs in memnode.h, but it must be defined here to avoid 2157c478bd9Sstevel@tonic-gate * recursive inclusion problems. Note that memnode.h includes this header. 2167c478bd9Sstevel@tonic-gate */ 2177c478bd9Sstevel@tonic-gate typedef uint64_t mnodeset_t; 2187c478bd9Sstevel@tonic-gate 2197c478bd9Sstevel@tonic-gate /* 2207c478bd9Sstevel@tonic-gate * lgroup structure 2217c478bd9Sstevel@tonic-gate * 2227c478bd9Sstevel@tonic-gate * Visible to generic code and contains the lgroup ID, CPUs in this lgroup, 2237c478bd9Sstevel@tonic-gate * and a platform handle used to identify this lgroup to the lgroup platform 2247c478bd9Sstevel@tonic-gate * support code 2257c478bd9Sstevel@tonic-gate */ 2267c478bd9Sstevel@tonic-gate typedef struct lgrp { 2277c478bd9Sstevel@tonic-gate 2287c478bd9Sstevel@tonic-gate lgrp_id_t lgrp_id; /* which lgroup */ 2297c478bd9Sstevel@tonic-gate int lgrp_latency; 2307c478bd9Sstevel@tonic-gate lgrp_handle_t lgrp_plathand; /* handle for platform calls */ 2317c478bd9Sstevel@tonic-gate struct lgrp *lgrp_parent; /* parent lgroup */ 2327c478bd9Sstevel@tonic-gate uint_t lgrp_reserved1; /* filler */ 2337c478bd9Sstevel@tonic-gate uint_t lgrp_childcnt; /* number of children lgroups */ 2347c478bd9Sstevel@tonic-gate klgrpset_t lgrp_children; /* children lgroups */ 2357c478bd9Sstevel@tonic-gate klgrpset_t lgrp_leaves; /* (direct decendant) leaf lgroups */ 2367c478bd9Sstevel@tonic-gate 2377c478bd9Sstevel@tonic-gate /* 2387c478bd9Sstevel@tonic-gate * set of lgroups containing a given type of resource 2397c478bd9Sstevel@tonic-gate * at this level of locality 2407c478bd9Sstevel@tonic-gate */ 2417c478bd9Sstevel@tonic-gate klgrpset_t lgrp_set[LGRP_RSRC_COUNT]; 2427c478bd9Sstevel@tonic-gate 2437c478bd9Sstevel@tonic-gate mnodeset_t lgrp_mnodes; /* set of memory nodes in this lgroup */ 2447c478bd9Sstevel@tonic-gate uint_t lgrp_nmnodes; /* number of memnodes */ 2457c478bd9Sstevel@tonic-gate uint_t lgrp_reserved2; /* filler */ 2467c478bd9Sstevel@tonic-gate 2477c478bd9Sstevel@tonic-gate struct cpu *lgrp_cpu; /* pointer to a cpu may be null */ 2487c478bd9Sstevel@tonic-gate uint_t lgrp_cpucnt; /* number of cpus in this lgrp */ 2497c478bd9Sstevel@tonic-gate kstat_t *lgrp_kstat; /* per-lgrp kstats */ 2507c478bd9Sstevel@tonic-gate } lgrp_t; 2517c478bd9Sstevel@tonic-gate 2527c478bd9Sstevel@tonic-gate /* 2537c478bd9Sstevel@tonic-gate * lgroup load average structure 2547c478bd9Sstevel@tonic-gate */ 2557c478bd9Sstevel@tonic-gate 2567c478bd9Sstevel@tonic-gate typedef struct lgrp_ld { 2577c478bd9Sstevel@tonic-gate lgrp_load_t lpl_loadavg; /* load average */ 2587c478bd9Sstevel@tonic-gate uint_t lpl_ncpu; /* how many cpus */ 2597c478bd9Sstevel@tonic-gate lgrp_id_t lpl_lgrpid; /* which group this lpl part of */ 2607c478bd9Sstevel@tonic-gate lgrp_t *lpl_lgrp; /* ptr to lpl's lgrp */ 2617c478bd9Sstevel@tonic-gate struct lgrp_ld *lpl_parent; /* lpl of parent lgrp */ 2627c478bd9Sstevel@tonic-gate struct cpu *lpl_cpus; /* list of cpus in lpl */ 2637c478bd9Sstevel@tonic-gate /* NULL for non-leaf lgrps */ 2647c478bd9Sstevel@tonic-gate uint_t lpl_nrset; /* no. of leaf lpls for lgrp */ 2657c478bd9Sstevel@tonic-gate hrtime_t lpl_homed_time; /* time of last homing to this lpl */ 2666890d023SEric Saxe uint_t lpl_rset_sz; /* Resource set capacity */ 2676890d023SEric Saxe struct lgrp_ld **lpl_rset; /* leaf lpls for lgrp */ 2687c478bd9Sstevel@tonic-gate /* contains ptr to self for leaf lgrp */ 2696890d023SEric Saxe int *lpl_id2rset; /* mapping of lgrpid to rset index */ 2707c478bd9Sstevel@tonic-gate } lpl_t; 2717c478bd9Sstevel@tonic-gate 2727c478bd9Sstevel@tonic-gate /* 2737c478bd9Sstevel@tonic-gate * 1 << LGRP_MAX_EFFECT_SHFT == lgrp_loadavg_max_effect 2747c478bd9Sstevel@tonic-gate */ 2757c478bd9Sstevel@tonic-gate #define LGRP_MAX_EFFECT_SHFT 16 2767c478bd9Sstevel@tonic-gate 2777c478bd9Sstevel@tonic-gate /* 2787c478bd9Sstevel@tonic-gate * Operations handled by lgrp_config() 2797c478bd9Sstevel@tonic-gate */ 2807c478bd9Sstevel@tonic-gate typedef enum lgrp_config_flag { 2817c478bd9Sstevel@tonic-gate LGRP_CONFIG_NOP, 2827c478bd9Sstevel@tonic-gate LGRP_CONFIG_CPU_ADD, 2837c478bd9Sstevel@tonic-gate LGRP_CONFIG_CPU_DEL, 2847c478bd9Sstevel@tonic-gate LGRP_CONFIG_CPU_ONLINE, 2857c478bd9Sstevel@tonic-gate LGRP_CONFIG_CPU_OFFLINE, 2867c478bd9Sstevel@tonic-gate LGRP_CONFIG_CPUPART_ADD, 2877c478bd9Sstevel@tonic-gate LGRP_CONFIG_CPUPART_DEL, 2887c478bd9Sstevel@tonic-gate LGRP_CONFIG_MEM_ADD, 2897c478bd9Sstevel@tonic-gate LGRP_CONFIG_MEM_DEL, 2907c478bd9Sstevel@tonic-gate LGRP_CONFIG_MEM_RENAME, 2917c478bd9Sstevel@tonic-gate LGRP_CONFIG_GEN_UPDATE, 2927c478bd9Sstevel@tonic-gate LGRP_CONFIG_FLATTEN, 29303400a71Sjjc LGRP_CONFIG_LAT_CHANGE_ALL, 29403400a71Sjjc LGRP_CONFIG_LAT_CHANGE 2957c478bd9Sstevel@tonic-gate } lgrp_config_flag_t; 2967c478bd9Sstevel@tonic-gate 2977c478bd9Sstevel@tonic-gate /* 298*d5d7cf4eSJonathan Chew * Stages of lgroup framework initialization (done through lgrp_init()): 299*d5d7cf4eSJonathan Chew * 300*d5d7cf4eSJonathan Chew * 1) Initialize common and platform specific code (called in mlsetup()) 301*d5d7cf4eSJonathan Chew * 302*d5d7cf4eSJonathan Chew * 2) Setup root lgroup and add CPU 0 to lgroup(s) (called near beginning of 303*d5d7cf4eSJonathan Chew * main() before startup()) 304*d5d7cf4eSJonathan Chew * 305*d5d7cf4eSJonathan Chew * 3) Probe from CPU 0 and copy and release any BOP_ALLOC-ed memory temporarily 306*d5d7cf4eSJonathan Chew * allocated before kernel memory allocator is setup (called in main() 307*d5d7cf4eSJonathan Chew * after startup(), gethrtime() is setup, and before interrupts enabled) 308*d5d7cf4eSJonathan Chew * 309*d5d7cf4eSJonathan Chew * 4) Check for null proc LPA on Starcat, collapse lgroup topology (if 310*d5d7cf4eSJonathan Chew * necessary), setup lgroup kstats, etc. (called before start_other_cpus()) 311*d5d7cf4eSJonathan Chew * 312*d5d7cf4eSJonathan Chew * 5) Finish any lgroup initialization needed including updating lgroup 313*d5d7cf4eSJonathan Chew * topology after all CPUs started (called after start_other_cpus()) 314*d5d7cf4eSJonathan Chew */ 315*d5d7cf4eSJonathan Chew typedef enum lgrp_init_stages { 316*d5d7cf4eSJonathan Chew LGRP_INIT_STAGE1, 317*d5d7cf4eSJonathan Chew LGRP_INIT_STAGE2, 318*d5d7cf4eSJonathan Chew LGRP_INIT_STAGE3, 319*d5d7cf4eSJonathan Chew LGRP_INIT_STAGE4, 320*d5d7cf4eSJonathan Chew LGRP_INIT_STAGE5 321*d5d7cf4eSJonathan Chew } lgrp_init_stages_t; 322*d5d7cf4eSJonathan Chew 323*d5d7cf4eSJonathan Chew /* 3247c478bd9Sstevel@tonic-gate * Memory allocation policies 3257c478bd9Sstevel@tonic-gate */ 3267c478bd9Sstevel@tonic-gate typedef enum lgrp_mem_policy { 3277c478bd9Sstevel@tonic-gate LGRP_MEM_POLICY_DEFAULT, 3287c478bd9Sstevel@tonic-gate LGRP_MEM_POLICY_NEXT, /* near LWP to next touch */ 3297c478bd9Sstevel@tonic-gate LGRP_MEM_POLICY_RANDOM_PROC, /* randomly across process */ 3307c478bd9Sstevel@tonic-gate LGRP_MEM_POLICY_RANDOM_PSET, /* randomly across processor set */ 3317c478bd9Sstevel@tonic-gate LGRP_MEM_POLICY_RANDOM, /* randomly across all lgroups */ 3327c478bd9Sstevel@tonic-gate LGRP_MEM_POLICY_ROUNDROBIN, /* round robin across all lgroups */ 3337c478bd9Sstevel@tonic-gate LGRP_MEM_POLICY_NEXT_CPU, /* Near next CPU to touch memory */ 3342cb27123Saguzovsk LGRP_MEM_POLICY_NEXT_SEG, /* lgrp specified directly by seg */ 3357c478bd9Sstevel@tonic-gate LGRP_NUM_MEM_POLICIES 3367c478bd9Sstevel@tonic-gate } lgrp_mem_policy_t; 3377c478bd9Sstevel@tonic-gate 3387c478bd9Sstevel@tonic-gate /* 3397c478bd9Sstevel@tonic-gate * Search scopes for finding resouces 3407c478bd9Sstevel@tonic-gate */ 3417c478bd9Sstevel@tonic-gate typedef enum lgrp_res_ss { 3427c478bd9Sstevel@tonic-gate LGRP_SRCH_LOCAL, /* Search local lgroup only */ 3437c478bd9Sstevel@tonic-gate LGRP_SRCH_HIER /* Search entire hierarchy */ 3447c478bd9Sstevel@tonic-gate } lgrp_res_ss_t; 3457c478bd9Sstevel@tonic-gate 3467c478bd9Sstevel@tonic-gate /* 3477c478bd9Sstevel@tonic-gate * Cookie used for lgrp mnode selection 3487c478bd9Sstevel@tonic-gate */ 3497c478bd9Sstevel@tonic-gate typedef struct lgrp_mnode_cookie { 3507c478bd9Sstevel@tonic-gate lgrp_t *lmc_lgrp; /* lgrp under consideration */ 3517c478bd9Sstevel@tonic-gate mnodeset_t lmc_nodes; /* nodes not yet tried in lgrp */ 3527c478bd9Sstevel@tonic-gate int lmc_cnt; /* how many nodes in untried set */ 3537c478bd9Sstevel@tonic-gate mnodeset_t lmc_tried; /* nodes already tried */ 3547c478bd9Sstevel@tonic-gate int lmc_ntried; /* how many nodes in tried set */ 3557c478bd9Sstevel@tonic-gate lgrp_res_ss_t lmc_scope; /* consider non-local nodes? */ 3567c478bd9Sstevel@tonic-gate ushort_t lmc_rand; /* a "random" number */ 3577c478bd9Sstevel@tonic-gate } lgrp_mnode_cookie_t; 3587c478bd9Sstevel@tonic-gate 3597c478bd9Sstevel@tonic-gate /* 3607c478bd9Sstevel@tonic-gate * Information needed to implement memory allocation policy 3617c478bd9Sstevel@tonic-gate */ 3627c478bd9Sstevel@tonic-gate typedef struct lgrp_mem_policy_info { 3637c478bd9Sstevel@tonic-gate int mem_policy; /* memory allocation policy */ 3642cb27123Saguzovsk lgrp_id_t mem_lgrpid; /* lgroup id */ 3657c478bd9Sstevel@tonic-gate } lgrp_mem_policy_info_t; 3667c478bd9Sstevel@tonic-gate 3677c478bd9Sstevel@tonic-gate /* 3687c478bd9Sstevel@tonic-gate * Shared memory policy segment 3697c478bd9Sstevel@tonic-gate */ 3707c478bd9Sstevel@tonic-gate typedef struct lgrp_shm_policy_seg { 3717c478bd9Sstevel@tonic-gate u_offset_t shm_off; /* offset into shared object */ 3727c478bd9Sstevel@tonic-gate size_t shm_size; /* size of segment */ 3737c478bd9Sstevel@tonic-gate lgrp_mem_policy_info_t shm_policy; /* memory allocation policy */ 3747c478bd9Sstevel@tonic-gate avl_node_t shm_tree; /* AVL tree */ 3757c478bd9Sstevel@tonic-gate } lgrp_shm_policy_seg_t; 3767c478bd9Sstevel@tonic-gate 3777c478bd9Sstevel@tonic-gate /* 3787c478bd9Sstevel@tonic-gate * Shared memory locality info 3797c478bd9Sstevel@tonic-gate */ 3807c478bd9Sstevel@tonic-gate typedef struct lgrp_shm_locality { 3817c478bd9Sstevel@tonic-gate size_t loc_count; /* reference count */ 3827c478bd9Sstevel@tonic-gate avl_tree_t *loc_tree; /* policy segment tree */ 3837c478bd9Sstevel@tonic-gate krwlock_t loc_lock; /* protects tree */ 3847c478bd9Sstevel@tonic-gate } lgrp_shm_locality_t; 3857c478bd9Sstevel@tonic-gate 3867c478bd9Sstevel@tonic-gate /* 3877c478bd9Sstevel@tonic-gate * Queries that may be made to determine lgroup memory size 3887c478bd9Sstevel@tonic-gate */ 3897c478bd9Sstevel@tonic-gate typedef enum { 3907c478bd9Sstevel@tonic-gate LGRP_MEM_SIZE_FREE, /* number of free pages */ 3917c478bd9Sstevel@tonic-gate LGRP_MEM_SIZE_AVAIL, /* number of pages in phys_avail */ 3927c478bd9Sstevel@tonic-gate LGRP_MEM_SIZE_INSTALL /* number of pages in phys_install */ 3937c478bd9Sstevel@tonic-gate } lgrp_mem_query_t; 3947c478bd9Sstevel@tonic-gate 3957c478bd9Sstevel@tonic-gate /* 3967c478bd9Sstevel@tonic-gate * Argument for the memory copy-rename operation, contains the source and the 3977c478bd9Sstevel@tonic-gate * destination platform handles. 3987c478bd9Sstevel@tonic-gate */ 3997c478bd9Sstevel@tonic-gate typedef struct lgrp_config_mem_rename { 4007c478bd9Sstevel@tonic-gate lgrp_handle_t lmem_rename_from; 4017c478bd9Sstevel@tonic-gate lgrp_handle_t lmem_rename_to; 4027c478bd9Sstevel@tonic-gate } lgrp_config_mem_rename_t; 4037c478bd9Sstevel@tonic-gate 4047c478bd9Sstevel@tonic-gate /* Macro to clear an lgroup bitmap */ 4057c478bd9Sstevel@tonic-gate #define klgrpset_clear(klgrpset) \ 4067c478bd9Sstevel@tonic-gate (klgrpset) = (klgrpset_t)0 4077c478bd9Sstevel@tonic-gate 4087c478bd9Sstevel@tonic-gate /* Macro to fill an lgroup bitmap */ 4097c478bd9Sstevel@tonic-gate #define klgrpset_fill(klgrpset) \ 4107c478bd9Sstevel@tonic-gate (klgrpset) = (klgrpset_t)(-1) 4117c478bd9Sstevel@tonic-gate 4127c478bd9Sstevel@tonic-gate /* Macro to add an lgroup to an lgroup bitmap */ 4137c478bd9Sstevel@tonic-gate #define klgrpset_add(klgrpset, lgrpid) \ 4147c478bd9Sstevel@tonic-gate (klgrpset) |= ((klgrpset_t)1 << (lgrpid)) 4157c478bd9Sstevel@tonic-gate 4167c478bd9Sstevel@tonic-gate /* Macro to delete an lgroup from an lgroup bitmap */ 4177c478bd9Sstevel@tonic-gate #define klgrpset_del(klgrpset, lgrpid) \ 4187c478bd9Sstevel@tonic-gate (klgrpset) &= ~((klgrpset_t)1 << (lgrpid)) 4197c478bd9Sstevel@tonic-gate 4207c478bd9Sstevel@tonic-gate /* Macro to copy a klgrpset into another klgrpset */ 4217c478bd9Sstevel@tonic-gate #define klgrpset_copy(klgrpset_to, klgrpset_from) \ 4227c478bd9Sstevel@tonic-gate (klgrpset_to) = (klgrpset_from) 4237c478bd9Sstevel@tonic-gate 4247c478bd9Sstevel@tonic-gate /* Macro to perform an 'and' operation on a pair of lgroup bitmaps */ 4257c478bd9Sstevel@tonic-gate #define klgrpset_and(klgrpset_rslt, klgrpset_arg) \ 4267c478bd9Sstevel@tonic-gate (klgrpset_rslt) &= (klgrpset_arg) 4277c478bd9Sstevel@tonic-gate 4287c478bd9Sstevel@tonic-gate /* Macro to perform an 'or' operation on a pair of lgroup bitmaps */ 4297c478bd9Sstevel@tonic-gate #define klgrpset_or(klgrpset_rslt, klgrpset_arg) \ 4307c478bd9Sstevel@tonic-gate (klgrpset_rslt) |= (klgrpset_arg) 4317c478bd9Sstevel@tonic-gate 4327c478bd9Sstevel@tonic-gate /* Macro to perform a 'diff' operation on a pair of lgroup bitmaps */ 4337c478bd9Sstevel@tonic-gate #define klgrpset_diff(klgrpset_rslt, klgrpset_arg) \ 4347c478bd9Sstevel@tonic-gate (klgrpset_rslt) &= ~(klgrpset_arg) 4357c478bd9Sstevel@tonic-gate 4367c478bd9Sstevel@tonic-gate /* Macro to check if an lgroup is a member of an lgrpset */ 4377c478bd9Sstevel@tonic-gate #define klgrpset_ismember(klgrpset, lgrpid) \ 4387c478bd9Sstevel@tonic-gate ((klgrpset) & ((klgrpset_t)1 << (lgrpid))) 4397c478bd9Sstevel@tonic-gate 4407c478bd9Sstevel@tonic-gate /* Macro to check if an lgroup bitmap is empty */ 4417c478bd9Sstevel@tonic-gate #define klgrpset_isempty(klgrpset) \ 4427c478bd9Sstevel@tonic-gate ((klgrpset) == (klgrpset_t)0) 4437c478bd9Sstevel@tonic-gate 4447c478bd9Sstevel@tonic-gate /* Macro to check if two lgrpsets intersect */ 4457c478bd9Sstevel@tonic-gate #define klgrpset_intersects(klgrpset1, klgrpset2) \ 4467c478bd9Sstevel@tonic-gate ((klgrpset1) & (klgrpset2)) 4477c478bd9Sstevel@tonic-gate 4487c478bd9Sstevel@tonic-gate /* Macro to count the number of members in an lgrpset */ 4497c478bd9Sstevel@tonic-gate #define klgrpset_nlgrps(klgrpset, count) \ 4507c478bd9Sstevel@tonic-gate { \ 4517c478bd9Sstevel@tonic-gate lgrp_id_t lgrpid; \ 4527c478bd9Sstevel@tonic-gate for (lgrpid = 0, count = 0; lgrpid <= lgrp_alloc_max; lgrpid++) {\ 4537c478bd9Sstevel@tonic-gate if (klgrpset_ismember(klgrpset, lgrpid)) \ 4547c478bd9Sstevel@tonic-gate count++; \ 4557c478bd9Sstevel@tonic-gate } \ 4567c478bd9Sstevel@tonic-gate } 4577c478bd9Sstevel@tonic-gate 4587c478bd9Sstevel@tonic-gate /* Macro to get total memory size (in bytes) of a given set of lgroups */ 4597c478bd9Sstevel@tonic-gate #define klgrpset_totalsize(klgrpset, size) \ 4607c478bd9Sstevel@tonic-gate { \ 4617c478bd9Sstevel@tonic-gate lgrp_handle_t hand; \ 4627c478bd9Sstevel@tonic-gate lgrp_id_t lgrpid; \ 4637c478bd9Sstevel@tonic-gate \ 4647c478bd9Sstevel@tonic-gate for (lgrpid = 0, size = 0; lgrpid <= lgrp_alloc_max; lgrpid++) {\ 4657c478bd9Sstevel@tonic-gate if (klgrpset_ismember(klgrpset, lgrpid) && \ 4667c478bd9Sstevel@tonic-gate lgrp_table[lgrpid]) { \ 4677c478bd9Sstevel@tonic-gate hand = lgrp_table[lgrpid]->lgrp_plathand; \ 4687c478bd9Sstevel@tonic-gate size += lgrp_plat_mem_size(hand, \ 4697c478bd9Sstevel@tonic-gate LGRP_MEM_SIZE_AVAIL) * PAGESIZE; \ 4707c478bd9Sstevel@tonic-gate } \ 4717c478bd9Sstevel@tonic-gate } \ 4727c478bd9Sstevel@tonic-gate } 4737c478bd9Sstevel@tonic-gate 4747c478bd9Sstevel@tonic-gate /* 4757c478bd9Sstevel@tonic-gate * Does this lgroup exist? 4767c478bd9Sstevel@tonic-gate */ 4777c478bd9Sstevel@tonic-gate #define LGRP_EXISTS(lgrp) \ 4787c478bd9Sstevel@tonic-gate (lgrp != NULL && lgrp->lgrp_id != LGRP_NONE) 4797c478bd9Sstevel@tonic-gate 4807c478bd9Sstevel@tonic-gate /* 4816890d023SEric Saxe * Macro for testing if a CPU is contained in an lgrp. 4826890d023SEric Saxe */ 4836890d023SEric Saxe #define LGRP_CONTAINS_CPU(lgrp, cpu) \ 4846890d023SEric Saxe (klgrpset_ismember(lgrp->lgrp_set[LGRP_RSRC_CPU], \ 4856890d023SEric Saxe cpu->cpu_lpl->lpl_lgrpid)) 4866890d023SEric Saxe 4876890d023SEric Saxe /* 4887c478bd9Sstevel@tonic-gate * Initialize an lgrp_mnode_cookie 4897c478bd9Sstevel@tonic-gate */ 4907c478bd9Sstevel@tonic-gate #define LGRP_MNODE_COOKIE_INIT(c, lgrp, scope) \ 4917c478bd9Sstevel@tonic-gate { \ 4927c478bd9Sstevel@tonic-gate bzero(&(c), sizeof (lgrp_mnode_cookie_t)); \ 4937c478bd9Sstevel@tonic-gate (&(c))->lmc_lgrp = lgrp; \ 4947c478bd9Sstevel@tonic-gate (&(c))->lmc_nodes = lgrp->lgrp_mnodes; \ 4957c478bd9Sstevel@tonic-gate (&(c))->lmc_cnt = lgrp->lgrp_nmnodes; \ 4967c478bd9Sstevel@tonic-gate (&(c))->lmc_scope = scope; \ 4977c478bd9Sstevel@tonic-gate (&(c))->lmc_rand = (ushort_t)gethrtime_unscaled() >> 4; \ 4987c478bd9Sstevel@tonic-gate } 4997c478bd9Sstevel@tonic-gate 5007c478bd9Sstevel@tonic-gate /* 5017c478bd9Sstevel@tonic-gate * Upgrade cookie scope from LGRP_SRCH_LOCAL to LGRP_SRCH_HIER. 5027c478bd9Sstevel@tonic-gate */ 5037c478bd9Sstevel@tonic-gate #define LGRP_MNODE_COOKIE_UPGRADE(c) \ 5047c478bd9Sstevel@tonic-gate { \ 5057c478bd9Sstevel@tonic-gate ASSERT((&(c))->lmc_scope == LGRP_SRCH_LOCAL); \ 5067c478bd9Sstevel@tonic-gate (&(c))->lmc_scope = LGRP_SRCH_HIER; \ 5077c478bd9Sstevel@tonic-gate } 5087c478bd9Sstevel@tonic-gate 5097c478bd9Sstevel@tonic-gate /* 5107c478bd9Sstevel@tonic-gate * Macro to see whether memory allocation policy can be reapplied 5117c478bd9Sstevel@tonic-gate */ 5127c478bd9Sstevel@tonic-gate #define LGRP_MEM_POLICY_REAPPLICABLE(p) \ 5137c478bd9Sstevel@tonic-gate (p == LGRP_MEM_POLICY_NEXT) 5147c478bd9Sstevel@tonic-gate 5157c478bd9Sstevel@tonic-gate /* 5167c478bd9Sstevel@tonic-gate * Return true if lgrp has CPU resources in the cpupart 5177c478bd9Sstevel@tonic-gate */ 5187c478bd9Sstevel@tonic-gate #define LGRP_CPUS_IN_PART(lgrpid, cpupart) \ 5197c478bd9Sstevel@tonic-gate (cpupart->cp_lgrploads[lgrpid].lpl_ncpu > 0) 5207c478bd9Sstevel@tonic-gate 5217c478bd9Sstevel@tonic-gate extern int lgrp_alloc_max; 5227c478bd9Sstevel@tonic-gate extern lgrp_t *lgrp_table[NLGRPS_MAX]; /* indexed by lgrp_id */ 5237c478bd9Sstevel@tonic-gate extern int nlgrps; /* number of lgroups in machine */ 5247c478bd9Sstevel@tonic-gate extern int nlgrpsmax; /* max number of lgroups on platform */ 5257c478bd9Sstevel@tonic-gate extern lgrp_gen_t lgrp_gen; /* generation of lgroup hierarchy */ 5267c478bd9Sstevel@tonic-gate extern int lgrp_initialized; /* single-CPU initialization done */ 5277c478bd9Sstevel@tonic-gate extern int lgrp_topo_initialized; /* lgrp topology constructed */ 5287c478bd9Sstevel@tonic-gate extern lgrp_t *lgrp_root; /* root lgroup */ 5297c478bd9Sstevel@tonic-gate extern unsigned int lgrp_topo_levels; 5307c478bd9Sstevel@tonic-gate extern lpl_t *lpl_bootstrap; /* bootstrap lpl for non-active CPUs */ 5317c478bd9Sstevel@tonic-gate 5327c478bd9Sstevel@tonic-gate 5337c478bd9Sstevel@tonic-gate /* generic interfaces */ 5347c478bd9Sstevel@tonic-gate 5357c478bd9Sstevel@tonic-gate /* 5367c478bd9Sstevel@tonic-gate * lgroup management 5377c478bd9Sstevel@tonic-gate */ 5387c478bd9Sstevel@tonic-gate int lgrp_optimizations(void); 539*d5d7cf4eSJonathan Chew void lgrp_init(lgrp_init_stages_t); 5407c478bd9Sstevel@tonic-gate lgrp_t *lgrp_create(void); 5417c478bd9Sstevel@tonic-gate void lgrp_destroy(lgrp_t *); 5427c478bd9Sstevel@tonic-gate void lgrp_config(lgrp_config_flag_t, uintptr_t, uintptr_t); 5437c478bd9Sstevel@tonic-gate lgrp_t *lgrp_hand_to_lgrp(lgrp_handle_t); 5447c478bd9Sstevel@tonic-gate 5457c478bd9Sstevel@tonic-gate /* 5467c478bd9Sstevel@tonic-gate * lgroup stats 5477c478bd9Sstevel@tonic-gate */ 5487c478bd9Sstevel@tonic-gate void lgrp_kstat_create(struct cpu *); 5497c478bd9Sstevel@tonic-gate void lgrp_kstat_destroy(struct cpu *); 5507c478bd9Sstevel@tonic-gate void lgrp_stat_add(lgrp_id_t, lgrp_stat_t, int64_t); 5517c478bd9Sstevel@tonic-gate int64_t lgrp_stat_read(lgrp_id_t, lgrp_stat_t); 5527c478bd9Sstevel@tonic-gate 5537c478bd9Sstevel@tonic-gate /* 5547c478bd9Sstevel@tonic-gate * lgroup memory 5557c478bd9Sstevel@tonic-gate */ 5567c478bd9Sstevel@tonic-gate lgrp_mem_policy_t lgrp_madv_to_policy(uchar_t, size_t, int); 5577c478bd9Sstevel@tonic-gate pgcnt_t lgrp_mem_size(lgrp_id_t, lgrp_mem_query_t); 5587c478bd9Sstevel@tonic-gate lgrp_t *lgrp_mem_choose(struct seg *, caddr_t, size_t); 5597c478bd9Sstevel@tonic-gate int lgrp_memnode_choose(lgrp_mnode_cookie_t *); 5607c478bd9Sstevel@tonic-gate lgrp_mem_policy_t lgrp_mem_policy_default(size_t, int); 5617c478bd9Sstevel@tonic-gate int lgrp_mnode_update(klgrpset_t, klgrpset_t *); 5627c478bd9Sstevel@tonic-gate lgrp_t *lgrp_pfn_to_lgrp(pfn_t); 5637c478bd9Sstevel@tonic-gate lgrp_t *lgrp_phys_to_lgrp(u_longlong_t); /* used by numat driver */ 5647c478bd9Sstevel@tonic-gate int lgrp_privm_policy_set(lgrp_mem_policy_t, lgrp_mem_policy_info_t *, 5657c478bd9Sstevel@tonic-gate size_t); 5667c478bd9Sstevel@tonic-gate void lgrp_shm_policy_init(struct anon_map *, vnode_t *); 5677c478bd9Sstevel@tonic-gate void lgrp_shm_policy_fini(struct anon_map *, vnode_t *); 5687c478bd9Sstevel@tonic-gate lgrp_mem_policy_info_t *lgrp_shm_policy_get(struct anon_map *, ulong_t, 5697c478bd9Sstevel@tonic-gate vnode_t *, u_offset_t); 5707c478bd9Sstevel@tonic-gate int lgrp_shm_policy_set(lgrp_mem_policy_t, struct anon_map *, ulong_t, 5717c478bd9Sstevel@tonic-gate vnode_t *, u_offset_t, size_t); 5727c478bd9Sstevel@tonic-gate 5737c478bd9Sstevel@tonic-gate /* 5747c478bd9Sstevel@tonic-gate * Used by numat driver 5757c478bd9Sstevel@tonic-gate */ 5767c478bd9Sstevel@tonic-gate int lgrp_query_cpu(processorid_t, lgrp_id_t *); 5777c478bd9Sstevel@tonic-gate int lgrp_query_load(processorid_t, lgrp_load_t *); 5787c478bd9Sstevel@tonic-gate 5797c478bd9Sstevel@tonic-gate /* 5807c478bd9Sstevel@tonic-gate * lgroup thread placement 5817c478bd9Sstevel@tonic-gate */ 58203400a71Sjjc lpl_t *lgrp_affinity_best(kthread_t *, struct cpupart *, lgrp_id_t, 58303400a71Sjjc boolean_t); 5847c478bd9Sstevel@tonic-gate void lgrp_affinity_init(lgrp_affinity_t **); 5857c478bd9Sstevel@tonic-gate void lgrp_affinity_free(lgrp_affinity_t **); 5867c478bd9Sstevel@tonic-gate lpl_t *lgrp_choose(kthread_t *t, struct cpupart *); 5877c478bd9Sstevel@tonic-gate lgrp_t *lgrp_home_lgrp(void); 5887c478bd9Sstevel@tonic-gate lgrp_id_t lgrp_home_id(kthread_t *); 5897c478bd9Sstevel@tonic-gate void lgrp_loadavg(lpl_t *, uint_t, int); 5907c478bd9Sstevel@tonic-gate void lgrp_move_thread(kthread_t *, lpl_t *, int); 5912cb27123Saguzovsk uint64_t lgrp_get_trthr_migrations(void); 5922cb27123Saguzovsk void lgrp_update_trthr_migrations(uint64_t); 5937c478bd9Sstevel@tonic-gate 5947c478bd9Sstevel@tonic-gate /* 5957c478bd9Sstevel@tonic-gate * lgroup topology 5967c478bd9Sstevel@tonic-gate */ 5977c478bd9Sstevel@tonic-gate int lgrp_leaf_add(lgrp_t *, lgrp_t **, int, klgrpset_t *); 5987c478bd9Sstevel@tonic-gate int lgrp_leaf_delete(lgrp_t *, lgrp_t **, int, klgrpset_t *); 5997c478bd9Sstevel@tonic-gate int lgrp_rsets_empty(klgrpset_t *); 6007c478bd9Sstevel@tonic-gate int lgrp_rsets_member(klgrpset_t *, lgrp_id_t); 6017c478bd9Sstevel@tonic-gate int lgrp_topo_flatten(int, lgrp_t **, int, klgrpset_t *); 6027c478bd9Sstevel@tonic-gate int lgrp_topo_ht_limit(void); 6037c478bd9Sstevel@tonic-gate int lgrp_topo_ht_limit_default(void); 6047c478bd9Sstevel@tonic-gate int lgrp_topo_ht_limit_set(int); 6057c478bd9Sstevel@tonic-gate int lgrp_topo_update(lgrp_t **, int, klgrpset_t *); 6067c478bd9Sstevel@tonic-gate 6077c478bd9Sstevel@tonic-gate /* 6087c478bd9Sstevel@tonic-gate * lpl topology 6097c478bd9Sstevel@tonic-gate */ 6107c478bd9Sstevel@tonic-gate void lpl_topo_bootstrap(lpl_t *, int); 6117c478bd9Sstevel@tonic-gate int lpl_topo_flatten(int); 6127c478bd9Sstevel@tonic-gate int lpl_topo_verify(struct cpupart *); 6137c478bd9Sstevel@tonic-gate 6147c478bd9Sstevel@tonic-gate 6157c478bd9Sstevel@tonic-gate /* platform interfaces */ 616*d5d7cf4eSJonathan Chew void lgrp_plat_init(lgrp_init_stages_t); 6177c478bd9Sstevel@tonic-gate lgrp_t *lgrp_plat_alloc(lgrp_id_t lgrpid); 6187c478bd9Sstevel@tonic-gate void lgrp_plat_config(lgrp_config_flag_t, uintptr_t); 6197c478bd9Sstevel@tonic-gate lgrp_handle_t lgrp_plat_cpu_to_hand(processorid_t); 6207c478bd9Sstevel@tonic-gate lgrp_handle_t lgrp_plat_pfn_to_hand(pfn_t); 6217c478bd9Sstevel@tonic-gate int lgrp_plat_max_lgrps(void); 6227c478bd9Sstevel@tonic-gate pgcnt_t lgrp_plat_mem_size(lgrp_handle_t, lgrp_mem_query_t); 6237c478bd9Sstevel@tonic-gate int lgrp_plat_latency(lgrp_handle_t, lgrp_handle_t); 6247c478bd9Sstevel@tonic-gate lgrp_handle_t lgrp_plat_root_hand(void); 6257c478bd9Sstevel@tonic-gate 626ce8eb11aSdp78419 extern uint32_t lgrp_expand_proc_thresh; 627ce8eb11aSdp78419 extern uint32_t lgrp_expand_proc_diff; 628ce8eb11aSdp78419 extern pgcnt_t lgrp_mem_free_thresh; 629ce8eb11aSdp78419 extern uint32_t lgrp_loadavg_tolerance; 630ce8eb11aSdp78419 extern uint32_t lgrp_loadavg_max_effect; 631ce8eb11aSdp78419 extern uint32_t lgrp_load_thresh; 632ce8eb11aSdp78419 extern lgrp_mem_policy_t lgrp_mem_policy_root; 633ce8eb11aSdp78419 6347c478bd9Sstevel@tonic-gate #endif /* _KERNEL && _KMEMUSER */ 6357c478bd9Sstevel@tonic-gate 6367c478bd9Sstevel@tonic-gate #ifdef __cplusplus 6377c478bd9Sstevel@tonic-gate } 6387c478bd9Sstevel@tonic-gate #endif 6397c478bd9Sstevel@tonic-gate 6407c478bd9Sstevel@tonic-gate #endif /* _LGRP_H */ 641