From patchwork Tue Jun 7 15:20:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 12872062 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0BDACC433EF for ; Tue, 7 Jun 2022 15:20:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 442856B0071; Tue, 7 Jun 2022 11:20:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CB986B0072; Tue, 7 Jun 2022 11:20:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 26C6C6B0074; Tue, 7 Jun 2022 11:20:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 11B586B0071 for ; Tue, 7 Jun 2022 11:20:16 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CC88860A44 for ; Tue, 7 Jun 2022 15:20:15 +0000 (UTC) X-FDA: 79551800790.22.E04E8D6 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf14.hostedemail.com (Postfix) with ESMTP id 68F4B100052 for ; Tue, 7 Jun 2022 15:20:14 +0000 (UTC) Date: Tue, 7 Jun 2022 17:20:10 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1654615212; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=R7jmGl84+KOfJrsw2TDk+nVmXhGIQK1pXnJ2FoEEZmM=; b=X6iOAH+nHquVV/IZIPJ8srsFhySUj3cyAkMqfuC/YAPX7ZGlpbIAT/RSYvwGYgasj3OEi9 vNJmODoAzAhAgSrgFB3ObcGNNSonY6d+8gw+k/3LO5HiJ6h6nAkoVMVgMJEQQGokE20+Uo KhCGLDTg+fNRSc/i0696lPI7LwhSW9l5U2Jexx02ESW2CfusOyYjFs2mbJt04zS2kpc8Bn 5QWFuy5FsVga4h4hUMSB2lPXG2FfLCfzLhL2rmyPzS4mJ5+B2QXRh+fkCLC8VRdmhU6blP 8M+I38b2iJG2mcWZUD5zpqnoN76zQhtmncg8YgAMAInIGc3veMKWZ9IPIYry1w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1654615212; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=R7jmGl84+KOfJrsw2TDk+nVmXhGIQK1pXnJ2FoEEZmM=; b=yr8KLGg59tgk0JiPsFvTH4eMtWlt1pbQUmI1ZDTwfonHTkarUymsKD4H5i4ON1r9BQ9OHT B1YljlmoUtU3hkAA== From: Sebastian Andrzej Siewior To: linux-mm@kvack.org Cc: Andrew Morton , Christoph Lameter , David Rientjes , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Joonsoo Kim , Oliver Glitta , Pekka Enberg , Roman Gushchin , Thomas Gleixner , Vlastimil Babka Subject: [PATCH] mm/slub: Move the stackdepot related allocation out of IRQ-off section. Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Stat-Signature: dfpzq7cr6dhr8mtms8ogtxu4zdmuxtxt X-Rspam-User: Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=X6iOAH+n; dkim=pass header.d=linutronix.de header.s=2020e header.b=yr8KLGg5; spf=pass (imf14.hostedemail.com: domain of bigeasy@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=bigeasy@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 68F4B100052 X-HE-Tag: 1654615214-6155 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The set_track() invocation in free_debug_processing() is invoked with acquired slab_lock(). The lock disables interrupts on PREEMPT_RT and this forbids to allocate memory which is done in stack_depot_save(). Split set_track() into two parts: set_track_prepare() which allocate memory and set_track_update() which only performs the assignment of the trace data structure. Use set_track_prepare() before disabling interrupts. Fixes: 5cf909c553e9e ("mm/slub: use stackdepot to save stack trace in objects") Signed-off-by: Sebastian Andrzej Siewior Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Sebastian Andrzej Siewior Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Vlastimil Babka --- mm/slub.c | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index e5535020e0fdf..ee0445ccb288c 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -726,19 +726,42 @@ static struct track *get_track(struct kmem_cache *s, void *object, return kasan_reset_tag(p + alloc); } -static void noinline set_track(struct kmem_cache *s, void *object, - enum track_item alloc, unsigned long addr) +static noinline depot_stack_handle_t set_track_prepare(void) { - struct track *p = get_track(s, object, alloc); - + depot_stack_handle_t handle = 0; #ifdef CONFIG_STACKDEPOT unsigned long entries[TRACK_ADDRS_COUNT]; unsigned int nr_entries; nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 3); - p->handle = stack_depot_save(entries, nr_entries, GFP_NOWAIT); + handle = stack_depot_save(entries, nr_entries, GFP_NOWAIT); #endif + return handle; +} +static void set_track_update(struct kmem_cache *s, void *object, + enum track_item alloc, unsigned long addr, + depot_stack_handle_t handle) +{ + struct track *p = get_track(s, object, alloc); + +#ifdef CONFIG_STACKDEPOT + p->handle = handle; +#endif + p->addr = addr; + p->cpu = smp_processor_id(); + p->pid = current->pid; + p->when = jiffies; +} + +static __always_inline void set_track(struct kmem_cache *s, void *object, + enum track_item alloc, unsigned long addr) +{ + struct track *p = get_track(s, object, alloc); + +#ifdef CONFIG_STACKDEPOT + p->handle = set_track_prepare(); +#endif p->addr = addr; p->cpu = smp_processor_id(); p->pid = current->pid; @@ -1373,6 +1396,10 @@ static noinline int free_debug_processing( int cnt = 0; unsigned long flags, flags2; int ret = 0; + depot_stack_handle_t handle = 0; + + if (s->flags & SLAB_STORE_USER) + handle = set_track_prepare(); spin_lock_irqsave(&n->list_lock, flags); slab_lock(slab, &flags2); @@ -1391,7 +1418,7 @@ static noinline int free_debug_processing( } if (s->flags & SLAB_STORE_USER) - set_track(s, object, TRACK_FREE, addr); + set_track_update(s, object, TRACK_FREE, addr, handle); trace(s, slab, object, 0); /* Freepointer not overwritten by init_object(), SLAB_POISON moved it */ init_object(s, object, SLUB_RED_INACTIVE);