Received: by 10.213.65.68 with SMTP id h4csp687733imn; Tue, 20 Mar 2018 12:45:58 -0700 (PDT) X-Google-Smtp-Source: AG47ELu5r3ApaCIAPGkI8Ku4RuCU4JiOHlgpGlbuBNGDYozt3gLtk/YqerC90Dj0KYSlJFRJ/8KO X-Received: by 10.98.137.90 with SMTP id v87mr14627681pfd.80.1521575158647; Tue, 20 Mar 2018 12:45:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521575158; cv=none; d=google.com; s=arc-20160816; b=eFz2q6grOLVHiN+9amqLnI3L5+dLgum2X7hNJud6qB9MvG71z2lccKvatlaLrw9CDf bxYMcUIpyOhvUrWQHCTdUxAPIkZPcgPziKX+3bISQkCdb7LuA9cEBF6tHM+yznv9wAWL ZonVeklf47YKswvNXuDHF/KlWsio/HkOIW+xTmUcK4oCMWFNJJLGjETqnM+JkQFe31Lk lzOF3TDi1CW8h54rLIaII5n2MN2fLPrtMggY+5hWaj+GrRxY7CKsxnmCBOY4J2C7AXjv 7n64OHY4xkaf3P0r9nAf/uYLmsAqS75HZ6UFOo4aL0gBXu/Ac6H5PHxHU+n0wIz3qjTT iXLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=BeOyNGWaMwHKNPTmp5U2ODyamuRtt8pPmR1Z2SyXfgg=; b=msAydDIw2XV3cICJjSb4qLiVg3MZhIiPYx5Ge7wk2NvHALBSgoOmZ/p6vTRdqa50ba 9RETTmWobpdY8Ixw4J8qqZook68Ue7w8y/6gxZg2RjS4S7Jw7LLJSR3cSKQgaQXDvjBn eZv2huhDLz2sVCelu7vAfAeW/XsxvvceoPinSCYSwiQN+tp8DXp46ky/1JZ3DB5fS0pB ZW8BR0o2QwW+cn3HyrO+dcOJc2GsRrgi4PIKlnuMTPseTy89p91zjuI+qRz7Hf0d2rcR cllGjxcRefGuOXWtxFJrq3BYOhIxcVpfyKFesNz9DFALB8qus3lf7qHDyB7kwyqRbYhB TQDA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x6si1571570pfb.105.2018.03.20.12.45.44; Tue, 20 Mar 2018 12:45:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751458AbeCTTor (ORCPT + 99 others); Tue, 20 Mar 2018 15:44:47 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:35586 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751317AbeCTTop (ORCPT ); Tue, 20 Mar 2018 15:44:45 -0400 Received: from p4fea5f09.dip0.t-ipconnect.de ([79.234.95.9] helo=nanos.glx-home) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1eyNBS-0002o0-1q; Tue, 20 Mar 2018 20:44:34 +0100 Date: Tue, 20 Mar 2018 20:44:33 +0100 (CET) From: Thomas Gleixner To: Daniel Vetter cc: Intel Graphics Development , LKML , Philippe Ombredanne , Greg Kroah-Hartman , Kate Stewart , Waiman Long , Daniel Vetter Subject: Re: [PATCH] RFC: debugobjects: capture stack traces at _init() time In-Reply-To: <20180320160258.11381-1-daniel.vetter@ffwll.ch> Message-ID: References: <20180320160258.11381-1-daniel.vetter@ffwll.ch> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 20 Mar 2018, Daniel Vetter wrote: > Sometimes it's really easy to know which object has gone boom and > where the offending code is, and sometimes it's really hard. One case > we're trying to hunt down is when module unload catches a live debug > object, with a module with lots of them. > > Capture a full stack trace from debug_object_init() and dump it when > there's a problem. > > FIXME: Should we have a separate Kconfig knob for the backtraces, > they're quite expensive? Atm I'm just selecting it for the general > debug object stuff. Just make it boot time enabled. We really want to be able to switch it off. > +#define ODEBUG_STACKDEPTH 32 Do we really need it that deep? I doubt that. > +static noinline depot_stack_handle_t save_stack(struct debug_obj *obj) > +{ > + unsigned long entries[ODEBUG_STACKDEPTH]; > + struct stack_trace trace = { > + .entries = entries, > + .max_entries = ODEBUG_STACKDEPTH, > + .skip = 2 > + }; > + > + save_stack_trace(&trace); > + if (trace.nr_entries != 0 && > + trace.entries[trace.nr_entries-1] == ULONG_MAX) > + trace.nr_entries--; > + > + /* May be called under spinlock, so avoid sleeping */ > + return depot_save_stack(&trace, GFP_NOWAIT); I really don't like the idea of unconditional allocations in that code path. We went great length to make it perform halfways sane with the pool. Though we should actually have per cpu pools to avoid the lock contention, but thats a different problem. I'd rather make the storage a fixed size allocation which is appended to the debug object. Something like this: struct debug_obj_trace { struct stack_trace trace; unsigned long entries[ODEBUG_STACKDEPTH]; }; struct debug_obj { unsigned int astate; void *object; struct debug_obj_descr *descr; struct debug_obj_trace trace[0]; }; void __init debug_objects_mem_init(void) { unsigned long objsize = sizeof (struct debug_obj); if (!debug_objects_enabled) return; if (debug_objects_trace_stack) objsize += sizeof(struct debug_obj_trace); obj_cache = kmem_cache_create("debug_objects_cache", objsize, 0, SLAB_DEBUG_OBJECTS, NULL); __debug_object_init(void *addr, struct debug_obj_descr *descr, int onstack) { .... case ODEBUG_STATE_NONE: case ODEBUG_STATE_INIT: case ODEBUG_STATE_INACTIVE: if (debug_object_trace_stack) { obj->trace[0].trace.entries = obj->trace[0].entries; save_stack_trace(&trace[0].trace); } That means we need to size the static objects which are used during early boot with stack under the assumption that stack tracing is enabled, but that's simple enough. Hmm? Thanks, tglx