Skip to contentSkip to conversation

Fix __pfn_to_page(pfn) for CONFIG_DISCONTIGMEM=y

PATCH In review Rafael J. Wysocki 3 participants 11 messages Nov 8, 2008 – Nov 9, 2008 Generic include/asm header files

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix __pfn_to_page(pfn) for CONFIG_DISCONTIGMEM=y

Hi Andrew,

This would be good to have in .28 IMO.

Thanks,
Rafael

---
From: Rafael J. Wysocki <[email protected]>
Subject: Fix __pfn_to_page(pfn) for CONFIG_DISCONTIGMEM=y

Fix macro __pfn_to_page(pfn) so that it doesn't evaluate its argument twice in the CONFIG_DISCONTIGMEM=y case, because 'pfn' may be a result of a funtion call having side effects.

For example, the hibernation code applies pfn_to_page(pfn) to the result of a function returning the pfn corresponding to the next set bit in a bitmap and the current bit position is modified on each call. This leads to "interesting" failures for CONFIG_DISCONTIGMEM=y due to the current behavior of __pfn_to_page(pfn).

---
 include/asm-generic/memory_model.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/asm-generic/memory_model.h +1 -1
Index: linux-2.6/include/asm-generic/memory_model.h
===================================================================
@@ -34,7 +34,7 @@
 
 #define __pfn_to_page(pfn)			\
 ({	unsigned long __pfn = (pfn);		\
-	unsigned long __nid = arch_pfn_to_nid(pfn);  \
+	unsigned long __nid = arch_pfn_to_nid(__pfn);  \
 	NODE_DATA(__nid)->node_mem_map + arch_local_page_offset(__pfn, __nid);\
 })
 
Acked-by on v1 1/1
#1 lore raw

Hi!

Quoted 1 line

This would be good to have in .28 IMO.

Actually, this makes sense even for .27-stable, AFAICT.

Quoted 6 lines

From: Rafael J. Wysocki <[email protected]>
Subject: Fix __pfn_to_page(pfn) for CONFIG_DISCONTIGMEM=y

Fix macro __pfn_to_page(pfn) so that it doesn't evaluate its argument twice in the CONFIG_DISCONTIGMEM=y case, because 'pfn' may be a result of a funtion call having side effects.

function call?

Quoted 8 lines

For example, the hibernation code applies pfn_to_page(pfn) to the result of a function returning the pfn corresponding to the next set bit in a bitmap and the current bit position is modified on each call. This leads to "interesting" failures for CONFIG_DISCONTIGMEM=y due to the current behavior of __pfn_to_page(pfn).

Quoted 16 lines
 include/asm-generic/memory_model.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/include/asm-generic/memory_model.h
===================================================================

include/asm-generic/memory_model.h +1 -1
@@ -34,7 +34,7 @@
 
 #define __pfn_to_page(pfn)			\
 ({	unsigned long __pfn = (pfn);		\
-	unsigned long __nid = arch_pfn_to_nid(pfn);  \
+	unsigned long __nid = arch_pfn_to_nid(__pfn);  \
 	NODE_DATA(__nid)->node_mem_map + arch_local_page_offset(__pfn, __nid);\
 })
 
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#2 lore raw
Quoted 5 lines · Pavel Machek

Hi!

Quoted 1 line

This would be good to have in .28 IMO.

Actually, this makes sense even for .27-stable, AFAICT.

Yes, it does, but it has to be merged first. :-)

Quoted 8 lines
Quoted 6 lines

From: Rafael J. Wysocki <[email protected]>
Subject: Fix __pfn_to_page(pfn) for CONFIG_DISCONTIGMEM=y

Fix macro __pfn_to_page(pfn) so that it doesn't evaluate its argument twice in the CONFIG_DISCONTIGMEM=y case, because 'pfn' may be a result of a funtion call having side effects.

function call?

Oh, I mean __pfn_to_page(a_function(something)), where a_function() does more than just computing the result.

Quoted 21 lines
Quoted 8 lines

For example, the hibernation code applies pfn_to_page(pfn) to the result of a function returning the pfn corresponding to the next set bit in a bitmap and the current bit position is modified on each call. This leads to "interesting" failures for CONFIG_DISCONTIGMEM=y due to the current behavior of __pfn_to_page(pfn).

Quoted 9 lines
 include/asm-generic/memory_model.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/include/asm-generic/memory_model.h
===================================================================

include/asm-generic/memory_model.h +0 -0
@@ -34,7 +34,7 @@
 
Quoted 6 lines

include/asm-generic/memory_model.h line 39

Quoted 6 lines
include/asm-generic/memory_model.h +1 -1
 #define __pfn_to_page(pfn)			\
 ({	unsigned long __pfn = (pfn);		\
-	unsigned long __nid = arch_pfn_to_nid(pfn);  \
+	unsigned long __nid = arch_pfn_to_nid(__pfn);  \
 	NODE_DATA(__nid)->node_mem_map + arch_local_page_offset(__pfn, __nid);\
 })

Thanks,
Rafael

#3 lore raw
Quoted 8 lines · On Sat, 8 Nov 2008 14:12:21 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 5 lines · Pavel Machek

Hi!

Quoted 1 line

This would be good to have in .28 IMO.

Actually, this makes sense even for .27-stable, AFAICT.

Yes, it does, but it has to be merged first. :-)

It applies to 2.6.26 (at least). Is there no need for it in kernels earlier than 2.6.27.x?

#4 lore raw
In reply to Rafael J. Wysocki
Quoted 8 lines · On Sat, 8 Nov 2008 14:12:21 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 5 lines · Pavel Machek

Hi!

Quoted 1 line

This would be good to have in .28 IMO.

Actually, this makes sense even for .27-stable, AFAICT.

Yes, it does, but it has to be merged first. :-)

It applies to 2.6.26 (at least). Is there no need for it in kernels earlier than 2.6.27.x?

#5 lore raw
Quoted 5 lines · Andrew Morton
Quoted 3 lines · On Sat, 8 Nov 2008 14:12:21 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 2 lines · Pavel Machek

Hi!

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

This would be good to have in .28 IMO.

Actually, this makes sense even for .27-stable, AFAICT.

Yes, it does, but it has to be merged first. :-)

It applies to 2.6.26 (at least). Is there no need for it in kernels earlier than 2.6.27.x?

It would be nice to fix it there, too. (OTOH that config never worked and we did not see huge pile of complains, so I guess the world would not fall down if it was not in 2.6.26...)
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#6 lore raw
Quoted 10 lines · Pavel Machek
Quoted 9 lines · Andrew Morton
Quoted 7 lines · On Sat, 8 Nov 2008 14:12:21 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 5 lines · Pavel Machek

Hi!

Quoted 1 line

This would be good to have in .28 IMO.

Actually, this makes sense even for .27-stable, AFAICT.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Yes, it does, but it has to be merged first. :-)

It applies to 2.6.26 (at least). Is there no need for it in kernels earlier than 2.6.27.x?

It would be nice to fix it there, too. (OTOH that config never worked and we did not see huge pile of complains, so I guess the world would not fall down if it was not in 2.6.26...)

Yes, it's a bug, so it would be nice to fix it. Still, the practical meaning of the fix would be minimal in 2.6.26 and earlier kernels IMO.

Thanks,
Rafael

#7 lore raw
In reply to Pavel Machek
Quoted 10 lines · Pavel Machek
Quoted 9 lines · Andrew Morton
Quoted 7 lines · On Sat, 8 Nov 2008 14:12:21 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 5 lines · Pavel Machek

Hi!

Quoted 1 line

This would be good to have in .28 IMO.

Actually, this makes sense even for .27-stable, AFAICT.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Yes, it does, but it has to be merged first. :-)

It applies to 2.6.26 (at least). Is there no need for it in kernels earlier than 2.6.27.x?

It would be nice to fix it there, too. (OTOH that config never worked and we did not see huge pile of complains, so I guess the world would not fall down if it was not in 2.6.26...)

Yes, it's a bug, so it would be nice to fix it. Still, the practical meaning of the fix would be minimal in 2.6.26 and earlier kernels IMO.

Thanks,
Rafael

#8 lore raw
In reply to Andrew Morton
Quoted 5 lines · Andrew Morton
Quoted 3 lines · On Sat, 8 Nov 2008 14:12:21 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 2 lines · Pavel Machek

Hi!

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

This would be good to have in .28 IMO.

Actually, this makes sense even for .27-stable, AFAICT.

Yes, it does, but it has to be merged first. :-)

It applies to 2.6.26 (at least). Is there no need for it in kernels earlier than 2.6.27.x?

It would be nice to fix it there, too. (OTOH that config never worked and we did not see huge pile of complains, so I guess the world would not fall down if it was not in 2.6.26...)
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#9 lore raw
In reply to Pavel Machek
Quoted 5 lines · Pavel Machek

Hi!

Quoted 1 line

This would be good to have in .28 IMO.

Actually, this makes sense even for .27-stable, AFAICT.

Yes, it does, but it has to be merged first. :-)

Quoted 8 lines
Quoted 6 lines

From: Rafael J. Wysocki <[email protected]>
Subject: Fix __pfn_to_page(pfn) for CONFIG_DISCONTIGMEM=y

Fix macro __pfn_to_page(pfn) so that it doesn't evaluate its argument twice in the CONFIG_DISCONTIGMEM=y case, because 'pfn' may be a result of a funtion call having side effects.

function call?

Oh, I mean __pfn_to_page(a_function(something)), where a_function() does more than just computing the result.

Quoted 21 lines
Quoted 8 lines

For example, the hibernation code applies pfn_to_page(pfn) to the result of a function returning the pfn corresponding to the next set bit in a bitmap and the current bit position is modified on each call. This leads to "interesting" failures for CONFIG_DISCONTIGMEM=y due to the current behavior of __pfn_to_page(pfn).

Quoted 9 lines
 include/asm-generic/memory_model.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/include/asm-generic/memory_model.h
===================================================================

include/asm-generic/memory_model.h +0 -0
@@ -34,7 +34,7 @@
 
Quoted 6 lines

include/asm-generic/memory_model.h line 39

Quoted 6 lines
include/asm-generic/memory_model.h +1 -1
 #define __pfn_to_page(pfn)			\
 ({	unsigned long __pfn = (pfn);		\
-	unsigned long __nid = arch_pfn_to_nid(pfn);  \
+	unsigned long __nid = arch_pfn_to_nid(__pfn);  \
 	NODE_DATA(__nid)->node_mem_map + arch_local_page_offset(__pfn, __nid);\
 })

Thanks,
Rafael

Acked-by on v1 1/1
#10 lore raw
In reply to Rafael J. Wysocki

Hi!

Quoted 1 line

This would be good to have in .28 IMO.

Actually, this makes sense even for .27-stable, AFAICT.

Quoted 6 lines

From: Rafael J. Wysocki <[email protected]>
Subject: Fix __pfn_to_page(pfn) for CONFIG_DISCONTIGMEM=y

Fix macro __pfn_to_page(pfn) so that it doesn't evaluate its argument twice in the CONFIG_DISCONTIGMEM=y case, because 'pfn' may be a result of a funtion call having side effects.

function call?

Quoted 8 lines

For example, the hibernation code applies pfn_to_page(pfn) to the result of a function returning the pfn corresponding to the next set bit in a bitmap and the current bit position is modified on each call. This leads to "interesting" failures for CONFIG_DISCONTIGMEM=y due to the current behavior of __pfn_to_page(pfn).

Quoted 16 lines
 include/asm-generic/memory_model.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/include/asm-generic/memory_model.h
===================================================================

include/asm-generic/memory_model.h +1 -1
@@ -34,7 +34,7 @@
 
 #define __pfn_to_page(pfn)			\
 ({	unsigned long __pfn = (pfn);		\
-	unsigned long __nid = arch_pfn_to_nid(pfn);  \
+	unsigned long __nid = arch_pfn_to_nid(__pfn);  \
 	NODE_DATA(__nid)->node_mem_map + arch_local_page_offset(__pfn, __nid);\
 })
 
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html