linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* atmel-mci causes kernel panic when CONFIG_DEBUG_VM is set
@ 2011-05-19  7:53 Ludovic Desroches
  2011-05-19  8:04 ` Barry Song
  2011-05-19 18:25 ` Uwe Kleine-König
  0 siblings, 2 replies; 6+ messages in thread
From: Ludovic Desroches @ 2011-05-19  7:53 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

There is a bug with the atmel-mci driver when the debug feature 
CONFIG_DEBUG_VM is set.

Into the atmci_read_data_pio function we use flush_dcache_page (do we 
really need it?) which call the page_mapping function where we can find 
VM_BUG_ON(PageSlab(Page)). Then a kernel panic happens.

I don't understand the purpose of the VM_BUG_ON(PageSlab(Page)) (the 
page comes from a scatter list). How could I correct this problem?

Thanks for your help

Regards,

Ludovic

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

* atmel-mci causes kernel panic when CONFIG_DEBUG_VM is set
  2011-05-19  7:53 atmel-mci causes kernel panic when CONFIG_DEBUG_VM is set Ludovic Desroches
@ 2011-05-19  8:04 ` Barry Song
  2011-05-19  9:24   ` Ludovic Desroches
  2011-05-19 18:25 ` Uwe Kleine-König
  1 sibling, 1 reply; 6+ messages in thread
From: Barry Song @ 2011-05-19  8:04 UTC (permalink / raw)
  To: linux-arm-kernel

2011/5/19 Ludovic Desroches <ludovic.desroches@atmel.com>:
> Hello,
>
> There is a bug with the atmel-mci driver when the debug feature
> CONFIG_DEBUG_VM is set.
>
> Into the atmci_read_data_pio function we use flush_dcache_page (do we really
> need it?) which call the page_mapping function where we can find
> VM_BUG_ON(PageSlab(Page)). Then a kernel panic happens.
>
> I don't understand the purpose of the VM_BUG_ON(PageSlab(Page)) (the page
> comes from a scatter list). How could I correct this problem?

linux/include/linux/mmdebug.h:

#ifdef CONFIG_DEBUG_VM
#define VM_BUG_ON(cond) BUG_ON(cond)
#else
#define VM_BUG_ON(cond) do { (void)(cond); } while (0)
#endif

it is something like "assert" in kernel.

>
> Thanks for your help
>
> Regards,
>
> Ludovic
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>

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

* atmel-mci causes kernel panic when CONFIG_DEBUG_VM is set
  2011-05-19  8:04 ` Barry Song
@ 2011-05-19  9:24   ` Ludovic Desroches
  2011-05-19 12:17     ` Ludovic Desroches
  0 siblings, 1 reply; 6+ messages in thread
From: Ludovic Desroches @ 2011-05-19  9:24 UTC (permalink / raw)
  To: linux-arm-kernel

On 5/19/2011 10:04 AM, Barry Song wrote:
> 2011/5/19 Ludovic Desroches<ludovic.desroches@atmel.com>:
>> Hello,
>>
>> There is a bug with the atmel-mci driver when the debug feature
>> CONFIG_DEBUG_VM is set.
>>
>> Into the atmci_read_data_pio function we use flush_dcache_page (do we really
>> need it?) which call the page_mapping function where we can find
>> VM_BUG_ON(PageSlab(Page)). Then a kernel panic happens.
>>
>> I don't understand the purpose of the VM_BUG_ON(PageSlab(Page)) (the page
>> comes from a scatter list). How could I correct this problem?
> linux/include/linux/mmdebug.h:
>
> #ifdef CONFIG_DEBUG_VM
> #define VM_BUG_ON(cond) BUG_ON(cond)
> #else
> #define VM_BUG_ON(cond) do { (void)(cond); } while (0)
> #endif
>
> it is something like "assert" in kernel.

Thanks for your answer but I know that. My question is more focused on 
why there is this check.

Is flushing a page taken from a slab forbidden ? Is it risky ? Is it no 
sense ?


Regards,

Ludovic

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

* atmel-mci causes kernel panic when CONFIG_DEBUG_VM is set
  2011-05-19  9:24   ` Ludovic Desroches
@ 2011-05-19 12:17     ` Ludovic Desroches
  2011-05-19 15:16       ` Ludovic Desroches
  0 siblings, 1 reply; 6+ messages in thread
From: Ludovic Desroches @ 2011-05-19 12:17 UTC (permalink / raw)
  To: linux-arm-kernel

On 5/19/2011 11:24 AM, Ludovic Desroches wrote:
> On 5/19/2011 10:04 AM, Barry Song wrote:
>> 2011/5/19 Ludovic Desroches<ludovic.desroches@atmel.com>:
>>> Hello,
>>>
>>> There is a bug with the atmel-mci driver when the debug feature
>>> CONFIG_DEBUG_VM is set.
>>>
>>> Into the atmci_read_data_pio function we use flush_dcache_page (do 
>>> we really
>>> need it?) which call the page_mapping function where we can find
>>> VM_BUG_ON(PageSlab(Page)). Then a kernel panic happens.
>>>
>>> I don't understand the purpose of the VM_BUG_ON(PageSlab(Page)) (the 
>>> page
>>> comes from a scatter list). How could I correct this problem?
>> linux/include/linux/mmdebug.h:
>>
>> #ifdef CONFIG_DEBUG_VM
>> #define VM_BUG_ON(cond) BUG_ON(cond)
>> #else
>> #define VM_BUG_ON(cond) do { (void)(cond); } while (0)
>> #endif
>>
>> it is something like "assert" in kernel.
>
> Thanks for your answer but I know that. My question is more focused on 
> why there is this check.
This the reason:

commit b5fab14e5d87df4d94161ae5f5e0c8625f9ffda2
Author: Christoph Lameter <clameter@sgi.com>
Date:   Tue Jul 17 04:03:33 2007 -0700

     Add VM_BUG_ON in case someone uses page_mapping on a slab page

     Detect slab objects being passed to the page oriented functions of 
the VM.

     It is not sufficient to simply return NULL because the functions 
calling
     page_mapping may depend on other items of the page_struct also to 
be setup
     properly.  Moreover slab object may not be properly aligned.  The page
     oriented functions of the VM expect to operate on page aligned, 
page sized
     objects.  Operations on object straddling page boundaries may only 
affect the
     objects partially which may lead to surprising results.

     It is better to detect eventually remaining uses and eliminate them.


> Is flushing a page taken from a slab forbidden ? Is it risky ? Is it 
> no sense ?
>
Other drivers do a flush_dcache_page on a page coming from a scatter 
list. So I think they will also have an assert when CONFIG_DEBUG_VM is set.

What is the proper way to do this flush (if needed) ?


Regards,

Ludovic

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

* atmel-mci causes kernel panic when CONFIG_DEBUG_VM is set
  2011-05-19 12:17     ` Ludovic Desroches
@ 2011-05-19 15:16       ` Ludovic Desroches
  0 siblings, 0 replies; 6+ messages in thread
From: Ludovic Desroches @ 2011-05-19 15:16 UTC (permalink / raw)
  To: linux-arm-kernel

As suggested I forward the question to Christoph Lameter and linux-mm.

Thanks for your help.

Regards

Ludovic Desroches

On 5/19/2011 2:17 PM, Ludovic Desroches wrote:
> On 5/19/2011 11:24 AM, Ludovic Desroches wrote:
>> On 5/19/2011 10:04 AM, Barry Song wrote:
>>> 2011/5/19 Ludovic Desroches<ludovic.desroches@atmel.com>:
>>>> Hello,
>>>>
>>>> There is a bug with the atmel-mci driver when the debug feature
>>>> CONFIG_DEBUG_VM is set.
>>>>
>>>> Into the atmci_read_data_pio function we use flush_dcache_page (do 
>>>> we really
>>>> need it?) which call the page_mapping function where we can find
>>>> VM_BUG_ON(PageSlab(Page)). Then a kernel panic happens.
>>>>
>>>> I don't understand the purpose of the VM_BUG_ON(PageSlab(Page)) 
>>>> (the page
>>>> comes from a scatter list). How could I correct this problem?
>>> linux/include/linux/mmdebug.h:
>>>
>>> #ifdef CONFIG_DEBUG_VM
>>> #define VM_BUG_ON(cond) BUG_ON(cond)
>>> #else
>>> #define VM_BUG_ON(cond) do { (void)(cond); } while (0)
>>> #endif
>>>
>>> it is something like "assert" in kernel.
>>
>> Thanks for your answer but I know that. My question is more focused 
>> on why there is this check.
> This the reason:
>
> commit b5fab14e5d87df4d94161ae5f5e0c8625f9ffda2
> Author: Christoph Lameter <clameter@sgi.com>
> Date:   Tue Jul 17 04:03:33 2007 -0700
>
>     Add VM_BUG_ON in case someone uses page_mapping on a slab page
>
>     Detect slab objects being passed to the page oriented functions of 
> the VM.
>
>     It is not sufficient to simply return NULL because the functions 
> calling
>     page_mapping may depend on other items of the page_struct also to 
> be setup
>     properly.  Moreover slab object may not be properly aligned.  The 
> page
>     oriented functions of the VM expect to operate on page aligned, 
> page sized
>     objects.  Operations on object straddling page boundaries may only 
> affect the
>     objects partially which may lead to surprising results.
>
>     It is better to detect eventually remaining uses and eliminate them.
>
>
>> Is flushing a page taken from a slab forbidden ? Is it risky ? Is it 
>> no sense ?
>>
> Other drivers do a flush_dcache_page on a page coming from a scatter 
> list. So I think they will also have an assert when CONFIG_DEBUG_VM is 
> set.
>
> What is the proper way to do this flush (if needed) ?
>
>
> Regards,
>
> Ludovic
>
>

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

* atmel-mci causes kernel panic when CONFIG_DEBUG_VM is set
  2011-05-19  7:53 atmel-mci causes kernel panic when CONFIG_DEBUG_VM is set Ludovic Desroches
  2011-05-19  8:04 ` Barry Song
@ 2011-05-19 18:25 ` Uwe Kleine-König
  1 sibling, 0 replies; 6+ messages in thread
From: Uwe Kleine-König @ 2011-05-19 18:25 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

On Thu, May 19, 2011 at 09:53:12AM +0200, Ludovic Desroches wrote:
> There is a bug with the atmel-mci driver when the debug feature
> CONFIG_DEBUG_VM is set.
for the new audience: the driver does the following:

	flush_dcache_page(sg_page(sg));

with sg being a struct scatterlist * provided by the caller of the
struct mmc_host_ops.request callback.

> Into the atmci_read_data_pio function we use flush_dcache_page (do
> we really need it?) which call the page_mapping function where we
> can find VM_BUG_ON(PageSlab(Page)). Then a kernel panic happens.
> 
> I don't understand the purpose of the VM_BUG_ON(PageSlab(Page)) (the
> page comes from a scatter list). How could I correct this problem?
I discussed this problem with Steven and Peter on irc and Steven found
two functions in the mmc code (mmc_send_cxd_data and mmc_send_bus_test)
that use the following idiom:

	struct scatterlist sg;
	void *data_buf;

	data_buf = kmalloc(len, GFP_KERNEL);

	sg_init_one(&sg, data_buf, len);

Is that allowed (i.e. pass  kmalloc'd memory to sg_init_one)? That might
be the source of the slub page in the scatterlist, no?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

end of thread, other threads:[~2011-05-19 18:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-19  7:53 atmel-mci causes kernel panic when CONFIG_DEBUG_VM is set Ludovic Desroches
2011-05-19  8:04 ` Barry Song
2011-05-19  9:24   ` Ludovic Desroches
2011-05-19 12:17     ` Ludovic Desroches
2011-05-19 15:16       ` Ludovic Desroches
2011-05-19 18:25 ` Uwe Kleine-König

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).