From: Roger Larsson <roger.larsson@norran.net>
To: linux-mm@kvack.org
Cc: Rik van Riel <riel@conectiva.com.br>
Subject: [RFC] alternative swap_amount
Date: Tue, 8 May 2001 22:48:46 +0200 [thread overview]
Message-ID: <200105082051.f48KpTx08708@maila.telia.com> (raw)
Hi again,
Got some time to spend...
I wonder about the fairness in swap_amount (mm/vmscan.c)
Suppose you have a small process with
mm->rss <= SWAP_MIN
then swap_amount will
return SWAP_MIN
Resulting in an attempt to swap out ALL pages of that process.
And if it had less pages even claim that we did not succeed...???
Shouldn't the return value at least be limited by the actual number
of pages in the mm?
Rules:
0 -> 0 (if there are no pages anyway..., must be handled)
low -> P% of low (but require that we will finally get 0 pages left)
high -> p% of high
One, _untested_ example, would be:
static inline int swap_amount(struct mm_struct *mm)
{
/* begin with high, I have slightly more big than small ? */
int nr = mm->rss >> SWAP_SHIFT;
if (nr < SWAP_MIN) {
nr = (mm->rss + 1) / 2; /* 0 => 0, 1 => 1, 2 => 1, 3 => 2 */
if (nr > SWAP_MIN)
nr = SWAP_MIN;
}
return nr;
}
Compare these outputs:
rss _old _new
0 8 0
1 8 1
2 8 1
4 8 2
8 8 4
16 8 8
32 8 8
64 8 8
128 8 8
256 8 8
512 16 16
1024 32 32
2048 64 64
4096 128 128
/RogerL
---- original code ----
#define SWAP_SHIFT 5
#define SWAP_MIN 8
static inline int swap_amount(struct mm_struct *mm)
{
int nr = mm->rss >> SWAP_SHIFT;
return nr < SWAP_MIN ? SWAP_MIN : nr;
}
static int swap_out(unsigned int priority, int gfp_mask)
{
int counter;
int retval = 0;
struct mm_struct *mm = current->mm;
/* Always start by trying to penalize the process that is allocating memory*/
if (mm)
retval = swap_out_mm(mm, swap_amount(mm));
--
Roger Larsson
Skelleftea
Sweden
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
reply other threads:[~2001-05-08 20:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200105082051.f48KpTx08708@maila.telia.com \
--to=roger.larsson@norran.net \
--cc=linux-mm@kvack.org \
--cc=riel@conectiva.com.br \
/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