From patchwork Thu Apr 18 08:41:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906739 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B3033922 for ; Thu, 18 Apr 2019 09:06:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C132289AF for ; Thu, 18 Apr 2019 09:06:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FE2928AE3; Thu, 18 Apr 2019 09:06:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8AA5A28AB2 for ; Thu, 18 Apr 2019 09:06:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 843376E119; Thu, 18 Apr 2019 09:06:43 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a01:7a0:2:106d:700::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4CFA36E103; Thu, 18 Apr 2019 09:06:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH2zW-0001ls-Ty; Thu, 18 Apr 2019 11:05:59 +0200 Message-Id: <20190418084119.056416939@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:19 +0200 From: Thomas Gleixner To: LKML Subject: [Intel-gfx] [patch V2 00/29] stacktrace: Consolidate stack trace usage X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mike Snitzer , David Airlie , Catalin Marinas , dri-devel@lists.freedesktop.org, linux-mm@kvack.org, dm-devel@redhat.com, Alexander Potapenko , Christoph Lameter , Christoph Hellwig , Alasdair Kergon , Marek Szyprowski , linux-arch@vger.kernel.org, x86@kernel.org, kasan-dev@googlegroups.com, Johannes Thumshirn , Andrey Ryabinin , Alexey Dobriyan , intel-gfx@lists.freedesktop.org, David Rientjes , Akinobu Mita , Steven Rostedt , Josef Bacik , Mike Rapoport , Andy Lutomirski , Josh Poimboeuf , David Sterba , Dmitry Vyukov , Chris Mason , Pekka Enberg , iommu@lists.linux-foundation.org, Andrew Morton , Robin Murphy , linux-btrfs@vger.kernel.org MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP This is an update to V1: https://lkml.kernel.org/r/20190410102754.387743324@linutronix.de Struct stack_trace is a sinkhole for input and output parameters which is largely pointless for most usage sites. In fact if embedded into other data structures it creates indirections and extra storage overhead for no benefit. Looking at all usage sites makes it clear that they just require an interface which is based on a storage array. That array is either on stack, global or embedded into some other data structure. Some of the stack depot usage sites are outright wrong, but fortunately the wrongness just causes more stack being used for nothing and does not have functional impact. Fix this up by: 1) Providing plain storage array based interfaces for stacktrace and stackdepot. 2) Cleaning up the mess at the callsites including some related cleanups. 3) Removing the struct stack_trace based interfaces This is not yet changing the struct stack_trace interfaces at the architecture level, but it removes the exposure to the usage sites. The last two patches are extending the cleanup to the architecture level by replacing the various save_stack_trace.* architecture interfaces with a more unified arch_stack_walk() interface. x86 is converted, but I have worked through all architectures already and it removes lots of duplicated code and allows consolidation across the board. The rest of the architecture patches are not included in this posting as I want to get feedback on the approach itself. The diffstat of cleaning up the remaining architectures is currently on top of the current lot is: 47 files changed, 402 insertions(+), 1196 deletions(-) Once this has settled, the core interfaces can be improved by adding features, which allow to get rid of the imprecise 'skip number of entries' approach which tries to remove the stack tracer and the callsites themself from the trace. That's error prone due to inlining and other issues. Having e.g. a _RET_IP_ based filter allows to do that far more reliable. The series is based on: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core/stacktrace which contains the removal of the inconsistent and pointless ULONG_MAX termination of stacktraces. It's also available from git: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git WIP.core/stacktrace up to: 131038eb3e2f ("x86/stacktrace: Use common infrastructure") Changes vs. V1: - Applied the ULONG_MAX termination cleanup in tip - Addressed the review comments - Fixed up the last users of struct stack_trace outside the stacktrace core and architecture code (livepatch, tracing) - Added the new arch_stack_walk() model and converted x86 to it Thanks, tglx --- arch/x86/Kconfig | 1 arch/x86/kernel/stacktrace.c | 116 +-------- drivers/gpu/drm/drm_mm.c | 22 - drivers/gpu/drm/i915/i915_vma.c | 11 drivers/gpu/drm/i915/intel_runtime_pm.c | 21 - drivers/md/dm-bufio.c | 15 - drivers/md/persistent-data/dm-block-manager.c | 19 - fs/btrfs/ref-verify.c | 15 - fs/proc/base.c | 14 - include/linux/ftrace.h | 18 - include/linux/lockdep.h | 9 include/linux/stackdepot.h | 8 include/linux/stacktrace.h | 80 +++++- kernel/backtracetest.c | 11 kernel/dma/debug.c | 13 - kernel/latencytop.c | 17 - kernel/livepatch/transition.c | 22 - kernel/locking/lockdep.c | 81 ++---- kernel/stacktrace.c | 323 ++++++++++++++++++++++++-- kernel/trace/trace.c | 105 +++----- kernel/trace/trace.h | 8 kernel/trace/trace_events_hist.c | 12 kernel/trace/trace_stack.c | 76 ++---- lib/Kconfig | 4 lib/fault-inject.c | 12 lib/stackdepot.c | 50 ++-- mm/kasan/common.c | 30 -- mm/kasan/report.c | 7 mm/kmemleak.c | 24 - mm/page_owner.c | 79 ++---- mm/slub.c | 12 31 files changed, 664 insertions(+), 571 deletions(-)