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