mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Getting the page size of currently running kernel
@ 2005-02-20  3:01 Scott Bronson
  2005-02-20  3:22 ` Jan Knutar
  2005-02-20  3:28 ` Roland Dreier
  0 siblings, 2 replies; 4+ messages in thread
From: Scott Bronson @ 2005-02-20  3:01 UTC (permalink / raw)
  To: LKML

Is there any way to get a running kernel to tell you the size of its pages?

Why: I'm writing a quick Perl hack to monitor the memory usage of the TCP 
stack over time.  Easy enough: /proc/net/sockstat gives the current value of 
tcp_memory_allocated.  But how do I convert this into bytes?  I don't want to 
hard code PAGE_SIZE into my Perl script, complete with a lookup table for 4K 
vs. 8K architectures!  Am I missing something obvious here?

Thanks,

    - Scott


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Getting the page size of currently running kernel
  2005-02-20  3:01 Getting the page size of currently running kernel Scott Bronson
@ 2005-02-20  3:22 ` Jan Knutar
  2005-02-20  3:28 ` Roland Dreier
  1 sibling, 0 replies; 4+ messages in thread
From: Jan Knutar @ 2005-02-20  3:22 UTC (permalink / raw)
  To: Scott Bronson; +Cc: LKML

On Sunday 20 February 2005 05:01, Scott Bronson wrote:
> Is there any way to get a running kernel to tell you the size of its pages?
> 
> Why: I'm writing a quick Perl hack to monitor the memory usage of the TCP 
> stack over time.  Easy enough: /proc/net/sockstat gives the current value of 
> tcp_memory_allocated.  But how do I convert this into bytes?  I don't want to 
> hard code PAGE_SIZE into my Perl script, complete with a lookup table for 4K 
> vs. 8K architectures!  Am I missing something obvious here?

Can you call functions in glibc through perl?
If so, then getpagesize(2) is what you're looking for.
Can you do raw syscalls in perl, if so, you could get the same info that way.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Getting the page size of currently running kernel
  2005-02-20  3:01 Getting the page size of currently running kernel Scott Bronson
  2005-02-20  3:22 ` Jan Knutar
@ 2005-02-20  3:28 ` Roland Dreier
  2005-02-20  4:39   ` Scott Bronson
  1 sibling, 1 reply; 4+ messages in thread
From: Roland Dreier @ 2005-02-20  3:28 UTC (permalink / raw)
  To: Scott Bronson; +Cc: LKML

    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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Getting the page size of currently running kernel
  2005-02-20  3:28 ` Roland Dreier
@ 2005-02-20  4:39   ` Scott Bronson
  0 siblings, 0 replies; 4+ messages in thread
From: Scott Bronson @ 2005-02-20  4:39 UTC (permalink / raw)
  To: Roland Dreier; +Cc: LKML

On Saturday 19 February 2005 19:28, Roland Dreier wrote:
> 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)

And I was going nuts looking all over /proc and /sys for it.  :)  _SC_PAGESIZE 
is a part of Perl's POSIX module.  Thanks Roland and Jan.

    - Scott

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-02-20  4:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-20  3:01 Getting the page size of currently running kernel Scott Bronson
2005-02-20  3:22 ` Jan Knutar
2005-02-20  3:28 ` Roland Dreier
2005-02-20  4:39   ` Scott Bronson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®