/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _LGRP_H
#define _LGRP_H
/*
* locality group definitions for kernel
*/
#ifdef __cplusplus
extern "C" {
#endif
#endif /* !_KERNEL && !_KMEMUSER */
#include <sys/lgrp_user.h>
/* null platform handle */
/*
* Maximum number of lgrps a platform may define.
*/
/*
* The load-average we expect for one cpu-bound thread's worth of load
*/
/*
* The input to the load-average generating function for one cpu-bound thread's
* worth of load
*/
/*
* LPL actions
*/
typedef enum {
} lpl_act_t;
/*
* lgroup statistics. Most of these are counters that are updated
* dynamically so they are hashed to CPU buckets to reduce cache
* interference. The remaining statistics are snapshots of kernel
* data, so they aren't stored in the array of counter stats.
*
* For the hashed stats to make sense, you have to sum all the buckets for
* that stat, hence macros are provided to read the stats.
*/
/*
* Flags for what to do with lgroup memory policy
* Used for heap and stack where policy is extended to new segments added to
* the end
*/
/* Return a pointer suitable for an atomic 64-bit op on the bucket */
/* Sum up all the buckets and return the value in 'val' */
int bkt; \
}
/* Reset all buckets for the stat to 0 */
int i; \
for (i = 0; i < LGRP_NUM_CPU_BUCKETS; i++) \
}
/*
* Define all of the statistics that are kept for lgrp kstats,
* and their corresponding text names.
*/
typedef enum lgrp_stat_types {
/* always keep >= LGRP_NUM_COUNTER_STATS */
} lgrp_stat_t;
typedef enum lgrp_snap_stat_types {
#define LGRP_KSTAT_NAMES \
static char *lgrp_kstat_names[] = { \
\
/* Counter stats */ \
"lwp migrations", \
"alloc fail", \
"pages migrated from", \
"pages migrated to", \
"pages failed to migrate to", \
"pages failed to migrate from", \
"pages marked for migration", \
"pages failed to mark", \
"default policy", \
"next-touch policy", \
"random policy", \
"span process policy", \
"span psrset policy", \
"round robin policy", \
"next-seg policy", \
\
/* Snapshot stats */ \
"cpus", \
"pages free", \
"pages avail", \
"pages installed", \
"load average", \
"loadscale" \
}
(int)LGRP_NUM_SNAPSHOT_STATS)
/*
* The contents of this structure are opaque and should only be
* accessed through the LGRP_STAT macro.
*/
struct lgrp_stats {
};
/* The kernel's version of a bitmap of lgroups */
/*
* This really belongs in memnode.h, but it must be defined here to avoid
* recursive inclusion problems. Note that memnode.h includes this header.
*/
/*
* lgroup structure
*
* Visible to generic code and contains the lgroup ID, CPUs in this lgroup,
* and a platform handle used to identify this lgroup to the lgroup platform
* support code
*/
typedef struct lgrp {
int lgrp_latency;
/*
* set of lgroups containing a given type of resource
* at this level of locality
*/
} lgrp_t;
/*
* lgroup load average structure
*/
typedef struct lgrp_ld {
/* NULL for non-leaf lgrps */
/* contains ptr to self for leaf lgrp */
} lpl_t;
/*
* 1 << LGRP_MAX_EFFECT_SHFT == lgrp_loadavg_max_effect
*/
/*
* Operations handled by lgrp_config()
*/
typedef enum lgrp_config_flag {
/*
* Stages of lgroup framework initialization (done through lgrp_init()):
*
* 1) Initialize common and platform specific code (called in mlsetup())
*
* 2) Setup root lgroup and add CPU 0 to lgroup(s) (called near beginning of
* main() before startup())
*
* 3) Probe from CPU 0 and copy and release any BOP_ALLOC-ed memory temporarily
* allocated before kernel memory allocator is setup (called in main()
* after startup(), gethrtime() is setup, and before interrupts enabled)
*
* 4) Check for null proc LPA on Starcat, collapse lgroup topology (if
* necessary), setup lgroup kstats, etc. (called before start_other_cpus())
*
* 5) Finish any lgroup initialization needed including updating lgroup
* topology after all CPUs started (called after start_other_cpus())
*/
typedef enum lgrp_init_stages {
/*
* Memory allocation policies
*/
typedef enum lgrp_mem_policy {
/*
* Search scopes for finding resouces
*/
typedef enum lgrp_res_ss {
/*
* Cookie used for lgrp mnode selection
*/
typedef struct lgrp_mnode_cookie {
/*
* Information needed to implement memory allocation policy
*/
typedef struct lgrp_mem_policy_info {
/*
* Shared memory policy segment
*/
typedef struct lgrp_shm_policy_seg {
/*
* Shared memory locality info
*/
typedef struct lgrp_shm_locality {
/*
* Queries that may be made to determine lgroup memory size
*/
typedef enum {
/*
* Argument for the memory copy-rename operation, contains the source and the
* destination platform handles.
*/
typedef struct lgrp_config_mem_rename {
/* Macro to clear an lgroup bitmap */
(klgrpset) = (klgrpset_t)0
/* Macro to fill an lgroup bitmap */
/* Macro to add an lgroup to an lgroup bitmap */
/* Macro to delete an lgroup from an lgroup bitmap */
/* Macro to copy a klgrpset into another klgrpset */
(klgrpset_to) = (klgrpset_from)
/* Macro to perform an 'and' operation on a pair of lgroup bitmaps */
(klgrpset_rslt) &= (klgrpset_arg)
/* Macro to perform an 'or' operation on a pair of lgroup bitmaps */
(klgrpset_rslt) |= (klgrpset_arg)
/* Macro to perform a 'diff' operation on a pair of lgroup bitmaps */
(klgrpset_rslt) &= ~(klgrpset_arg)
/* Macro to check if an lgroup is a member of an lgrpset */
/* Macro to check if an lgroup bitmap is empty */
((klgrpset) == (klgrpset_t)0)
/* Macro to check if two lgrpsets intersect */
/* Macro to count the number of members in an lgrpset */
{ \
count++; \
} \
}
/* Macro to get total memory size (in bytes) of a given set of lgroups */
{ \
\
lgrp_table[lgrpid]) { \
LGRP_MEM_SIZE_AVAIL) * PAGESIZE; \
} \
} \
}
/*
* Does this lgroup exist?
*/
/*
* Macro for testing if a CPU is contained in an lgrp.
*/
/*
* Initialize an lgrp_mnode_cookie
*/
{ \
bzero(&(c), sizeof (lgrp_mnode_cookie_t)); \
}
/*
* Upgrade cookie scope from LGRP_SRCH_LOCAL to LGRP_SRCH_HIER.
*/
#define LGRP_MNODE_COOKIE_UPGRADE(c) \
{ \
(&(c))->lmc_scope = LGRP_SRCH_HIER; \
}
/*
* Macro to see whether memory allocation policy can be reapplied
*/
#define LGRP_MEM_POLICY_REAPPLICABLE(p) \
(p == LGRP_MEM_POLICY_NEXT)
/*
* Return true if lgrp has CPU resources in the cpupart
*/
extern int lgrp_alloc_max;
extern int nlgrps; /* number of lgroups in machine */
extern int nlgrpsmax; /* max number of lgroups on platform */
extern int lgrp_initialized; /* single-CPU initialization done */
extern int lgrp_topo_initialized; /* lgrp topology constructed */
extern unsigned int lgrp_topo_levels;
/* generic interfaces */
/*
* lgroup management
*/
int lgrp_optimizations(void);
void lgrp_init(lgrp_init_stages_t);
lgrp_t *lgrp_create(void);
void lgrp_destroy(lgrp_t *);
/*
* lgroup stats
*/
void lgrp_kstat_create(struct cpu *);
void lgrp_kstat_destroy(struct cpu *);
/*
* lgroup memory
*/
size_t);
vnode_t *, u_offset_t);
/*
* Used by numat driver
*/
/*
* lgroup thread placement
*/
void lgrp_affinity_init(lgrp_affinity_t **);
void lgrp_affinity_free(lgrp_affinity_t **);
lgrp_t *lgrp_home_lgrp(void);
/*
* lgroup topology
*/
int lgrp_rsets_empty(klgrpset_t *);
int lgrp_topo_ht_limit(void);
int lgrp_topo_ht_limit_default(void);
int lgrp_topo_ht_limit_set(int);
/*
* lpl topology
*/
void lpl_topo_bootstrap(lpl_t *, int);
int lpl_topo_flatten(int);
int lpl_topo_verify(struct cpupart *);
/* platform interfaces */
void lgrp_plat_init(lgrp_init_stages_t);
int lgrp_plat_max_lgrps(void);
lgrp_handle_t lgrp_plat_root_hand(void);
extern uint32_t lgrp_expand_proc_thresh;
extern uint32_t lgrp_expand_proc_diff;
extern pgcnt_t lgrp_mem_free_thresh;
extern uint32_t lgrp_loadavg_tolerance;
extern uint32_t lgrp_loadavg_max_effect;
extern uint32_t lgrp_load_thresh;
#endif /* _KERNEL && _KMEMUSER */
#ifdef __cplusplus
}
#endif
#endif /* _LGRP_H */