From: Ben Greear <greearb@candelatech.com>
To: Christoph Lameter <cl@linux.com>
Cc: penberg@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] slub: Add method to verify memory is not freed.
Date: Fri, 01 Jul 2011 07:23:41 -0700 [thread overview]
Message-ID: <4E0DD86D.80806@candelatech.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1107010909060.2458@router.home>
On 07/01/2011 07:11 AM, Christoph Lameter wrote:
> On Tue, 28 Jun 2011, greearb@candelatech.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@vger.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@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
next prev parent reply other threads:[~2011-07-01 14:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-29 0:47 [PATCH v2 0/2] SLUB memory debugging improvements greearb
2011-06-29 0:47 ` [PATCH v2 1/2] slub: Enable backtrace for create/delete points greearb
2011-07-01 14:08 ` Christoph Lameter
2011-07-01 14:20 ` Ben Greear
2011-06-29 0:47 ` [PATCH v2 2/2] slub: Add method to verify memory is not freed greearb
2011-07-01 14:11 ` Christoph Lameter
2011-07-01 14:23 ` Ben Greear [this message]
2011-07-07 18:00 ` Ben Greear
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E0DD86D.80806@candelatech.com \
--to=greearb@candelatech.com \
--cc=cl@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=penberg@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox