linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* try_to_swap_out() deactivating pages w. count > 2
@ 2001-04-21 15:48 Mike Galbraith
  2001-04-21 16:08 ` Mike Galbraith
  2001-04-21 16:42 ` Rik van Riel
  0 siblings, 2 replies; 8+ messages in thread
From: Mike Galbraith @ 2001-04-21 15:48 UTC (permalink / raw)
  To: linux-kernel

Hi,

A printk added to 2.4.4-pre5 try_to_swap_out()...

drop_pte:
		mm->rss--;
{
	int age = page->age;
	int count = page_count(page);
	int cache = PageSwapCache(page);
	printk("[pid-%d] page:%p deact:%d cache:%d age:%d count:%d\n",
			current->pid, page, !age, cache, age, count-1);
}

make -j30 bzImage

29:17: klogd 1.3-3, log source = /proc/kmsg started.
29:27: SysRq: Log level set to 0
30:04: [pid-4] page:c10e225c deact:1 cache:0 age:0 count:2
30:04: [pid-4] page:c10e33e0 deact:1 cache:0 age:0 count:2
30:04: [pid-4] page:c10e3394 deact:1 cache:0 age:0 count:2
30:04: [pid-4] page:c10e1cb8 deact:1 cache:0 age:0 count:2
30:04: [pid-4] page:c10e1c20 deact:1 cache:0 age:0 count:2
30:04: [pid-4] page:c10eb894 deact:1 cache:0 age:0 count:2
30:04: [pid-4] page:c10eb7b0 deact:1 cache:0 age:0 count:2
30:04: [pid-4] page:c10f0bb4 deact:0 cache:0 age:4 count:3
30:04: [pid-4] page:c10f1320 deact:0 cache:1 age:2 count:1
30:04: [pid-4] page:c10f136c deact:0 cache:1 age:2 count:1
30:04: [pid-4] page:c10599f4 deact:0 cache:0 age:29 count:164 [164? 1]
30:04: [pid-4] page:c10599a8 deact:0 cache:0 age:26 count:164
30:04: [pid-4] page:c105995c deact:0 cache:0 age:37 count:164
30:04: [pid-4] page:c10598c4 deact:0 cache:0 age:34 count:164
30:04: [pid-4] page:c1059878 deact:0 cache:0 age:34 count:164
30:04: [pid-4] page:c105982c deact:0 cache:0 age:34 count:164
30:04: [pid-4] page:c10599f4 deact:0 cache:0 age:32 count:163
30:04: [pid-4] page:c10599a8 deact:0 cache:0 age:26 count:163
30:04: [pid-4] page:c10debbc deact:1 cache:0 age:0 count:2
30:04: [pid-4] page:c10deb70 deact:1 cache:0 age:0 count:2
30:04: [pid-4] page:c10deb24 deact:1 cache:0 age:0 count:2
30:04: [pid-4] page:c10e1aa4 deact:1 cache:0 age:0 count:2

(snip 1000+ lines)

grep c10599f4 log
30:04: [pid-4] page:c10599f4 deact:0 cache:0 age:29 count:164
30:04: [pid-4] page:c10599f4 deact:0 cache:0 age:32 count:163
30:04: [pid-4] page:c10599f4 deact:0 cache:0 age:32 count:162
30:04: [pid-4] page:c10599f4 deact:0 cache:0 age:32 count:161
30:04: [pid-4] page:c10599f4 deact:0 cache:0 age:32 count:160
30:04: [pid-4] page:c10599f4 deact:0 cache:0 age:32 count:159
30:04: [pid-4] page:c10599f4 deact:0 cache:0 age:32 count:158
30:04: [pid-4] page:c10599f4 deact:0 cache:0 age:32 count:157
30:05: [pid-4] page:c10599f4 deact:0 cache:0 age:16 count:155
30:05: [pid-4] page:c10599f4 deact:0 cache:0 age:22 count:156
30:05: [pid-4] page:c10599f4 deact:0 cache:0 age:22 count:155
30:05: [pid-4] page:c10599f4 deact:0 cache:0 age:50 count:157
30:05: [pid-4] page:c10599f4 deact:0 cache:0 age:16 count:157
41:41: [pid-4] page:c10599f4 deact:1 cache:0 age:0 count:59
41:41: [pid-4] page:c10599f4 deact:1 cache:0 age:0 count:58
41:41: [pid-4] page:c10599f4 deact:1 cache:0 age:0 count:57
41:41: [pid-4] page:c10599f4 deact:1 cache:0 age:0 count:56
41:41: [pid-4] page:c10599f4 deact:1 cache:0 age:0 count:55
41:41: [pid-4] page:c10599f4 deact:1 cache:0 age:0 count:54
41:41: [pid-4] page:c10599f4 deact:1 cache:0 age:0 count:53
41:41: [pid-4] page:c10599f4 deact:1 cache:0 age:0 count:52
41:41: [pid-4] page:c10599f4 deact:1 cache:0 age:0 count:51
41:41: [pid-4] page:c10599f4 deact:1 cache:0 age:0 count:50
41:59: [pid-4] page:c10599f4 deact:1 cache:0 age:0 count:49
41:59: [pid-4] page:c10599f4 deact:1 cache:0 age:0 count:48
41:59: [pid-4] page:c10599f4 deact:1 cache:0 age:0 count:47
41:59: [pid-4] page:c10599f4 deact:1 cache:0 age:0 count:46
41:59: [pid-4] page:c10599f4 deact:1 cache:0 age:0 count:45
41:59: [pid-4] page:c10599f4 deact:1 cache:0 age:0 count:44

(klogd only logged 1196 pages during the whole build)

grep deact:0 log|wc -l                 = 961
grep count:[12] log|wc -l              = 875

grep deact:1 log|wc -l                 = 235
grep deact:1 log|grep count:[12]|wc -l = 103

1.  what kind of page has 164 references?
2.  why deactivate pages (lots) with count > 2?  PINGpong.

	-Mike


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

* Re: try_to_swap_out() deactivating pages w. count > 2
  2001-04-21 15:48 try_to_swap_out() deactivating pages w. count > 2 Mike Galbraith
@ 2001-04-21 16:08 ` Mike Galbraith
  2001-04-21 16:42 ` Rik van Riel
  1 sibling, 0 replies; 8+ messages in thread
From: Mike Galbraith @ 2001-04-21 16:08 UTC (permalink / raw)
  To: linux-kernel

Oops.. looking at aging too hard :)

What kind of page is it?

	-Mike


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

* Re: try_to_swap_out() deactivating pages w. count > 2
  2001-04-21 15:48 try_to_swap_out() deactivating pages w. count > 2 Mike Galbraith
  2001-04-21 16:08 ` Mike Galbraith
@ 2001-04-21 16:42 ` Rik van Riel
  2001-04-21 17:42   ` Linus Torvalds
  2001-04-21 17:48   ` Mike Galbraith
  1 sibling, 2 replies; 8+ messages in thread
From: Rik van Riel @ 2001-04-21 16:42 UTC (permalink / raw)
  To: Mike Galbraith; +Cc: linux-kernel

On Sat, 21 Apr 2001, Mike Galbraith wrote:

> 30:04: [pid-4] page:c10599f4 deact:0 cache:0 age:29 count:164 [164? 1]
> 30:04: [pid-4] page:c10599a8 deact:0 cache:0 age:26 count:164

> 1.  what kind of page has 164 references?

mmap(/lib/libc.so, FLAGS);

> 2.  why deactivate pages (lots) with count > 2?  PINGpong.

They're not deactivated, they're removed from this proces' virtual
memory mapping.

What I _am_ worried about is the fact that we do this to pages with
a really high page age. These things are in active use and cannot
be swapped out any time soon, yet we do claim swap space for it ...

regards,

Rik
--
Virtual memory is like a game you can't win;
However, without VM there's truly nothing to lose...

		http://www.surriel.com/
http://www.conectiva.com/	http://distro.conectiva.com.br/


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

* Re: try_to_swap_out() deactivating pages w. count > 2
  2001-04-21 16:42 ` Rik van Riel
@ 2001-04-21 17:42   ` Linus Torvalds
  2001-04-21 17:48   ` Mike Galbraith
  1 sibling, 0 replies; 8+ messages in thread
From: Linus Torvalds @ 2001-04-21 17:42 UTC (permalink / raw)
  To: linux-kernel

In article <Pine.LNX.4.21.0104211336390.1685-100000@imladris.rielhome.conectiva>,
Rik van Riel  <riel@conectiva.com.br> wrote:
>
>What I _am_ worried about is the fact that we do this to pages with
>a really high page age. These things are in active use and cannot
>be swapped out any time soon, yet we do claim swap space for it ...

Ehh... And if we didn't do that, then how could they every become less
active?

We should _absolutely_ do the swap space reclaiming without looking at
the page count. If we don't, you will never free those pages, and I have
a trivial exploit for you that will basically mlock all pages in memory.

try_to_swap_out() _absolutely_ does the right thing.  Also note how it
will need to allocate the swap space backing store only once. 

		Linus

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

* Re: try_to_swap_out() deactivating pages w. count > 2
  2001-04-21 16:42 ` Rik van Riel
  2001-04-21 17:42   ` Linus Torvalds
@ 2001-04-21 17:48   ` Mike Galbraith
  1 sibling, 0 replies; 8+ messages in thread
From: Mike Galbraith @ 2001-04-21 17:48 UTC (permalink / raw)
  To: Rik van Riel; +Cc: linux-kernel

On Sat, 21 Apr 2001, Rik van Riel wrote:

> On Sat, 21 Apr 2001, Mike Galbraith wrote:
>
> > 30:04: [pid-4] page:c10599f4 deact:0 cache:0 age:29 count:164 [164? 1]
> > 30:04: [pid-4] page:c10599a8 deact:0 cache:0 age:26 count:164
>
> > 1.  what kind of page has 164 references?
>
> mmap(/lib/libc.so, FLAGS);

I figured that out too in the meantime.  (14hrs at a stretch makes
more than eyeballs bleary..)

> > 2.  why deactivate pages (lots) with count > 2?  PINGpong.
>
> They're not deactivated, they're removed from this proces' virtual
> memory mapping.

blush.. yup.

> What I _am_ worried about is the fact that we do this to pages with
> a really high page age. These things are in active use and cannot
> be swapped out any time soon, yet we do claim swap space for it ...

I'll see if it makes any noticable difference tomorrow.  Enough
fruitless effort for one day.

:) Am I likely to learn more about how swapcache works when I try
to instantly donate these to page_launder() tomorrow morning?

[4] mm:c2ce9f00 page:c1001060 deact:0 cache:1 buf:0 age:5 cnt:1
[2285] mm:c67ef760 page:c1002b18 deact:0 cache:1 buf:0 age:5 cnt:1

	-Mike


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

* Re: try_to_swap_out() deactivating pages w. count > 2
  2001-04-21 17:51 ` Rik van Riel
  2001-04-21 17:55   ` Rik van Riel
@ 2001-04-21 18:03   ` Linus Torvalds
  1 sibling, 0 replies; 8+ messages in thread
From: Linus Torvalds @ 2001-04-21 18:03 UTC (permalink / raw)
  To: Rik van Riel; +Cc: linux-kernel


On Sat, 21 Apr 2001, Rik van Riel wrote:
> > 
> > We should _absolutely_ do the swap space reclaiming without looking at
> > the page count.
> 
> page->age != page->count

It's all the same thing.

The page age and count are used to decice when the page actually gets
thrown _out_ of memory. That's a decision that is based on the _physical_
page attributes.

But try_to_swap_out() is based on the attribute on this particular virtual
mapping of the page. If this particular virtual mapping does not have the
"accessed" bit set, then try_to_swap_out() should get rid of that virtual
mapping. It should absolutely not use the global page characteristics
(either global usage count or global age) in making that decision. Because
those do not matter - they have absoilutely no meaning for this virtual
mapping of the page.

Put another way: if process A is a heavy user of a page, and process B
just touched it once and will never touch it again, what do you think
should happen?

Answer: the page should be dropped from process B. It's a cheap thing to
do (we can get it back if necessary without any IO), and it means that if
we end up having toi actually swap out the page eventually, we will not be
confused by "noise" in the page count from a mappign that hasn't been
active for a long time.

		Linus


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

* Re: try_to_swap_out() deactivating pages w. count > 2
  2001-04-21 17:51 ` Rik van Riel
@ 2001-04-21 17:55   ` Rik van Riel
  2001-04-21 18:03   ` Linus Torvalds
  1 sibling, 0 replies; 8+ messages in thread
From: Rik van Riel @ 2001-04-21 17:55 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel

On Sat, 21 Apr 2001, Rik van Riel wrote:
> On Sat, 21 Apr 2001, Linus Torvalds wrote:

> > Ehh... And if we didn't do that, then how could they every become less
> > active?
> > 
> > We should _absolutely_ do the swap space reclaiming without looking at
> > the page count.
> 
> page->age != page->count

Umm, forget that.  We only decrease page->age in refill_inactive_scan,
so we NEED to put it there. You're right, I should wake up and think
a bit more about my own code ;)

Rik
--
Virtual memory is like a game you can't win;
However, without VM there's truly nothing to lose...

		http://www.surriel.com/
http://www.conectiva.com/	http://distro.conectiva.com.br/


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

* Re: try_to_swap_out() deactivating pages w. count > 2
       [not found] <200104211742.KAA17813@penguin.transmeta.com>
@ 2001-04-21 17:51 ` Rik van Riel
  2001-04-21 17:55   ` Rik van Riel
  2001-04-21 18:03   ` Linus Torvalds
  0 siblings, 2 replies; 8+ messages in thread
From: Rik van Riel @ 2001-04-21 17:51 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel

On Sat, 21 Apr 2001, Linus Torvalds wrote:
> In article <Pine.LNX.4.21.0104211336390.1685-100000@imladris.rielhome.conectiva>,
> Rik van Riel  <riel@conectiva.com.br> wrote:
> >
> >What I _am_ worried about is the fact that we do this to pages with
> >a really high page age. These things are in active use and cannot
> >be swapped out any time soon, yet we do claim swap space for it ...
> 
> Ehh... And if we didn't do that, then how could they every become less
> active?
> 
> We should _absolutely_ do the swap space reclaiming without looking at
> the page count.

page->age != page->count

Rik
--
Virtual memory is like a game you can't win;
However, without VM there's truly nothing to lose...

		http://www.surriel.com/
http://www.conectiva.com/	http://distro.conectiva.com.br/


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

end of thread, other threads:[~2001-04-21 18:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-21 15:48 try_to_swap_out() deactivating pages w. count > 2 Mike Galbraith
2001-04-21 16:08 ` Mike Galbraith
2001-04-21 16:42 ` Rik van Riel
2001-04-21 17:42   ` Linus Torvalds
2001-04-21 17:48   ` Mike Galbraith
     [not found] <200104211742.KAA17813@penguin.transmeta.com>
2001-04-21 17:51 ` Rik van Riel
2001-04-21 17:55   ` Rik van Riel
2001-04-21 18:03   ` Linus Torvalds

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).