Operating System - HP-UX
1838507 Members
2975 Online
110126 Solutions
New Discussion

Re: How to get instruction and Data cache sizes from command or APIs.

 
shivakumara
Occasional Advisor

How to get instruction and Data cache sizes from command or APIs.

Hi all,
To one of my application I wanted to get the size of instruction and Datacache. Can anyone help me out regarding to this?

-shivu
3 REPLIES 3
spex
Honored Contributor

Re: How to get instruction and Data cache sizes from command or APIs.

Shivu,

I'm not sure that I understand your question completely.

If 'nbuf' and 'bufpages' are both set to 0, you have a dynamic buffer cache, whose size is between 'dbc_min_pct' and 'dbc_max_pct'. 'kmtune -l' will list kernel params.

To get the current size of your OS buffer cache, enter 'glance -m' and look at 'Buf Cache'.

PCS
Ted Buis
Honored Contributor

Re: How to get instruction and Data cache sizes from command or APIs.

You may be able to see this initially from the dmesg file on more recent servers otherwise, there may be an option from the getconf or sysconf command. You can check the man pages at docs.hp.com. I didn't see it at a quick glance. In some cases you may be able to know this from the processor type and speed, but not always.
Mom 6
A. Clay Stephenson
Acclaimed Contributor

Re: How to get instruction and Data cache sizes from command or APIs.

No, this question has nothing to do with buffer cache; it's related to on-CPU or near CPU (L2,L3) very fast memory so that main memory does not have to be fetched.
By definition, any attempt to extract these data is going to be non-portable.

I can't imagine why anything other than an Assembler or an Optimizer would care (and even then the current machimne might not match the target machine) but here is one approach for HP-UX leveraging the STM commands. I assume that you have installed STM.

#!/usr/bin/sh

typeset DEV=""
typeset TDIR=${TMPDIR:-/var/tmp}
typeset T1=${TDIR}/X${$}_1.txt
typeset -i STAT=254

trap 'eval rm -f ${T1}' 0 1 2 15

export PATH=${PATH}:/usr/sbin

rm -f ${T1}
echo "map; wait " | cstm | \
awk '{if (($3 == "CPU") && ($0 ~ "Information Successful *$")) print $1}' |
while read DEV
do
echo "select device ${DEV}; info; wait; infolog; exit" | cstm >> ${T1}
done
if [[ -s "${T1}" ]]
then
grep -E -i "Data Cache|Instruction Cache" ${T1}
STAT=0
fi
exit ${STAT}

If it ain't broke, I can fix that.