[procps] feature request: hugepage support in ps tools

  • From: Dan Pritts <danno@xxxxxxxxx>
  • To: procps@xxxxxxxxxxxxx
  • Date: Mon, 02 Dec 2013 11:51:14 -0500

Hi folks,

Sorry for the spam, I really wasn't sure where to ask about this.

We're running several tomcat apps on an RHEL6 server.  We've
configured Java to use hugepages, which seems to work fine.

I have been unable to find any tools that account for how much
hugepage memory each java process is using.  The same problem
is there for KVM guests, I guess.

I poked around in /proc and found some info in each process's
numa_maps. for example:

7f6463800000 default file=/anon_hugepage\040(deleted) huge anon=2 dirty=2 N2=1 N3=1

I'm not entirely sure I've got everything correct, although my results are plausible.
However, it's quite fragile, numa_maps is not readable by normal users,
and it would sure be nice to have this in normal userland tools.



For the record and for anyone who happens across this in the archives,
here's the perl I came up with.

sub counthugepages {
    my $pid=$_[0];
    open (NUMAMAPS, "/proc/$pid/numa_maps") || die "can't open numa_maps";
    my $HUGEPAGECOUNT=0;
    while (my $line=<NUMAMAPS>) {
        next unless ($line =~ m{ huge }) ;
        next unless ($line =~ m{dirty=});
        chomp $line;
        $line =~ s{.*dirty=}{};
        $line =~ s{\s.*$}{};
        $HUGEPAGECOUNT+=$line;
    }
    close NUMAMAPS;
    # we want megabytes out, but we counted 2-megabyte hugepages
    return ($HUGEPAGECOUNT*2);
}

thanks
danno
--
Dan Pritts
ICPSR Computing & Network Services
University of Michigan
+1 (734)615-7362

Other related posts: