mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Fix __pfn_to_page(pfn) for CONFIG_DISCONTIGMEM=y
@ 2008-11-08 12:53 Rafael J. Wysocki
  2008-11-08 12:59 ` Pavel Machek
  0 siblings, 1 reply; 6+ messages in thread
From: Rafael J. Wysocki @ 2008-11-08 12:53 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Linus Torvalds, LKML, Pavel Machek, pm list

Hi Andrew,

This would be good to have in .28 IMO.

Thanks,
Rafael


---
From: Rafael J. Wysocki <rjw@sisk.pl>
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).

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Pavel Machek <pavel@suse.cz>
---
 include/asm-generic/memory_model.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/include/asm-generic/memory_model.h
===================================================================
--- linux-2.6.orig/include/asm-generic/memory_model.h
+++ 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);\
 })
 

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

* Re: [PATCH] Fix __pfn_to_page(pfn) for CONFIG_DISCONTIGMEM=y
  2008-11-08 12:53 [PATCH] Fix __pfn_to_page(pfn) for CONFIG_DISCONTIGMEM=y Rafael J. Wysocki
@ 2008-11-08 12:59 ` Pavel Machek
  2008-11-08 13:12   ` Rafael J. Wysocki
  0 siblings, 1 reply; 6+ messages in thread
From: Pavel Machek @ 2008-11-08 12:59 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Andrew Morton, Linus Torvalds, LKML, pm list

Hi!

> This would be good to have in .28 IMO.

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

> From: Rafael J. Wysocki <rjw@sisk.pl>
> 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?

> 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).
> 
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> Cc: Pavel Machek <pavel@suse.cz>

Acked-by: Pavel Machek <pavel@suse.cz>


>  include/asm-generic/memory_model.h |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Index: linux-2.6/include/asm-generic/memory_model.h
> ===================================================================
> --- linux-2.6.orig/include/asm-generic/memory_model.h
> +++ 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);\
>  })
>  

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

* Re: [PATCH] Fix __pfn_to_page(pfn) for CONFIG_DISCONTIGMEM=y
  2008-11-08 12:59 ` Pavel Machek
@ 2008-11-08 13:12   ` Rafael J. Wysocki
  2008-11-09  5:54     ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Rafael J. Wysocki @ 2008-11-08 13:12 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Andrew Morton, Linus Torvalds, LKML, pm list

On Saturday, 8 of November 2008, Pavel Machek wrote:
> Hi!
> 
> > 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. :-)

> > From: Rafael J. Wysocki <rjw@sisk.pl>
> > 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.
 
> > 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).
> > 
> > Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> > Cc: Pavel Machek <pavel@suse.cz>
> 
> Acked-by: Pavel Machek <pavel@suse.cz>
> 
> 
> >  include/asm-generic/memory_model.h |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > Index: linux-2.6/include/asm-generic/memory_model.h
> > ===================================================================
> > --- linux-2.6.orig/include/asm-generic/memory_model.h
> > +++ 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);\
> >  })

Thanks,
Rafael

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

* Re: [PATCH] Fix __pfn_to_page(pfn) for CONFIG_DISCONTIGMEM=y
  2008-11-08 13:12   ` Rafael J. Wysocki
@ 2008-11-09  5:54     ` Andrew Morton
  2008-11-09 11:37       ` Pavel Machek
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2008-11-09  5:54 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Pavel Machek, Linus Torvalds, LKML, pm list

On Sat, 8 Nov 2008 14:12:21 +0100 "Rafael J. Wysocki" <rjw@sisk.pl> wrote:

> On Saturday, 8 of November 2008, Pavel Machek wrote:
> > Hi!
> > 
> > > 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?

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

* Re: [PATCH] Fix __pfn_to_page(pfn) for CONFIG_DISCONTIGMEM=y
  2008-11-09  5:54     ` Andrew Morton
@ 2008-11-09 11:37       ` Pavel Machek
  2008-11-09 13:17         ` Rafael J. Wysocki
  0 siblings, 1 reply; 6+ messages in thread
From: Pavel Machek @ 2008-11-09 11:37 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Rafael J. Wysocki, Linus Torvalds, LKML, pm list

On Sat 2008-11-08 21:54:58, Andrew Morton wrote:
> On Sat, 8 Nov 2008 14:12:21 +0100 "Rafael J. Wysocki" <rjw@sisk.pl> wrote:
> 
> > On Saturday, 8 of November 2008, Pavel Machek wrote:
> > > Hi!
> > > 
> > > > 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
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

* Re: [PATCH] Fix __pfn_to_page(pfn) for CONFIG_DISCONTIGMEM=y
  2008-11-09 11:37       ` Pavel Machek
@ 2008-11-09 13:17         ` Rafael J. Wysocki
  0 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2008-11-09 13:17 UTC (permalink / raw)
  To: Pavel Machek, Andrew Morton; +Cc: Linus Torvalds, LKML, pm list

On Sunday, 9 of November 2008, Pavel Machek wrote:
> On Sat 2008-11-08 21:54:58, Andrew Morton wrote:
> > On Sat, 8 Nov 2008 14:12:21 +0100 "Rafael J. Wysocki" <rjw@sisk.pl> wrote:
> > 
> > > On Saturday, 8 of November 2008, Pavel Machek wrote:
> > > > Hi!
> > > > 
> > > > > 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...)

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

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

end of thread, other threads:[~2008-11-09 13:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-08 12:53 [PATCH] Fix __pfn_to_page(pfn) for CONFIG_DISCONTIGMEM=y Rafael J. Wysocki
2008-11-08 12:59 ` Pavel Machek
2008-11-08 13:12   ` Rafael J. Wysocki
2008-11-09  5:54     ` Andrew Morton
2008-11-09 11:37       ` Pavel Machek
2008-11-09 13:17         ` Rafael J. Wysocki

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

all inboxes | Powered by JetHome®