linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RE: Correctly determine amount of "free memory"
@ 2004-12-06 15:57 Gregory Giguashvili
  2004-12-06 16:10 ` bert hubert
  0 siblings, 1 reply; 8+ messages in thread
From: Gregory Giguashvili @ 2004-12-06 15:57 UTC (permalink / raw)
  To: bert hubert; +Cc: linux-kernel

> On the side, it would not hurt to study 'overcommit' and mlock(2). The
answer to your question is > not static unless care is taken. 
I'm using mlock(2), but the problem is that I need to allocate as much
memory as possible without causing swapping, so I need to have _rough_
estimate before actually allocating the memory.

Thanks,
Giga

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

* Re: Correctly determine amount of "free memory"
  2004-12-06 15:57 Correctly determine amount of "free memory" Gregory Giguashvili
@ 2004-12-06 16:10 ` bert hubert
  0 siblings, 0 replies; 8+ messages in thread
From: bert hubert @ 2004-12-06 16:10 UTC (permalink / raw)
  To: Gregory Giguashvili; +Cc: linux-kernel

On Mon, Dec 06, 2004 at 05:57:09PM +0200, Gregory Giguashvili wrote:

> I'm using mlock(2), but the problem is that I need to allocate as much
> memory as possible without causing swapping, so I need to have _rough_
> estimate before actually allocating the memory.

I think a guy called 'Ben' from google went over this a couple of years ago,
the discussion might still be relevant. His email address contained
'google.com' and he posted on lkml.

Too lazy to google for it now but this will point you in the right
direction.

-- 
http://www.PowerDNS.com      Open source, database driven DNS Software 
http://lartc.org           Linux Advanced Routing & Traffic Control HOWTO

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

* RE: Correctly determine amount of "free memory"
@ 2004-12-07 15:58 Gregory Giguashvili
  0 siblings, 0 replies; 8+ messages in thread
From: Gregory Giguashvili @ 2004-12-07 15:58 UTC (permalink / raw)
  To: linux-kernel

Experimenting with my simple memory allocation program for little more
time, I found that Free=MemTotal-Active gives kind of rough
approximation to the "free" memory amount. Can I make it somehow better?

What about SwapCached or Inact_target? Are there any pointers to the
information I might find useful on this subject other than
http://www.redhat.com/advice/tips/meminfo.html?

Thanks 
Giga
P.S. I need this to work with 2.4.19+ and 2.6 kernels...

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

* RE: Correctly determine amount of "free memory"
@ 2004-12-06 19:00 Gregory Giguashvili
  0 siblings, 0 replies; 8+ messages in thread
From: Gregory Giguashvili @ 2004-12-06 19:00 UTC (permalink / raw)
  To: linux-kernel

> That's not really a meaningful question. 
Sorry, I did my best :)

> The qualified answer is that /proc/meminfo gives you the available
information and what number 
> you want depends upon what you plan to do with it. Swapping is not
necessarily the right metric 
> for two reasons.
I plan to commit the largest chunk of memory in the quickest way. This
operation may be slowed down by swapping - that's why I don't want to
get there. If swapping is not the right metric, what is then? 

According to my humble experiments with 2.4 and 2.6 kernels, some cashed
memory reported in /proc/meminfo is reused and some is swapped. The real
problem here is that I couldn't find the right way to "predict" how much
cached memory will be discarded before starting to swap when system is
low on available RAM.

Thanks
Giga

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

* RE: Correctly determine amount of "free memory"
  2004-12-06 14:53 Gregory Giguashvili
  2004-12-06 15:16 ` bert hubert
@ 2004-12-06 18:26 ` David Schwartz
  1 sibling, 0 replies; 8+ messages in thread
From: David Schwartz @ 2004-12-06 18:26 UTC (permalink / raw)
  To: linux-kernel


> Assuming that I define "free memory" as maximum memory that can be
> allocated without causing swapping, is there a way I can give the best
> "free memory" amount estimate?

	That's not really a meaningful question. In fact, technically, no matter
how much memory you allocate you won't change the amount of swapping because
allocation has no affect on the working set size.

> I've tried to play with /proc/meminfo values with some progress, but I'd
> like to get a qualified answer from people working with VM bits and
> bytes.

	The qualified answer is that /proc/meminfo gives you the available
information and what number you want depends upon what you plan to do with
it. Swapping is not necessarily the right metric for two reasons. First, a
system might swap even though it's under a perfectly normal (or even low)
load. Second, there are bad memory situations a system can get in even if
it's not swapping, for example, a system with no buffer cache for file I/O
wouldn't be swapping, but it wouldn't perform well either.

	DS



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

* RE: Correctly determine amount of "free memory"
@ 2004-12-06 17:04 Gregory Giguashvili
  0 siblings, 0 replies; 8+ messages in thread
From: Gregory Giguashvili @ 2004-12-06 17:04 UTC (permalink / raw)
  To: bert hubert; +Cc: linux-kernel

> I think a guy called 'Ben' from google went over this a couple of
years ago, the discussion might 
> still be relevant. His email address contained 'google.com' and he
posted on lkml.

Is http://www.cs.helsinki.fi/linux/linux-kernel/2001-43/0661.html what
you mean? If so, it is about mlock problems in 2.4.9 kernels.
Unfortunatelly, they don't discuss available memory issue even though
it's mentioned a couple of times.

Thanks 
Giga

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

* Re: Correctly determine amount of "free memory"
  2004-12-06 14:53 Gregory Giguashvili
@ 2004-12-06 15:16 ` bert hubert
  2004-12-06 18:26 ` David Schwartz
  1 sibling, 0 replies; 8+ messages in thread
From: bert hubert @ 2004-12-06 15:16 UTC (permalink / raw)
  To: Gregory Giguashvili; +Cc: linux-kernel

On Mon, Dec 06, 2004 at 04:53:34PM +0200, Gregory Giguashvili wrote:
> Assuming that I define "free memory" as maximum memory that can be
> allocated without causing swapping, is there a way I can give the best
> "free memory" amount estimate?

On the side, it would not hurt to study 'overcommit' and mlock(2). The
answer to your question is not static unless care is taken.

-- 
http://www.PowerDNS.com      Open source, database driven DNS Software 
http://lartc.org           Linux Advanced Routing & Traffic Control HOWTO

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

* Correctly determine amount of "free memory"
@ 2004-12-06 14:53 Gregory Giguashvili
  2004-12-06 15:16 ` bert hubert
  2004-12-06 18:26 ` David Schwartz
  0 siblings, 2 replies; 8+ messages in thread
From: Gregory Giguashvili @ 2004-12-06 14:53 UTC (permalink / raw)
  To: linux-kernel

Hi,

Assuming that I define "free memory" as maximum memory that can be
allocated without causing swapping, is there a way I can give the best
"free memory" amount estimate?

I've tried to play with /proc/meminfo values with some progress, but I'd
like to get a qualified answer from people working with VM bits and
bytes.

Thanks a lot
Giga

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

end of thread, other threads:[~2004-12-07 16:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-06 15:57 Correctly determine amount of "free memory" Gregory Giguashvili
2004-12-06 16:10 ` bert hubert
  -- strict thread matches above, loose matches on Subject: below --
2004-12-07 15:58 Gregory Giguashvili
2004-12-06 19:00 Gregory Giguashvili
2004-12-06 17:04 Gregory Giguashvili
2004-12-06 14:53 Gregory Giguashvili
2004-12-06 15:16 ` bert hubert
2004-12-06 18:26 ` David Schwartz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).