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 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 23*ba3594baSGarrett D'Amore * Copyright 2014 Garrett D'Amore <garrett@damore.org> 24*ba3594baSGarrett D'Amore * 257c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 267c478bd9Sstevel@tonic-gate * Use is subject to license terms. 277c478bd9Sstevel@tonic-gate */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifndef _LGRP_USER_H 307c478bd9Sstevel@tonic-gate #define _LGRP_USER_H 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate /* 337c478bd9Sstevel@tonic-gate * latency group definitions for user 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 417c478bd9Sstevel@tonic-gate #include <sys/inttypes.h> 427c478bd9Sstevel@tonic-gate #include <sys/lgrp.h> 437c478bd9Sstevel@tonic-gate #include <sys/procset.h> 447c478bd9Sstevel@tonic-gate #include <sys/processor.h> 457c478bd9Sstevel@tonic-gate #include <sys/pset.h> 467c478bd9Sstevel@tonic-gate #include <sys/types.h> 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate /* 507c478bd9Sstevel@tonic-gate * lgroup interface version 517c478bd9Sstevel@tonic-gate */ 527c478bd9Sstevel@tonic-gate #define LGRP_VER_NONE 0 /* no lgroup interface version */ 537c478bd9Sstevel@tonic-gate #define LGRP_VER_CURRENT 2 /* current lgroup interface version */ 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate /* 577c478bd9Sstevel@tonic-gate * lgroup system call subcodes 587c478bd9Sstevel@tonic-gate */ 597c478bd9Sstevel@tonic-gate #define LGRP_SYS_MEMINFO 0 /* meminfo(2) aka MISYS_MEMINFO */ 607c478bd9Sstevel@tonic-gate #define LGRP_SYS_GENERATION 1 /* lgrp_generation() */ 617c478bd9Sstevel@tonic-gate #define LGRP_SYS_VERSION 2 /* lgrp_version() */ 627c478bd9Sstevel@tonic-gate #define LGRP_SYS_SNAPSHOT 3 /* lgrp_snapshot() */ 637c478bd9Sstevel@tonic-gate #define LGRP_SYS_AFFINITY_GET 4 /* lgrp_affinity_set() */ 647c478bd9Sstevel@tonic-gate #define LGRP_SYS_AFFINITY_SET 5 /* lgrp_affinity_get() */ 657c478bd9Sstevel@tonic-gate #define LGRP_SYS_LATENCY 6 /* lgrp_latency() */ 667c478bd9Sstevel@tonic-gate #define LGRP_SYS_HOME 7 /* lgrp_home() */ 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate /* 707c478bd9Sstevel@tonic-gate * lgroup resources 717c478bd9Sstevel@tonic-gate */ 727c478bd9Sstevel@tonic-gate #define LGRP_RSRC_COUNT 2 /* no. of resource types in lgroup */ 737c478bd9Sstevel@tonic-gate #define LGRP_RSRC_CPU 0 /* CPU resources */ 747c478bd9Sstevel@tonic-gate #define LGRP_RSRC_MEM 1 /* memory resources */ 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate typedef int lgrp_rsrc_t; 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate /* 817c478bd9Sstevel@tonic-gate * lgroup affinity 827c478bd9Sstevel@tonic-gate */ 837c478bd9Sstevel@tonic-gate #define LGRP_AFF_NONE 0x0 /* no affinity */ 847c478bd9Sstevel@tonic-gate #define LGRP_AFF_WEAK 0x10 /* weak affinity */ 857c478bd9Sstevel@tonic-gate #define LGRP_AFF_STRONG 0x100 /* strong affinity */ 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate typedef int lgrp_affinity_t; 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate /* 907c478bd9Sstevel@tonic-gate * Arguments to lgrp_affinity_{get,set}() 917c478bd9Sstevel@tonic-gate */ 927c478bd9Sstevel@tonic-gate typedef struct lgrp_affinity_args { 937c478bd9Sstevel@tonic-gate idtype_t idtype; /* ID type */ 947c478bd9Sstevel@tonic-gate id_t id; /* ID */ 957c478bd9Sstevel@tonic-gate lgrp_id_t lgrp; /* lgroup */ 967c478bd9Sstevel@tonic-gate lgrp_affinity_t aff; /* affinity */ 977c478bd9Sstevel@tonic-gate } lgrp_affinity_args_t; 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate /* 1017c478bd9Sstevel@tonic-gate * Flags to specify contents of lgroups desired 1027c478bd9Sstevel@tonic-gate */ 1037c478bd9Sstevel@tonic-gate typedef enum lgrp_content { 1047c478bd9Sstevel@tonic-gate LGRP_CONTENT_ALL, /* everything in lgroup */ 1057c478bd9Sstevel@tonic-gate /* everything in lgroup's hierarchy (for compatability) */ 1067c478bd9Sstevel@tonic-gate LGRP_CONTENT_HIERARCHY = LGRP_CONTENT_ALL, 1077c478bd9Sstevel@tonic-gate LGRP_CONTENT_DIRECT /* what's directly contained in lgroup */ 1087c478bd9Sstevel@tonic-gate } lgrp_content_t; 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate /* 1127c478bd9Sstevel@tonic-gate * Flags for lgrp_latency_cookie() specifying what hardware resources to get 1137c478bd9Sstevel@tonic-gate * latency between 1147c478bd9Sstevel@tonic-gate */ 1157c478bd9Sstevel@tonic-gate typedef enum lgrp_lat_between { 1167c478bd9Sstevel@tonic-gate LGRP_LAT_CPU_TO_MEM /* latency between CPU and memory */ 1177c478bd9Sstevel@tonic-gate } lgrp_lat_between_t; 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate /* 1217c478bd9Sstevel@tonic-gate * lgroup memory size type 1227c478bd9Sstevel@tonic-gate */ 1237c478bd9Sstevel@tonic-gate typedef longlong_t lgrp_mem_size_t; 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate /* 1277c478bd9Sstevel@tonic-gate * lgroup memory size flags 1287c478bd9Sstevel@tonic-gate */ 1297c478bd9Sstevel@tonic-gate typedef enum lgrp_mem_size_flag { 1307c478bd9Sstevel@tonic-gate LGRP_MEM_SZ_FREE, /* free memory */ 1317c478bd9Sstevel@tonic-gate LGRP_MEM_SZ_INSTALLED /* installed memory */ 1327c478bd9Sstevel@tonic-gate } lgrp_mem_size_flag_t; 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate /* 1367c478bd9Sstevel@tonic-gate * View of lgroups 1377c478bd9Sstevel@tonic-gate */ 1387c478bd9Sstevel@tonic-gate typedef enum lgrp_view { 1397c478bd9Sstevel@tonic-gate LGRP_VIEW_CALLER, /* what's available to the caller */ 1407c478bd9Sstevel@tonic-gate LGRP_VIEW_OS /* what's available to operating system */ 1417c478bd9Sstevel@tonic-gate } lgrp_view_t; 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate /* 1457c478bd9Sstevel@tonic-gate * lgroup information needed by user 1467c478bd9Sstevel@tonic-gate */ 1477c478bd9Sstevel@tonic-gate typedef struct lgrp_info { 1487c478bd9Sstevel@tonic-gate lgrp_id_t info_lgrpid; /* lgroup ID */ 1497c478bd9Sstevel@tonic-gate int info_latency; /* latency */ 1507c478bd9Sstevel@tonic-gate ulong_t *info_parents; /* parent lgroups */ 1517c478bd9Sstevel@tonic-gate ulong_t *info_children; /* children lgroups */ 1527c478bd9Sstevel@tonic-gate ulong_t *info_rset; /* lgroup resources */ 1537c478bd9Sstevel@tonic-gate pgcnt_t info_mem_free; /* free memory */ 1547c478bd9Sstevel@tonic-gate pgcnt_t info_mem_install; /* installed memory */ 1557c478bd9Sstevel@tonic-gate processorid_t *info_cpuids; /* CPU IDs */ 1567c478bd9Sstevel@tonic-gate int info_ncpus; /* number of CPUs */ 1577c478bd9Sstevel@tonic-gate } lgrp_info_t; 1587c478bd9Sstevel@tonic-gate 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate /* 1617c478bd9Sstevel@tonic-gate * Type of lgroup cookie to use with interface routines 1627c478bd9Sstevel@tonic-gate */ 1637c478bd9Sstevel@tonic-gate typedef uintptr_t lgrp_cookie_t; 1647c478bd9Sstevel@tonic-gate 1657c478bd9Sstevel@tonic-gate #define LGRP_COOKIE_NONE 0 /* no cookie */ 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate /* 1697c478bd9Sstevel@tonic-gate * Type of lgroup generation number 1707c478bd9Sstevel@tonic-gate */ 1717c478bd9Sstevel@tonic-gate typedef uint_t lgrp_gen_t; 1727c478bd9Sstevel@tonic-gate 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate /* 1757c478bd9Sstevel@tonic-gate * Format of lgroup hierarchy snapshot 1767c478bd9Sstevel@tonic-gate */ 1777c478bd9Sstevel@tonic-gate typedef struct lgrp_snapshot_header { 1787c478bd9Sstevel@tonic-gate int ss_version; /* lgroup interface version */ 1797c478bd9Sstevel@tonic-gate int ss_levels; /* levels of hierarchy */ 1807c478bd9Sstevel@tonic-gate int ss_nlgrps; /* number of lgroups */ 1817c478bd9Sstevel@tonic-gate int ss_nlgrps_os; /* number of lgroups (OS view) */ 1827c478bd9Sstevel@tonic-gate int ss_nlgrps_max; /* maximum number of lgroups */ 1837c478bd9Sstevel@tonic-gate int ss_root; /* root lgroup */ 1847c478bd9Sstevel@tonic-gate int ss_ncpus; /* total number of CPUs */ 1857c478bd9Sstevel@tonic-gate lgrp_view_t ss_view; /* view of lgroup hierarchy */ 1867c478bd9Sstevel@tonic-gate psetid_t ss_pset; /* caller's pset ID */ 1877c478bd9Sstevel@tonic-gate lgrp_gen_t ss_gen; /* snapshot generation ID */ 1887c478bd9Sstevel@tonic-gate size_t ss_size; /* total size of snapshot */ 1897c478bd9Sstevel@tonic-gate uintptr_t ss_magic; /* snapshot magic number */ 1907c478bd9Sstevel@tonic-gate lgrp_info_t *ss_info; /* lgroup info array */ 1917c478bd9Sstevel@tonic-gate processorid_t *ss_cpuids; /* lgroup CPU ID array */ 1927c478bd9Sstevel@tonic-gate ulong_t *ss_lgrpset; /* bit mask of available lgroups */ 1937c478bd9Sstevel@tonic-gate ulong_t *ss_parents; /* lgroup parent bit masks */ 1947c478bd9Sstevel@tonic-gate ulong_t *ss_children; /* lgroup children bit masks */ 1957c478bd9Sstevel@tonic-gate ulong_t *ss_rsets; /* lgroup resource set bit masks */ 1967c478bd9Sstevel@tonic-gate int **ss_latencies; /* latencies between lgroups */ 1977c478bd9Sstevel@tonic-gate } lgrp_snapshot_header_t; 1987c478bd9Sstevel@tonic-gate 1997c478bd9Sstevel@tonic-gate 2007c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32 2017c478bd9Sstevel@tonic-gate /* 2027c478bd9Sstevel@tonic-gate * lgroup information needed by 32-bit user 2037c478bd9Sstevel@tonic-gate */ 2047c478bd9Sstevel@tonic-gate typedef struct lgrp_info32 { 2057c478bd9Sstevel@tonic-gate int info_lgrpid; /* lgroup ID */ 2067c478bd9Sstevel@tonic-gate int info_latency; /* latency */ 2077c478bd9Sstevel@tonic-gate caddr32_t info_parents; /* parent lgroups */ 2087c478bd9Sstevel@tonic-gate caddr32_t info_children; /* children lgroups */ 2097c478bd9Sstevel@tonic-gate caddr32_t info_rset; /* lgroup resources */ 2107c478bd9Sstevel@tonic-gate uint32_t info_mem_free; /* free memory */ 2117c478bd9Sstevel@tonic-gate uint32_t info_mem_install; /* installed memory */ 2127c478bd9Sstevel@tonic-gate caddr32_t info_cpuids; /* CPU IDs */ 2137c478bd9Sstevel@tonic-gate int info_ncpus; /* number of CPUs */ 2147c478bd9Sstevel@tonic-gate } lgrp_info32_t; 2157c478bd9Sstevel@tonic-gate 2167c478bd9Sstevel@tonic-gate 2177c478bd9Sstevel@tonic-gate /* 2187c478bd9Sstevel@tonic-gate * Format of lgroup hierarchy snapshot for 32-bit programs 2197c478bd9Sstevel@tonic-gate */ 2207c478bd9Sstevel@tonic-gate typedef struct lgrp_snapshot_header32 { 2217c478bd9Sstevel@tonic-gate int ss_version; /* lgroup interface version */ 2227c478bd9Sstevel@tonic-gate int ss_levels; /* levels of hierarchy */ 2237c478bd9Sstevel@tonic-gate int ss_nlgrps; /* number of lgroups */ 2247c478bd9Sstevel@tonic-gate int ss_nlgrps_os; /* number of lgroups (OS view) */ 2257c478bd9Sstevel@tonic-gate int ss_nlgrps_max; /* maximum number of lgroups */ 2267c478bd9Sstevel@tonic-gate int ss_root; /* root lgroup */ 2277c478bd9Sstevel@tonic-gate int ss_ncpus; /* total number of CPUs */ 2287c478bd9Sstevel@tonic-gate int ss_view; /* view of lgroup hierarchy */ 2297c478bd9Sstevel@tonic-gate int ss_pset; /* caller's pset ID */ 2307c478bd9Sstevel@tonic-gate uint_t ss_gen; /* snapshot generation ID */ 2317c478bd9Sstevel@tonic-gate size32_t ss_size; /* total size of snapshot */ 2327c478bd9Sstevel@tonic-gate uint32_t ss_magic; /* snapshot magic number */ 2337c478bd9Sstevel@tonic-gate caddr32_t ss_info; /* lgroup info array */ 2347c478bd9Sstevel@tonic-gate caddr32_t ss_cpuids; /* lgroup CPU ID array */ 2357c478bd9Sstevel@tonic-gate caddr32_t ss_lgrpset; /* bit mask of available lgroups */ 2367c478bd9Sstevel@tonic-gate caddr32_t ss_parents; /* lgroup parent bit masks */ 2377c478bd9Sstevel@tonic-gate caddr32_t ss_children; /* lgroup children bit masks */ 2387c478bd9Sstevel@tonic-gate caddr32_t ss_rsets; /* lgroup resource set bit masks */ 2397c478bd9Sstevel@tonic-gate caddr32_t ss_latencies; /* latencies between lgroups */ 2407c478bd9Sstevel@tonic-gate } lgrp_snapshot_header32_t; 2417c478bd9Sstevel@tonic-gate 2427c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 2437c478bd9Sstevel@tonic-gate 2447c478bd9Sstevel@tonic-gate 2457c478bd9Sstevel@tonic-gate #if (!defined(_KERNEL) && !defined(_KMEMUSER)) 2467c478bd9Sstevel@tonic-gate 2477c478bd9Sstevel@tonic-gate lgrp_affinity_t lgrp_affinity_get(idtype_t idtype, id_t id, lgrp_id_t lgrp); 2487c478bd9Sstevel@tonic-gate 2497c478bd9Sstevel@tonic-gate int lgrp_affinity_set(idtype_t idtype, id_t id, lgrp_id_t lgrp, 2507c478bd9Sstevel@tonic-gate lgrp_affinity_t aff); 2517c478bd9Sstevel@tonic-gate 2527c478bd9Sstevel@tonic-gate int lgrp_children(lgrp_cookie_t cookie, lgrp_id_t lgrp, 2537c478bd9Sstevel@tonic-gate lgrp_id_t *children, uint_t count); 2547c478bd9Sstevel@tonic-gate 2557c478bd9Sstevel@tonic-gate int lgrp_cookie_stale(lgrp_cookie_t cookie); 2567c478bd9Sstevel@tonic-gate 2577c478bd9Sstevel@tonic-gate int lgrp_cpus(lgrp_cookie_t cookie, lgrp_id_t lgrp, 2587c478bd9Sstevel@tonic-gate processorid_t *cpuids, uint_t count, lgrp_content_t content); 2597c478bd9Sstevel@tonic-gate 2607c478bd9Sstevel@tonic-gate int lgrp_fini(lgrp_cookie_t cookie); 2617c478bd9Sstevel@tonic-gate 2627c478bd9Sstevel@tonic-gate int lgrp_latency(lgrp_id_t from, lgrp_id_t to); 2637c478bd9Sstevel@tonic-gate 2647c478bd9Sstevel@tonic-gate int lgrp_latency_cookie(lgrp_cookie_t cookie, lgrp_id_t from, 2657c478bd9Sstevel@tonic-gate lgrp_id_t to, lgrp_lat_between_t between); 2667c478bd9Sstevel@tonic-gate 2677c478bd9Sstevel@tonic-gate lgrp_id_t lgrp_home(idtype_t idtype, id_t id); 2687c478bd9Sstevel@tonic-gate 2697c478bd9Sstevel@tonic-gate lgrp_cookie_t lgrp_init(lgrp_view_t view); 2707c478bd9Sstevel@tonic-gate 2717c478bd9Sstevel@tonic-gate lgrp_mem_size_t lgrp_mem_size(lgrp_cookie_t cookie, lgrp_id_t lgrp, 2727c478bd9Sstevel@tonic-gate lgrp_mem_size_flag_t type, lgrp_content_t content); 2737c478bd9Sstevel@tonic-gate 2747c478bd9Sstevel@tonic-gate int lgrp_nlgrps(lgrp_cookie_t cookie); 2757c478bd9Sstevel@tonic-gate 2767c478bd9Sstevel@tonic-gate int lgrp_parents(lgrp_cookie_t cookie, lgrp_id_t lgrp, 2777c478bd9Sstevel@tonic-gate lgrp_id_t *parents, uint_t count); 2787c478bd9Sstevel@tonic-gate 2797c478bd9Sstevel@tonic-gate int lgrp_resources(lgrp_cookie_t cookie, lgrp_id_t lgrp, 2807c478bd9Sstevel@tonic-gate lgrp_id_t *lgrps, uint_t count, lgrp_rsrc_t type); 2817c478bd9Sstevel@tonic-gate 2827c478bd9Sstevel@tonic-gate lgrp_id_t lgrp_root(lgrp_cookie_t cookie); 2837c478bd9Sstevel@tonic-gate 2847c478bd9Sstevel@tonic-gate int lgrp_version(int version); 2857c478bd9Sstevel@tonic-gate 2867c478bd9Sstevel@tonic-gate lgrp_view_t lgrp_view(lgrp_cookie_t cookie); 2877c478bd9Sstevel@tonic-gate 2887c478bd9Sstevel@tonic-gate #endif /* !_KERNEL && !_KMEMUSER */ 2897c478bd9Sstevel@tonic-gate 2907c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2917c478bd9Sstevel@tonic-gate } 2927c478bd9Sstevel@tonic-gate #endif 2937c478bd9Sstevel@tonic-gate 2947c478bd9Sstevel@tonic-gate #endif /* _LGRP_USER_H */ 295