public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Move some more structures into "mostly_readonly"
@ 2005-06-07 18:30 christoph
  2005-06-07 19:41 ` Christoph Hellwig
  2005-06-08 12:16 ` Pavel Machek
  0 siblings, 2 replies; 16+ messages in thread
From: christoph @ 2005-06-07 18:30 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel

Move syscall table, timer_hpet and the boot_cpu_data into the "mostly_readonly" section.

Signed-off-by: Alok N Kataria <alokk@calsoftinc.com>
Signed-off-by: Shai Fultheim <shai@scalex86.org>
Signed-off-by: Christoph Lameter <christoph@scalex86.org>

Index: linux-2.6.12-rc6-mm1/arch/i386/kernel/entry.S
===================================================================
--- linux-2.6.12-rc6-mm1.orig/arch/i386/kernel/entry.S	2005-06-07 11:15:43.000000000 -0700
+++ linux-2.6.12-rc6-mm1/arch/i386/kernel/entry.S	2005-06-07 11:26:36.000000000 -0700
@@ -680,6 +680,8 @@ ENTRY(spurious_interrupt_bug)
 	pushl $do_spurious_interrupt_bug
 	jmp error_code
 
+.section .data.mostly_readonly,"a"
 #include "syscall_table.S"
 
 syscall_table_size=(.-sys_call_table)
+.previous
Index: linux-2.6.12-rc6-mm1/arch/i386/kernel/setup.c
===================================================================
--- linux-2.6.12-rc6-mm1.orig/arch/i386/kernel/setup.c	2005-06-07 11:15:43.000000000 -0700
+++ linux-2.6.12-rc6-mm1/arch/i386/kernel/setup.c	2005-06-07 11:27:48.000000000 -0700
@@ -82,7 +82,8 @@ EXPORT_SYMBOL(efi_enabled);
 /* cpu data as detected by the assembly code in head.S */
 struct cpuinfo_x86 new_cpu_data __initdata = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
 /* common cpu data for all cpus */
-struct cpuinfo_x86 boot_cpu_data = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
+struct cpuinfo_x86 boot_cpu_data __cacheline_aligned_mostly_readonly
+		= { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
 EXPORT_SYMBOL(boot_cpu_data);
 
 unsigned long mmu_cr4_features;
Index: linux-2.6.12-rc6-mm1/arch/i386/kernel/syscall_table.S
===================================================================
--- linux-2.6.12-rc6-mm1.orig/arch/i386/kernel/syscall_table.S	2005-06-07 11:15:43.000000000 -0700
+++ linux-2.6.12-rc6-mm1/arch/i386/kernel/syscall_table.S	2005-06-07 11:26:36.000000000 -0700
@@ -1,4 +1,3 @@
-.data
 ENTRY(sys_call_table)
 	.long sys_restart_syscall	/* 0 - old "setup()" system call, used for restarting */
 	.long sys_exit
Index: linux-2.6.12-rc6-mm1/arch/i386/kernel/timers/timer_hpet.c
===================================================================
--- linux-2.6.12-rc6-mm1.orig/arch/i386/kernel/timers/timer_hpet.c	2005-06-07 11:15:43.000000000 -0700
+++ linux-2.6.12-rc6-mm1/arch/i386/kernel/timers/timer_hpet.c	2005-06-07 11:26:36.000000000 -0700
@@ -180,7 +180,7 @@ static int __init init_hpet(char* overri
 /************************************************************/
 
 /* tsc timer_opts struct */
-static struct timer_opts timer_hpet = {
+static struct timer_opts timer_hpet __cacheline_aligned_mostly_readonly = {
 	.name = 		"hpet",
 	.mark_offset =		mark_offset_hpet,
 	.get_offset =		get_offset_hpet,

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

* Re: [PATCH] Move some more structures into "mostly_readonly"
  2005-06-07 18:30 [PATCH] Move some more structures into "mostly_readonly" christoph
@ 2005-06-07 19:41 ` Christoph Hellwig
  2005-06-07 19:59   ` christoph
  2005-06-08 12:16 ` Pavel Machek
  1 sibling, 1 reply; 16+ messages in thread
From: Christoph Hellwig @ 2005-06-07 19:41 UTC (permalink / raw)
  To: christoph; +Cc: akpm, linux-kernel

On Tue, Jun 07, 2005 at 11:30:03AM -0700, christoph wrote:
> Move syscall table, timer_hpet and the boot_cpu_data into the "mostly_readonly" section.

the syscall table should be completely readonly.


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

* Re: [PATCH] Move some more structures into "mostly_readonly"
  2005-06-07 19:41 ` Christoph Hellwig
@ 2005-06-07 19:59   ` christoph
  2005-06-07 20:59     ` Arjan van de Ven
  0 siblings, 1 reply; 16+ messages in thread
From: christoph @ 2005-06-07 19:59 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: akpm, linux-kernel

On Tue, 7 Jun 2005, Christoph Hellwig wrote:

> On Tue, Jun 07, 2005 at 11:30:03AM -0700, christoph wrote:
> > Move syscall table, timer_hpet and the boot_cpu_data into the "mostly_readonly" section.
> 
> the syscall table should be completely readonly.

Why was it in .data in the first place? There must be some reason why it 
was writable?


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

* Re: [PATCH] Move some more structures into "mostly_readonly"
  2005-06-07 19:59   ` christoph
@ 2005-06-07 20:59     ` Arjan van de Ven
  2005-06-07 21:31       ` Brian Gerst
  0 siblings, 1 reply; 16+ messages in thread
From: Arjan van de Ven @ 2005-06-07 20:59 UTC (permalink / raw)
  To: christoph; +Cc: Christoph Hellwig, akpm, linux-kernel

On Tue, 2005-06-07 at 12:59 -0700, christoph wrote:
> On Tue, 7 Jun 2005, Christoph Hellwig wrote:
> 
> > On Tue, Jun 07, 2005 at 11:30:03AM -0700, christoph wrote:
> > > Move syscall table, timer_hpet and the boot_cpu_data into the "mostly_readonly" section.
> > 
> > the syscall table should be completely readonly.
> 
> Why was it in .data in the first place? There must be some reason why it 
> was writable?

probably a historic oversight.



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

* Re: [PATCH] Move some more structures into "mostly_readonly"
  2005-06-07 20:59     ` Arjan van de Ven
@ 2005-06-07 21:31       ` Brian Gerst
  2005-06-07 22:23         ` christoph
                           ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Brian Gerst @ 2005-06-07 21:31 UTC (permalink / raw)
  To: Arjan van de Ven; +Cc: christoph, Christoph Hellwig, akpm, linux-kernel

Arjan van de Ven wrote:
> On Tue, 2005-06-07 at 12:59 -0700, christoph wrote:
> 
>>On Tue, 7 Jun 2005, Christoph Hellwig wrote:
>>
>>
>>>On Tue, Jun 07, 2005 at 11:30:03AM -0700, christoph wrote:
>>>
>>>>Move syscall table, timer_hpet and the boot_cpu_data into the "mostly_readonly" section.
>>>
>>>the syscall table should be completely readonly.
>>
>>Why was it in .data in the first place? There must be some reason why it 
>>was writable?
> 
> 
> probably a historic oversight.
> 

It doesn't really matter.  .rodata isn't actually mapped read-only. 
Doing so would break up the large pages used to map the kernel.

--
				Brian Gerst

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

* Re: [PATCH] Move some more structures into "mostly_readonly"
  2005-06-07 21:31       ` Brian Gerst
@ 2005-06-07 22:23         ` christoph
  2005-06-07 22:54           ` Jeremy Maitin-Shepard
  2005-06-08 10:00         ` Jörn Engel
  2005-06-08 14:24         ` Arnd Bergmann
  2 siblings, 1 reply; 16+ messages in thread
From: christoph @ 2005-06-07 22:23 UTC (permalink / raw)
  To: Brian Gerst; +Cc: Arjan van de Ven, Christoph Hellwig, akpm, linux-kernel, shai

On Tue, 7 Jun 2005, Brian Gerst wrote:

> It doesn't really matter.  .rodata isn't actually mapped read-only. Doing so
> would break up the large pages used to map the kernel.

In that case.... here is a patch that moves the table into rodata.

Subject: Move some more structures into "mostly_readonly" and readonly

---

Move syscall timer_hpet and the boot_cpu_data into the "mostly_readonly"
section. And move the syscall table to readonly

Signed-off-by: Alok N Kataria <alokk@calsoftinc.com>
Signed-off-by: Shai Fultheim <shai@scalex86.org>
Signed-off-by: Christoph Lameter <christoph@scalex86.org>

Index: linux-2.6.12-rc6-mm1/arch/i386/kernel/entry.S
===================================================================
--- linux-2.6.12-rc6-mm1.orig/arch/i386/kernel/entry.S	2005-06-07 15:17:15.000000000 -0700
+++ linux-2.6.12-rc6-mm1/arch/i386/kernel/entry.S	2005-06-07 15:18:20.000000000 -0700
@@ -680,6 +680,8 @@ ENTRY(spurious_interrupt_bug)
 	pushl $do_spurious_interrupt_bug
 	jmp error_code
 
+.section .ro_data,"a"
 #include "syscall_table.S"
 
 syscall_table_size=(.-sys_call_table)
+.previous
Index: linux-2.6.12-rc6-mm1/arch/i386/kernel/setup.c
===================================================================
--- linux-2.6.12-rc6-mm1.orig/arch/i386/kernel/setup.c	2005-06-07 15:17:15.000000000 -0700
+++ linux-2.6.12-rc6-mm1/arch/i386/kernel/setup.c	2005-06-07 15:18:51.000000000 -0700
@@ -82,7 +82,8 @@ EXPORT_SYMBOL(efi_enabled);
 /* cpu data as detected by the assembly code in head.S */
 struct cpuinfo_x86 new_cpu_data __initdata = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
 /* common cpu data for all cpus */
-struct cpuinfo_x86 boot_cpu_data = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
+struct cpuinfo_x86 boot_cpu_data  __cacheline_aligned_mostly_readonly
+		= { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
 EXPORT_SYMBOL(boot_cpu_data);
 
 unsigned long mmu_cr4_features;
Index: linux-2.6.12-rc6-mm1/arch/i386/kernel/syscall_table.S
===================================================================
--- linux-2.6.12-rc6-mm1.orig/arch/i386/kernel/syscall_table.S	2005-06-07 15:17:15.000000000 -0700
+++ linux-2.6.12-rc6-mm1/arch/i386/kernel/syscall_table.S	2005-06-07 15:18:20.000000000 -0700
@@ -1,4 +1,3 @@
-.data
 ENTRY(sys_call_table)
 	.long sys_restart_syscall	/* 0 - old "setup()" system call, used for restarting */
 	.long sys_exit
Index: linux-2.6.12-rc6-mm1/arch/i386/kernel/timers/timer_hpet.c
===================================================================
--- linux-2.6.12-rc6-mm1.orig/arch/i386/kernel/timers/timer_hpet.c	2005-06-07 15:17:15.000000000 -0700
+++ linux-2.6.12-rc6-mm1/arch/i386/kernel/timers/timer_hpet.c	2005-06-07 15:18:20.000000000 -0700
@@ -180,7 +180,7 @@ static int __init init_hpet(char* overri
 /************************************************************/
 
 /* tsc timer_opts struct */
-static struct timer_opts timer_hpet = {
+static struct timer_opts timer_hpet __cacheline_aligned_mostly_readonly = {
 	.name = 		"hpet",
 	.mark_offset =		mark_offset_hpet,
 	.get_offset =		get_offset_hpet,

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

* Re: [PATCH] Move some more structures into "mostly_readonly"
  2005-06-07 22:23         ` christoph
@ 2005-06-07 22:54           ` Jeremy Maitin-Shepard
  2005-06-08  6:29             ` Arjan van de Ven
  0 siblings, 1 reply; 16+ messages in thread
From: Jeremy Maitin-Shepard @ 2005-06-07 22:54 UTC (permalink / raw)
  To: linux-kernel

christoph <christoph@scalex86.org> writes:

> On Tue, 7 Jun 2005, Brian Gerst wrote:
>> It doesn't really matter.  .rodata isn't actually mapped read-only. Doing so
>> would break up the large pages used to map the kernel.

> In that case.... here is a patch that moves the table into rodata.

AFS writes to the system call table.  If as Brian says, .rodata isn't
actually mapped read-only, then users of AFS could use this syscall
table patch without problems, but it is nonetheless pointless and
misleading.

-- 
Jeremy Maitin-Shepard

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

* Re: [PATCH] Move some more structures into "mostly_readonly"
  2005-06-07 22:54           ` Jeremy Maitin-Shepard
@ 2005-06-08  6:29             ` Arjan van de Ven
  2005-06-08 17:56               ` Jeremy Maitin-Shepard
  0 siblings, 1 reply; 16+ messages in thread
From: Arjan van de Ven @ 2005-06-08  6:29 UTC (permalink / raw)
  To: Jeremy Maitin-Shepard; +Cc: linux-kernel

On Tue, 2005-06-07 at 18:54 -0400, Jeremy Maitin-Shepard wrote:
> christoph <christoph@scalex86.org> writes:
> 
> > On Tue, 7 Jun 2005, Brian Gerst wrote:
> >> It doesn't really matter.  .rodata isn't actually mapped read-only. Doing so
> >> would break up the large pages used to map the kernel.
> 
> > In that case.... here is a patch that moves the table into rodata.
> 
> AFS writes to the system call table.  

afaik they stopped doing that for 2.6 now that the syscall table isn't
exported.



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

* Re: [PATCH] Move some more structures into "mostly_readonly"
  2005-06-07 21:31       ` Brian Gerst
  2005-06-07 22:23         ` christoph
@ 2005-06-08 10:00         ` Jörn Engel
  2005-06-08 10:07           ` Arjan van de Ven
  2005-06-08 14:24         ` Arnd Bergmann
  2 siblings, 1 reply; 16+ messages in thread
From: Jörn Engel @ 2005-06-08 10:00 UTC (permalink / raw)
  To: Brian Gerst
  Cc: Arjan van de Ven, christoph, Christoph Hellwig, akpm,
	linux-kernel

On Tue, 7 June 2005 17:31:19 -0400, Brian Gerst wrote:
> 
> It doesn't really matter.  .rodata isn't actually mapped read-only. 
> Doing so would break up the large pages used to map the kernel.

Can you confirm that for every architecture?  Or just i386?

Jörn

-- 
There is no worse hell than that provided by the regrets
for wasted opportunities.
-- Andre-Louis Moreau in Scarabouche

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

* Re: [PATCH] Move some more structures into "mostly_readonly"
  2005-06-08 10:00         ` Jörn Engel
@ 2005-06-08 10:07           ` Arjan van de Ven
  2005-06-08 10:20             ` Jörn Engel
  0 siblings, 1 reply; 16+ messages in thread
From: Arjan van de Ven @ 2005-06-08 10:07 UTC (permalink / raw)
  To: Jörn Engel
  Cc: Brian Gerst, christoph, Christoph Hellwig, akpm, linux-kernel

On Wed, 2005-06-08 at 12:00 +0200, Jörn Engel wrote:
> On Tue, 7 June 2005 17:31:19 -0400, Brian Gerst wrote:
> > 
> > It doesn't really matter.  .rodata isn't actually mapped read-only. 
> > Doing so would break up the large pages used to map the kernel.
> 
> Can you confirm that for every architecture?  Or just i386?

does it matter? it's supposed to be read only, only sometimes that's not
enforced unfortunately.



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

* Re: [PATCH] Move some more structures into "mostly_readonly"
  2005-06-08 10:07           ` Arjan van de Ven
@ 2005-06-08 10:20             ` Jörn Engel
  2005-06-08 10:35               ` Arjan van de Ven
  0 siblings, 1 reply; 16+ messages in thread
From: Jörn Engel @ 2005-06-08 10:20 UTC (permalink / raw)
  To: Arjan van de Ven
  Cc: Brian Gerst, christoph, Christoph Hellwig, akpm, linux-kernel

On Wed, 8 June 2005 12:07:25 +0200, Arjan van de Ven wrote:
> On Wed, 2005-06-08 at 12:00 +0200, Jörn Engel wrote:
> > On Tue, 7 June 2005 17:31:19 -0400, Brian Gerst wrote:
> > > 
> > > It doesn't really matter.  .rodata isn't actually mapped read-only. 
> > > Doing so would break up the large pages used to map the kernel.
> > 
> > Can you confirm that for every architecture?  Or just i386?
> 
> does it matter? it's supposed to be read only, only sometimes that's not
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> enforced unfortunately.

I agree.  What I don't agree with is "It doesn't really matter" - not
after debugging the occasional memory corruptions.

Jörn

-- 
The grand essentials of happiness are: something to do, something to
love, and something to hope for.
-- Allan K. Chalmers

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

* Re: [PATCH] Move some more structures into "mostly_readonly"
  2005-06-08 10:20             ` Jörn Engel
@ 2005-06-08 10:35               ` Arjan van de Ven
  2005-06-08 11:08                 ` Jörn Engel
  0 siblings, 1 reply; 16+ messages in thread
From: Arjan van de Ven @ 2005-06-08 10:35 UTC (permalink / raw)
  To: Jörn Engel
  Cc: Brian Gerst, christoph, Christoph Hellwig, akpm, linux-kernel

On Wed, 2005-06-08 at 12:20 +0200, Jörn Engel wrote:
> On Wed, 8 June 2005 12:07:25 +0200, Arjan van de Ven wrote:
> > On Wed, 2005-06-08 at 12:00 +0200, Jörn Engel wrote:
> > > On Tue, 7 June 2005 17:31:19 -0400, Brian Gerst wrote:
> > > > 
> > > > It doesn't really matter.  .rodata isn't actually mapped read-only. 
> > > > Doing so would break up the large pages used to map the kernel.
> > > 
> > > Can you confirm that for every architecture?  Or just i386?
> > 
> > does it matter? it's supposed to be read only, only sometimes that's not
>                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > enforced unfortunately.
> 
> I agree.  What I don't agree with is "It doesn't really matter" - not
> after debugging the occasional memory corruptions.

I agree, and it would be very useful to have a debug option in the
kernel that say checksums rodata (and probably the kernel text which is
also read only) periodically and raises an alarm if the checksum
changes. 


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

* Re: [PATCH] Move some more structures into "mostly_readonly"
  2005-06-08 10:35               ` Arjan van de Ven
@ 2005-06-08 11:08                 ` Jörn Engel
  0 siblings, 0 replies; 16+ messages in thread
From: Jörn Engel @ 2005-06-08 11:08 UTC (permalink / raw)
  To: Arjan van de Ven
  Cc: Brian Gerst, christoph, Christoph Hellwig, akpm, linux-kernel

On Wed, 8 June 2005 12:35:33 +0200, Arjan van de Ven wrote:
> 
> I agree, and it would be very useful to have a debug option in the
> kernel that say checksums rodata (and probably the kernel text which is
> also read only) periodically and raises an alarm if the checksum
> changes. 

Not really.  You want to catch the bad guy in the act.  A bit later
isn't much better than a lot later.

Lacking the mainframe key stores, I guess the best thing is to keep
.rodata under read-only tlbs.

Jörn

-- 
Sometimes, asking the right question is already the answer.
-- Unknown

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

* Re: [PATCH] Move some more structures into "mostly_readonly"
  2005-06-07 18:30 [PATCH] Move some more structures into "mostly_readonly" christoph
  2005-06-07 19:41 ` Christoph Hellwig
@ 2005-06-08 12:16 ` Pavel Machek
  1 sibling, 0 replies; 16+ messages in thread
From: Pavel Machek @ 2005-06-08 12:16 UTC (permalink / raw)
  To: christoph; +Cc: akpm, linux-kernel

Hi!

> Move syscall table, timer_hpet and the boot_cpu_data into the
> "mostly_readonly" section.

What is "mostly readonly" section usefull for? It looks ugly to my
eyes. Does it help performance or what?
								Pavel

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

* Re: [PATCH] Move some more structures into "mostly_readonly"
  2005-06-07 21:31       ` Brian Gerst
  2005-06-07 22:23         ` christoph
  2005-06-08 10:00         ` Jörn Engel
@ 2005-06-08 14:24         ` Arnd Bergmann
  2 siblings, 0 replies; 16+ messages in thread
From: Arnd Bergmann @ 2005-06-08 14:24 UTC (permalink / raw)
  To: Brian Gerst
  Cc: Arjan van de Ven, christoph, Christoph Hellwig, akpm,
	linux-kernel

On Dinsdag 07 Juni 2005 23:31, Brian Gerst wrote:
> 
> It doesn't really matter.  .rodata isn't actually mapped read-only. 
> Doing so would break up the large pages used to map the kernel.

There are some platforms that are able to have the .rodata section
of the kernel in ROM, and not all architectures support large pages,
so putting syscall_table and others into ROM could be a noticeable
advantage.

	Arnd <><

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

* Re: [PATCH] Move some more structures into "mostly_readonly"
  2005-06-08  6:29             ` Arjan van de Ven
@ 2005-06-08 17:56               ` Jeremy Maitin-Shepard
  0 siblings, 0 replies; 16+ messages in thread
From: Jeremy Maitin-Shepard @ 2005-06-08 17:56 UTC (permalink / raw)
  To: Arjan van de Ven; +Cc: linux-kernel

Arjan van de Ven <arjan@infradead.org> writes:

> On Tue, 2005-06-07 at 18:54 -0400, Jeremy Maitin-Shepard wrote:
>> AFS writes to the system call table.  

> afaik they stopped doing that for 2.6 now that the syscall table isn't
> exported.

I believe it is still done in 2.6; the syscall table is first located
using various heuristics.

-- 
Jeremy Maitin-Shepard

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

end of thread, other threads:[~2005-06-08 17:56 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-07 18:30 [PATCH] Move some more structures into "mostly_readonly" christoph
2005-06-07 19:41 ` Christoph Hellwig
2005-06-07 19:59   ` christoph
2005-06-07 20:59     ` Arjan van de Ven
2005-06-07 21:31       ` Brian Gerst
2005-06-07 22:23         ` christoph
2005-06-07 22:54           ` Jeremy Maitin-Shepard
2005-06-08  6:29             ` Arjan van de Ven
2005-06-08 17:56               ` Jeremy Maitin-Shepard
2005-06-08 10:00         ` Jörn Engel
2005-06-08 10:07           ` Arjan van de Ven
2005-06-08 10:20             ` Jörn Engel
2005-06-08 10:35               ` Arjan van de Ven
2005-06-08 11:08                 ` Jörn Engel
2005-06-08 14:24         ` Arnd Bergmann
2005-06-08 12:16 ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox