mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: pacman@manson.clss.net
To: linux-kernel@vger.kernel.org
Subject: swapping problem 2.4.16
Date: Tue, 18 Dec 2001 11:25:09 -0500 (EST)	[thread overview]
Message-ID: <20011218162509.6476.qmail@manson.clss.net> (raw)

My machine (8 MB RAM, please hold the applause) hangs with 2.4.16 whenever it
needs to swap (which usually coincides with the launching of gettys).

AltGr+ScrollLock during the freeze shows a call trace like this:
sys_newstat->getname->kmalloc->try_to_free_pages->shrink_caches->shrink_cache
(some entries omitted; all this data is from pencil-and-paper notes, there
may be some transcription errors)

Shift+ScrollLock says this:

Mem-info:
Free pages: 84 kB (0kB HighMem)
Zone:DMA freepages: 84kB min: 80kB low: 160kB high: 240kB
Zone:Normal freepages: 0kB min: 0kB low: 0kB high: 0kB
Zone:HighMem freepages: 0kB min: 0kB low: 0kB high: 0kB
( Active: 84, inactive: 1360, free: 21 )
1*4kB 0*8kB 1*16kB 0*32kB 1*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB = 84 kB)
= 0 kB)
= 0 kB)
Swap cache: add 0, delete 0, find 0/0, race 0+0
Free swap: 31076 kB
2048 pages of RAM
0 pages of HIGHMEM
394 reserved pages
877 pages shared
0 pages swap cached
8 pages in page table cache
Buffer memory: 92kB

Loading up shrink_cache with printks was very revealing. shrink_cache is
called repeatedly, with nr_pages=32 with priority looping from 6 down to 1,
and it returns 32 every time. I don't understand exactly how shrink_cache is
supposed to work, but I assume that what I need it to do is call swap_out().
That call is never being reached, because of these formulae:

int max_scan = nr_inactive_pages / priority;
int max_mapped = nr_pages << (9 - priority);

max_scan is the number of iterations of the big loop that surrounds most of
the function. max_mapped is decremented at most once per iteration of that
outer loop, and swap_out will never be called until max_mapped reaches 0.
Therefore if the initial value of max_mapped is greater than the initial
value of max_scan, there is no chance of reaching the swap_out() call. And
using my numbers:

                   max_scan =                  max_mapped =
priority | nr_inactive_pages / priority | nr_pages << (9 - priority)
       6 |       1360 / 6 = 226         | 32 << 3 = 256
       5 |       1360 / 5 = 272         | 32 << 4 = 512
       4 |       1360 / 4 = 340         | 32 << 5 = 1024
       3 |       1360 / 3 = 453         | 32 << 6 = 2048
       2 |       1360 / 2 = 680         | 32 << 7 = 4096
       1 |       1360 / 1 = 1360        | 32 << 8 = 8192

Not only is max_mapped larger than max_scan, the gap between them widens as
the priority approaches 1. That seems to go against my understanding of what
the priority is supposed to mean - that as you get close to 1 you should get
*more* likely to swap something out.

As an experiment I changed this statement:

                        if (--max_mapped >= 0)
                                continue;

to this:

                        if (--max_mapped >= 0 && priority!=1)
                                continue;

and now it boots, swaps, and survives.


                 reply	other threads:[~2001-12-18 16:25 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=20011218162509.6476.qmail@manson.clss.net \
    --to=pacman@manson.clss.net \
    --cc=linux-kernel@vger.kernel.org \
    /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®