[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4E0DD86D.80806@candelatech.com>
Date: Fri, 01 Jul 2011 07:23:41 -0700
From: Ben Greear <greearb@...delatech.com>
To: Christoph Lameter <cl@...ux.com>
CC: penberg@...nel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/2] slub: Add method to verify memory is not freed.
On 07/01/2011 07:11 AM, Christoph Lameter wrote:
> On Tue, 28 Jun 2011, greearb@...delatech.com wrote:
>
>> diff --git a/include/linux/slab.h b/include/linux/slab.h
>> index ad4dd1c..916ce0f 100644
>> --- a/include/linux/slab.h
>> +++ b/include/linux/slab.h
>> @@ -302,6 +302,19 @@ extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
>>
>> #endif /* CONFIG_NUMA */
>>
>> +/**
>> + * Calling this on allocated memory will check that the memory
>> + * is expected to be in use, and print warnings if not.
>> + */
>> +#if defined(CONFIG_SLUB)&& defined(CONFIG_SLUB_DEBUG)
>> +extern bool verify_mem_not_deleted(const void *x);
>> +#else
>> +static inline bool verify_mem_not_deleted(const void *x)
>> +{
>> + return true;
>> +}
>> +#endif
>> +
>
> Why is this in slab.h and not slub_def.h?
No reason..I'll move it.
>
>> diff --git a/mm/slub.c b/mm/slub.c
>> index 3477ce5..f64caca 100644
>> --- a/mm/slub.c
>> +++ b/mm/slub.c
>> @@ -2958,6 +2958,42 @@ size_t ksize(const void *object)
>> }
>> EXPORT_SYMBOL(ksize);
>>
>> +#ifdef CONFIG_SLUB_DEBUG
>> +bool verify_mem_not_deleted(const void *x)
>> +{
>> + struct page *page;
>> + void *object = (void *)x;
>> + unsigned long flags;
>> + bool rv;
>> +
>> + if (unlikely(ZERO_OR_NULL_PTR(x)))
>> + return false;
>> +
>> + local_irq_save(flags);
>> +
>> + page = virt_to_head_page(x);
>> + if (unlikely(!PageSlab(page))) {
>> + /* maybe it was from stack? */
>> + rv = true;
>> + goto out_unlock;
>> + }
>
> The above check is problematic for slabs that have SLAB_DESTROY_BY_RCU
> set. PageSlab(page) may be true to the next rcu interval.
Well, any suggestions on how to do this better?
Thanks,
Ben
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
Ben Greear <greearb@...delatech.com>
Candela Technologies Inc http://www.candelatech.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists