public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] silence unused pgdat warning from alloc_bootmem_node and friends
@ 2006-11-22 14:38 Andy Whitcroft
  2006-11-22 21:24 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Whitcroft @ 2006-11-22 14:38 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, apw

silence unused pgdat warning from alloc_bootmem_node and friends

x86 NUMA systems only define bootmem for node 0.  alloc_bootmem_node()
and friends therefore ignore the passed pgdat and use NODE_DATA(0)
in all cases.  This leads to the following warnings as we are not
using the passed parameter:

  .../mm/page_alloc.c: In function 'zone_wait_table_init':
  .../mm/page_alloc.c:2259: warning: unused variable 'pgdat'

One option would be to define all variables used with these macros
__attribute__ ((unused)), but this would leave us exposed should
these become genuinely unused.

The key here is that we _are_ using the value, we ignore it but that
is a deliberate action.  This patch adds a nested local variable
within the alloc_bootmem_node helper to which the pgdat parameter is
assigned making it 'used'.  The nested local is marked __attribute__
((unused)) to silence this same warning for it.

Against 2.6.19-rc5-mm2.

Signed-off-by: Andy Whitcroft <apw@shadowen.org>
---
diff --git a/include/asm-i386/mmzone.h b/include/asm-i386/mmzone.h
index 61b0733..3503ad6 100644
--- a/include/asm-i386/mmzone.h
+++ b/include/asm-i386/mmzone.h
@@ -120,13 +120,26 @@ static inline int pfn_valid(int pfn)
 	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
 #define alloc_bootmem_low_pages(x) \
 	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0)
-#define alloc_bootmem_node(ignore, x) \
-	__alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
-#define alloc_bootmem_pages_node(ignore, x) \
-	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
-#define alloc_bootmem_low_pages_node(ignore, x) \
-	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0)
-
+#define alloc_bootmem_node(pgdat, x)					\
+({									\
+	struct pglist_data  __attribute__ ((unused))			\
+				*__alloc_bootmem_node__pgdat = (pgdat);	\
+	__alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES,	\
+						__pa(MAX_DMA_ADDRESS));	\
+})
+#define alloc_bootmem_pages_node(pgdat, x)				\
+({									\
+	struct pglist_data  __attribute__ ((unused))			\
+				*__alloc_bootmem_node__pgdat = (pgdat);	\
+	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE,		\
+						__pa(MAX_DMA_ADDRESS))	\
+})
+#define alloc_bootmem_low_pages_node(pgdat, x)				\
+({									\
+	struct pglist_data  __attribute__ ((unused))			\
+				*__alloc_bootmem_node__pgdat = (pgdat);	\
+	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0);		\
+})
 #endif /* CONFIG_NEED_MULTIPLE_NODES */
 
 #endif /* _ASM_MMZONE_H_ */

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

* Re: [PATCH] silence unused pgdat warning from alloc_bootmem_node and friends
  2006-11-22 14:38 [PATCH] silence unused pgdat warning from alloc_bootmem_node and friends Andy Whitcroft
@ 2006-11-22 21:24 ` Andrew Morton
  2006-11-23  9:16   ` Andy Whitcroft
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2006-11-22 21:24 UTC (permalink / raw)
  To: Andy Whitcroft; +Cc: linux-kernel

On Wed, 22 Nov 2006 14:38:51 +0000
Andy Whitcroft <apw@shadowen.org> wrote:

> silence unused pgdat warning from alloc_bootmem_node and friends
> 
> x86 NUMA systems only define bootmem for node 0.  alloc_bootmem_node()
> and friends therefore ignore the passed pgdat and use NODE_DATA(0)
> in all cases.  This leads to the following warnings as we are not
> using the passed parameter:
> 
>   .../mm/page_alloc.c: In function 'zone_wait_table_init':
>   .../mm/page_alloc.c:2259: warning: unused variable 'pgdat'
> 
> One option would be to define all variables used with these macros
> __attribute__ ((unused)), but this would leave us exposed should
> these become genuinely unused.
> 
> The key here is that we _are_ using the value, we ignore it but that
> is a deliberate action.  This patch adds a nested local variable
> within the alloc_bootmem_node helper to which the pgdat parameter is
> assigned making it 'used'.  The nested local is marked __attribute__
> ((unused)) to silence this same warning for it.
> 
> Against 2.6.19-rc5-mm2.
> 
> Signed-off-by: Andy Whitcroft <apw@shadowen.org>
> ---
> diff --git a/include/asm-i386/mmzone.h b/include/asm-i386/mmzone.h
> index 61b0733..3503ad6 100644
> --- a/include/asm-i386/mmzone.h
> +++ b/include/asm-i386/mmzone.h
> @@ -120,13 +120,26 @@ static inline int pfn_valid(int pfn)
>  	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
>  #define alloc_bootmem_low_pages(x) \
>  	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0)
> -#define alloc_bootmem_node(ignore, x) \
> -	__alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
> -#define alloc_bootmem_pages_node(ignore, x) \
> -	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
> -#define alloc_bootmem_low_pages_node(ignore, x) \
> -	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0)
> -
> +#define alloc_bootmem_node(pgdat, x)					\
> +({									\
> +	struct pglist_data  __attribute__ ((unused))			\
> +				*__alloc_bootmem_node__pgdat = (pgdat);	\
> +	__alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES,	\
> +						__pa(MAX_DMA_ADDRESS));	\
> +})
> +#define alloc_bootmem_pages_node(pgdat, x)				\
> +({									\
> +	struct pglist_data  __attribute__ ((unused))			\
> +				*__alloc_bootmem_node__pgdat = (pgdat);	\
> +	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE,		\
> +						__pa(MAX_DMA_ADDRESS))	\
> +})
> +#define alloc_bootmem_low_pages_node(pgdat, x)				\
> +({									\
> +	struct pglist_data  __attribute__ ((unused))			\
> +				*__alloc_bootmem_node__pgdat = (pgdat);	\
> +	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0);		\
> +})
>  #endif /* CONFIG_NEED_MULTIPLE_NODES */
>  

Can these be switched to functions, or do they actually need to be macros?



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

* Re: [PATCH] silence unused pgdat warning from alloc_bootmem_node and friends
  2006-11-22 21:24 ` Andrew Morton
@ 2006-11-23  9:16   ` Andy Whitcroft
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Whitcroft @ 2006-11-23  9:16 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

Andrew Morton wrote:
> On Wed, 22 Nov 2006 14:38:51 +0000
> Andy Whitcroft <apw@shadowen.org> wrote:
> 
>> silence unused pgdat warning from alloc_bootmem_node and friends
>>
>> x86 NUMA systems only define bootmem for node 0.  alloc_bootmem_node()
>> and friends therefore ignore the passed pgdat and use NODE_DATA(0)
>> in all cases.  This leads to the following warnings as we are not
>> using the passed parameter:
>>
>>   .../mm/page_alloc.c: In function 'zone_wait_table_init':
>>   .../mm/page_alloc.c:2259: warning: unused variable 'pgdat'
>>
>> One option would be to define all variables used with these macros
>> __attribute__ ((unused)), but this would leave us exposed should
>> these become genuinely unused.
>>
>> The key here is that we _are_ using the value, we ignore it but that
>> is a deliberate action.  This patch adds a nested local variable
>> within the alloc_bootmem_node helper to which the pgdat parameter is
>> assigned making it 'used'.  The nested local is marked __attribute__
>> ((unused)) to silence this same warning for it.
>>
>> Against 2.6.19-rc5-mm2.
>>
>> Signed-off-by: Andy Whitcroft <apw@shadowen.org>
>> ---
>> diff --git a/include/asm-i386/mmzone.h b/include/asm-i386/mmzone.h
>> index 61b0733..3503ad6 100644
>> --- a/include/asm-i386/mmzone.h
>> +++ b/include/asm-i386/mmzone.h
>> @@ -120,13 +120,26 @@ static inline int pfn_valid(int pfn)
>>  	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
>>  #define alloc_bootmem_low_pages(x) \
>>  	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0)
>> -#define alloc_bootmem_node(ignore, x) \
>> -	__alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
>> -#define alloc_bootmem_pages_node(ignore, x) \
>> -	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
>> -#define alloc_bootmem_low_pages_node(ignore, x) \
>> -	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0)
>> -
>> +#define alloc_bootmem_node(pgdat, x)					\
>> +({									\
>> +	struct pglist_data  __attribute__ ((unused))			\
>> +				*__alloc_bootmem_node__pgdat = (pgdat);	\
>> +	__alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES,	\
>> +						__pa(MAX_DMA_ADDRESS));	\
>> +})
>> +#define alloc_bootmem_pages_node(pgdat, x)				\
>> +({									\
>> +	struct pglist_data  __attribute__ ((unused))			\
>> +				*__alloc_bootmem_node__pgdat = (pgdat);	\
>> +	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE,		\
>> +						__pa(MAX_DMA_ADDRESS))	\
>> +})
>> +#define alloc_bootmem_low_pages_node(pgdat, x)				\
>> +({									\
>> +	struct pglist_data  __attribute__ ((unused))			\
>> +				*__alloc_bootmem_node__pgdat = (pgdat);	\
>> +	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0);		\
>> +})
>>  #endif /* CONFIG_NEED_MULTIPLE_NODES */
>>  
> 
> Can these be switched to functions, or do they actually need to be macros?

I did first attempt to make them inline functions, that leads us to some
new dependancies such as on MAX_DMA_ADDRESS.  I must admit to backing
off at that point, the dependancy problems between mmzone.h and mm.h
caused huge amounts of problems for me in the past and I was shy of
playng with them again.

I'll take a look see if thats the only one or if it is indeed still
endemic.  I know some of the issues were fixed with additional headers.

-apw

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

end of thread, other threads:[~2006-11-23  9:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-22 14:38 [PATCH] silence unused pgdat warning from alloc_bootmem_node and friends Andy Whitcroft
2006-11-22 21:24 ` Andrew Morton
2006-11-23  9:16   ` Andy Whitcroft

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