lkml.org 
[lkml]   [2005]   [Feb]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: Getting the page size of currently running kernel
From
Date
    Scott> Is there any way to get a running kernel to tell you the
Scott> size of its pages? Why: I'm writing a quick Perl hack to
Scott> monitor the memory usage of the TCP stack over time. Easy
Scott> enough: /proc/net/sockstat gives the current value of
Scott> tcp_memory_allocated. But how do I convert this into
Scott> bytes? I don't want to hard code PAGE_SIZE into my Perl
Scott> script, complete with a lookup table for 4K vs. 8K
Scott> architectures! Am I missing something obvious here?

I'm not sure exactly how to call it from perl, but from C one can use
sysconf(3) like:

page_size = sysconf(_SC_PAGESIZE);

(one can also use getpagesize(2) to do exactly the same thing)

- R.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:10    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site