Re: Topic for discussion: OS Design

From: Richard B. Johnson (root@chaos.analogic.com)
Date: Thu Oct 26 2000 - 08:17:49 EST


On Thu, 26 Oct 2000, Albert D. Cahalan wrote:

> Richard B. Johnson writes:
> > On Sun, 22 Oct 2000, Dwayne C . Litzenberger wrote:
>
> > o Once installed, a kernel module is every bit as "efficient"
> > as some driver linked into the kernel at build-time. Of course
>
> I doubt this is true on most modern processors. On the Pentium
> and above, large pages are used for the kernel. The PowerPC port
             ^^^^^^^^^^^

The page-size is determined by the architecture. They are 4096 bytes
in the pentium. /usr/include/asm/page.h PAGE_SHIFT = 12, PAGE_SIZE =
1 << PAGE_SHIFT.

It doesn't matter if it's a module (linked during run-time) or
a group of procedures (linked during compile time).

> uses BAT registers. Other ports have other hacks to reduce TLB
> misses and/or wasted memory. Also, you waste half a page or more
> for the average module.

Since kernel memory is allocated in pages, you use whatever you
need. If a module is 4097 bytes in length, you could, in principle,
'waste' 4095 bytes. So what? it's never paged or otherwise producing
any overhead whatsoever.

These are modules I have written for a project. Since these are object
files, they contain not only code, but also a relocation table. So they
don't require as much memory as the file size shows. However, since
these are all modules, the relocation table is similar in size and
can be considered a constant.

         6204 Oct 24 10:48 firewire.o 8192 - 6204 = 1988
        11120 Oct 24 10:48 gpib_drvr.o 12288 - 11120 = 1168
         6692 Oct 24 10:48 ramdisk.o 8192 - 6692 = 1500
         3886 Oct 24 10:48 rtc_drvr.o 4096 - 3886 = 210
         6776 Oct 25 12:38 vxibus.o 8192 - 6776 = 1416
Totals ---- ----
                                               34678 6282

This shows that out of 34,678 bytes we needed, we wasted 6282, ~1.5
pages. Since there are 5 modules, we waste about 1/3 page per module.

So I don't, as you say; "... waste 1/2 page or more per module".

Installed modules are part of the kernel. They are not some 'programs'
that are executed via some strange indirection. Every module procedure,
(open/close/read/write/ioctl/lseek/poll/etc) is called precisely like
any "permanent" driver. There is no additional overhead.

Cheers,
Dick Johnson

Penguin : Linux version 2.2.17 on an i686 machine (801.18 BogoMips).

"Memory is like gasoline. You use it up when you are running. Of
course you get it all back when you reboot..."; Actual explanation
obtained from the Micro$oft help desk.

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



This archive was generated by hypermail 2b29 : Tue Oct 31 2000 - 21:00:18 EST