From: Joonsoo Kim <iamjoonsoo.kim@lge.com>
To: Alexander Potapenko <glider@google.com>
Cc: Andrey Konovalov <adech.fo@gmail.com>,
Christoph Lameter <cl@linux.com>,
Dmitriy Vyukov <dvyukov@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Steven Rostedt <rostedt@goodmis.org>,
Kostya Serebryany <kcc@google.com>,
Andrey Ryabinin <aryabinin@virtuozzo.com>,
Kuthonuzo Luruo <kuthonuzo.luruo@hpe.com>,
kasan-dev <kasan-dev@googlegroups.com>,
Linux Memory Management List <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v6] mm, kasan: switch SLUB to stackdepot, enable memory quarantine for SLUB
Date: Thu, 14 Jul 2016 15:56:21 +0900 [thread overview]
Message-ID: <20160714065621.GC29676@js1304-P5Q-DELUXE> (raw)
In-Reply-To: <CAG_fn=VM=nMFgKCGEHdD+A4TP9-8XoXKbXDyeXCc6ntkB16q0Q@mail.gmail.com>
On Tue, Jul 12, 2016 at 03:02:19PM +0200, Alexander Potapenko wrote:
> >> +
> >> /* Add alloc meta. */
> >> cache->kasan_info.alloc_meta_offset = *size;
> >> *size += sizeof(struct kasan_alloc_meta);
> >> @@ -392,17 +385,36 @@ void kasan_cache_create(struct kmem_cache *cache, size_t *size,
> >> cache->object_size < sizeof(struct kasan_free_meta)) {
> >> cache->kasan_info.free_meta_offset = *size;
> >> *size += sizeof(struct kasan_free_meta);
> >> + } else {
> >> + cache->kasan_info.free_meta_offset = 0;
> >> }
> >> redzone_adjust = optimal_redzone(cache->object_size) -
> >> (*size - cache->object_size);
> >> +
> >> if (redzone_adjust > 0)
> >> *size += redzone_adjust;
> >> - *size = min(KMALLOC_MAX_CACHE_SIZE,
> >> +
> >> +#ifdef CONFIG_SLAB
> >> + *size = min(KMALLOC_MAX_SIZE,
> >> max(*size,
> >> cache->object_size +
> >> optimal_redzone(cache->object_size)));
> >> -}
> >> + /*
> >> + * If the metadata doesn't fit, don't enable KASAN at all.
> >> + */
> >> + if (*size <= cache->kasan_info.alloc_meta_offset ||
> >> + *size <= cache->kasan_info.free_meta_offset) {
> >> + *size = orig_size;
> >> + return;
> >> + }
> >> +#else
> >> + *size = max(*size,
> >> + cache->object_size +
> >> + optimal_redzone(cache->object_size));
> >> +
> >> #endif
> >
> > Hmm... could you explain why SLAB needs min(KMALLOC_MAX_SIZE, XX) but
> > not SLUB?
>
> Because if the size is bigger than KMALLOC_MAX_SIZE then
> __kmem_cache_create() returns -E2BIG for SLAB. This happens right at
> startup in create_boot_cache().
> As far as I understand, SLUB doesn't have the upper limit (or is it
> that we just aren't hitting it?)
Perhaps, SLUB also has the upper limit although it wasn't triggered
easily since there is no such kmem_cache. Unlikely, SLAB has a such
sized kmem_cache in default (kmalloc-XXXXX). I haven't look at
calculate_order() in detail but it would give you some insight.
Thanks.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2016-07-14 6:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-08 10:36 [PATCH v6] mm, kasan: switch SLUB to stackdepot, enable memory quarantine for SLUB Alexander Potapenko
2016-07-08 17:00 ` Andrey Ryabinin
2016-07-12 10:10 ` Alexander Potapenko
2016-07-11 6:02 ` Joonsoo Kim
2016-07-12 13:02 ` Alexander Potapenko
2016-07-14 6:56 ` Joonsoo Kim [this message]
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=20160714065621.GC29676@js1304-P5Q-DELUXE \
--to=iamjoonsoo.kim@lge.com \
--cc=adech.fo@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=aryabinin@virtuozzo.com \
--cc=cl@linux.com \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=kcc@google.com \
--cc=kuthonuzo.luruo@hpe.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rostedt@goodmis.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;
as well as URLs for NNTP newsgroup(s).