From: Con Kolivas <kernel@kolivas.org>
To: Con Kolivas <kernel@kolivas.org>
Cc: Andrew Morton <akpm@osdl.org>,
nigelenki@comcast.net, linux-kernel@vger.kernel.org,
ck@vds.kolivas.org
Subject: Re: Autoregulate swappiness & inactivation
Date: Thu, 08 Jul 2004 16:45:44 +1000 [thread overview]
Message-ID: <cone.1089269144.63871.4554.502@pc.kolivas.org> (raw)
In-Reply-To: <cone.1089268800.781084.4554.502@pc.kolivas.org>
[-- Attachment #1.1: Type: text/plain, Size: 753 bytes --]
Con Kolivas writes:
> Andrew Morton writes:
>
>> Con Kolivas <kernel@kolivas.org> wrote:
>>>
>>> > How about autoregulated swappiness, which seems to be very efficient at
>>> > its job?
>>>
>>> It's been around for quite a while, and akpm has not expressed any
>>> interest in it so I think this will only ever flounder in the -ck domain.
>>
>> Nobody sent me the patch. And the
>> justification/explanation/sales-brochure. And the benchmarks...
>
> Ah what the heck. They can only be knocked back to where they already are.
Hmm the second patch doesn't appear complete against mm6. I'll have to
re-create it once I can look at the code at home. Here is the version
against vanilla so you can see what it's supposed to do. Apologies.
Con
[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2.1: vm_autoregulate --]
[-- Type: text/plain, Size: 4654 bytes --]
Index: linux-2.6.7-ck/include/linux/swap.h
===================================================================
--- linux-2.6.7-ck.orig/include/linux/swap.h 2004-07-01 19:41:13.375151780 +1000
+++ linux-2.6.7-ck/include/linux/swap.h 2004-07-01 19:41:30.134517540 +1000
@@ -175,7 +175,7 @@
extern int try_to_free_pages(struct zone **, unsigned int, unsigned int);
extern int shrink_all_memory(int);
extern int vm_swappiness;
-extern int auto_swappiness;
+extern int vm_autoregulate;
#ifdef CONFIG_MMU
/* linux/mm/shmem.c */
Index: linux-2.6.7-ck/include/linux/sysctl.h
===================================================================
--- linux-2.6.7-ck.orig/include/linux/sysctl.h 2004-07-01 19:41:13.376151623 +1000
+++ linux-2.6.7-ck/include/linux/sysctl.h 2004-07-01 19:41:30.136517226 +1000
@@ -166,7 +166,7 @@
VM_LAPTOP_MODE=23, /* vm laptop mode */
VM_BLOCK_DUMP=24, /* block dump mode */
VM_HUGETLB_GROUP=25, /* permitted hugetlb group */
- VM_AUTO_SWAPPINESS=26, /* Make vm_swappiness autoregulated */
+ VM_AUTOREGULATE=26, /* swappiness and inactivation autoregulated */
};
Index: linux-2.6.7-ck/kernel/sysctl.c
===================================================================
--- linux-2.6.7-ck.orig/kernel/sysctl.c 2004-07-01 19:41:13.377151466 +1000
+++ linux-2.6.7-ck/kernel/sysctl.c 2004-07-01 19:41:30.137517069 +1000
@@ -744,9 +744,9 @@
.extra2 = &one_hundred,
},
{
- .ctl_name = VM_AUTO_SWAPPINESS,
- .procname = "autoswappiness",
- .data = &auto_swappiness,
+ .ctl_name = VM_AUTOREGULATE,
+ .procname = "autoregulate",
+ .data = &vm_autoregulate,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = &proc_dointvec,
Index: linux-2.6.7-ck/mm/vmscan.c
===================================================================
--- linux-2.6.7-ck.orig/mm/vmscan.c 2004-07-01 19:41:13.378151309 +1000
+++ linux-2.6.7-ck/mm/vmscan.c 2004-07-01 19:45:01.086359211 +1000
@@ -43,7 +43,8 @@
* From 0 .. 100. Higher means more swappy.
*/
int vm_swappiness = 60;
-int auto_swappiness = 1;
+int vm_autoregulate = 1;
+static int app_percent = 1;
static long total_memory;
#define lru_to_page(_head) (list_entry((_head)->prev, struct page, lru))
@@ -649,7 +650,9 @@
long mapped_ratio;
long distress;
long swap_tendency;
+ struct sysinfo i;
+ si_meminfo(&i);
lru_add_drain();
pgmoved = 0;
spin_lock_irq(&zone->lru_lock);
@@ -691,23 +694,21 @@
*/
mapped_ratio = (sc->nr_mapped * 100) / total_memory;
+ /*
+ * app_percent is the percentage of physical ram used
+ * by application pages.
+ */
+ si_meminfo(&i);
#ifdef CONFIG_SWAP
- if (auto_swappiness) {
- int app_percent;
- struct sysinfo i;
-
+ app_percent = 100 - ((i.freeram + get_page_cache_size() -
+ swapper_space.nrpages) / (i.totalram / 100));
+
+ if (vm_autoregulate) {
si_swapinfo(&i);
if (likely(i.totalswap >= 100)) {
int swap_centile;
- /*
- * app_percent is the percentage of physical ram used
- * by application pages.
- */
- si_meminfo(&i);
- app_percent = 100 - ((i.freeram + get_page_cache_size() -
- swapper_space.nrpages) / (i.totalram / 100));
/*
* swap_centile is the percentage of the last (sizeof physical
@@ -724,6 +725,9 @@
} else
vm_swappiness = 0;
}
+#else
+ app_percent = 100 - ((i.freeram + get_page_cache_size()) /
+ (i.totalram / 100));
#endif
/*
@@ -834,11 +838,16 @@
static void
shrink_zone(struct zone *zone, struct scan_control *sc)
{
- unsigned long scan_active, scan_inactive;
- int count;
+ unsigned long scan_active, scan_inactive, biased_active;
+ int count, biased_ap;
scan_inactive = (zone->nr_active + zone->nr_inactive) >> sc->priority;
+ if (vm_autoregulate) {
+ biased_ap = app_percent * app_percent / 100;
+ biased_active = zone->nr_active / (101 - biased_ap) * 100;
+ } else
+ biased_active = zone->nr_active;
/*
* Try to keep the active list 2/3 of the size of the cache. And
* make sure that refill_inactive is given a decent number of pages.
@@ -849,7 +858,7 @@
* `scan_active' just to make sure that the kernel will slowly sift
* through the active list.
*/
- if (zone->nr_active >= 4*(zone->nr_inactive*2 + 1)) {
+ if (biased_active >= 4*(zone->nr_inactive*2 + 1)) {
/* Don't scan more than 4 times the inactive list scan size */
scan_active = 4*scan_inactive;
} else {
@@ -857,7 +866,7 @@
/* Cast to long long so the multiply doesn't overflow */
- tmp = (unsigned long long)scan_inactive * zone->nr_active;
+ tmp = (unsigned long long)scan_inactive * biased_active;
do_div(tmp, zone->nr_inactive*2 + 1);
scan_active = (unsigned long)tmp;
}
[-- Attachment #2.2: Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2004-07-08 6:46 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-07 15:16 2.6.7-ck5 Con Kolivas
2004-07-07 15:39 ` 2.6.7-ck5 John Richard Moser
2004-07-07 15:47 ` 2.6.7-ck5 Con Kolivas
2004-07-07 15:53 ` 2.6.7-ck5 Prakash K. Cheemplavam
2004-07-07 16:11 ` 2.6.7-ck5 P
2004-07-07 17:10 ` 2.6.7-ck5 Prakash K. Cheemplavam
2004-07-07 16:17 ` 2.6.7-ck5 Redeeman
2004-07-08 4:38 ` 2.6.7-ck5 Andrew Morton
2004-07-08 6:40 ` [PATCH] Autoregulate swappiness & inactivation Con Kolivas
2004-07-08 6:45 ` Con Kolivas [this message]
2004-07-08 7:06 ` Nick Piggin
2004-07-08 7:12 ` Con Kolivas
2004-07-08 7:31 ` Nick Piggin
2004-07-08 8:03 ` Con Kolivas
2004-07-08 8:12 ` Nick Piggin
2004-07-08 17:06 ` John Richard Moser
2004-07-08 17:14 ` [ck] " Mikhail Ramendik
2004-07-08 17:10 ` [ck] Re: [PATCH] " Mikhail Ramendik
2004-07-09 1:03 ` Nick Piggin
2004-07-08 7:10 ` Andrew Morton
2004-07-08 7:58 ` Con Kolivas
2004-07-08 8:08 ` Andrew Morton
2004-07-08 8:27 ` Con Kolivas
2004-07-08 10:54 ` FabF
2004-07-09 1:05 ` Con Kolivas
2004-07-09 9:48 ` FabF
2004-07-09 10:43 ` Nick Piggin
2004-07-09 11:14 ` FabF
2004-07-09 11:24 ` Nick Piggin
2004-07-10 9:44 ` FabF
[not found] ` <40EFC076.9050504@yahoo.com.au>
2004-07-10 10:57 ` rss recovery FabF
2004-07-10 12:03 ` Nick Piggin
2004-07-13 13:12 ` FabF
2004-07-08 16:26 ` Autoregulate swappiness & inactivation Timothy Miller
2004-07-08 17:12 ` John Richard Moser
2004-07-08 18:37 ` Timothy Miller
2004-07-08 21:40 ` John Richard Moser
2004-07-09 7:44 ` Felipe Alfaro Solana
2004-07-08 16:24 ` [PATCH] Autotune swappiness Con Kolivas
2004-07-08 16:44 ` Andrew Morton
2004-07-09 0:39 ` Con Kolivas
2004-07-09 1:19 ` [ck] " Kerin Millar
2004-07-09 14:23 ` Martin J. Bligh
2004-07-09 14:26 ` Con Kolivas
2004-07-08 15:57 ` [ck] Re: 2.6.7-ck5 GSehp
2004-07-07 16:45 ` 2.6.7-ck5 John Richard Moser
2004-07-07 17:10 ` 2.6.7-ck5 Prakash K. Cheemplavam
2004-07-07 22:26 ` 2.6.7-ck5 Wes Janzen
2004-07-07 22:53 ` 2.6.7-ck5 Con Kolivas
-- strict thread matches above, loose matches on Subject: below --
2000-01-01 17:31 Autoregulate swappiness & inactivation deepfire
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=cone.1089269144.63871.4554.502@pc.kolivas.org \
--to=kernel@kolivas.org \
--cc=akpm@osdl.org \
--cc=ck@vds.kolivas.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nigelenki@comcast.net \
/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®