* [PATCH] revert to static = {0}
@ 2003-08-05 15:48 Hugh Dickins
2003-08-05 16:07 ` Arjan van de Ven
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Hugh Dickins @ 2003-08-05 15:48 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Andrew Morton, Randy Dunlap, Leann Ogasawara, linux-kernel
Please revert to static zero initialization of a const: when thus
initialized it's linked into a readonly cacheline shared between cpus;
otherwise it's linked into bss, likely to be in a dirty cacheline
bouncing between cpus.
--- 2.6.0-test2-bk/mm/shmem.c Tue Aug 5 15:57:31 2003
+++ linux/mm/shmem.c Tue Aug 5 16:16:55 2003
@@ -296,7 +296,7 @@
struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
struct page *page = NULL;
swp_entry_t *entry;
- static const swp_entry_t unswapped;
+ static const swp_entry_t unswapped = {0};
if (sgp != SGP_WRITE &&
((loff_t) index << PAGE_CACHE_SHIFT) >= i_size_read(inode))
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] revert to static = {0}
2003-08-05 15:48 [PATCH] revert to static = {0} Hugh Dickins
@ 2003-08-05 16:07 ` Arjan van de Ven
2003-08-05 18:41 ` [PATCH] revert to static = {0} + comment Hugh Dickins
2003-08-05 16:09 ` [PATCH] revert to static = {0} Randy.Dunlap
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Arjan van de Ven @ 2003-08-05 16:07 UTC (permalink / raw)
To: Hugh Dickins
Cc: Linus Torvalds, Andrew Morton, Randy Dunlap, Leann Ogasawara,
linux-kernel
[-- Attachment #1: Type: text/plain, Size: 395 bytes --]
On Tue, 2003-08-05 at 17:48, Hugh Dickins wrote:
> Please revert to static zero initialization of a const: when thus
> initialized it's linked into a readonly cacheline shared between cpus;
> otherwise it's linked into bss, likely to be in a dirty cacheline
> bouncing between cpus.
how about adding a big fat comment here that says this?
Otherwise this keeps happening all the time...
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] revert to static = {0}
2003-08-05 15:48 [PATCH] revert to static = {0} Hugh Dickins
2003-08-05 16:07 ` Arjan van de Ven
@ 2003-08-05 16:09 ` Randy.Dunlap
2003-08-05 18:49 ` Hugh Dickins
2003-08-05 16:18 ` Lou Langholtz
2003-08-05 17:44 ` Jeff Garzik
3 siblings, 1 reply; 10+ messages in thread
From: Randy.Dunlap @ 2003-08-05 16:09 UTC (permalink / raw)
To: Hugh Dickins; +Cc: torvalds, akpm, ogasawara, linux-kernel
On Tue, 5 Aug 2003 16:48:02 +0100 (BST) Hugh Dickins <hugh@veritas.com> wrote:
| Please revert to static zero initialization of a const: when thus
| initialized it's linked into a readonly cacheline shared between cpus;
| otherwise it's linked into bss, likely to be in a dirty cacheline
| bouncing between cpus.
|
| --- 2.6.0-test2-bk/mm/shmem.c Tue Aug 5 15:57:31 2003
| +++ linux/mm/shmem.c Tue Aug 5 16:16:55 2003
| @@ -296,7 +296,7 @@
| struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
| struct page *page = NULL;
| swp_entry_t *entry;
| - static const swp_entry_t unswapped;
| + static const swp_entry_t unswapped = {0};
In all of the "don't init statics to 0" patches, should we
check for "const" also and leave those with 0 initializers
(with explanation as Arjan requested)?
--
~Randy
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] revert to static = {0}
2003-08-05 15:48 [PATCH] revert to static = {0} Hugh Dickins
2003-08-05 16:07 ` Arjan van de Ven
2003-08-05 16:09 ` [PATCH] revert to static = {0} Randy.Dunlap
@ 2003-08-05 16:18 ` Lou Langholtz
2003-08-05 17:44 ` Jeff Garzik
3 siblings, 0 replies; 10+ messages in thread
From: Lou Langholtz @ 2003-08-05 16:18 UTC (permalink / raw)
To: Hugh Dickins
Cc: Linus Torvalds, Andrew Morton, Randy Dunlap, Leann Ogasawara,
linux-kernel
Hugh Dickins wrote:
>Please revert to static zero initialization of a const: when thus
>initialized it's linked into a readonly cacheline shared between cpus;
>otherwise it's linked into bss, likely to be in a dirty cacheline
>bouncing between cpus.
>
>--- 2.6.0-test2-bk/mm/shmem.c Tue Aug 5 15:57:31 2003
>+++ linux/mm/shmem.c Tue Aug 5 16:16:55 2003
>@@ -296,7 +296,7 @@
> struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
> struct page *page = NULL;
> swp_entry_t *entry;
>- static const swp_entry_t unswapped;
>+ static const swp_entry_t unswapped = {0};
>
> if (sgp != SGP_WRITE &&
> ((loff_t) index << PAGE_CACHE_SHIFT) >= i_size_read(inode))
>
>
If this static zero initialization makes it into the kernel distro for
the given reason, please also add a comment sharing your above mentioned
reasoning.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] revert to static = {0}
2003-08-05 15:48 [PATCH] revert to static = {0} Hugh Dickins
` (2 preceding siblings ...)
2003-08-05 16:18 ` Lou Langholtz
@ 2003-08-05 17:44 ` Jeff Garzik
2003-08-05 18:51 ` Hugh Dickins
3 siblings, 1 reply; 10+ messages in thread
From: Jeff Garzik @ 2003-08-05 17:44 UTC (permalink / raw)
To: Hugh Dickins
Cc: Linus Torvalds, Andrew Morton, Randy Dunlap, Leann Ogasawara,
linux-kernel
On Tue, Aug 05, 2003 at 04:48:02PM +0100, Hugh Dickins wrote:
> Please revert to static zero initialization of a const: when thus
> initialized it's linked into a readonly cacheline shared between cpus;
> otherwise it's linked into bss, likely to be in a dirty cacheline
> bouncing between cpus.
>
> --- 2.6.0-test2-bk/mm/shmem.c Tue Aug 5 15:57:31 2003
> +++ linux/mm/shmem.c Tue Aug 5 16:16:55 2003
> @@ -296,7 +296,7 @@
> struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
> struct page *page = NULL;
> swp_entry_t *entry;
> - static const swp_entry_t unswapped;
> + static const swp_entry_t unswapped = {0};
>
> if (sgp != SGP_WRITE &&
> ((loff_t) index << PAGE_CACHE_SHIFT) >= i_size_read(inode))
>
If it's const, it shouldn't be linked into anything at all... right?
Jeff
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] revert to static = {0} + comment
2003-08-05 16:07 ` Arjan van de Ven
@ 2003-08-05 18:41 ` Hugh Dickins
0 siblings, 0 replies; 10+ messages in thread
From: Hugh Dickins @ 2003-08-05 18:41 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Arjan van de Ven, linux-kernel
Please revert to static zero initialization of a const: when thus
initialized it's linked into a readonly cacheline shared between cpus;
otherwise it's linked into bss, likely to be in a dirty cacheline
bouncing between cpus.
On 5 Aug 2003, Arjan van de Ven wrote:
> how about adding a big fat comment here that says this?
> Otherwise this keeps happening all the time...
and others concurred.
Okay, by popular request, here it is with a small thin comment.
--- 2.6.0-test2-bk/mm/shmem.c Tue Aug 5 15:57:31 2003
+++ linux/mm/shmem.c Tue Aug 5 19:29:16 2003
@@ -296,7 +296,8 @@
struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
struct page *page = NULL;
swp_entry_t *entry;
- static const swp_entry_t unswapped;
+ static const swp_entry_t unswapped = {0};
+ /* = {0} to go in readonly data, to avoid bss cacheline bounce */
if (sgp != SGP_WRITE &&
((loff_t) index << PAGE_CACHE_SHIFT) >= i_size_read(inode))
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] revert to static = {0}
2003-08-05 16:09 ` [PATCH] revert to static = {0} Randy.Dunlap
@ 2003-08-05 18:49 ` Hugh Dickins
0 siblings, 0 replies; 10+ messages in thread
From: Hugh Dickins @ 2003-08-05 18:49 UTC (permalink / raw)
To: Randy.Dunlap; +Cc: linux-kernel
On Tue, 5 Aug 2003, Randy.Dunlap wrote:
>
> In all of the "don't init statics to 0" patches, should we
> check for "const" also and leave those with 0 initializers
> (with explanation as Arjan requested)?
It's certainly something to consider. This was my "= {0}" so
I know the reasoning, but I've not looked at and won't speak for others.
Hugh
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] revert to static = {0}
2003-08-05 17:44 ` Jeff Garzik
@ 2003-08-05 18:51 ` Hugh Dickins
2003-08-05 19:06 ` William Lee Irwin III
0 siblings, 1 reply; 10+ messages in thread
From: Hugh Dickins @ 2003-08-05 18:51 UTC (permalink / raw)
To: Jeff Garzik; +Cc: linux-kernel
On Tue, 5 Aug 2003, Jeff Garzik wrote:
>
> If it's const, it shouldn't be linked into anything at all... right?
Sorry, Jeff, I don't get your point.
Hugh
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] revert to static = {0}
2003-08-05 18:51 ` Hugh Dickins
@ 2003-08-05 19:06 ` William Lee Irwin III
2003-08-05 21:13 ` Jeff Garzik
0 siblings, 1 reply; 10+ messages in thread
From: William Lee Irwin III @ 2003-08-05 19:06 UTC (permalink / raw)
To: Hugh Dickins; +Cc: Jeff Garzik, linux-kernel
On Tue, 5 Aug 2003, Jeff Garzik wrote:
>> If it's const, it shouldn't be linked into anything at all... right?
On Tue, Aug 05, 2003 at 07:51:41PM +0100, Hugh Dickins wrote:
> Sorry, Jeff, I don't get your point.
I suspect this assumes const values will get constant folded, which I'm
not sure is the case, though it certainly sounds legal and worthwhile
for a compiler to do when reasonable (i.e. for small structures and/or
extractions of small fields of const structures).
-- wli
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] revert to static = {0}
2003-08-05 19:06 ` William Lee Irwin III
@ 2003-08-05 21:13 ` Jeff Garzik
0 siblings, 0 replies; 10+ messages in thread
From: Jeff Garzik @ 2003-08-05 21:13 UTC (permalink / raw)
To: William Lee Irwin III; +Cc: Hugh Dickins, linux-kernel
William Lee Irwin III wrote:
> On Tue, 5 Aug 2003, Jeff Garzik wrote:
>
>>>If it's const, it shouldn't be linked into anything at all... right?
>
>
> On Tue, Aug 05, 2003 at 07:51:41PM +0100, Hugh Dickins wrote:
>
>>Sorry, Jeff, I don't get your point.
>
>
> I suspect this assumes const values will get constant folded, which I'm
> not sure is the case, though it certainly sounds legal and worthwhile
> for a compiler to do when reasonable (i.e. for small structures and/or
> extractions of small fields of const structures).
Correct. In fact, some Linux kernel code _assumes_ the compiler will
fold constants...
Jeff
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2003-08-05 21:13 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-05 15:48 [PATCH] revert to static = {0} Hugh Dickins
2003-08-05 16:07 ` Arjan van de Ven
2003-08-05 18:41 ` [PATCH] revert to static = {0} + comment Hugh Dickins
2003-08-05 16:09 ` [PATCH] revert to static = {0} Randy.Dunlap
2003-08-05 18:49 ` Hugh Dickins
2003-08-05 16:18 ` Lou Langholtz
2003-08-05 17:44 ` Jeff Garzik
2003-08-05 18:51 ` Hugh Dickins
2003-08-05 19:06 ` William Lee Irwin III
2003-08-05 21:13 ` Jeff Garzik
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).