mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kyle Moffett <mrmacman_g4@mac.com>
To: Ram Gupta <ram.gupta5@gmail.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>,
	linux mailing-list <linux-kernel@vger.kernel.org>
Subject: Re: RSS Limit implementation issue
Date: Fri, 10 Feb 2006 11:31:01 -0500	[thread overview]
Message-ID: <87DAB6BD-536F-4772-8496-12ED56700468@mac.com> (raw)
In-Reply-To: <728201270602100650q22938b88x237b8fb043c82408@mail.gmail.com>

On Feb 10, 2006, at 09:50, Ram Gupta wrote:
> On 2/9/06, Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
>> That is what I would expect. Or perhaps even allowing the process  
>> to exceed the RSS but using the RSS limit as a swapper target so  
>> that the process is victimised early. No point forcing swapping  
>> and the RSS limit when there is free memory, only where the  
>> resource is contended ..
>
> So we will need some kind of free memory threshold . If free memory  
> is more than it than we can let RSS exceed & scheduler can also  
> schedule it in this situation but not if free memory is less than  
> the threshhold. Also we need to figure out a way for swapper to  
> target pages based on RSS limit. One possible  disadvantage I can  
> think is that  as the swapper swaps out a page based on RSS limit ,  
> the process's rss will become within the rss limit & then scheduler  
> will schedule this process again & hence possibly same page might  
> have to be brought in. This may cause increase in swapping. What do  
> you think how much realistic is this scenario?

Just use a basic hysteresis device:

When allocating resources:
if (resource > limit + delta)
	disable_process();

When freeing resources:
if (resource < limit - delta)
	enable_process();

If the delta is set to something reasonable (say 1 or 2 pages), then  
the process will only be rescheduled when it gets enough free RSS  
(one page to satisfy its latest request and a few spare).  Even  
better, you could use a running average of "time between RSS- 
triggered-pauses" to figure out how much memory you should keep free.  
Pseudocode below:

[Tuneables]
unsigned int time_quantum_factor;
unsigned int limit;
unsigned int max_delta;

[Per-process state]
unsigned int pages;
unsigned int delta;
unsigned long long last_limit_time;

[When allocating resources]
if (pages > limit + delta) {
	int time_factor = log2(now - last_limit_time)
		- time_quantum_factor;
	last_limit_time = now;
	
	if (time_factor < 0 && delta < max_delta)
		delta <<= 1;
	else if (time_factor > 0 && delta > 1)
		delta >>= 1;
	
	put_process_to_sleep();
}

[When freeing resources]
if (resource < limit - delta)
	enable_process();

The effect of this code would be that the RSS code would avoid  
rescheduling a process more often than every 1<<time_quantum_factor  
microseconds.  It would attempt to provide a safe hysteresis delta  
such that the process would have enough pages free that it could  
probably run for at least the minimum amount of time.  Note that the  
code would _only_ have an effect if the process is already about to  
sleep on an RSS limit, otherwise that code path would never get hit.   
Obviously it's possible to adjust this algorithm to react more slowly  
or quickly by adjusting the shift values, but it should work well  
enough for a beta as-is.

Cheers,
Kyle Moffett

--
I didn't say it would work as a defense, just that they can spin that  
out for years in court if it came to it.
   -- Rob Landley




  reply	other threads:[~2006-02-10 16:31 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-09 21:10 Ram Gupta
2006-02-09 23:07 ` Alan Cox
2006-02-10 14:50   ` Ram Gupta
2006-02-10 16:31     ` Kyle Moffett [this message]
2006-02-10 22:20     ` Rik van Riel
2006-03-23 16:55   ` Ram Gupta
2006-03-29 20:16     ` Bill Davidsen
2006-03-30 21:41       ` Roger Heflin
2006-04-04 19:28         ` Bill Davidsen
2006-04-05 18:50           ` Roger Heflin
2006-04-07  2:55           ` kingsley
2006-03-31  3:00       ` Peter Chubb
2006-03-31  3:31         ` Bill Davidsen
2006-02-09 23:12 ` Bernd Eckenfels
2006-02-10 21:41 ` Bill Davidsen
     [not found] <mail.linux.kernel/728201270602091310r67a3f2dcq4788199f26a69528@mail.gmail.com>
     [not found] ` <06Feb11.024837est.33911@gpu.utcc.utoronto.ca>
2006-02-13 14:52   ` Ram Gupta
     [not found]     ` <06Feb13.151216est.821021@ugw.utcc.utoronto.ca>
2006-02-13 20:37       ` Ram Gupta
     [not found] <5ErmY-5vN-5@gated-at.bofh.it>
     [not found] ` <5EGm2-2eZ-27@gated-at.bofh.it>
     [not found]   ` <5TBku-7fu-3@gated-at.bofh.it>
2006-03-24 23:06     ` Bodo Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87DAB6BD-536F-4772-8496-12ED56700468@mac.com \
    --to=mrmacman_g4@mac.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ram.gupta5@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®