lkml.org 
[lkml]   [1999]   [Jan]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Review and report of linux kernel VM

------------------------------------------------------------------------------

This message was forwarded to you from Deja News by hjl@lucon.org.
Deja News, the discussion network, offers free web-based access to more than
50,000 high-quality discussion forums. Come and visit us on the web at
http://www.dejanews.com/=zzz_maf/

------------------------------------------------------------------------------

Join and get 4 bestselling audiobooks 1c
http://www.audiobookclub.com/micro/home.asp?AID=S036L004B009

------------------------------------------------------------------------------

(beginning of original message)

Subject: Re: Review and report of linux kernel VM
From: dyson@dyson.iquest.net ("John S. Dyson")
Date: 1999/01/15
Newsgroups: mailing.freebsd.hackers
>
> In general terms, linux's VM system is much cleaner then FreeBSD's... and
> I mean a *whole lot* cleaner, but at the cost of eating some extra memory.
> It isn't a whole lot of extra memory - maybe a meg or two for a typical
> system managing a lot of processes, and much less for typical 'small'
> systems. They are able to completely avoid the vm_object stacking
> (and related complexity) that we do, and they are able to completely
> avoid most of the pmap complexity in FreeBSD as well.
>
IMO, the "cleaness" might be better described as "too simple."

>
> Linux appears to map all of physical memory into KVM. This avoids
> FreeBSD's (struct buf) complexity at the cost of not being able to
> deal with huge-memory configurations. I'm not 100% sure of this, but
> its my read of the code until someone corrects me.
>
I suggest that we should get rid of the (struct buf) complexity by
creating the concept of temporary kernel mappings. Such mappings
are a resource limited so that the system doesn't have to map all
of memory, yet have a cleaner, more consistant scheme than the current.

The vm_page_t's at the end of the struct bufs were only a first step
in that arena. There are about 5-10 more steps needed before it is
really fully realized.

>
> * For the nominal page scan, it is using a one-hand clock algorithm.
> All I can say is: Oh my god! Are they nuts? That was abandoned
> a decade ago. The priority mechanism they've implemented is nearly
> useless.
>
> * To locate pages to swap out, it takes a pass through the task list.
> Ostensibly it locates the task with the largest RSS to then try to
> swap pages out from rather then select pages that are not in use.
> From my read of the code, it also botches this badly.
>
Yep, and it has been very difficult for me not to "educate" them on
the right way to do it. Frankly, their code works really well until
it is overused. Given the Linux VM code, "overused" mostly means
used at all. :-).

>
> Linux does not appear to do any page coloring whatsoever, but it would
> not be hard to add it in.
>
It wasn't hard to add to FreeBSD, but the coloring should be moved to
a machine dependent section of the codebase.

>
> Linux cannot swap-out its page tables or page directories. Thus, idle
> tasks can eat a significant amount of memory. This isn't a big deal for
> most systems ( small systems: no problem. Big systems: probably have lots
> of memory anyway ). But, mmap()'d files can create a significant burden
> if you have a lot of forked processes ( news, sendmail, web server,
> etc...). Not only does Linux have to scan the page tables for all the
> processes mapping the file, whether or not they are actively using the
> page being checked for, but Linux's swapout algorithm scans page tables
> and, effectively, makes redundant scans of shared objects.
>
The key here is to NEVER swap out page tables or page directories. One
should FREE them when it is possible. The notion of a dirty page table,
or on that is on disk is meaningless. The FreeBSD code releases page
table pages when they are empty. Page directories should be freeable
when all descendants are no longer mapped (including page tables.) Of
course, in that evaulation, the kernel mappings should be ignored, and
when "swapping" page directories in, they are rebuilt from the kernel
requirments. (FreeBSD doesn't release page directories yet, unless
a process exits.)

> What FreeBSD can learn
>
> Well, the main thing is that the Linux VM system is very, very clean
> compared to the FreeBSD implementation. Cleaning up FreeBSD's VM system
> complexity is what I've been concentrating on and will continue to
> concentrate on. However, part of the reason that FreeBSD's VM system
> is more complex is because it does not use the page tables to store
> reference information. Instead, it uses the vm_object and pmap modules.
> I actually like this feature of FreeBSD. A lot.
>
IMO, the pmap level is super flexible, but also there is too much stratification
between the pmap code and the VM code. Layering is good for reference
implementations, but also adds overhead. It would be "nice" to be able
for the upper level VM code to simply modify page table entries sometimes,
wouldn't it? One thing that I did in the FreeBSD code was to minimize the
transitions between the pmap and VM layers. Perhaps that should be better
defined, but if you wanted to rework the interfaces, you might see a
major cleanup.

>
> The biggest thing we need to do to clean up our VM system is, basically,
> to completely rewrite the struct buf filesystem buffering mechanism to
> make it much, much less complex - basically it should only be used as
> placeholders for read and write ops and not used to cache block number
> mappings between the files and the VM system, nor should it be used to
> map pages into KVM. Separating out these three mechanisms into three
> different subsystems would simplify the code enormously, I think. For
> example, we could implement a simple vm_object KVM mapping mechanism
> using FreeBSD's existing vm_object stacking model to map portions of a
> vm_object (aka filesystem partition) into KVM.
>
I agree. Take a look at using a seperate kernel mapping concept (there
might even be some of that work still lying around somewhere.) You can
then change buffers into what they should really be: I/O requests. The
kernel mappings can be a dynamically allocated resource that are cached
LRU or somesuch. Part of the technology to support them ended up being
pmap_kenter/pmap_kremove and pmap_qenter/pmap_qremove. Without those, the
temporary kernel mappings would have been terribly expensive.

>
> Linux demarks interrupts from supervisor code much better then we do.
> If we move some of the more sophisticated operational capabilities
> out of our interrupt subsystem, we could get rid of most of the spl*()
> junk we currently have to do. This is a real sore spot in current
> FreeBSD code. Interrupts are just too complex. I'd also get rid of
> FreeBSD's intermediate 'software interrupt' layer, which is able to
> do even more complex things then hard interrupt code. The latency
> considerations just don't make any sense verses running pending software
> interrupts synchronously in tsleep(), prior to actually sleeping. We
> need to do this anyway ( or move softints to kernel threads ) to be able
> to take advantage of SMP mechanisms. The *only* thing our interrupts
> should be allowed to do is finish I/O on a page or use zalloc().
>
Note that Linux doesn't even handle IDE PIO correctly, and has historically
lost interrupts due to it (and they added a software interrupt scheme ot
allow it to work.) IDE DMA saved their a**.

John

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message


(end of original message)
------------------------------------------------------------------------------

You can view this message and the related discussion by following this link:
http://www.dejanews.com/=zzz_maf/dnquery.xp?search=thread&svcclass=dnserver&recnum=%3c77lt66$5o4$1@FreeBSD.csie.NCTU.edu.tw%3e%231/2
We hope to see you soon at Deja News, the discussion network.
http://www.dejanews.com/=zzz_maf/


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:49    [W:0.053 / U:0.868 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site