Rusty's module talk at the Kernel Summit
Quoted 9 lines · Keith Owens
Quoted 2 lines · Adam J. Richter
As individual space optimizations go, 4% is respectable,
especially for something that has no costIt is not at no cost. Getting 4% requires arch dependent code to handle all the tables that are affected by partial text removal. I can get 2% for nothing by discarding data.init. Discarding text.init is a lot harder.
[...]
Quoted 9 lines
The problem is the partial removal of code when there are tables that point to _all_ the code. Partial code removal requires a lot of work to adjust every table that refers to code and correct them. To make it worse, the tables are arch specific. Most architectures have
__ex_table, with different formats for each arch. Some have unwind data, always arch dependent format. MIPS has dbe.Data is not referenced by any of these tables so a partial discard of data is easy, no side effects to worry about.
OK, I agree that anyone wanting to implement discarding of
some module init sections would be best off to start with .init.data.
I don't know enough about the formats of these tables right now
to really understand the best way to handle them, but I suspect that the simplest approach might be a mechanism where copy_*_user and the like could generate assembler that does a .pushsection to a different section depending on the current section, so you could have "__ex_table" and ".init.__ex_table", etc. Then it might be possible to deal with these sections in a way that is not architecture specific, and be able to discard the obselete parts of these tables after the init code has completed. However, this would probably require a gas or gcc extension.
[...]
Quoted 11 lines
Quoted 2 lines
As I understand it,
__ex_tableis just for copy_{to,from}_uesr,
which would almost never be done from init sections
__ex_tableis used for any code that requires recovery. Mainly copy..user but not exclusively.Quoted 1 line
The core kernel already deals with the same issue.
It does not. There is no code to adjust any tables after discarding kernel
__initsections. We rely on the fact that the discarded kernel area is not reused for executable text.
Come to think of it, if the core kernel's .text.init pages could
later be vmalloc'ed for module .text section, then I think you may have found a potential kernel bug.
Adam J. Richter __ ______________ 575 Oroville Road [email protected] \ / Milpitas, California 95035 +1 408 309-6081 | g g d r a s i l United States of America
"Free Software For The Rest Of Us."
Quoted 9 lines · Adam J. Richter
Quoted 3 lines · Keith Owens
It does not. There is no code to adjust any tables after discarding kernel
__initsections. We rely on the fact that the discarded kernel area is not reused for executable text.Come to think of it, if the core kernel's .text.init pages could
later be vmalloc'ed for module .text section, then I think you may have found a potential kernel bug.
No: the virtual address (which is what matters) would be different:
core kernel's .text.init is not in vmalloc virtual address range.
Hugh
Am Mittwoch, 3. Juli 2002 19:07 schrieb Hugh Dickins:
Quoted 6 lines · Adam J. Richter
Quoted 5 lines · Keith Owens
Quoted 3 lines
It does not. There is no code to adjust any tables after discarding kernel
__initsections. We rely on the fact that the discarded kernel area is not reused for executable text.
Quoted 6 lines
Quoted 3 lines
Come to think of it, if the core kernel's .text.init pages could
later be vmalloc'ed for module .text section, then I think you may have found a potential kernel bug.No: the virtual address (which is what matters) would be different:
core kernel's .text.init is not in vmalloc virtual address range.
Does that mean that kmalloc cannot be used to load modules? At least for small modules it would save TLB entries.
Regards
Oliver
Quoted 11 lines · Oliver Neukum
Am Mittwoch, 3. Juli 2002 19:07 schrieb Hugh Dickins:
Quoted 10 lines · Adam J. Richter
Quoted 8 lines · Keith Owens
Quoted 3 lines
It does not. There is no code to adjust any tables after discarding kernel
__initsections. We rely on the fact that the discarded kernel area is not reused for executable text.=09Come to think of it, if the core kernel's .text.init pages could later be vmalloc'ed for module .text section, then I think you may have found a potential kernel bug.
Quoted 5 lines
Quoted 2 lines
No: the virtual address (which is what matters) would be different:
core kernel's .text.init is not in vmalloc virtual address range.Does that mean that kmalloc cannot be used to load modules? At least for small modules it would save TLB entries.
That is correct. It is not safe to use kmalloc() storage for executable code. At least not until every architecture has been changed to adjust their tables after freeing part of the kernel.
Quoted 6 lines · Adam J. Richter
I don't know enough about the formats of these tables right now
to really understand the best way to handle them, but I suspect that the simplest approach might be a mechanism where copy_*_user and the like could generate assembler that does a .pushsection to a different section depending on the current section, so you could have "__ex_table" and ".init.__ex_table", etc.
Unfortunately there is no way to get the current section name from code. I looked for one when I was trying to solve the __devexit dangling pointer problem.
Quoted 3 lines
Come to think of it, if the core kernel's .text.init pages could
later be vmalloc'ed for module .text section, then I think you may have found a potential kernel bug.
AFAICT that cannot occur. The freed kernel .text.init pages are used for kmalloc, not vmalloc.