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: 10906761 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 209CD161F for ; Thu, 18 Apr 2019 09:07:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 071BA28857 for ; Thu, 18 Apr 2019 09:07:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB1D0289DA; Thu, 18 Apr 2019 09:07:01 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8569F28857 for ; Thu, 18 Apr 2019 09:07:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388372AbfDRJGv (ORCPT ); Thu, 18 Apr 2019 05:06:51 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:33654 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388344AbfDRJGu (ORCPT ); Thu, 18 Apr 2019 05:06:50 -0400 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 Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Christoph Lameter , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , iommu@lists.linux-foundation.org, Robin Murphy , Christoph Hellwig , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Daniel Vetter , Rodrigo Vivi , linux-arch@vger.kernel.org Subject: [patch V2 00/29] stacktrace: Consolidate stack trace usage Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org 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(-)