fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
44c4f64b9f50f21ae3e51ad48a595c85f53db4bcJohn Levon * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This program is strictly for demonstration purposes and not for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * production use. It demonstrates how to access the dynamic memory
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * caching statistics and turning variables via the kstat library.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef enum {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print Usage
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("USAGE: wake - wakeup thread, hys - max hysteresis\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(" age1 n - num cyc to full host aging and "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "dealloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(" age2 n - num cyc to full meta aging and "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "dealloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(" age3 n - num cyc to full one pg aging and "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "dealloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(" pcnt1 n - percent to sec1/sec2 trans\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(" pcnt2 n - percent to sec2/sec3 trans\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(" hdpcnt n - max percent of cents for holds\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("No Args - print current settings only\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * grab and parse argument list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("pargs=%x - %s\n", (uint_t)pargs, *pargs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((p_dynmem_knp+DIRECTIVE)->newval == NO_VALUE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((p_dynmem_knp+DIRECTIVE)->newval == NO_VALUE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* while(*pargs && cl) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * open the kstat library
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is the name module about
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte info_ksp.ksp = kstat_lookup(kctl, SDBC_KSTAT_MODULE, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * using the info get a copy of the data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (kstat_read(kctl, info_ksp.ksp, NULL) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * print the current data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_data_lookup(info_ksp.ksp, p_dynmem_knp->named);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * modify the data and write it back
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p_dynmem_knp->knp->value.ul = p_dynmem_knp->newval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (kstat_write(kctl, info_ksp.ksp, NULL) == -1) {