fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
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#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
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#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteTITLE: Dynamic Memory Implementation Overview
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteDATE: 10/13/2000
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteAUTHOR: Jim Guerrera (james.guerrera@east)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte1.0 Dynamic Memory Implementation in the SCM Module
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe system memory allocation required by the Storage Cache Manager (SCM)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortehas been modified to more fully conform to the requirements of the Solaris
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteOS. The previous implementation required that the total memory requirements
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteof the package be allocated 'up front' during bootup and was never released.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe current implementation performs 'on demand' allocations at the time
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortememory is required in a piecemeal manner. In addition the requisitioned
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortememory will be released back to the system at some later time.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte2.0 Implementation
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte2.1 Memory Allocation
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe memory allocation involves modifications primarily to sd_alloc_buf()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortein module sd_bcache.c. When a request is received for cache and system
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteresources it is broken down and each piece catagorized both as an
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteindependent entity and as a member of a group with close neighbors. Cache
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteresources comprise cache control entries (ccent), write control entries
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte(wctrl for FWC support) and sytem memory. The current allocation algorithim
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefor ccent and wrctl remains the same. The memory allocation has been modified
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteand falls into two general catagories - single page and multi-page
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteallocations.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte2.1.1 A single page allocation means exactly that - the ccent points to and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteowns one page of system memory. If two or more ccent are requisitioned to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesupport the caching request then only the first entry in the group actually
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteowns the the allocated memory of two or more pages. The secondary entries
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesimply point to page boundaries within this larger piece of contiguous memory.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe first entry is termed a host and the secondaries are termed parasites.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe process for determining what is a host, a parasite or anything else is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedone in three phases. Phase one simply determines whether the caching request
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortereferences a disk area already in cache and marks it as such. If it is not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortein cache it is typed as eligible - i.e. needing memory allocation. Phase
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetwo scans this list of typed cache entries and based on immediate neighbors
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteis catagorized as host, pest or downgraded to other. A host can only exist
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteif there is one or more eligible entries immediately following it and it
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteitself either starts the list or immediately follows a non-eligible entry.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIf either condition proves false the catagory remains as eligible (i.e.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteneeds memory allocation) but the type is cleared to not host (i.e. other).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe next phase is simply a matter of scanning the cache entry list and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteallocating multipage memory for hosts, single page entries for others or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesimply setting up pointers in the parasitic entries into it's corresponding
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortehost multipage memory allocation block.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte2.1.2 The maximum number of parasitic entries following a host memory
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteallocation is adjustable by the system administrator. The details of this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteare under the description of the KSTAT interface (Sec 3.0).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte2.2 Memory Deallocation
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMemory deallocation is implemented in sd_dealloc_dm() in module sd_io.c.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThis possibly overly complicated routine works as follows:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIn general the routine sleeps a specified amount of time then wakes and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteexamines the entire centry list. If an entry is available (i.e. not in use
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteby another thread and has memory which may be deallocated) it takes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepossession and ages the centry by one tick. It then determines if the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecentry has aged sufficiently to have its memory deallocated and for it to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortebe placed at the top of the lru.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte2.3 There are two general deallocation schemes in place depending on
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortewhether the centry is a single page allocation centry or it is a member
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteof a host/parasite multipage allocation chain.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte2.3.1 The behavior for a single page allocation centry is as follows:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIf the given centry is selected as a 'holdover' it will age normally
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortehowever at full aging it will only be placed at the head of the lru.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIt's memory will not be deallocated until a further aging level has
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortebeen reached. The entries selected for this behavior are governed by
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecounting the number of these holdovers in existence on each wakeup
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteand comparing it to a specified percentage. This comparision is always
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteone cycle out of date and will float in the relative vicinity of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortespecified number.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIn addition there is a placeholder for centries identified as 'sticky
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortemeta-data' with its own aging counter. It operates exactly as the holdover
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteentries as regards to aging but is absolute - i.e. no percentage governs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortethe number of such entries.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte2.3.2 The percentage and additional aging count are adjustable by the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesystem administrator. The details of this are under the description of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortethe KSTAT interface (Sec. 3.0).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte2.3.3 The behavior for a host/parasite chain is as follows:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe host/parasite subchain is examined. If all entries are fully aged the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteentire chain is removed - i.e memory is deallocated from the host centry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteand all centry fields are cleared and each entry requeued on to the lru.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThere are three sleep times and two percentage levels specifiable by the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesystem administrator. A meaningful relationship between these variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteis:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesleeptime1 >= sleeptime2 >= sleeptime2 and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte100% >= pcntfree1 >= pcntfree2 >= 0%
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesleeptime1 is honored between 100% free and pcntfree1. sleeptime2 is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortehonored between pcntfree1 and pcntfree2. sleeptime3 is honored between
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepcntfree2 and 0% free. The general thrust here is to automatically
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteadjust sleep time to centry load.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIn addition there exist an accelerated aging flag which mimics hysterisis
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortebehavior. If the available centrys fall between pcntfree1 and pcntfree2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortean 8 bit counter is switched on. The effect is to keep the timer value
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteat sleeptime2 for 8 cycles even if the number available cache entries
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedrifts above pcntfree1. If it falls below pcntfree2 an additional 8 bit
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecounter is switched on. This causes the sleep timer to remain at sleeptime3
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefor at least 8 cycles even if it floats above pcntfree2 or even pcntfree1.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe overall effect of this is to accelerate the release of system resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteunder what the thread thinks is a heavy load as measured by the number of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteused cache entries.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte3.0 Dynamic Memory Tuning
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteA number of behavior modification variables are accessible via system calls
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteto the kstat library. A sample program exercising the various features can
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortebe found in ./src/cmd/ns/sdbc/sdbc_dynmem.c. In addition the behavior variable
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteidentifiers can be placed in the sdbc.conf file and will take effect on bootup.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThere is also a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortenumber of dynamic memory statistics available to gauge its current state.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte3.1 Behavior Variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_monitor_dynmem --- D0=monitor thread shutdown in the console window
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte D1=print deallocation thread stats to the console
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte window
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte D2=print more deallocation thread stats to the console
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte window
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (usage: setting a value of 6 = 2+4 sets D1 and D2)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_max_dyn_list ----- 1 to ?: sets the maximum host/parasite list length
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (A length of 1 prevents any multipage allocations from
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte occuring and effectively removes the concept of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte host/parasite.)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_cache_aging_ct1 -- 1 to 255: fully aged count (everything but meta and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte holdover)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_cache_aging_ct2 -- 1 to 255: fully aged count for meta-data entries
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_cache_aging_ct3 -- 1 to 255: fully aged count for holdovers
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_cache_aging_sec1 - 1 to 255: sleep level 1 for 100% to pcnt1 free cache
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entries
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_cache_aging_sec2 - 1 to 255: sleep level 2 for pcnt1 to pcnt2 free cache
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entries
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_cache_aging_sec3 - 1 to 255: sleep level 3 for pcnt2 to 0% free cache
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entries
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_cache_aging_pcnt1- 0 to 100: cache free percent for transition from
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sleep1 to sleep2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_cache_aging_pcnt2- 0 to 100: cache free percent for transition from
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sleep2 to sleep3
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_max_holds_pcnt --- 0 to 100: max percent of cache entries to be maintained
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte as holdovers
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte3.2 Statistical Variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteCache Stats (per wake cycle) (r/w):
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_alloc_ct --------- total allocations performed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_dealloc_ct ------- total deallocations performed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_history ---------- current hysterisis flag setting
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_nodatas ---------- cache entries w/o memory assigned
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_candidates ------- cache entries ready to be aged or released
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_deallocs --------- cache entries w/memory deallocated and requeued
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_hosts ------------ number of host cache entries
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_pests ------------ number of parasitic cache entries
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_metas ------------ number of meta-data cache entries
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_holds ------------ number of holdovers (fully aged w/memory and requeued)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_others ----------- number of not [host, pests or metas]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_notavail --------- number of cache entries to bypass (nodatas+'in use by
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte other processes')
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_process_directive- D0=1 wake thread
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte D1=1 temporaily accelerate aging (set the hysterisis
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_simplect --------- simple count of the number of times the kstat update
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte routine has been called
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte3.3 Range Checks and Limits
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteOnly range limits are checked. Internal inconsistencies are not checked
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte(e.g. pcnt2 > pcnt1). Inconsistencies won't break the system you just won't
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget meaningful behavior.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe aging counter and sleep timer limits are arbitrarily limited to a byte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortewide counter. This can be expanded. However max'ing the values under the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecurrent implementation yields about 18 hours for full aging.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte3.4 Kstat Lookup Name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe kstat_lookup() module name is "sdbc:dynmem" with an instance of 0.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte3.5 Defaults
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteDefault values are:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_max_dyn_list = 8
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_monitor_dynmem = 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_cache_aging_ct1 = 3
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_cache_aging_ct2 = 3
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_cache_aging_ct3 = 3
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_cache_aging_sec1 = 10
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_cache_aging_sec2 = 5
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_cache_aging_sec3 = 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_cache_aging_pcnt1 = 50
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_cache_aging_pcnt2 = 25
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_max_holds_pcnt = 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteTo make the dynmem act for all intents and purposes like the static model
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortebeyond the inital startup the appropriate values are:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_max_dyn_list = 1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_cache_aging_ct1/2/3=255,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_cache_aging_sec1/2/3=255
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe remaining variables are irrelevant.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte4.0 KSTAT Implementation for Existing Statistics
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe existing cache statistical reporting mechanism has been replaced by
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortethe kstat library reporting mechanism. In general the statistics fall into
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetwo general catagories - global and shared. The global stats reflect gross
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortebehavior over all cached volumes and shared reflects behavior particular
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteto each cached volume.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte4.1 Global KSTAT lookup_name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe kstat_lookup() module name is "sdbc:gstats" with an instance of 0. The
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteidentifying ascii strings and associated values matching the sd_stats driver
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestructure are:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_dirty -------- net_dirty
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_pending ------ net_pending
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_free --------- net_free
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_count -------- st_count - number of opens for device
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_loc_count ---- st_loc_count - number of open devices
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_rdhits ------- st_rdhits - number of read hits
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_rdmiss ------- st_rdmiss - number of read misses
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_wrhits ------- st_wrhits - number of write hits
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_wrmiss ------- st_wrmiss - number of write misses
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_blksize ------ st_blksize - cache block size
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_num_memsize -- SD_MAX_MEM - number of defined blocks
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (currently 6)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteTo find the size of each memory blocks append the numbers 0 to 5 to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte'sdbc_memsize'.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_memsize0 ----- local memory
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_memsize1 ----- cache memory
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_memsize2 ----- iobuf memory
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_memsize3 ----- hash memory
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_memsize4 ----- global memory
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_memsize5 ----- stats memory
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_total_cmem --- st_total_cmem - memory used by cache structs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_total_smem --- st_total_smem - memory used by stat structs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_lru_blocks --- st_lru_blocks
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_lru_noreq ---- st_lru_noreq
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_lru_req ------ st_lru_req
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_num_wlru_inq - MAX_CACHE_NET - number of net (currently 4)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteTo find the size of the least recently used write cache per net append
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortethe numbers 0-3 to sdbc_wlru_inq
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_wlru_inq0 ---- net 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_wlru_inq1 ---- net 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_wlru_inq2 ---- net 2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_wlru_inq3 ---- net 3
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_cachesize ---- st_cachesize - cache size
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_numblocks ---- st_numblocks - cache blocks
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_num_shared --- MAXFILES*2 - number of shared structures (one for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte each cached volume)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte This number dictates the maximum
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index size for shared stats and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte names given below.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_simplect ----- simple count of the number of times the kstat update routine
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte has been called
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteAll fields are read only.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte4.2 Shared Structures KSTAT lookup_name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe kstat_lookup() module name is "sdbc:shstats" and "sdbc:shname" both with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortean instance of 0. The identifying ascii strings and associated values matching
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortethe sd_shared driver structure are:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc:shstats module
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_index ------- structure index number
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_alloc ------- sh_alloc - is this allocated?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_failed ------ sh_failed - Disk failure status (0=ok,1= /o error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ,2= open failed)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_cd ---------- sh_cd - the cache descriptor. (for stats)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_cache_read -- sh_cache_read - Number of bytes read from cache
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_cache_write - sh_cache_write - Number of bytes written to cache
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_disk_read --- sh_disk_read - Number of bytes read from disk
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_disk_write -- sh_disk_write - Number of bytes written to disk
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_filesize ---- sh_filesize - Filesize
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_numdirty ---- sh_numdirty - Number of dirty blocks
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_numio ------- sh_numio - Number of blocks on way to disk
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_numfail ----- sh_numfail - Number of blocks failed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_flushloop --- sh_flushloop - Loops delayed so far
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_flag -------- sh_flag - Flags visible to user programs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_simplect ---- simple count of the number of times the kstat update routine
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte has been called
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc:shname module
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteread in as raw bytes and interpreted as a nul terminated assci string.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThese two modules operate hand in hand based on information obtained from the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte"sdbc:gstats" module. "sdbc:gstats - sdbc_num_shared" gives the maximum number
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepossible of shared devices. It does not tell how many devices are actually
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecached - just the maximum possible. In order to determine the number present
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteand retrieve the statistics for each device the user must:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte1. open and read "sdbc:shstats"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte2. set the index "sdbc_index" to a starting value (presumably 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte3. write the kstat module ( the only item in the module is sdbc_index)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteWhat this does is set a starting index for all subsequent reads.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte4. to get the device count and associated statistics the user now simply
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortereads each module "sdbc:shstats" and "sdbc:shname" as a group repeatedly -
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortethe index will auto increment
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteTo reset the index set "sdbc:shstats - sdbc_index" to the required value
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteand write the module.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe first entry returning a nul string to "sdbc:shname" signifies no more
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconfigured devices.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte