From patchwork Thu Apr 18 08:41:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906719 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 F33AB161F for ; Thu, 18 Apr 2019 09:06:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC224289AF for ; Thu, 18 Apr 2019 09:06:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CFD2C28AB2; Thu, 18 Apr 2019 09:06:21 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49540289AF for ; Thu, 18 Apr 2019 09:06:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0C04A6B0266; Thu, 18 Apr 2019 05:06:12 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 022F86B0008; Thu, 18 Apr 2019 05:06:11 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E2ED26B0010; Thu, 18 Apr 2019 05:06:11 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by kanga.kvack.org (Postfix) with ESMTP id 91ADE6B0008 for ; Thu, 18 Apr 2019 05:06:11 -0400 (EDT) Received: by mail-wm1-f72.google.com with SMTP id y189so1535845wmd.4 for ; Thu, 18 Apr 2019 02:06:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=PNBFVRoc9HP4CIX/Gjc0tnPba+utjyGgJUxB8b6IKHg=; b=eBKy6HYZj64UaroAj6ozru0F9Dk8Hfir52nkSNe/P//5TqdNc1CbjYNCEizJN7x9dC z3g1OstMx1bHf3jKGQAcjPgcJ+HUxW2NmQba7Fo6+yKtj9o3uJrEimX4f9llv+V/BsJ1 U8G1NidrMcr9f3QPtl/XrbDoBYhHIx4RFMXG86EPy74zT3DD/0ojiiKLM3ARARNxlnn7 1HXN5i1DzJyZxhIfu4kD9QATJqHkGb1nI/iyuV+wcQhS/XBhk3fBCcb+cYMj2Sqy1/Sl FZsb7l6wTM58wSfmAM71Rxy4VSZEO91LxEfcs3785pK0RHohs4Wic1x0FRRRbtkujj3h AGPg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAVDIf7I5Fnwa4vezY5rNGoLbGE5OJoWy5JWD/cxY4vub5yfA6Z3 P50o0JB/7RufR+R42dSNfSw0wLVb5eHvXoP1S407VAneMiOFu6aoD+7JHiyHEpV6gydqDRTS2d2 W7A4nSGYf8M2LPPx2jAIfJ9+EfJYC+tdDQm/u+OEwrHCsm4uW8+SdKdIFJvANXWn82A== X-Received: by 2002:a7b:c353:: with SMTP id l19mr2134155wmj.12.1555578370896; Thu, 18 Apr 2019 02:06:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqzL7egUYu5e77MqJ1YlXin2jUbd2N560tiI9+gP/nylVUFAUN730DgAddPJM5xUTNA5e4gC X-Received: by 2002:a7b:c353:: with SMTP id l19mr2134075wmj.12.1555578369800; Thu, 18 Apr 2019 02:06:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578369; cv=none; d=google.com; s=arc-20160816; b=m0EWcuQgfuRVVjSrPJD5iQb0Q89Okvvq+c3tkN4Ae5bywx/5wM+ogUisD6zFysuKHr L3yq2z92p2EhDOxepbN3BVG8MMsh31fCLls0x5vn3dUSncRmE42aO1WXxdwVusdSmD2s 3qFtiCFjbQLYDs9JiGeSeugqQsGr0o4XIpZyOPv89nMbsb5mTrOdrSLwYS0Sm7sqp58H U+Dxg010ZUpxE9MKAKxfUINXKklVindb9CJjIx2gMcqsR9AIdAaDGGfQ1MvVHK5t42qt a0nXl5OqV7p5iCzOD2Q5pNFuV9UznIVoyfTdGyyemrqpN3G6YgubINJQVEkBkOZVgM0Q rQ+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=PNBFVRoc9HP4CIX/Gjc0tnPba+utjyGgJUxB8b6IKHg=; b=OLQcsIOETfCWuP8A9Co6sraaAA5NdNFeDNPWaVepfnFogVkGCrzbDNYaPx58sIdNLZ bYm64vL6r+s76xYHqNkY5crmNNR6QIq9wgdcSxujvFvmb0/QD+Bf8FDA5CCsTsY7fv5o DwkZcJsOPHQGAqGlXPxY5AwNm8RLQK4KnnZEJH/XuTwEgTnS+2lH+bDD4gIiXvg0vmet 7pEJBzus3ozUs17N/aG8YcsBY9FBhDbq90SvztE3kDIfTuxi8K0pkRd3sTDcmoUnsBDY hDyiu/zX1UZFXLS29vo+XJzz0/W8x/O+G0ZXnII1uouWHq8XKx41N0c+roMF2IrqE3gj ZgQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id z2si1253992wrp.169.2019.04.18.02.06.09 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH2zZ-0001lv-2D; Thu, 18 Apr 2019 11:06:01 +0200 Message-Id: <20190418084253.142712304@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:20 +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 01/29] tracing: Cleanup stack trace code References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP - Remove the extra array member of stack_dump_trace[]. It's not required as the stack tracer stores at max array size - 1 entries so there is still an empty slot. - Make variables which are only used in trace_stack.c static. - Simplify the enable/disable logic. - Rename stack_trace_print() as it's using the stack_trace_ namespace. Free the name up for stack trace related functions. Signed-off-by: Thomas Gleixner Cc: Steven Rostedt Reviewed-by: Steven Rostedt (VMware) --- V2: Add more cleanups and use print_max_stack() as requested by Steven. --- include/linux/ftrace.h | 18 ++++-------------- kernel/trace/trace_stack.c | 36 ++++++++++++------------------------ 2 files changed, 16 insertions(+), 38 deletions(-) --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h @@ -241,21 +241,11 @@ static inline void ftrace_free_mem(struc #ifdef CONFIG_STACK_TRACER -#define STACK_TRACE_ENTRIES 500 - -struct stack_trace; - -extern unsigned stack_trace_index[]; -extern struct stack_trace stack_trace_max; -extern unsigned long stack_trace_max_size; -extern arch_spinlock_t stack_trace_max_lock; - extern int stack_tracer_enabled; -void stack_trace_print(void); -int -stack_trace_sysctl(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, - loff_t *ppos); + +int stack_trace_sysctl(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, + loff_t *ppos); /* DO NOT MODIFY THIS VARIABLE DIRECTLY! */ DECLARE_PER_CPU(int, disable_stack_tracer); --- a/kernel/trace/trace_stack.c +++ b/kernel/trace/trace_stack.c @@ -18,8 +18,10 @@ #include "trace.h" -static unsigned long stack_dump_trace[STACK_TRACE_ENTRIES + 1]; -unsigned stack_trace_index[STACK_TRACE_ENTRIES]; +#define STACK_TRACE_ENTRIES 500 + +static unsigned long stack_dump_trace[STACK_TRACE_ENTRIES]; +static unsigned stack_trace_index[STACK_TRACE_ENTRIES]; /* * Reserve one entry for the passed in ip. This will allow @@ -31,17 +33,16 @@ struct stack_trace stack_trace_max = { .entries = &stack_dump_trace[0], }; -unsigned long stack_trace_max_size; -arch_spinlock_t stack_trace_max_lock = +static unsigned long stack_trace_max_size; +static arch_spinlock_t stack_trace_max_lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED; DEFINE_PER_CPU(int, disable_stack_tracer); static DEFINE_MUTEX(stack_sysctl_mutex); int stack_tracer_enabled; -static int last_stack_tracer_enabled; -void stack_trace_print(void) +static void print_max_stack(void) { long i; int size; @@ -61,16 +62,7 @@ void stack_trace_print(void) } } -/* - * When arch-specific code overrides this function, the following - * data should be filled up, assuming stack_trace_max_lock is held to - * prevent concurrent updates. - * stack_trace_index[] - * stack_trace_max - * stack_trace_max_size - */ -void __weak -check_stack(unsigned long ip, unsigned long *stack) +static void check_stack(unsigned long ip, unsigned long *stack) { unsigned long this_size, flags; unsigned long *p, *top, *start; static int tracer_frame; @@ -179,7 +171,7 @@ check_stack(unsigned long ip, unsigned l stack_trace_max.nr_entries = x; if (task_stack_end_corrupted(current)) { - stack_trace_print(); + print_max_stack(); BUG(); } @@ -412,23 +404,20 @@ stack_trace_sysctl(struct ctl_table *tab void __user *buffer, size_t *lenp, loff_t *ppos) { - int ret; + int ret, was_enabled; mutex_lock(&stack_sysctl_mutex); + was_enabled = !!stack_tracer_enabled; ret = proc_dointvec(table, write, buffer, lenp, ppos); - if (ret || !write || - (last_stack_tracer_enabled == !!stack_tracer_enabled)) + if (ret || !write || (was_enabled == !!stack_tracer_enabled)) goto out; - last_stack_tracer_enabled = !!stack_tracer_enabled; - if (stack_tracer_enabled) register_ftrace_function(&trace_ops); else unregister_ftrace_function(&trace_ops); - out: mutex_unlock(&stack_sysctl_mutex); return ret; @@ -444,7 +433,6 @@ static __init int enable_stacktrace(char strncpy(stack_trace_filter_buf, str + len, COMMAND_LINE_SIZE); stack_tracer_enabled = 1; - last_stack_tracer_enabled = 1; return 1; } __setup("stacktrace", enable_stacktrace); From patchwork Thu Apr 18 08:41:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906723 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 15C3C161F for ; Thu, 18 Apr 2019 09:06:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF033289C5 for ; Thu, 18 Apr 2019 09:06:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E2A0C28A9B; Thu, 18 Apr 2019 09:06:25 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61DA2289DA for ; Thu, 18 Apr 2019 09:06:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8189D6B0008; Thu, 18 Apr 2019 05:06:12 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7A00B6B000D; Thu, 18 Apr 2019 05:06:12 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F86E6B0010; Thu, 18 Apr 2019 05:06:12 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by kanga.kvack.org (Postfix) with ESMTP id 9BCB76B000A for ; Thu, 18 Apr 2019 05:06:11 -0400 (EDT) Received: by mail-wr1-f71.google.com with SMTP id m13so1510059wrr.17 for ; Thu, 18 Apr 2019 02:06:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=IbpSsAiPcW8cv6WMadHzF6JIvxj3aoR9tMjXje3c20A=; b=i2/jYz1EXIL7VLX9u6Wv4+dHHE7SkF854I/4ils5tFeH2Me4GISr7NqX0aODa2J7EB GAa/RZbnNyVVqRGRQChpZ6bTlOIZrnUmFhQIKMSw6CducfeX9Tillkt1OPz+ergb2V9i zV1YDATkPl0+n+g4UC5kJzlNWFwyKS7L7Sc/juSuumoeTU9gAg0zyls/GR5hPoZmYcHr FuaNsN0VzTbIne7EDxINzqnOHwmK/LNKxmYQfgc36EoRrkDflv8ZEHFDG2Tn+ZtnxtoI GuYVNK1zkxqkyw2g6uEOlI77sFQOc5KMJXYjQoaT69UDTPAWKZK4Jsr/j7G1wpl88jaZ CZxA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAUFLEHi0fFNcCn1Xeh4RDYtXyT/scQzQP1bXyrqPVTTgOCaRHB9 XxTOXZuoMppYMbENhs5STf/qskFBRdH6oZlpmVwhQ56QAK663H+jrYPBaITaSw9LZkdGPYqNDAF MJNA3nKUMAdeSV6vOncX4RyTP0iClBdO0zK/laOkP5xdcpoCHmH68449kVClIGgQjLA== X-Received: by 2002:a5d:558c:: with SMTP id i12mr1998103wrv.123.1555578371086; Thu, 18 Apr 2019 02:06:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwIetfm2w0NmaGu+VbePCFGRuUun89Hg5tVe3/Y5H10PO+PDXMEjm/UmvlLIbci++LkuB7F X-Received: by 2002:a5d:558c:: with SMTP id i12mr1998020wrv.123.1555578369934; Thu, 18 Apr 2019 02:06:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578369; cv=none; d=google.com; s=arc-20160816; b=UqkUC+6eRTDS7CS/KbpYlZ7HgocXbYXz0WS3nLAL7TgLDcg1XdwI0rQtwwpGR3A1/5 dFGpyNi+J2wDK9leUYtS0aeyFfrz7WQj3fyf+r5qjfr/uXGyrKBkgz2SOh+Wh+SVbRxr 9sTQkzzagXPzTYfwbL5X7vwiUdmyEV/95ReUx+t/Ek7zCLlcmVa5ywqFq/hGYjRjkr4u xhXYLKxy/5FQMuSprKA6EiGuRo/EKBYA/SQnqMz2r7jhKGAn098ix2TvUk5VDF+61fy2 vSZ/R8aUC74OVhrWcCnyv57+mEM8REVD0FbE3wzidh2hYc+sJ3G6au+tUXI65+T/ZkiX tIQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=IbpSsAiPcW8cv6WMadHzF6JIvxj3aoR9tMjXje3c20A=; b=ztE7rN3ZOuYmEtCJEjs5l2bw9O9Ak4GDaXON8ewkbs3sTt+E88sgE/CvpSjtzyYtYO yWwbcoAwQM9OhBU8DRgUMkqMhQ+PAOP5+1vZ39iR+RZ/nW3XFrVOiq/LL7Hg8JXmnfyL BF0LXJHXyZeU9sHPoTs1SW/Xr91qMX+RxY3KOFHWP6VP8yIABDrULJcwsfwuU2kkbjSw YWflTysycpIkhHeZA8qr3899gqoL2CGm/c/hbMP+ZpgR036AvmsGArSeTzePFlWbOtXU 9r3YBW8swSue2q8sTJSjziEnhTsciLxazRvDmcRJ4BIE56LRPgK/ZbnYXOE7VomPV0Ue siLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id e7si1276796wrc.181.2019.04.18.02.06.09 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH2zb-0001m0-4R; Thu, 18 Apr 2019 11:06:03 +0200 Message-Id: <20190418084253.234868907@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:21 +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 02/29] stacktrace: Provide helpers for common stack trace operations References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP All operations with stack traces are based on struct stack_trace. That's a horrible construct as the struct is a kitchen sink for input and output. Quite some usage sites embed it into their own data structures which creates weird indirections. There is absolutely no point in doing so. For all use cases a storage array and the number of valid stack trace entries in the array is sufficient. Provide helper functions which avoid the struct stack_trace indirection so the usage sites can be cleaned up. Signed-off-by: Thomas Gleixner --- include/linux/stacktrace.h | 27 +++++++ kernel/stacktrace.c | 160 ++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 172 insertions(+), 15 deletions(-) --- a/include/linux/stacktrace.h +++ b/include/linux/stacktrace.h @@ -3,11 +3,26 @@ #define __LINUX_STACKTRACE_H #include +#include struct task_struct; struct pt_regs; #ifdef CONFIG_STACKTRACE +void stack_trace_print(unsigned long *trace, unsigned int nr_entries, + int spaces); +int stack_trace_snprint(char *buf, size_t size, unsigned long *entries, + unsigned int nr_entries, int spaces); +unsigned int stack_trace_save(unsigned long *store, unsigned int size, + unsigned int skipnr); +unsigned int stack_trace_save_tsk(struct task_struct *task, + unsigned long *store, unsigned int size, + unsigned int skipnr); +unsigned int stack_trace_save_regs(struct pt_regs *regs, unsigned long *store, + unsigned int size, unsigned int skipnr); +unsigned int stack_trace_save_user(unsigned long *store, unsigned int size); + +/* Internal interfaces. Do not use in generic code */ struct stack_trace { unsigned int nr_entries, max_entries; unsigned long *entries; @@ -41,4 +56,16 @@ extern void save_stack_trace_user(struct # define save_stack_trace_tsk_reliable(tsk, trace) ({ -ENOSYS; }) #endif /* CONFIG_STACKTRACE */ +#if defined(CONFIG_STACKTRACE) && defined(CONFIG_HAVE_RELIABLE_STACKTRACE) +int stack_trace_save_tsk_reliable(struct task_struct *tsk, unsigned long *store, + unsigned int size); +#else +static inline int stack_trace_save_tsk_reliable(struct task_struct *tsk, + unsigned long *store, + unsigned int size) +{ + return -ENOSYS; +} +#endif + #endif /* __LINUX_STACKTRACE_H */ --- a/kernel/stacktrace.c +++ b/kernel/stacktrace.c @@ -11,35 +11,52 @@ #include #include -void print_stack_trace(struct stack_trace *trace, int spaces) +/** + * stack_trace_print - Print the entries in the stack trace + * @entries: Pointer to storage array + * @nr_entries: Number of entries in the storage array + * @spaces: Number of leading spaces to print + */ +void stack_trace_print(unsigned long *entries, unsigned int nr_entries, + int spaces) { - int i; + unsigned int i; - if (WARN_ON(!trace->entries)) + if (WARN_ON(!entries)) return; - for (i = 0; i < trace->nr_entries; i++) - printk("%*c%pS\n", 1 + spaces, ' ', (void *)trace->entries[i]); + for (i = 0; i < nr_entries; i++) + printk("%*c%pS\n", 1 + spaces, ' ', (void *)entries[i]); +} +EXPORT_SYMBOL_GPL(stack_trace_print); + +void print_stack_trace(struct stack_trace *trace, int spaces) +{ + stack_trace_print(trace->entries, trace->nr_entries, spaces); } EXPORT_SYMBOL_GPL(print_stack_trace); -int snprint_stack_trace(char *buf, size_t size, - struct stack_trace *trace, int spaces) +/** + * stack_trace_snprint - Print the entries in the stack trace into a buffer + * @buf: Pointer to the print buffer + * @size: Size of the print buffer + * @entries: Pointer to storage array + * @nr_entries: Number of entries in the storage array + * @spaces: Number of leading spaces to print + */ +int stack_trace_snprint(char *buf, size_t size, unsigned long *entries, + unsigned int nr_entries, int spaces) { - int i; - int generated; - int total = 0; + unsigned int generated, i, total = 0; - if (WARN_ON(!trace->entries)) + if (WARN_ON(!entries)) return 0; - for (i = 0; i < trace->nr_entries; i++) { + for (i = 0; i < nr_entries; i++) { generated = snprintf(buf, size, "%*c%pS\n", 1 + spaces, ' ', - (void *)trace->entries[i]); + (void *)entries[i]); total += generated; - - /* Assume that generated isn't a negative number */ if (generated >= size) { buf += size; size = 0; @@ -51,6 +68,14 @@ int snprint_stack_trace(char *buf, size_ return total; } +EXPORT_SYMBOL_GPL(stack_trace_snprint); + +int snprint_stack_trace(char *buf, size_t size, + struct stack_trace *trace, int spaces) +{ + return stack_trace_snprint(buf, size, trace->entries, + trace->nr_entries, spaces); +} EXPORT_SYMBOL_GPL(snprint_stack_trace); /* @@ -77,3 +102,108 @@ save_stack_trace_tsk_reliable(struct tas WARN_ONCE(1, KERN_INFO "save_stack_tsk_reliable() not implemented yet.\n"); return -ENOSYS; } + +/** + * stack_trace_save - Save a stack trace into a storage array + * @store: Pointer to storage array + * @size: Size of the storage array + * @skipnr: Number of entries to skip at the start of the stack trace + */ +unsigned int stack_trace_save(unsigned long *store, unsigned int size, + unsigned int skipnr) +{ + struct stack_trace trace = { + .entries = store, + .max_entries = size, + .skip = skipnr + 1, + }; + + save_stack_trace(&trace); + return trace.nr_entries; +} +EXPORT_SYMBOL_GPL(stack_trace_save); + +/** + * stack_trace_save_tsk - Save a task stack trace into a storage array + * @task: The task to examine + * @store: Pointer to storage array + * @size: Size of the storage array + * @skipnr: Number of entries to skip at the start of the stack trace + */ +unsigned int stack_trace_save_tsk(struct task_struct *task, + unsigned long *store, unsigned int size, + unsigned int skipnr) +{ + struct stack_trace trace = { + .entries = store, + .max_entries = size, + .skip = skipnr + 1, + }; + + save_stack_trace_tsk(task, &trace); + return trace.nr_entries; +} + +/** + * stack_trace_save_regs - Save a stack trace based on pt_regs into a storage array + * @regs: Pointer to pt_regs to examine + * @store: Pointer to storage array + * @size: Size of the storage array + * @skipnr: Number of entries to skip at the start of the stack trace + */ +unsigned int stack_trace_save_regs(struct pt_regs *regs, unsigned long *store, + unsigned int size, unsigned int skipnr) +{ + struct stack_trace trace = { + .entries = store, + .max_entries = size, + .skip = skipnr, + }; + + save_stack_trace_regs(regs, &trace); + return trace.nr_entries; +} + +#ifdef CONFIG_HAVE_RELIABLE_STACKTRACE +/** + * stack_trace_save_tsk_reliable - Save task stack with verification + * @tsk: Pointer to the task to examine + * @store: Pointer to storage array + * @size: Size of the storage array + * + * Returns: An error if it detects any unreliable features of the + * stack. Otherwise it guarantees that the stack trace is + * reliable and returns the number of entries stored. + * + * If the task is not 'current', the caller *must* ensure the task is inactive. + */ +int stack_trace_save_tsk_reliable(struct task_struct *tsk, unsigned long *store, + unsigned int size) +{ + struct stack_trace trace = { + .entries = store, + .max_entries = size, + }; + int ret = save_stack_trace_tsk_reliable(tsk, &trace); + + return ret ? ret : trace.nr_entries; +} +#endif + +#ifdef CONFIG_USER_STACKTRACE_SUPPORT +/** + * stack_trace_save_user - Save a user space stack trace into a storage array + * @store: Pointer to storage array + * @size: Size of the storage array + */ +unsigned int stack_trace_save_user(unsigned long *store, unsigned int size) +{ + struct stack_trace trace = { + .entries = store, + .max_entries = size, + }; + + save_stack_trace_user(&trace); + return trace.nr_entries; +} +#endif /* CONFIG_USER_STACKTRACE_SUPPORT */ From patchwork Thu Apr 18 08:41:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906725 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 56E84161F for ; Thu, 18 Apr 2019 09:06:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FBA5289AF for ; Thu, 18 Apr 2019 09:06:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 32E4928A9B; Thu, 18 Apr 2019 09:06:29 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED481289AF for ; Thu, 18 Apr 2019 09:06:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA8896B000A; Thu, 18 Apr 2019 05:06:12 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 94BE76B0010; Thu, 18 Apr 2019 05:06:12 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3576B6B000A; Thu, 18 Apr 2019 05:06:12 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by kanga.kvack.org (Postfix) with ESMTP id B1DD46B000D for ; Thu, 18 Apr 2019 05:06:11 -0400 (EDT) Received: by mail-wr1-f71.google.com with SMTP id n5so500478wrv.10 for ; Thu, 18 Apr 2019 02:06:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=XKNHsKVL53fEymf/PDnpaEhKhMIAQzy9pwzTM1OgbZg=; b=gjTspitdp4GS0aZ28IZ+OIJY+wtFK5FFDCZWdKedafvQvD33SN+o88OHR4kwKZqnqJ +wzDet/oZzxJUYuC8Midsxz+TGB6VK1hqWLtN9w6rqsuZ+l7oEqV5VrX96sG2cTix2wK tyPsU6h6V9Rre7MiRWkFSHg8JGbVUCCQOIj7kZ6Mwt7qJGctMi9gDF4y3IkpeQWExU7E NQ7l22cAUteDp4zN5T2S46bTwlq1O+HQkT0HcwQUs8Ck0s8AZ5yaPx/dc9+Zb+qTYVKN +qcNqkpmpGhextk/UyyvdpGbIiy3eRbTlmz/g18LK8MpDftNpFLGpcyJ8gH5CQGnpWZn srkQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAXM86ayfBXZhPmMG8iAXbty4pYkp2UKgtCEmavif/PvQPT2bNoD LWfEO3Y5rluOQOP4W+n6WXrNBx/PlX9mgeptipltSf+4W4N9q1K2NLFuNgiOoAaXPY58fQhKmVK 5QMBFHYs1MViUEs5216ey0Q3fMS2tXUVBAmavosH0sPBvdxjm+NSUieQm3p3xSQHvNQ== X-Received: by 2002:adf:f147:: with SMTP id y7mr59660684wro.102.1555578371221; Thu, 18 Apr 2019 02:06:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqyA2FGGcKYpZdQ0lPzP7IUtZmc+6Tp/A+g7EWW7PTEc0+Re2RPqM2WNpSQ4PKwl4vu+uuL2 X-Received: by 2002:adf:f147:: with SMTP id y7mr59660575wro.102.1555578369800; Thu, 18 Apr 2019 02:06:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578369; cv=none; d=google.com; s=arc-20160816; b=h6hdR69OBk9Z1HMuqh242YF1XOvr76XFMvo4q7fnHdfjhCnDqLrem1YtPpQScZj1ww wDAUC2DE4lO86vtrDUoUkmECiK8hZ2HLx6QMYqLUvY5aWDasE/uI+NkxUJXJ/AXFDtWu VSCdK/SE3s8ED4GQ2LYdb4WCMzwpJkRhnGLV9DDGvWb72vRQXHKn76MZkUp9tVKZO8/O RuPxpCfUZvToF4M7ynx+4o/ZTdTVKVa8lBCS8fn229BSK98JKvCp1n+bdhZW+zAJ5wQd F/qEnZKGcv7NQRNDoTAgte940dReCkQybz3LGuWniTB7FSCAb2LFCDEyhuDbQ/5T/l3d 1Pgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=XKNHsKVL53fEymf/PDnpaEhKhMIAQzy9pwzTM1OgbZg=; b=byi3Od7rSyDQPwhlZMMyB9W+fr5RdenGDmgYK1wbg1VoKJKTL1Oq5977vBcmpDsRzT y0GDQ+2ZiutPRPnFdduuQbEfYwFVL9mc7KeiGtHjhmoUBMcc7OL0ad/1CVNFrUboLycE IvAbss1iZ3614pyKVQrh8/6s72u3cQijhzhRMZgL82IM2vOYZaGfdECQjRCq+LlI5+yj tBs2zAsyWDdUmI6WGhXlTzs0kO4bPvtwrkVEeEOIKcFqBX1O4kTyv4ZqB3fx53r5aBsG qgl5ik/u7Mdwc8bxWRzkLQKQRh0igAgqe8q/quGMXIYsKCGu2y2Opv/K/D3R2tTeGZ78 7geA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id f25si1090350wml.78.2019.04.18.02.06.09 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH2zc-0001m4-W3; Thu, 18 Apr 2019 11:06:05 +0200 Message-Id: <20190418084253.337266121@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:22 +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 03/29] lib/stackdepot: Provide functions which operate on plain storage arrays References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP The struct stack_trace indirection in the stack depot functions is a truly pointless excercise which requires horrible code at the callsites. Provide interfaces based on plain storage arrays. Signed-off-by: Thomas Gleixner Acked-by: Alexander Potapenko --- include/linux/stackdepot.h | 4 ++ lib/stackdepot.c | 66 ++++++++++++++++++++++++++++++++------------- 2 files changed, 51 insertions(+), 19 deletions(-) --- a/include/linux/stackdepot.h +++ b/include/linux/stackdepot.h @@ -26,7 +26,11 @@ typedef u32 depot_stack_handle_t; struct stack_trace; depot_stack_handle_t depot_save_stack(struct stack_trace *trace, gfp_t flags); +depot_stack_handle_t stack_depot_save(unsigned long *entries, + unsigned int nr_entries, gfp_t gfp_flags); void depot_fetch_stack(depot_stack_handle_t handle, struct stack_trace *trace); +unsigned int stack_depot_fetch(depot_stack_handle_t handle, + unsigned long **entries); #endif --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -194,40 +194,56 @@ static inline struct stack_record *find_ return NULL; } -void depot_fetch_stack(depot_stack_handle_t handle, struct stack_trace *trace) +/** + * stack_depot_fetch - Fetch stack entries from a depot + * + * @entries: Pointer to store the entries address + */ +unsigned int stack_depot_fetch(depot_stack_handle_t handle, + unsigned long **entries) { union handle_parts parts = { .handle = handle }; void *slab = stack_slabs[parts.slabindex]; size_t offset = parts.offset << STACK_ALLOC_ALIGN; struct stack_record *stack = slab + offset; - trace->nr_entries = trace->max_entries = stack->size; - trace->entries = stack->entries; - trace->skip = 0; + *entries = stack->entries; + return stack->size; +} +EXPORT_SYMBOL_GPL(stack_depot_fetch); + +void depot_fetch_stack(depot_stack_handle_t handle, struct stack_trace *trace) +{ + unsigned int nent = stack_depot_fetch(handle, &trace->entries); + + trace->max_entries = trace->nr_entries = nent; } EXPORT_SYMBOL_GPL(depot_fetch_stack); /** - * depot_save_stack - save stack in a stack depot. - * @trace - the stacktrace to save. - * @alloc_flags - flags for allocating additional memory if required. + * stack_depot_save - Save a stack trace from an array * - * Returns the handle of the stack struct stored in depot. + * @entries: Pointer to storage array + * @nr_entries: Size of the storage array + * @alloc_flags: Allocation gfp flags + * + * Returns the handle of the stack struct stored in depot */ -depot_stack_handle_t depot_save_stack(struct stack_trace *trace, - gfp_t alloc_flags) +depot_stack_handle_t stack_depot_save(unsigned long *entries, + unsigned int nr_entries, + gfp_t alloc_flags) { - u32 hash; - depot_stack_handle_t retval = 0; struct stack_record *found = NULL, **bucket; - unsigned long flags; + depot_stack_handle_t retval = 0; struct page *page = NULL; void *prealloc = NULL; + unsigned long flags; + u32 hash; - if (unlikely(trace->nr_entries == 0)) + if (unlikely(nr_entries == 0)) goto fast_exit; - hash = hash_stack(trace->entries, trace->nr_entries); + hash = hash_stack(entries, nr_entries); bucket = &stack_table[hash & STACK_HASH_MASK]; /* @@ -235,8 +251,8 @@ depot_stack_handle_t depot_save_stack(st * The smp_load_acquire() here pairs with smp_store_release() to * |bucket| below. */ - found = find_stack(smp_load_acquire(bucket), trace->entries, - trace->nr_entries, hash); + found = find_stack(smp_load_acquire(bucket), entries, + nr_entries, hash); if (found) goto exit; @@ -264,10 +280,10 @@ depot_stack_handle_t depot_save_stack(st spin_lock_irqsave(&depot_lock, flags); - found = find_stack(*bucket, trace->entries, trace->nr_entries, hash); + found = find_stack(*bucket, entries, nr_entries, hash); if (!found) { struct stack_record *new = - depot_alloc_stack(trace->entries, trace->nr_entries, + depot_alloc_stack(entries, nr_entries, hash, &prealloc, alloc_flags); if (new) { new->next = *bucket; @@ -297,4 +313,16 @@ depot_stack_handle_t depot_save_stack(st fast_exit: return retval; } +EXPORT_SYMBOL_GPL(stack_depot_save); + +/** + * depot_save_stack - save stack in a stack depot. + * @trace - the stacktrace to save. + * @alloc_flags - flags for allocating additional memory if required. + */ +depot_stack_handle_t depot_save_stack(struct stack_trace *trace, + gfp_t alloc_flags) +{ + return stack_depot_save(trace->entries, trace->nr_entries, alloc_flags); +} EXPORT_SYMBOL_GPL(depot_save_stack); From patchwork Thu Apr 18 08:41:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906721 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 F022C922 for ; Thu, 18 Apr 2019 09:06:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D9876289AF for ; Thu, 18 Apr 2019 09:06:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD2DB28A9B; Thu, 18 Apr 2019 09:06:22 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5535289C5 for ; Thu, 18 Apr 2019 09:06:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5AF116B0006; Thu, 18 Apr 2019 05:06:12 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 52F386B0008; Thu, 18 Apr 2019 05:06:12 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0BE756B0006; Thu, 18 Apr 2019 05:06:12 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by kanga.kvack.org (Postfix) with ESMTP id 9D2686B000C for ; Thu, 18 Apr 2019 05:06:11 -0400 (EDT) Received: by mail-wm1-f72.google.com with SMTP id u6so1455570wml.3 for ; Thu, 18 Apr 2019 02:06:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=p1GV5L4kXkwF513RFzbpeqJMhNCAHm0+rLW65qR5s04=; b=lMnrI0E6WwqjukEHQbuMgutqTapQh1xT6XJI2eV353k6Tlc5t8TlwMd1b0W++oIsMc vj1InJCWlDzW5xHjfn0p/lzXxsieK1d7D0+d9n78N5v5XqxAH/zadytL8P1mGh5qDJL4 rcWdp7JjV+6+7zm9PYOOlcWFPJ9ftmNeObY1sipkHfF4TEWGdC9plHKSMt9Z550BGf0W acp5JiUOd2TeCPlLhY9i2/KlIza17UuDiUIAVeCN+XNbFeo/zkiAoMWJU88FxGdsR0kS LERm483WIV4bNBS3YjSX8pSjVuE4s2XnJ5bryEDOaRXx6KimW0Eem257nnPBBqtUjdp3 OAAw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAWQoMU+u3CIAp3vSYyXCQVUUWbSjS2JCgoU+bUtLgmAbQ9N6wWl PqqiOubcdtdpYdfcRAQNedHq4pE1MJH4NCaLWCG7mQDxaqSVdxfu13FMmAmy97ripoS/xaqz7km cgVReVtP1ao7l6tX9/6CMN+EgG92uzYz5zYODuj2tACwT5qwRPV3nRvYqAnZwoQbBCQ== X-Received: by 2002:a1c:1903:: with SMTP id 3mr2182619wmz.103.1555578371138; Thu, 18 Apr 2019 02:06:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwFXomz58L6bjRWX1EiX8MZ8XiYXNuCfKfuTO9V8Tn5vZBzGgbPtTHcyop3TcMIeUDETlCB X-Received: by 2002:a1c:1903:: with SMTP id 3mr2182555wmz.103.1555578370190; Thu, 18 Apr 2019 02:06:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578370; cv=none; d=google.com; s=arc-20160816; b=vlOBNWU8Xzs4L+T/ynffsE8nOLqoQfFGKAhkavS7CcGeHl93pub6RyI0mFDMRcFHRp 78vm8fp8UDaqAc8hpFj0nL6U0LGe0IzRBak2diFNSWOk+ZrXULPb2ORkUvYX/csHNP7p dba/6451L/1+x484B+nktdnRGL+QMlXyZpRoSIWOqg0ZOmAn6hJI2kdLxf8knwMkm40o CptLLVgyNVdFbLqSE4UgvbVcrqbZ2eGbckLICNZ6sySq6kAY5VvVVahjeJBmzWjVBaMv 2GfSsitc4cYD2xLy6zd8EZWsCQ1YHJoeI9ZDiwdkBUEoo9aTsfASvhbnSGVXOxJLgryL 06rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=p1GV5L4kXkwF513RFzbpeqJMhNCAHm0+rLW65qR5s04=; b=l7/prIImpCltXC646Y+bBzUSgbCKJP+qPDdK1agks2biZkdUANDArbMgcjr9DVzibN F0ySXpdIchWoivo8KTQjy5eim57wOLXZoMB4BIQsHXAE+9FsTNJqcu4za+WjoKnL8hXs xyIi81WZ2NJzybke0/sJBctHhJvAfU+sq9+ePoZjks5251Ctejq4ZLs8iEeG/ZpxHY6m pEtnLLkgAWJuKd3sO8ZK5lIFGeTNTyeh98rvGQbYlipvKdDegUrw1jEz53IugMUnym1Q yQ1ZjXNazoTIUNwNo7QEaiTD99mF/nI7CpEXkl5O4wyn9Wa1PHRvvvT4h8u7c/PRMbQa 0iCg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id d3si1228672wru.149.2019.04.18.02.06.10 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH2ze-0001mB-SZ; Thu, 18 Apr 2019 11:06:07 +0200 Message-Id: <20190418084253.431851214@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:23 +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 04/29] backtrace-test: Simplify stack trace handling References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Replace the indirection through struct stack_trace by using the storage array based interfaces. Signed-off-by: Thomas Gleixner --- kernel/backtracetest.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) --- a/kernel/backtracetest.c +++ b/kernel/backtracetest.c @@ -48,19 +48,14 @@ static void backtrace_test_irq(void) #ifdef CONFIG_STACKTRACE static void backtrace_test_saved(void) { - struct stack_trace trace; unsigned long entries[8]; + unsigned int nr_entries; pr_info("Testing a saved backtrace.\n"); pr_info("The following trace is a kernel self test and not a bug!\n"); - trace.nr_entries = 0; - trace.max_entries = ARRAY_SIZE(entries); - trace.entries = entries; - trace.skip = 0; - - save_stack_trace(&trace); - print_stack_trace(&trace, 0); + nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 0); + stack_trace_print(entries, nr_entries, 0); } #else static void backtrace_test_saved(void) From patchwork Thu Apr 18 08:41:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906727 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 3A988922 for ; Thu, 18 Apr 2019 09:06:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22A87289C5 for ; Thu, 18 Apr 2019 09:06:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15F1528A9B; Thu, 18 Apr 2019 09:06:32 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37869289C5 for ; Thu, 18 Apr 2019 09:06:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0EB866B000D; Thu, 18 Apr 2019 05:06:15 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 055986B0010; Thu, 18 Apr 2019 05:06:14 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E32B06B0269; Thu, 18 Apr 2019 05:06:14 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by kanga.kvack.org (Postfix) with ESMTP id 8DF5A6B000D for ; Thu, 18 Apr 2019 05:06:14 -0400 (EDT) Received: by mail-wr1-f72.google.com with SMTP id x9so1502346wrw.20 for ; Thu, 18 Apr 2019 02:06:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=QesvxAdhNbDpCrwGVxWTyn37DOC2nIpwHMLZVWagzF4=; b=lJnENKmEbWpN9ZtLJi4xJLdtmRhkGVOYv3BApZOaFGHu6XFcuMbN+eGK2+TXqU6oLn EqfeqQKecffwgyeSU6clyMuHknaSPv6VKMEvUfOshSUOYka2G0skiY+52xvHE70dc2dp XpXqbZ2i/h8EWOpLyFHx1SlJ/JvekzArGMVVrFWskebBGwDyPe0IXZ57YwlSvjA8zRCB 2qczDBGpPFc4VMQaR98cS/OhcvZLZfruNvwxBe2Wqw2ut51Fbfe7wO3Ftumv+x3Cf1bH F7VmipoxnyvEHPSED1SckSqn2Vg7RosDKAZXByCOGDJ2C3cYdBKT4VVWZ/EDLZUSFEEX GoDQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAX+Y1yGom0ArIN8MrkLgBekbV5ifye1xL7HEF0McOdWF4IFyfcU 1fUR1GOInYdYqdV3VrBHKCt/7l7Y8TdDkPnjT6ZUQN1uY7IDSkWYEPe/hzsOsXRaxAgms9e45fz rY1pH/1WtuLqt4i5vB5ZPdMByjq5FzsbXxhk5Bhz/vqWjTnH7+2JdKbg6R8ZOmx3L1A== X-Received: by 2002:a1c:3982:: with SMTP id g124mr2218467wma.25.1555578374115; Thu, 18 Apr 2019 02:06:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyDq7p6N7QSldg1tjppEc4gvb8DlJPXdOsuRk1URbWt2ih7/Ih05xOzgQUdHYYNhc3RDUVg X-Received: by 2002:a1c:3982:: with SMTP id g124mr2218416wma.25.1555578373271; Thu, 18 Apr 2019 02:06:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578373; cv=none; d=google.com; s=arc-20160816; b=R3kSlx5IsMfpdVX/m1Y7NckbcYruVTN4txdZmJTjKjmErHokpiT5lALO0dQzcjOsZ5 2NkT6SqE99eRWSIMUuf1Wq518te85zfbsB3fWa7lWS9awekekGZJI9ZOwSSypErfbKTK dMJfYH3mJgyAIKyYGM1/MKM0gmzSnK2ZHrVS77mCHYat2fYHdrX4xLTlp6m8iNwLJls4 1J2UlNLlo/xW7HcYaUvUgVnMkT1/Rih+HC+5fG9zHx7FqacRy4zjHqPLDUvFsOhNzkpk GyP518iuir0I9lCsOc/qlMqquXe7mF8lCM+bhtFVBtoHcKqe1duhpFPFwXCsqNi3QmcL VmRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=QesvxAdhNbDpCrwGVxWTyn37DOC2nIpwHMLZVWagzF4=; b=j8RYcufEO+732KIJLfL3JsfmB+ZBdAnWyqtsWQIFcTDpFwkjwN5rT2GCoT2GHBPFEd BBJDcSAXJD5MzzxbYfaHBqzq+LpHOME5o6B1qrcR+ce5CdVXOJX/2oswMbL8gZ5brlpm JwsoQ2PSl9J+ipqs4pHOuF1HOrDKxUgNgq+hy5nauEOU6uGUIK2ldBh15cZwDeZD0kV3 Pes7VUsc6/ZlCgC7PLkWLa/tAGK0w2pAVRjS86UrU8jgNQWvVQRL1v5td0FM/7DZAG4p fvMHp34uySqu82aqrLEzAyMZWH819vPabj0dAT9Kv2/nXwmLj/4Ws9nHTdImajySbvgE 2iRg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id l10si1083577wme.127.2019.04.18.02.06.13 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH2zh-0001mY-4r; Thu, 18 Apr 2019 11:06:09 +0200 Message-Id: <20190418084253.534580989@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:24 +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 05/29] proc: Simplify task stack retrieval References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Replace the indirection through struct stack_trace with an invocation of the storage array based interface. Signed-off-by: Thomas Gleixner Reviewed-by: Alexey Dobriyan Cc: Andrew Morton --- fs/proc/base.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -407,7 +407,6 @@ static void unlock_trace(struct task_str static int proc_pid_stack(struct seq_file *m, struct pid_namespace *ns, struct pid *pid, struct task_struct *task) { - struct stack_trace trace; unsigned long *entries; int err; @@ -430,20 +429,17 @@ static int proc_pid_stack(struct seq_fil if (!entries) return -ENOMEM; - trace.nr_entries = 0; - trace.max_entries = MAX_STACK_TRACE_DEPTH; - trace.entries = entries; - trace.skip = 0; - err = lock_trace(task); if (!err) { - unsigned int i; + unsigned int i, nr_entries; - save_stack_trace_tsk(task, &trace); + nr_entries = stack_trace_save_tsk(task, entries, + MAX_STACK_TRACE_DEPTH, 0); - for (i = 0; i < trace.nr_entries; i++) { + for (i = 0; i < nr_entries; i++) { seq_printf(m, "[<0>] %pB\n", (void *)entries[i]); } + unlock_trace(task); } kfree(entries); From patchwork Thu Apr 18 08:41:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906729 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 14EBF161F for ; Thu, 18 Apr 2019 09:06:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1C69289AF for ; Thu, 18 Apr 2019 09:06:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E515B28AB2; Thu, 18 Apr 2019 09:06:35 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFD04289AF for ; Thu, 18 Apr 2019 09:06:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F4376B0010; Thu, 18 Apr 2019 05:06:16 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 584BC6B0269; Thu, 18 Apr 2019 05:06:16 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3FBDA6B026A; Thu, 18 Apr 2019 05:06:16 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by kanga.kvack.org (Postfix) with ESMTP id DEEB26B0010 for ; Thu, 18 Apr 2019 05:06:15 -0400 (EDT) Received: by mail-wr1-f72.google.com with SMTP id k17so1525759wrq.7 for ; Thu, 18 Apr 2019 02:06:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=ndPMY5lfafu/EZtXmPJOgPVCY5qMZpY8tacLKTDS9zk=; b=Pk3YnYJvUHMnYQ7fi7i9K4sL3J+PYy5Ke6XmPb51ZPCv4QE+7Ik5lMzO+YLIaVBBiN BwqhUg1lrG1s3eJUO3Fsy1yP9GjQKlLlblvcdlB2UdhA3AV1yW/8cSs+qfoc2JaWZ1iW YAYrCE3TDkPyV8YeuNtGBYLGwocSX6M+dGw8iwSD5WGt3e5cbaabXuGrUfHMTsCwrO52 aU3xAN89uJaV5/RWK+MvCYHIHH3v73WV/NMaZ56tuMcRPlyu4GdTUUVBZgqQPRyuR497 n+XMbtM5xNVYVIGhVbTkiouoDByuQoUOd144Llcq4fswA8uHFZroUXRRS/4U3mT+8Hct zXOw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAXQO/rFGqrWw3mNJxDAiNPXYj2AUHC1WvlxyWCg4K0Z3a2QgkD3 sLNa2Av0z4ZxqVs/f1Tka57Sp2vpghmIkmKiJnZWb+YAsG9Q6koy2ddYMpasyTrT0z1f7cCdQr2 zg6U2vTONrzKyAv3hxDTEVgULQwF4qbsTsFzL8SuxKjpPtFKbJvzKsf6r9gKzwcFtrg== X-Received: by 2002:a1c:2246:: with SMTP id i67mr2209475wmi.148.1555578375439; Thu, 18 Apr 2019 02:06:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqzw56sN8U5xexBs784LmZGqb793r+1BwbIlCgB+Wtr4fG242biYnAljKV5XCu8uueGeG59D X-Received: by 2002:a1c:2246:: with SMTP id i67mr2209395wmi.148.1555578374325; Thu, 18 Apr 2019 02:06:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578374; cv=none; d=google.com; s=arc-20160816; b=tvkPKxA8djFWnkr6fqskuYl5TELrPtJcoO1EKkRKY/Sw4XOS3v+ZdLQoGOwDEPKqkc w6rU8zLdmO1vgIDNpBzU6GU8aqZr/j0E4RuY9Qq/QC0jTdYBU+g8lC5cG2NyNa85doVX IXVhFsEjajc8Y2VcT867c7DO6XaFfFxs/1lr8jnv9hEKnntdBgTsRGFC33bD+R3evFoS 1se3J5gEaobrJOWIZ24qVKrNR9TIDuc50pIAvPdPdCM2RhiUU/ydDJAN/c3h4ft4W5WY TmmYup1CJ9wN336zuNhWAaLKiOqQw8R362aYO+15r4++Em+qA2GoilRj70xkYCQnsg33 QnLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=ndPMY5lfafu/EZtXmPJOgPVCY5qMZpY8tacLKTDS9zk=; b=PDP4TXicDSBtReAeIXfUHjlTAsTFXd9aLWRwtrixtcM2tDU+ZmLuOZ+Pxib7aGpK3h yHHIITF+/WKEYnJB/UNwR3qVkNE1DEl9lEvJCEvbtK+TEm8yTYAyNYBdYy56nsElVvZI TBijnEIEq/wAo50N0ODoCdT+k2+RN6lJkNKZZAuLDP2GtBfJBu/TZUPiljy+i5HoPCoL qKfXCalE1vydF19jbJQzokk1LQmAM5qNWLKb+rFOs1tCssIwe6XDlfky1ZjCMGQYGmkM Q7/eaw+QuqyNtSboDtQ6BCscL2kWLWerkw0GTZhRx73qH3W2gSIaSg2Mbzs2r6OVpjk6 UPSA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id c8si1189775wro.416.2019.04.18.02.06.14 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH2zj-0001n0-DA; Thu, 18 Apr 2019 11:06:11 +0200 Message-Id: <20190418084253.628227766@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:25 +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 06/29] latency_top: Simplify stack trace handling References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Replace the indirection through struct stack_trace with an invocation of the storage array based interface. Signed-off-by: Thomas Gleixner --- kernel/latencytop.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) --- a/kernel/latencytop.c +++ b/kernel/latencytop.c @@ -141,20 +141,6 @@ account_global_scheduler_latency(struct memcpy(&latency_record[i], lat, sizeof(struct latency_record)); } -/* - * Iterator to store a backtrace into a latency record entry - */ -static inline void store_stacktrace(struct task_struct *tsk, - struct latency_record *lat) -{ - struct stack_trace trace; - - memset(&trace, 0, sizeof(trace)); - trace.max_entries = LT_BACKTRACEDEPTH; - trace.entries = &lat->backtrace[0]; - save_stack_trace_tsk(tsk, &trace); -} - /** * __account_scheduler_latency - record an occurred latency * @tsk - the task struct of the task hitting the latency @@ -191,7 +177,8 @@ void __sched lat.count = 1; lat.time = usecs; lat.max = usecs; - store_stacktrace(tsk, &lat); + + stack_trace_save_tsk(tsk, lat.backtrace, LT_BACKTRACEDEPTH, 0); raw_spin_lock_irqsave(&latency_lock, flags); From patchwork Thu Apr 18 08:41:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906735 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 4DB391850 for ; Thu, 18 Apr 2019 09:06:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37D8C28AC4 for ; Thu, 18 Apr 2019 09:06:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B41528AF3; Thu, 18 Apr 2019 09:06:43 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F40728AE3 for ; Thu, 18 Apr 2019 09:06:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C0F546B026B; Thu, 18 Apr 2019 05:06:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BBFB76B026C; Thu, 18 Apr 2019 05:06:18 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A899B6B026D; Thu, 18 Apr 2019 05:06:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by kanga.kvack.org (Postfix) with ESMTP id 524216B026C for ; Thu, 18 Apr 2019 05:06:18 -0400 (EDT) Received: by mail-wr1-f72.google.com with SMTP id o16so1521652wrp.8 for ; Thu, 18 Apr 2019 02:06:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=0M2OLeqxAULJLF3vLiIc4vZkAtZeGcOr3pXLUexTG5I=; b=Ys1+IYRZHI9BG6VkhAyivZElvgDyHEo/yKt7/i+wNje+5d6Xj2W01mVCoxmDZtOHNe KQT+yB259Gjr38ZlEAN07TL/jZO3riAbOG0tIXTy/UO4M9/Qwx4+NH4V9pxko52TghKI QhaQdVta//5NK0kN6f//k9m6gG8oT1Q8LQGETgz36cmaYm9RH65RYQ1zTo7bzTbs8FwU X/Eqo4wKkmGfO8iMbUGc2IwLLbk/vylJeJFW+UELNEAl6NWNuORsf0W1lYAnoVDZEYzp JqgNU+Cuih0zAW5jzPWVdIJW9dzHGaDvkKjAZVy9OUlkwraWELSzsQxJixFDBz+/9Hcx rdrg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAWoxBGVpobMSnzKoPFHrE65/lVe5xCJVK2VpilaITPQMC9QXceE ehvj1JZoNPvtZjYJVy2FiKHBWJd3MpUXOpVWHTSuzce7OQrrjEb13UK73vuMaL2Rst6TqskWp6s z8czB9lHFb6HOBlXo2xmqfSg7qqkwgE+072QBwoDjVjorZKkzlc4j6xjgXO4ptzoXHw== X-Received: by 2002:a1c:7512:: with SMTP id o18mr2356413wmc.68.1555578377864; Thu, 18 Apr 2019 02:06:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwTcsNIxWvAbBy58Mdmd+4E54O8PHh3nKmlDoE45DGWMl2iMWvxlfBMyINtj7SMUZ1C/Zl0 X-Received: by 2002:a1c:7512:: with SMTP id o18mr2356326wmc.68.1555578376615; Thu, 18 Apr 2019 02:06:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578376; cv=none; d=google.com; s=arc-20160816; b=BnXvBYKv0le1HWHDAcE4zzxlXd2fifKVjYS3syQlKLIk8eekADDY8Qf3U1g3hCI2pW kc+G/afclRx4mBQVLh/ITReMXauPVFUhDMFAgbrfDae//9PE1B4amLBBuCOj1k1VUcJe 9SXN7BndhWeRkUKN+KJm4+unxihxVUw2TzkW/zFQaoAppDOjUrvA4IffzJG643UyRGLr qtS6oxPK/eBXA9KL/+5YGvVd/7FjxB2O4g02tIUZhzeIL11k/CnSPNgKsCHziN8S3vAN CDOWNlr0UsFtZfE/iqQqgaNMpi307bx29WOaYEqOw0rr97+zz0lfih00teQtby2HuI8m f59w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=0M2OLeqxAULJLF3vLiIc4vZkAtZeGcOr3pXLUexTG5I=; b=Q681mtisgEi12+VKbuwR0rR7VC+jvha1TJbz1TOfLOIjra0oX6HL/1B8alL5dF1yW5 B4catw9YL6Dx8EdCpudIdSBIPFwsvS5JxDPukq9nMrBhHI740GdbpwAXAO+aFA2YFfaG IWEongJfRSUxZXtpwb4xRJIpA98ITrzfwJowXaIWt1KA7ksELIerv7swW78iqkJghcF2 ZjotziFg0cnDh/vV48I4jJhVkZWUmHOPMmeqFbQ7kdzQR1jGna3hxbnjrDlXbT3oyDk8 Kqph4QlSuLBeVeQwPJ6JKl1L71KxevWof1zhJcQ+VbHlH2gAVBtjc6M5+rCan5kKbiwR avtA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id a11si1060932wmg.137.2019.04.18.02.06.16 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH2zl-0001nA-9k; Thu, 18 Apr 2019 11:06:13 +0200 Message-Id: <20190418084253.720040206@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:26 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , Andrew Morton , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Christoph Lameter , Alexey Dobriyan , 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 07/29] mm/slub: Simplify stack trace retrieval References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Replace the indirection through struct stack_trace with an invocation of the storage array based interface. Signed-off-by: Thomas Gleixner Cc: Andrew Morton Cc: Pekka Enberg Cc: linux-mm@kvack.org Cc: David Rientjes Cc: Christoph Lameter --- mm/slub.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) --- a/mm/slub.c +++ b/mm/slub.c @@ -552,18 +552,14 @@ static void set_track(struct kmem_cache if (addr) { #ifdef CONFIG_STACKTRACE - struct stack_trace trace; + unsigned int nr_entries; - trace.nr_entries = 0; - trace.max_entries = TRACK_ADDRS_COUNT; - trace.entries = p->addrs; - trace.skip = 3; metadata_access_enable(); - save_stack_trace(&trace); + nr_entries = stack_trace_save(p->addrs, TRACK_ADDRS_COUNT, 3); metadata_access_disable(); - if (trace.nr_entries < TRACK_ADDRS_COUNT) - p->addrs[trace.nr_entries] = 0; + if (nr_entries < TRACK_ADDRS_COUNT) + p->addrs[nr_entries] = 0; #endif p->addr = addr; p->cpu = smp_processor_id(); From patchwork Thu Apr 18 08:41:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906731 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 C8C26161F for ; Thu, 18 Apr 2019 09:06:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFD7A289AF for ; Thu, 18 Apr 2019 09:06:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9FF3428AEB; Thu, 18 Apr 2019 09:06:39 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BE77289DA for ; Thu, 18 Apr 2019 09:06:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 495566B026A; Thu, 18 Apr 2019 05:06:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 41DCB6B026B; Thu, 18 Apr 2019 05:06:18 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2C0316B026C; Thu, 18 Apr 2019 05:06:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by kanga.kvack.org (Postfix) with ESMTP id B565D6B026A for ; Thu, 18 Apr 2019 05:06:17 -0400 (EDT) Received: by mail-wm1-f72.google.com with SMTP id i184so1519269wmi.9 for ; Thu, 18 Apr 2019 02:06:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=vE/h4iTaYWv2pX1V6FXNHaP6c7n1dI5SFaeY9qpaUbU=; b=s0GTE7OJD1KYSLdZOQCVulaTWf6+9tQLGHZjagIqiQyWHV8LEx2a32g88vRU8HZorP GyNqVtMhgNFxncK8YeQVaohgvymvVcQBV+RmLoqK1hOq9w7dENVfoSS32qapFlb3orEe +0gQKxP1oMde7HnSfVeIGdC/3KhzPrqyPlWtvd2zL4zuE/kbqdVwZLeWQXlrBmuYFzb4 9gzK518jV8BJXrfxw2NOya7Cuy9gHArikOpP6SXKJQNo0SaWwgqZCyeV64xAvTy0tbK5 4bSxWwsy0G8uFgqnxLLvcl9gkmpOzeOM7QKZ5CNFeyskMCbZ1eRha9nUIaxoL2nPA7mq zDCQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAUCaXNPvszblYnnyspFPDDoGfD3f/3RiSuTHgWij2Zb1Rei1j6B Yp9pPZL1HUwTac/8qUYjI0YOTklehWW95vxtLr2ki6Op8mm4UeVP8DQUOLvUL4mQjSIQrjqz5bY hla1ym3EVQLoyCRgfIgsNblB0vZxOPqI43IG3uPTvNEOuik28b9LYplH0sm4X/NLR2g== X-Received: by 2002:a5d:4a8d:: with SMTP id o13mr47878306wrq.209.1555578377275; Thu, 18 Apr 2019 02:06:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqz262Qh0LNuAQSJZPguwLT1QLX0B8TWwuB9CcF4GVzJy51k6fAvkUJaOutlyidEIKmbsEka X-Received: by 2002:a5d:4a8d:: with SMTP id o13mr47878226wrq.209.1555578376120; Thu, 18 Apr 2019 02:06:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578376; cv=none; d=google.com; s=arc-20160816; b=ggTJfWyZ8g620EzzVc96108Ya5Ne6fYTWZ9X1HIrQpKc/z89ngM8C/3HQCQ+xTDa4l 6pJfX7l7hrCbyxhmDnh59P3fBZoUhZIFcjCOVGJHfBhdBMy9pqrd9ip9NmAZvagjEccC +Rd9dDyC1TsSBR/npitDbxGqlvffisJJ/e44jOTK2YW757ZgWQZKPoUGUNAQ+Na7TdrN oe5/2yPRzsXzZhuLlpzag4FB61kCAK8Gr/U8ITkPbu5/NVuZyc0beNozaXFhaVmVJ9Aj u//XKBFs8FPpcZoffCLT7PPvCFOTEX28XdDgokEPXMYxjPCJKd+NYKRotu5h2IxVDz8C eznQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=vE/h4iTaYWv2pX1V6FXNHaP6c7n1dI5SFaeY9qpaUbU=; b=yy2JiYC1f5mV/vpd8wg9j77bKGnFeNmUptHTtRB43syvbf5qdK9gMJ49Xb51QF8ajD vQrxIcJeWx11aUfmg1J3Eld0fKdqbRxH/BjF2p8BQUddSUioc550/nPsuIiAbjt2CWU5 b9WPUpVXBI7i0KzR2sVvvzLO7XckwCqpTAJeoGeNnsCadZi3D5Cgu9/XzRBdqTmwGrtP 0JJrrLDA1h6Qi/Ip68Em27F/fIOdV2Jdou0jbv3Px8bO5T+2yzFdyAPRZ0Mv8wpsCybM WUq2NBPBqm4YVMckGziy5RmdTp+WmUKXxU7F5R0KQ9dQFDcZQwUQWz6NzoEpX3v6jrxH gEsg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id z185si1090349wmb.30.2019.04.18.02.06.15 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH2zn-0001nO-Dg; Thu, 18 Apr 2019 11:06:15 +0200 Message-Id: <20190418084253.811477032@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:27 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , Catalin Marinas , linux-mm@kvack.org, Alexey Dobriyan , Andrew Morton , Pekka Enberg , David Rientjes , Christoph Lameter , 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 08/29] mm/kmemleak: Simplify stacktrace handling References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Replace the indirection through struct stack_trace by using the storage array based interfaces. Signed-off-by: Thomas Gleixner Cc: Catalin Marinas Cc: linux-mm@kvack.org Acked-by: Catalin Marinas --- mm/kmemleak.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -410,11 +410,6 @@ static void print_unreferenced(struct se */ static void dump_object_info(struct kmemleak_object *object) { - struct stack_trace trace; - - trace.nr_entries = object->trace_len; - trace.entries = object->trace; - pr_notice("Object 0x%08lx (size %zu):\n", object->pointer, object->size); pr_notice(" comm \"%s\", pid %d, jiffies %lu\n", @@ -424,7 +419,7 @@ static void dump_object_info(struct kmem pr_notice(" flags = 0x%x\n", object->flags); pr_notice(" checksum = %u\n", object->checksum); pr_notice(" backtrace:\n"); - print_stack_trace(&trace, 4); + stack_trace_print(object->trace, object->trace_len, 4); } /* @@ -553,15 +548,7 @@ static struct kmemleak_object *find_and_ */ static int __save_stack_trace(unsigned long *trace) { - struct stack_trace stack_trace; - - stack_trace.max_entries = MAX_TRACE; - stack_trace.nr_entries = 0; - stack_trace.entries = trace; - stack_trace.skip = 2; - save_stack_trace(&stack_trace); - - return stack_trace.nr_entries; + return stack_trace_save(trace, MAX_TRACE, 2); } /* @@ -2019,13 +2006,8 @@ early_param("kmemleak", kmemleak_boot_co static void __init print_log_trace(struct early_log *log) { - struct stack_trace trace; - - trace.nr_entries = log->trace_len; - trace.entries = log->trace; - pr_notice("Early log backtrace:\n"); - print_stack_trace(&trace, 2); + stack_trace_print(log->trace, log->trace_len, 2); } /* From patchwork Thu Apr 18 08:41:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906741 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 32EA6161F for ; Thu, 18 Apr 2019 09:06:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B933289DA for ; Thu, 18 Apr 2019 09:06:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E3F528AB2; Thu, 18 Apr 2019 09:06:47 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC229289DA for ; Thu, 18 Apr 2019 09:06:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F1D5A6B0270; Thu, 18 Apr 2019 05:06:21 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EA8C86B026F; Thu, 18 Apr 2019 05:06:21 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D73036B0270; Thu, 18 Apr 2019 05:06:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by kanga.kvack.org (Postfix) with ESMTP id 7EBF76B026D for ; Thu, 18 Apr 2019 05:06:21 -0400 (EDT) Received: by mail-wr1-f72.google.com with SMTP id q16so1500602wrr.22 for ; Thu, 18 Apr 2019 02:06:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=vo4FaxAT2/1G624q3L+4nrU71S7g/ECh1ZFuY5z36RE=; b=rAuNipPvWzrzA46odsFFI5umCGktXmXro52fFxof4OyEy5Vzl7Ar5tGPHUS/GvmAXp PnXQjXyO6iAt0C21awu3FmxI0DpJMyNq3kymwUJJ8JGMELkZ+FfPCp2hO6EjQP4pMPqx WcWIOXybrpRYGMEJsyYRcuYAEt86uK4PgX3gF2RGVJ0XwSSn4ZTf89o5wQKU+WvTeKzG +WEgZ5I+yJgtofc9N8SpZswmKtTjOMb3XIcAeQB7Xq7KQWxYrBj3Msj4OTRiLRjV3oNt oiKZjjFvQmj8YXlVHf+afNeUka0dMsIeOT2ud1iluGIowlhZbG16foWFlK6AS5bu1WOX X+wQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAVZZRQkxhDBRRo1uCtE9V/XSrVq3titYKDmpQDa3ir6xMDFYAZm 2zxtjuaKEYj9nQiSMIYPNxYN1fCfzh8vOYiwXf4/8usGN6PLbSDDRZYEfTVv7V7YjNh3DrAY48y 5jNM8xjDjWXH/Ul6NLqpnSck0FBzTTUI6L4egc2Di3uz1ZV9/nj/w6H5WZmtn7RPDNA== X-Received: by 2002:a1c:7dd7:: with SMTP id y206mr2216067wmc.81.1555578381046; Thu, 18 Apr 2019 02:06:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwF+pQ1JF0wQSom4Hs6R8InEQu+xlG97/3RLIAarF7SRJZpyUnNBer/t2gzRb172atcFMpQ X-Received: by 2002:a1c:7dd7:: with SMTP id y206mr2215983wmc.81.1555578379995; Thu, 18 Apr 2019 02:06:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578379; cv=none; d=google.com; s=arc-20160816; b=f7hHESS9qBYBzh8IItm5pBQOJSJwwtTF5JowMUJhts8YNKGBO2ss+MWEitfcHXN5u/ zR/rbiW2rZhsxvxpK3zsVEqPic9PTIGo8KCYtIFrL4dY3KkTyuXfoPHOArxQCasjwWA1 vfVOgKAp5cHGODBlEBSWV4q8V8hKVnV3fqPq17AyIwVbrnvUznd9sZUe3TjQOIUYi/lh T9JgIwzDnp52RMi7+8iA/IKz1uhVGAVpQHtNix/UzgWn62VbhC7tFgmHFe95R12o2gCa 7n77yvx2ghcEpCcd1UJa6ofBSTb2J4LWfPAqOHzOE3Qv9NT/AP2V1uuGdE5aR6DZ2bdo zfWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=vo4FaxAT2/1G624q3L+4nrU71S7g/ECh1ZFuY5z36RE=; b=Tz/fpPBu+BzJMkr6U60ixmFraOjQepWRC5SC+FLS3L0tPMI4qs/Rw6oDyOjjzYGSsd IuNchivZkuRnydkyV0hHr9qz9YanVh9LzmB+x6pcuitpunPH/bkb0aArClnO8hXiA6ED KxCC/5/xdmtzwwopaxe7hu+Rpj+sUN8JhojjgCpVq0LUtF53iI4JinCUwCpxtF/cW2/4 VWqiO6754+xoU3UTCaTuBoWgug/RzUHwKUceRN5mH8tJbiTAg/Ah4XLJS+nSk0nw2G06 3/CAEU2h3WuJnv9DoXTf2lj+qVVKwyh+obtB2ebHn3lkbyKbbbLA50j2XhFJ4E3c5X2h 3G8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id u10si1222365wrq.57.2019.04.18.02.06.19 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH2zp-0001nn-CA; Thu, 18 Apr 2019 11:06:17 +0200 Message-Id: <20190418084253.903603121@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:28 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, linux-mm@kvack.org, Alexey Dobriyan , Andrew Morton , Pekka Enberg , David Rientjes , Christoph Lameter , Catalin Marinas , 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 09/29] mm/kasan: Simplify stacktrace handling References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Replace the indirection through struct stack_trace by using the storage array based interfaces. Signed-off-by: Thomas Gleixner Acked-by: Dmitry Vyukov Cc: Andrey Ryabinin Cc: Alexander Potapenko Cc: kasan-dev@googlegroups.com Cc: linux-mm@kvack.org Acked-by: Andrey Ryabinin --- mm/kasan/common.c | 30 ++++++++++++------------------ mm/kasan/report.c | 7 ++++--- 2 files changed, 16 insertions(+), 21 deletions(-) --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -48,34 +48,28 @@ static inline int in_irqentry_text(unsig ptr < (unsigned long)&__softirqentry_text_end); } -static inline void filter_irq_stacks(struct stack_trace *trace) +static inline unsigned int filter_irq_stacks(unsigned long *entries, + unsigned int nr_entries) { - int i; + unsigned int i; - if (!trace->nr_entries) - return; - for (i = 0; i < trace->nr_entries; i++) - if (in_irqentry_text(trace->entries[i])) { + for (i = 0; i < nr_entries; i++) { + if (in_irqentry_text(entries[i])) { /* Include the irqentry function into the stack. */ - trace->nr_entries = i + 1; - break; + return i + 1; } + } + return nr_entries; } static inline depot_stack_handle_t save_stack(gfp_t flags) { unsigned long entries[KASAN_STACK_DEPTH]; - struct stack_trace trace = { - .nr_entries = 0, - .entries = entries, - .max_entries = KASAN_STACK_DEPTH, - .skip = 0 - }; + unsigned int nr_entries; - save_stack_trace(&trace); - filter_irq_stacks(&trace); - - return depot_save_stack(&trace, flags); + nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 0); + nr_entries = filter_irq_stacks(entries, nr_entries); + return stack_depot_save(entries, nr_entries, flags); } static inline void set_track(struct kasan_track *track, gfp_t flags) --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -100,10 +100,11 @@ static void print_track(struct kasan_tra { pr_err("%s by task %u:\n", prefix, track->pid); if (track->stack) { - struct stack_trace trace; + unsigned long *entries; + unsigned int nr_entries; - depot_fetch_stack(track->stack, &trace); - print_stack_trace(&trace, 0); + nr_entries = stack_depot_fetch(track->stack, &entries); + stack_trace_print(entries, nr_entries, 0); } else { pr_err("(stack is not available)\n"); } From patchwork Thu Apr 18 08:41:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906745 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 215F7922 for ; Thu, 18 Apr 2019 09:06:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 080BB289DA for ; Thu, 18 Apr 2019 09:06:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF99928AC4; Thu, 18 Apr 2019 09:06:50 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B6DD289AF for ; Thu, 18 Apr 2019 09:06:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4E1226B026D; Thu, 18 Apr 2019 05:06:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 48FDC6B026E; Thu, 18 Apr 2019 05:06:22 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E9236B026F; Thu, 18 Apr 2019 05:06:22 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by kanga.kvack.org (Postfix) with ESMTP id C08C56B026E for ; Thu, 18 Apr 2019 05:06:21 -0400 (EDT) Received: by mail-wr1-f71.google.com with SMTP id f16so1526177wrs.6 for ; Thu, 18 Apr 2019 02:06:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=0y/QyUdaOvECJaR4ueRYQdFEB+ebIhDutCtUQ6iFeT4=; b=BsE7fwIJaoA1I80TNJJfYHrx3GSLDO1SKI4hvdppazbP8Noj5rxpKB/3gxqxZZ4eZL XJHt8B0A7zOhJJxxxo9bXKaIDmnQVglFOnt7lN15xW1dpyB8l3TzIsLYYVQshADb4oTR 2iHe2c2L5KOFz1MdbFH2V72QMnomzgBT4i0Dnj3iuafU2RDbEGhwmXSGlkSb+OUsf4sT WXVY0JivLsmX+mn+TLTZ9RoN7KcWo5Kk8L0W/vIRXZAmX+4/eV4N7JjLuLliKBnqcjYk 4VPFC0GXl1/6Nd4CWCJ9enxGaSTL7Zc9WIWY47LmLYOEhDJR44Ma3oYQsnF7A6nQVNOT MmsQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAUIZehqqg/LYSocHV+59C1WJyD/d18y/0lcz/9atQ2Ge9Ltb6zo 24XG0RvlsIT/vDvSv4iZmAEYvDFJSA419NmAlFTuW5T2UMxGtiu+7yqlcmdfpx7LGhDgp1iht5P af39YNDS7l8tpgoSdROJRRhWhkdBz9LiTJAuyoH62vmccmztRWYOyqQvNcI1pVcicag== X-Received: by 2002:adf:f309:: with SMTP id i9mr37465632wro.258.1555578381282; Thu, 18 Apr 2019 02:06:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqyjZRtYrYU9Zptp+vKB3+H+mz3rtEnvvwla/XPgRc3Y92xmlojerDNPxz73lXw1J4ikGkIj X-Received: by 2002:adf:f309:: with SMTP id i9mr37465580wro.258.1555578380416; Thu, 18 Apr 2019 02:06:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578380; cv=none; d=google.com; s=arc-20160816; b=UEGDuw1eGtudmV7NEvYv8TV9HenvfSrwWAyZck6d2GMZE1TW3L11NxD5/laT89o1hO hoWB9tbgiUqo1WSJVTW1mCpEw7ooQauWKePH1MIPFXac0vleFaO+sNNrHOPdBQ8UMaHW WbvclVeip7+JxiSWDD0fhN5doN1qEYVRoRuvY+1bH5loMEshSXX7a5JBMAe1WavSthqr uKpXKiQAOLvp+ThEGALAJ+7XcVZVktO00RkNV/61r21LsnVXJLE22LCHsUfg+Sgk4X7L M2oLbmkP50M9ReGVr6HdyYBVFbD6IQTbi2x+6z/ZATyJOmXJ0CcE0YKo1Rp3BGrpI+Cp coFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=0y/QyUdaOvECJaR4ueRYQdFEB+ebIhDutCtUQ6iFeT4=; b=DKFnvRIj+7LHy3LHb2NvwSeltu6tIUS+Wx1fqVEYuvP6PHc2FQtIOPxHWQDCHFWrpb Wgb4Cw2s6nqDF19e3oEaJ3+5Hvm9ETncfPXa+oawxZiWHddh9cpltZshUsZju8aSMMRt Jb5mvUq0t8xyyH9GalOtd/HFVXSBClPdGlXtz6K4BVOJAFDLgB33USzJ6Tk9JaDvEV6h /0mY+M+pzQdwqAM4GkvHkeqQXDW7KiQdHbZLyAKmc3ItjPRe/naVKEQXc9MWwEv9qrT+ fOnReELGAMPlEknzr3Ct7L8Vby9/m10b0GNvSaYSrC7xyBoIwyssCzhJp9QL3KB5mVmf 4LCA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id f199si1155963wmf.58.2019.04.18.02.06.20 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH2zr-0001oP-DR; Thu, 18 Apr 2019 11:06:19 +0200 Message-Id: <20190418084253.991328385@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:29 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , linux-mm@kvack.org, Mike Rapoport , David Rientjes , Andrew Morton , Alexey Dobriyan , Pekka Enberg , Christoph Lameter , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, 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 10/29] mm/page_owner: Simplify stack trace handling References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Replace the indirection through struct stack_trace by using the storage array based interfaces. The original code in all printing functions is really wrong. It allocates a storage array on stack which is unused because depot_fetch_stack() does not store anything in it. It overwrites the entries pointer in the stack_trace struct so it points to the depot storage. Signed-off-by: Thomas Gleixner Cc: linux-mm@kvack.org Cc: Mike Rapoport Cc: David Rientjes Cc: Andrew Morton --- mm/page_owner.c | 79 +++++++++++++++++++------------------------------------- 1 file changed, 28 insertions(+), 51 deletions(-) --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -58,15 +58,10 @@ static bool need_page_owner(void) static __always_inline depot_stack_handle_t create_dummy_stack(void) { unsigned long entries[4]; - struct stack_trace dummy; + unsigned int nr_entries; - dummy.nr_entries = 0; - dummy.max_entries = ARRAY_SIZE(entries); - dummy.entries = &entries[0]; - dummy.skip = 0; - - save_stack_trace(&dummy); - return depot_save_stack(&dummy, GFP_KERNEL); + nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 0); + return stack_depot_save(entries, nr_entries, GFP_KERNEL); } static noinline void register_dummy_stack(void) @@ -120,46 +115,39 @@ void __reset_page_owner(struct page *pag } } -static inline bool check_recursive_alloc(struct stack_trace *trace, - unsigned long ip) +static inline bool check_recursive_alloc(unsigned long *entries, + unsigned int nr_entries, + unsigned long ip) { - int i; + unsigned int i; - if (!trace->nr_entries) - return false; - - for (i = 0; i < trace->nr_entries; i++) { - if (trace->entries[i] == ip) + for (i = 0; i < nr_entries; i++) { + if (entries[i] == ip) return true; } - return false; } static noinline depot_stack_handle_t save_stack(gfp_t flags) { unsigned long entries[PAGE_OWNER_STACK_DEPTH]; - struct stack_trace trace = { - .nr_entries = 0, - .entries = entries, - .max_entries = PAGE_OWNER_STACK_DEPTH, - .skip = 2 - }; depot_stack_handle_t handle; + unsigned int nr_entries; - save_stack_trace(&trace); + nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 2); /* - * We need to check recursion here because our request to stackdepot - * could trigger memory allocation to save new entry. New memory - * allocation would reach here and call depot_save_stack() again - * if we don't catch it. There is still not enough memory in stackdepot - * so it would try to allocate memory again and loop forever. + * We need to check recursion here because our request to + * stackdepot could trigger memory allocation to save new + * entry. New memory allocation would reach here and call + * stack_depot_save_entries() again if we don't catch it. There is + * still not enough memory in stackdepot so it would try to + * allocate memory again and loop forever. */ - if (check_recursive_alloc(&trace, _RET_IP_)) + if (check_recursive_alloc(entries, nr_entries, _RET_IP_)) return dummy_handle; - handle = depot_save_stack(&trace, flags); + handle = stack_depot_save(entries, nr_entries, flags); if (!handle) handle = failure_handle; @@ -337,16 +325,10 @@ print_page_owner(char __user *buf, size_ struct page *page, struct page_owner *page_owner, depot_stack_handle_t handle) { - int ret; - int pageblock_mt, page_mt; + int ret, pageblock_mt, page_mt; + unsigned long *entries; + unsigned int nr_entries; char *kbuf; - unsigned long entries[PAGE_OWNER_STACK_DEPTH]; - struct stack_trace trace = { - .nr_entries = 0, - .entries = entries, - .max_entries = PAGE_OWNER_STACK_DEPTH, - .skip = 0 - }; count = min_t(size_t, count, PAGE_SIZE); kbuf = kmalloc(count, GFP_KERNEL); @@ -375,8 +357,8 @@ print_page_owner(char __user *buf, size_ if (ret >= count) goto err; - depot_fetch_stack(handle, &trace); - ret += snprint_stack_trace(kbuf + ret, count - ret, &trace, 0); + nr_entries = stack_depot_fetch(handle, &entries); + ret += stack_trace_snprint(kbuf + ret, count - ret, entries, nr_entries, 0); if (ret >= count) goto err; @@ -407,14 +389,9 @@ void __dump_page_owner(struct page *page { struct page_ext *page_ext = lookup_page_ext(page); struct page_owner *page_owner; - unsigned long entries[PAGE_OWNER_STACK_DEPTH]; - struct stack_trace trace = { - .nr_entries = 0, - .entries = entries, - .max_entries = PAGE_OWNER_STACK_DEPTH, - .skip = 0 - }; depot_stack_handle_t handle; + unsigned long *entries; + unsigned int nr_entries; gfp_t gfp_mask; int mt; @@ -438,10 +415,10 @@ void __dump_page_owner(struct page *page return; } - depot_fetch_stack(handle, &trace); + nr_entries = stack_depot_fetch(handle, &entries); pr_alert("page allocated via order %u, migratetype %s, gfp_mask %#x(%pGg)\n", page_owner->order, migratetype_names[mt], gfp_mask, &gfp_mask); - print_stack_trace(&trace, 0); + stack_trace_print(entries, nr_entries, 0); if (page_owner->last_migrate_reason != -1) pr_alert("page has been migrated, last migrate reason: %s\n", From patchwork Thu Apr 18 08:41:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906749 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 895B718FD for ; Thu, 18 Apr 2019 09:06:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7212B28857 for ; Thu, 18 Apr 2019 09:06:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65A75289DA; Thu, 18 Apr 2019 09:06:51 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06191289AF for ; Thu, 18 Apr 2019 09:06:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E7DEC6B0271; Thu, 18 Apr 2019 05:06:27 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E2FED6B0272; Thu, 18 Apr 2019 05:06:27 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D1E3C6B0273; Thu, 18 Apr 2019 05:06:27 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by kanga.kvack.org (Postfix) with ESMTP id 806D16B0271 for ; Thu, 18 Apr 2019 05:06:27 -0400 (EDT) Received: by mail-wm1-f71.google.com with SMTP id y189so1536476wmd.4 for ; Thu, 18 Apr 2019 02:06:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=BUnZ/ks7/6dECieHXMrPx4NPCWL205Gf+OSamdw8cq0=; b=Xu8+p0T+VXfSCO/dJeoc+OauWPLXWwmdLKudC4qrL56m5qJwErV6UpuCSDJgxZySy4 BODVtogqhTRwYOGPlr3C+OQzxQPiOhUyQN6BelQ8e0xi5IWMYEf//cpP8qGZfNqKMKFq ClmoJdxrlKY+vPtRgQEJmt1LchdGVp9oXTxB/uXD4sbmOwj4JlJKP5INSQqgpUmTdCe/ o21qv0wHM6/VqBfv1Qgod6b0Np9uu+yZgu0j0bUCj+RBye6l3w423Ghibx2OnE10DcBK cr1u14GQMt1q7T32bbMGCQsucdDDK9mW21ld7++z9c0KMnPxrqrTRZJlpU55ro24Njwi fSPQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAULvX9n43XEOzVvxsIg/MRxbV2bT7iemYqQ8K5UZTW4tBo8pnEc zyvlL76xRh56YeSK562oIwLURcgSlECF/Qv7nhsa3YhZCR45Hhj6cAE9wZhqve+jObHMeti2oqp tLS3pNMxWo+l8QDh9XsM5ETPd4Cq4eeA+Q4xZ3FTuo1H7/76T9wOw4Fo4GLwUAnFI6w== X-Received: by 2002:a5d:634c:: with SMTP id b12mr37029841wrw.203.1555578386981; Thu, 18 Apr 2019 02:06:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqzh4B1ZxVckSsU/YJ11mcVBMHyQaOan9SvVvsJKziE7l8eHbvpi4oFCLImjoPAcZ4F/N0qZ X-Received: by 2002:a5d:634c:: with SMTP id b12mr37029788wrw.203.1555578386273; Thu, 18 Apr 2019 02:06:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578386; cv=none; d=google.com; s=arc-20160816; b=pWWse/u/M2NXi4pPAVbFph7U7hNVZ9ZnzvUBQfh3zUKSMTSauOnX5+HpNrVs/Pys9s ddkbpaHyqPB7ijYiLw2OJ5dGgbGHRY2If6/o/0n0f7xni7ciCcJoUxfZ7qFYb4p9PM6w mq6X1gemXVvgCA8VRglpxr/eLgTdS8N2JkM8JuNjgLX839OMTWo7pwSTvFcsVrZUUVP/ JqFzTyCOsIyoo298vGmKWyB6B9C3U7wKPXlZzf9SfcOxjb+sETMVIiQvLw4UTs6fHMT7 VEbq+ssCfmUnojpxMiqKDV4tJdCl1XMcHpbVoKWVYq2th/8Zn7CUokJjtFIbGOtZMLvv 5faw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=BUnZ/ks7/6dECieHXMrPx4NPCWL205Gf+OSamdw8cq0=; b=KJolh1QHWW5sMm909X8Byo/bZtKJDtCaMNnD0tVkEfOvWq98V9zkPCUmzulHEq0YHv piTUnFkV8sSbL+7h0XPE/0q2zssEeqLYgScMq4/KIQlZVrXsatujD9HozkQYmxTDkw/Z v5lcBktrciJPJdxV+UdJ1tkaWbWMstdXsqpk9Xvxnorul/UP8752Lhcyp+vEaaHPW7Xc B+w80OnRh0V6PhqaJy4bTj6i6ydkUeL6Qbm9PqvE767dN/wvciUjbCAf5Ka7/Ol4IzfN +47jKekxj1Yr/ekoq3PMRZu4jOkj+wybIEywpv5fxx7OH7tk4H9IdqqWCvGK6VFpgBxP V3bA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id w7si1254912wru.51.2019.04.18.02.06.26 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH2zt-0001ox-KZ; Thu, 18 Apr 2019 11:06:21 +0200 Message-Id: <20190418084254.082820685@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:30 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , Akinobu Mita , 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 , 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 11/29] fault-inject: Simplify stacktrace retrieval References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Replace the indirection through struct stack_trace with an invocation of the storage array based interface. Signed-off-by: Thomas Gleixner Cc: Akinobu Mita --- lib/fault-inject.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) --- a/lib/fault-inject.c +++ b/lib/fault-inject.c @@ -65,22 +65,16 @@ static bool fail_task(struct fault_attr static bool fail_stacktrace(struct fault_attr *attr) { - struct stack_trace trace; int depth = attr->stacktrace_depth; unsigned long entries[MAX_STACK_TRACE_DEPTH]; - int n; + int n, nr_entries; bool found = (attr->require_start == 0 && attr->require_end == ULONG_MAX); if (depth == 0) return found; - trace.nr_entries = 0; - trace.entries = entries; - trace.max_entries = depth; - trace.skip = 1; - - save_stack_trace(&trace); - for (n = 0; n < trace.nr_entries; n++) { + nr_entries = stack_trace_save(entries, depth, 1); + for (n = 0; n < nr_entries; n++) { if (attr->reject_start <= entries[n] && entries[n] < attr->reject_end) return false; From patchwork Thu Apr 18 08:41:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906811 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 291E71850 for ; Thu, 18 Apr 2019 09:07:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1295D28857 for ; Thu, 18 Apr 2019 09:07:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 067E9289DA; Thu, 18 Apr 2019 09:07:38 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5515728857 for ; Thu, 18 Apr 2019 09:07:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8FEA46B0289; Thu, 18 Apr 2019 05:06:59 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8D8776B028A; Thu, 18 Apr 2019 05:06:59 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 779106B028B; Thu, 18 Apr 2019 05:06:59 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by kanga.kvack.org (Postfix) with ESMTP id 288016B0289 for ; Thu, 18 Apr 2019 05:06:59 -0400 (EDT) Received: by mail-wr1-f71.google.com with SMTP id c8so1527857wru.13 for ; Thu, 18 Apr 2019 02:06:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=MfbypmYEDLOn7xTXPHUvQYPMWvxACXS6VbAX/FlZGRw=; b=gnMqrZKwh4UgDxUUiUIRbfccO9SlvIP29tMLfHN5vCVEnXr/Ax08GcXyzMlwpsWSlE s7711XofMACs55Pn2SVnltvPtEZqG5zc4VgavARhMDfMBmHrMYacaIISWkOS0E3lr8Qi SDKYmqzDFCDmlvwQs7XRcLB5P/4jsDZhLRShcUv4zopkg3l9HlfF07gpES/pTckN6QQh xmB+vfXQT91qxYDheZHq53SMQRiGh73FNPbyX8XZRArSD39dZ9n6VUVVMB3dnamG0WiV yMoV35pZOmZ7D9ejpRHDEGPTUzSPIQuveaF9D2piqIedizb76oMgh1Pp6axfZ3EmzUUV AImA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAVQeTkeWusN2yNkG5MAJ6UjMFAUO5Two9xN9v/7n4ii5moC/dhf Ua/ozZFvDBliSuEXb6ixt30hxzb4X70ltM3skB8vkfsoljJx/v1fAgLF0LdYrdwAzolnFMGJag2 YlLqr7JN7DjgYCo9rZInC5L/ImX8L3dTKnWH5EUDmURDfhE9EpIGoNiurBSehP/JJcQ== X-Received: by 2002:a1c:9ec7:: with SMTP id h190mr2324209wme.105.1555578418669; Thu, 18 Apr 2019 02:06:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqz87ZTb9fP1JX24EN7J4maaliIPg+mi2mkP1wJWhgCOaUzt7fcKbok5d1ESlIOXf/OTbo6s X-Received: by 2002:a1c:9ec7:: with SMTP id h190mr2324148wme.105.1555578417778; Thu, 18 Apr 2019 02:06:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578417; cv=none; d=google.com; s=arc-20160816; b=EC/8daHr4Pm4eJChk1/4/D6n+TfDc1dLT8ZfWNmELfZIPS6qIYyLrBZNS/PyI5FjZA 9YMbjAjMawUyILgVlGOb/HHx9+4mezfhWASUOSjyQ4+mww2VG0jcN93OYF2jWATfoWOn AX4q0GGl1/c+2i6AzuHYPUFOZX4QdIN+ct/ScPjv7a8cYxEmhYMNrk44DIURGBtdYcSP dWRKDuJ3b1vKY8N8cjZXWR3YI6MrXgjpPsYmFa+wZNhk1/cNCTkjj13thv/PpI6YEbCo yGti0CD0D4kdloClq2fBTF062LhUYDSEQa7ypo0m2eH10bF8W1f3LZjpfp/6QiDf8xUu PF0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=MfbypmYEDLOn7xTXPHUvQYPMWvxACXS6VbAX/FlZGRw=; b=wD/YmI9v4vqASjPSRXAaKuEDup/E3f6Kk3cv05J99jR2a6kD3wcSblpthArRI8QVtV Qau8aw7aSkwe/L5DIpF7WIa1paKJjYG9T777U4YZeo+u9jpm4EjsZZW7dYi76hchkA0Y zWw//4UZ2NXpPzzm+fGpIv4byivdjwBBF1J19lWhYJfcPja5LIyhKzU7roxoOCZ8xb8h CRH4NsBeItpbKtAYMN1epRVnDBuWtLrEHRcg9x3pGhg5aee2kNn25cS5I30X+fTzMjed diYie8+V5Z/XDemrO4KrbpkZjqwI2WLU2ygCJva0m1jIovnw/6p/e9G537U7+B4+I9Yk Yajg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id a6si1068248wmf.82.2019.04.18.02.06.57 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de 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-0001pi-65; Thu, 18 Apr 2019 11:06:24 +0200 Message-Id: <20190418084254.180116966@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:31 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , iommu@lists.linux-foundation.org, Robin Murphy , Christoph Hellwig , Marek Szyprowski , 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 , 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 12/29] dma/debug: Simplify stracktrace retrieval References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Replace the indirection through struct stack_trace with an invocation of the storage array based interface. Signed-off-by: Thomas Gleixner Cc: iommu@lists.linux-foundation.org Cc: Robin Murphy Cc: Christoph Hellwig Cc: Marek Szyprowski Reviewed-by: Christoph Hellwig --- kernel/dma/debug.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) --- a/kernel/dma/debug.c +++ b/kernel/dma/debug.c @@ -89,8 +89,8 @@ struct dma_debug_entry { int sg_mapped_ents; enum map_err_types map_err_type; #ifdef CONFIG_STACKTRACE - struct stack_trace stacktrace; - unsigned long st_entries[DMA_DEBUG_STACKTRACE_ENTRIES]; + unsigned int stack_len; + unsigned long stack_entries[DMA_DEBUG_STACKTRACE_ENTRIES]; #endif }; @@ -174,7 +174,7 @@ static inline void dump_entry_trace(stru #ifdef CONFIG_STACKTRACE if (entry) { pr_warning("Mapped at:\n"); - print_stack_trace(&entry->stacktrace, 0); + stack_trace_print(entry->stack_entries, entry->stack_len, 0); } #endif } @@ -704,12 +704,9 @@ static struct dma_debug_entry *dma_entry spin_unlock_irqrestore(&free_entries_lock, flags); #ifdef CONFIG_STACKTRACE - entry->stacktrace.max_entries = DMA_DEBUG_STACKTRACE_ENTRIES; - entry->stacktrace.entries = entry->st_entries; - entry->stacktrace.skip = 1; - save_stack_trace(&entry->stacktrace); + entry->stack_len = stack_trace_save(entry->stack_entries, + ARRAY_SIZE(entry->stack_entries), 1); #endif - return entry; } From patchwork Thu Apr 18 08:41:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906817 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 09CD8922 for ; Thu, 18 Apr 2019 09:07:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7AB128857 for ; Thu, 18 Apr 2019 09:07:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DAD1C289DA; Thu, 18 Apr 2019 09:07:40 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71AA228857 for ; Thu, 18 Apr 2019 09:07:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF1616B028B; Thu, 18 Apr 2019 05:07:00 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EA3976B028D; Thu, 18 Apr 2019 05:07:00 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DBC396B028E; Thu, 18 Apr 2019 05:07:00 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by kanga.kvack.org (Postfix) with ESMTP id 7C09B6B028B for ; Thu, 18 Apr 2019 05:07:00 -0400 (EDT) Received: by mail-wm1-f69.google.com with SMTP id 187so5788488wmc.1 for ; Thu, 18 Apr 2019 02:07:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=NV6JAa7wwuylvkaEkDT0w0mvqeqkCtkC066wzQ8DD70=; b=NzXElwI4nH3wLJ1Cj5cjWKKb4qMxhl6u72pII4XBMvgBMNEG+zcQr2MG7wBNAyPUXb hxE69K0jUByRg0LOjuGufz+3Uq8WTbT6tvdNzQdXHgAC8E1MHIv6b3T3Lqzd04BL1rnW eXE9CXTXSyJ44kLC/tQyj5e4NoAuYQVeH+pjswTGkyjT7KgTuH6euuRJWHRRb3Fn/ytj S8h/X+VD43WIYdHzl+ou1DGNVKhIiN3z/oPAf6GzcIrVMkZolggHhi4846HUu+4+7nCM CMy9yR1/Hdffo4gCuwJDXfiFUabNlz0NGXq9SkOTzxH7p93M1AAmrNlE4MmZfj0hsB3W VTHQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAX+oRgu6F6EQEzwNbHGAVgdOfGP3WcuJ4k/cOKdePJo3TkOHxG+ kMq3Ni0qeGoUeuW8nxqdr2K7KCkYyQbyquzrgsJKUxPaODAo7c/NEQp/iq2RG6CBDbPdHFRuhrL 95N6kaN3cS+eJMude8JM9QEhU2lCttMGmNpjzgrHRS/7SxjMfiWkNmT67TtZoT1y6+Q== X-Received: by 2002:a1c:e709:: with SMTP id e9mr2204110wmh.14.1555578420037; Thu, 18 Apr 2019 02:07:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyuedQ4xej5hVB7f/RytKu0Tq+8F0YO9bQ0Y4xTl0rnx/lWkTfJfA/d6qgfjQcjELW3gnqv X-Received: by 2002:a1c:e709:: with SMTP id e9mr2204066wmh.14.1555578419318; Thu, 18 Apr 2019 02:06:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578419; cv=none; d=google.com; s=arc-20160816; b=mq0ZQ0plVAkxf2i0sk8H1fW5FUitLl3U5VKmVszEBsaR5bljHX6RaDHHq/VabMDVbO V0LBeec4TCQj3uapQk3bRku2lQUlAGg93uQWlQ7HVPF8YpU8kqBg4nOo7f3fsiahVBK4 839qb293RTaK0BN33zSBCiNAWKXcOu98xGjtga/iUO3YUiGJaNHtntxYqITTH57LJuCd 1FbUi8epDdKZR3krvom4JkXIIhYUxMNOKQEJgmbhkK1wBc/Am6jcuz2bjtudQAE9WW3k AN/72/I5i3NTIZ1AuV5qIbIqqGEG8W0HQ6qS8YFazzbWRH3J6gsuV23NFC02BypUiFcW pVzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=NV6JAa7wwuylvkaEkDT0w0mvqeqkCtkC066wzQ8DD70=; b=mGMP6i4Z4JdQNKqHy1YJQnovVsnTnhMVs/b9gLT3UZem1Hgd4qsHO4f+HmTCr1590k EWQfHIBAZGGGU567aoklxFqhCU9x6WM55PRqEzeiCVPhb8HnO2F1Rn98tBGCDVJdTXzE bQGKF8O56vZeT/Zjb0NiMVRBGBsW9NKdAZ4L9mAOmruKD+6x4wbeqaYgDEBLg5iNZHsX hJgHJByJXQJoeaWN51/5cC0BSOrfJvgZA2OPKE5PXBhPgL44CdDwNWVtyI62di4b9beX LpWnpzdcZdoJymh6i7HYqbGOFRxQpUU9Fwqgr49LcJ6wUcItCKQGgr8srZqD1wIxK4v7 nxpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id t63si1180520wmg.27.2019.04.18.02.06.59 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH2zy-0001qB-1o; Thu, 18 Apr 2019 11:06:26 +0200 Message-Id: <20190418084254.270025615@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:32 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, 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 , 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 13/29] btrfs: ref-verify: Simplify stack trace retrieval References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Replace the indirection through struct stack_trace with an invocation of the storage array based interface. Signed-off-by: Thomas Gleixner Reviewed-by: Johannes Thumshirn Acked-by: David Sterba Cc: Chris Mason Cc: Josef Bacik Cc: linux-btrfs@vger.kernel.org --- fs/btrfs/ref-verify.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) --- a/fs/btrfs/ref-verify.c +++ b/fs/btrfs/ref-verify.c @@ -205,28 +205,17 @@ static struct root_entry *lookup_root_en #ifdef CONFIG_STACKTRACE static void __save_stack_trace(struct ref_action *ra) { - struct stack_trace stack_trace; - - stack_trace.max_entries = MAX_TRACE; - stack_trace.nr_entries = 0; - stack_trace.entries = ra->trace; - stack_trace.skip = 2; - save_stack_trace(&stack_trace); - ra->trace_len = stack_trace.nr_entries; + ra->trace_len = stack_trace_save(ra->trace, MAX_TRACE, 2); } static void __print_stack_trace(struct btrfs_fs_info *fs_info, struct ref_action *ra) { - struct stack_trace trace; - if (ra->trace_len == 0) { btrfs_err(fs_info, " ref-verify: no stacktrace"); return; } - trace.nr_entries = ra->trace_len; - trace.entries = ra->trace; - print_stack_trace(&trace, 2); + stack_trace_print(ra->trace, ra->trace_len, 2); } #else static void inline __save_stack_trace(struct ref_action *ra) From patchwork Thu Apr 18 08:41:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906751 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 A0660922 for ; Thu, 18 Apr 2019 09:06:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 897C428857 for ; Thu, 18 Apr 2019 09:06:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C625289DA; Thu, 18 Apr 2019 09:06:55 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B38528857 for ; Thu, 18 Apr 2019 09:06:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF4A06B0275; Thu, 18 Apr 2019 05:06:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EA3656B0276; Thu, 18 Apr 2019 05:06:38 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA8CA6B0277; Thu, 18 Apr 2019 05:06:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by kanga.kvack.org (Postfix) with ESMTP id 780BE6B0275 for ; Thu, 18 Apr 2019 05:06:38 -0400 (EDT) Received: by mail-wr1-f69.google.com with SMTP id k17so1526702wrq.7 for ; Thu, 18 Apr 2019 02:06:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=dFxGRxA6GS3JHurHOjsZQL/dY8U8+zq9Oil1nNFfiJU=; b=aYMwnmg5RKxQKoj09kPVfQMmnQ6uPZBgiT5B+s4Ie/LP/9usYnrsYw1oaDdPsvtL/V HycBoGQb4sW5020yDfMCVK5Vl4lzFIVWL1K9MD/ctNYT1yFxiKRh+2bAqfKuQXVCnR07 uqX+DNuiohBHlaA+RDauhuCjLGfQgreF8mGDDgHw9q6GyEkQSXe8ZSpft3twEDKtU3g5 +WPaQ3hXwbJBSwkF17Bha4Zqmahchzls9PVSu8GrXpvadQ6oM9UnkHANhWdx/jxvHvqL WH/t4h04bOYAY/0Ymjh5518z896gMKXLOxgWDVsJlPc+CDwpBcOVdhYDAI+agKdvVblJ mW/Q== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAUpRZgBYWBjONfsLq7E4VsZYh+3InfBV+6b8qre4pndvbPXAe7q HTzFeY0iU1oAbZOeS+ug08ohTH9kbY70DRQwoKEVA9+u93TmhoQu3AeppE/1LObQZr2kEIfRjCG EVqAbmUookXdCeivxGydYH5ewllWNMRyuU9xZdCkMx6DnKhsCMS8Ja8tSzO2E6KD24g== X-Received: by 2002:a05:600c:211a:: with SMTP id u26mr2388057wml.74.1555578397906; Thu, 18 Apr 2019 02:06:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1NM1Dwou4qNHAIJC517SPt53PiQSIWtwyLSL3BGjEkcElN8KPc8M9NmxZsvOINtgErs6j X-Received: by 2002:a05:600c:211a:: with SMTP id u26mr2387977wml.74.1555578396704; Thu, 18 Apr 2019 02:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578396; cv=none; d=google.com; s=arc-20160816; b=qyKGMh/VnHY0FjTpQsqTykwgLnqxqpTDIbqopmZCZ91zXJ76FL6hMPMKTkscrE7ymD mUhKeiho3Gsl45KR4IwgcvlQLiRqFejWyWHFPOWjf22c3V80+wEAFw2JbZaEy9L3fvvc Lw8u6XvAy8kXGobG2T5g7kr6Ic3TSm8fCcsG5MKAF/UA/ee+51qU1Ntyf0iwROjzTDEH eHl1mFzvANLle5Z2Skfsulnn0fx2n1c9hQeSi47KFku6iTADzYgkq2LZxeUHkWHF98mF jtP/EepeM/TZ9i8JCqwKlT9wv5NLJma/qwOTc1ygTc4Xv0yauBkef4ZSrAR0V/hjeKMO 1KJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=dFxGRxA6GS3JHurHOjsZQL/dY8U8+zq9Oil1nNFfiJU=; b=pDHcg5XgCQsIL4z5iQfv3U3uyJHHgtjF+2svmQe993RrmQcmRxraJ0DO99yI5htmQc Cd1T3SJqKcM/9spRopQ5D4DqZW92bcsDwI87jzZr5GoQGSyr/dBU/Iw242vmt7hZj8KC VFIukBxDSCdObvc6CtmasWxbMEN+7WECZoz8VnIbvKkuPHso2svzF+A9whO9uvzLTGWD dZ9b5JgpCSrE2APJpq9C/M6q1QlP7zs+bpHe0zuZYBg9V/CmQ0FuCCD9Fw7Pazd2Ztfm /LHPlhuXGpdxWVzJKtV7GoxiCUjS9RKCpFIUyB6BX4e6R1zWRHLNw+eiUkcfEmNCHUrh OkBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id e8si542369wrw.290.2019.04.18.02.06.36 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH300-0001qd-GI; Thu, 18 Apr 2019 11:06:28 +0200 Message-Id: <20190418084254.361284697@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:33 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , 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, 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 14/29] dm bufio: Simplify stack trace retrieval References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Replace the indirection through struct stack_trace with an invocation of the storage array based interface. Signed-off-by: Thomas Gleixner Cc: dm-devel@redhat.com Cc: Mike Snitzer Cc: Alasdair Kergon --- drivers/md/dm-bufio.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) --- a/drivers/md/dm-bufio.c +++ b/drivers/md/dm-bufio.c @@ -150,7 +150,7 @@ struct dm_buffer { void (*end_io)(struct dm_buffer *, blk_status_t); #ifdef CONFIG_DM_DEBUG_BLOCK_STACK_TRACING #define MAX_STACK 10 - struct stack_trace stack_trace; + unsigned int stack_len; unsigned long stack_entries[MAX_STACK]; #endif }; @@ -232,11 +232,7 @@ static DEFINE_MUTEX(dm_bufio_clients_loc #ifdef CONFIG_DM_DEBUG_BLOCK_STACK_TRACING static void buffer_record_stack(struct dm_buffer *b) { - b->stack_trace.nr_entries = 0; - b->stack_trace.max_entries = MAX_STACK; - b->stack_trace.entries = b->stack_entries; - b->stack_trace.skip = 2; - save_stack_trace(&b->stack_trace); + b->stack_len = stack_trace_save(b->stack_entries, MAX_STACK, 2); } #endif @@ -438,7 +434,7 @@ static struct dm_buffer *alloc_buffer(st adjust_total_allocated(b->data_mode, (long)c->block_size); #ifdef CONFIG_DM_DEBUG_BLOCK_STACK_TRACING - memset(&b->stack_trace, 0, sizeof(b->stack_trace)); + b->stack_len = 0; #endif return b; } @@ -1520,8 +1516,9 @@ static void drop_buffers(struct dm_bufio DMERR("leaked buffer %llx, hold count %u, list %d", (unsigned long long)b->block, b->hold_count, i); #ifdef CONFIG_DM_DEBUG_BLOCK_STACK_TRACING - print_stack_trace(&b->stack_trace, 1); - b->hold_count = 0; /* mark unclaimed to avoid BUG_ON below */ + stack_trace_print(b->stack_entries, b->stack_len, 1); + /* mark unclaimed to avoid BUG_ON below */ + b->hold_count = 0; #endif } From patchwork Thu Apr 18 08:41:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906755 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 011E718FD for ; Thu, 18 Apr 2019 09:07:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCBC9289AF for ; Thu, 18 Apr 2019 09:06:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF64F28AE3; Thu, 18 Apr 2019 09:06:59 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 543ED28AC4 for ; Thu, 18 Apr 2019 09:06:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BBEE36B0276; Thu, 18 Apr 2019 05:06:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B49F36B0277; Thu, 18 Apr 2019 05:06:39 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A39006B0278; Thu, 18 Apr 2019 05:06:39 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by kanga.kvack.org (Postfix) with ESMTP id 4C35F6B0276 for ; Thu, 18 Apr 2019 05:06:39 -0400 (EDT) Received: by mail-wm1-f72.google.com with SMTP id b12so5789631wmj.0 for ; Thu, 18 Apr 2019 02:06:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=/+X3jSHweuVn+GxUpQY/TlAKbGiIavnKcuifhQFvNYY=; b=daFH4Ht6Q4q82E64mu/YPg/kWfPN55QJ8G9zSttHI23tisr3eyz1q/870uKOVELnH0 0MiIQ3avcGRwWs4TSFmj5HgNleshLZTpQ06qHAHuHv8rN2Msb/LXe6r/8sWSZUcvaBB1 mrmL6HNMI5Qb03TGHaqwOcDKNVsnHM1wOl1nc5573YALBEVbXBNbfFzfHbwCqw2YeDZM SLu5NVNnZIo4n2WNfjfn5EdihAY57RCPdnbT2bt87NjHCv97a9sKydnB2vh7dmgW9hyE 9/sxqaF1WJ8U1qgDmCr00lA1u9baOHgeaVmrTxfY/Kpcs+ZCR1SwHUyrRD41AAWQzywm E3Ng== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAV/PKJqC3y/b5wsW7QJRzJGjhzCHmxyzdA7SNw61/HlMMZSWO0K +FbARdkt9ZSZhbBMHtTUMvNjJQeGdmWE6BT4+q7G1URgCMUC4raWMSFwmZ2k6OwB2cfUpJjHUEy hGguBL85o/9hbqGk3qdrk8sPx4A7MvFzOytTP9NftXRy4OyC8DwP4UGFlZR6o4YS9PA== X-Received: by 2002:adf:82c9:: with SMTP id 67mr40294792wrc.261.1555578398845; Thu, 18 Apr 2019 02:06:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqzsxrL9z0BhUtkSYVo9hL++a6FhYvwHjT/+lAMfxFGDIY+eYb+DuKbbnUwXyjZF45aDHfm6 X-Received: by 2002:adf:82c9:: with SMTP id 67mr40294727wrc.261.1555578397783; Thu, 18 Apr 2019 02:06:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578397; cv=none; d=google.com; s=arc-20160816; b=B+7pRI7qAy/mRj0fyu60Xkp8IK/Mg2X0HrUvtrlr/mZ41WG60AzTQnXEDUjYYWTaEd 5dVrJUII9CKfxblMoZ4zABGjuq6tO3eyhGW0t84gHr91oeqnWcLxKCk2qXSp+3lOBuHL pNPoYsef9hkIIid0zIxOiPoTitGEJo8IrACvn7A5PttTdzRaaSU6Fv2/s7DE6gqKtk4E 6RKP+0O0wQnrsNtfWIdDO9BfwaGu9I5vEYh5WfxLoBlCpVhshYx1IQ02aKYbla/iIQHw Pnhgwif5aVAshYqk+e0FdfT9qE9boobzg8GLilkMarX6Gs9ua3W/JnHJXCdEqW+3vzXd b7aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=/+X3jSHweuVn+GxUpQY/TlAKbGiIavnKcuifhQFvNYY=; b=xfJXewQmzIBS036WZdLqT6/IdqgYvfSNnl2CY5uLRiW7Dj/6AD4hrzHv5ZjhWXU8dX AOEw9LeNxORAXXJVzraeUDDPSwF/nBZmje9fmvDOsvZckLSzGh1wg1QeJAIGkVVITzGs ZhDD3dlK/rIx7YuBjl0pfe8cZ01aH54IBsupKQjDUbiwJT/5QF8bggouGtKWpvI7PSTQ DEN89pGQozLobBcydPGd1kt39yTEMMoy8j4f7/YMeqxwHRYkzNuQ8DAmQ9fwr+VQF0gv AcSl2K0eC5CQNlL7cPmzrqmfxeuy3cnVZAQ7dBKhgQvjI3GjYMLc7ImmrgpW5fAeacXB Xeig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id g62si1085979wmf.93.2019.04.18.02.06.37 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH303-0001rK-1g; Thu, 18 Apr 2019 11:06:31 +0200 Message-Id: <20190418084254.459090858@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:34 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , 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, 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 15/29] dm persistent data: Simplify stack trace handling References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Replace the indirection through struct stack_trace with an invocation of the storage array based interface. This results in less storage space and indirection. Signed-off-by: Thomas Gleixner Cc: dm-devel@redhat.com Cc: Mike Snitzer Cc: Alasdair Kergon --- drivers/md/persistent-data/dm-block-manager.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) --- a/drivers/md/persistent-data/dm-block-manager.c +++ b/drivers/md/persistent-data/dm-block-manager.c @@ -35,7 +35,10 @@ #define MAX_HOLDERS 4 #define MAX_STACK 10 -typedef unsigned long stack_entries[MAX_STACK]; +struct stack_store { + unsigned int nr_entries; + unsigned long entries[MAX_STACK]; +}; struct block_lock { spinlock_t lock; @@ -44,8 +47,7 @@ struct block_lock { struct task_struct *holders[MAX_HOLDERS]; #ifdef CONFIG_DM_DEBUG_BLOCK_STACK_TRACING - struct stack_trace traces[MAX_HOLDERS]; - stack_entries entries[MAX_HOLDERS]; + struct stack_store traces[MAX_HOLDERS]; #endif }; @@ -73,7 +75,7 @@ static void __add_holder(struct block_lo { unsigned h = __find_holder(lock, NULL); #ifdef CONFIG_DM_DEBUG_BLOCK_STACK_TRACING - struct stack_trace *t; + struct stack_store *t; #endif get_task_struct(task); @@ -81,11 +83,7 @@ static void __add_holder(struct block_lo #ifdef CONFIG_DM_DEBUG_BLOCK_STACK_TRACING t = lock->traces + h; - t->nr_entries = 0; - t->max_entries = MAX_STACK; - t->entries = lock->entries[h]; - t->skip = 2; - save_stack_trace(t); + t->nr_entries = stack_trace_save(t->entries, MAX_STACK, 2); #endif } @@ -106,7 +104,8 @@ static int __check_holder(struct block_l DMERR("recursive lock detected in metadata"); #ifdef CONFIG_DM_DEBUG_BLOCK_STACK_TRACING DMERR("previously held here:"); - print_stack_trace(lock->traces + i, 4); + stack_trace_print(lock->traces[i].entries, + lock->traces[i].nr_entries, 4); DMERR("subsequent acquisition attempted here:"); dump_stack(); From patchwork Thu Apr 18 08:41:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906783 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 B906F161F for ; Thu, 18 Apr 2019 09:07:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A168628857 for ; Thu, 18 Apr 2019 09:07:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 957D2289DA; Thu, 18 Apr 2019 09:07:17 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EEB9E28857 for ; Thu, 18 Apr 2019 09:07:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 299666B027D; Thu, 18 Apr 2019 05:06:47 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 24A026B027E; Thu, 18 Apr 2019 05:06:47 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1115C6B027F; Thu, 18 Apr 2019 05:06:47 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by kanga.kvack.org (Postfix) with ESMTP id B74436B027E for ; Thu, 18 Apr 2019 05:06:46 -0400 (EDT) Received: by mail-wr1-f69.google.com with SMTP id e14so1509390wrt.18 for ; Thu, 18 Apr 2019 02:06:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=kxeJpbHI7As6QAtGU1p6Y41OP6F6oIuYF4MIr44OBP4=; b=bTveDyMDsoFXEHdWWadzME5owH8X7UK0rKDwiWwKMKmyg1+AgtFYMqZyPISXYMkYAf Z3BEvEreGc0mdkb3MJbS90G/Q/lLaudyPWrQdDmesTIoMuvPKv10xdHmIQhRB6FQeXSj 7Z1J4wt8Z5vkOie50Z+yXOLFjjDeP5WZQ7KETTRA8myT4oWAit0xcpTFUNLir0pRsRGb vr9rIS9SBrRYfbf/4iBwKzSCjsJxf0nnRFcOAaE4xs0sAViGX03/iTbGRkLOcycat3xb 9tm/Co3Bu5fiu1PTegfyK5PL2fA7lMFkQt8b9figHf6Q+EyG2TwoDBGEbIWFQ01LtQXv KwTg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAXajBi9gZXIFXL1ogfRze5YZorvpstKSUrJf4IrbnQtppgFPMCO OEKmUTkaAb8Vg/Hb2+mdbnrqY2jAgUektfx+PhUYpbmsOLF+/qWHKHjB19IZ45u7b6cQMQLTKo6 qZWyCdbaK5wzOm46DQyjRMA16w3b76RcP/XrDrDVFNWfQiM5+cZguZGegp/uy98AszQ== X-Received: by 2002:a1c:208c:: with SMTP id g134mr2355934wmg.70.1555578406209; Thu, 18 Apr 2019 02:06:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzX/du/tYHn3QIrlOyahsSx5/4ID4U03dppyU+Fpght7cHB+ar+wC4PsPpeAfBUxJGSldkQ X-Received: by 2002:a1c:208c:: with SMTP id g134mr2355879wmg.70.1555578405324; Thu, 18 Apr 2019 02:06:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578405; cv=none; d=google.com; s=arc-20160816; b=i3uK7PAnygSebBz9ln4nWzJybN68gH1lwhYmLyvPpEpkyE5aC65n7bKosz6EzOBmW7 LV0dYpsJDGovKRV9FSbt1UeXy52CmARyvp2lBBTvQGTgpGxKxCMac6Um3MGkXJOB0WEC rAW8Z4xW1uRoDQD8CP53EqWO4bWQiBOFMtzvXA6sC4pS4A7IkfG1if4FWCqueCBWE/W8 1+e0RMUuhgF6O4RbHmXlJQ3GTW5ORmZtxkfZepcdXegQ+mw1472FyYXXTPbDGJOA1FAu 9kwi2H7zEepFgTpYPPCUEyr5o+XZF77Z6Ye+beBOVhOKt65ilaid8pQqGShCsHdw1b6T nKKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=kxeJpbHI7As6QAtGU1p6Y41OP6F6oIuYF4MIr44OBP4=; b=hZL9UWuuqaMj+t3BfQcV8agqcDqhCiaKIKyX3eaIhWLBqzJ2x8IIJDIAB1d86SoXxw PoS+SIfcnTuORiP1TxK9zK4Cf6vYpTVdiKjGwio+2Ki99rPc4TBpz+OJ7evJ/CIGY8sN 3KiMS4HeZ4IlfLi/ZfHFBYdV2Hna1ZI9veQX7Jt8obZ6SEyqRD9qDeF9FTl5xeqxQglj tpXcDGcdWhLPTnErsP/HHHzdYrYv0tlQuJUAw1l7Npb735d/U0Mt9LAoZeV0GaZamCFD WnIath6G+NU3LZVJObFfNEgYq2/c6fbR0bSvMIzdP6o3lOD5OWVsHTG3isbMXkXJH8KW 1XyQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id x129si1154791wmg.27.2019.04.18.02.06.45 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH305-0001rb-3d; Thu, 18 Apr 2019 11:06:33 +0200 Message-Id: <20190418084254.549410214@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:35 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Daniel Vetter , Rodrigo Vivi , 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 , linux-arch@vger.kernel.org Subject: [patch V2 16/29] drm: Simplify stacktrace handling References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Replace the indirection through struct stack_trace by using the storage array based interfaces. The original code in all printing functions is really wrong. It allocates a storage array on stack which is unused because depot_fetch_stack() does not store anything in it. It overwrites the entries pointer in the stack_trace struct so it points to the depot storage. Signed-off-by: Thomas Gleixner Cc: intel-gfx@lists.freedesktop.org Cc: Joonas Lahtinen Cc: Maarten Lankhorst Cc: dri-devel@lists.freedesktop.org Cc: David Airlie Cc: Jani Nikula Cc: Daniel Vetter Cc: Rodrigo Vivi Acked-by: Daniel Vetter --- drivers/gpu/drm/drm_mm.c | 22 +++++++--------------- drivers/gpu/drm/i915/i915_vma.c | 11 ++++------- drivers/gpu/drm/i915/intel_runtime_pm.c | 21 +++++++-------------- 3 files changed, 18 insertions(+), 36 deletions(-) --- a/drivers/gpu/drm/drm_mm.c +++ b/drivers/gpu/drm/drm_mm.c @@ -106,22 +106,19 @@ static noinline void save_stack(struct drm_mm_node *node) { unsigned long entries[STACKDEPTH]; - struct stack_trace trace = { - .entries = entries, - .max_entries = STACKDEPTH, - .skip = 1 - }; + unsigned int n; - save_stack_trace(&trace); + n = stack_trace_save(entries, ARRAY_SIZE(entries), 1); /* May be called under spinlock, so avoid sleeping */ - node->stack = depot_save_stack(&trace, GFP_NOWAIT); + node->stack = stack_depot_save(entries, n, GFP_NOWAIT); } static void show_leaks(struct drm_mm *mm) { struct drm_mm_node *node; - unsigned long entries[STACKDEPTH]; + unsigned long *entries; + unsigned int nr_entries; char *buf; buf = kmalloc(BUFSZ, GFP_KERNEL); @@ -129,19 +126,14 @@ static void show_leaks(struct drm_mm *mm return; list_for_each_entry(node, drm_mm_nodes(mm), node_list) { - struct stack_trace trace = { - .entries = entries, - .max_entries = STACKDEPTH - }; - if (!node->stack) { DRM_ERROR("node [%08llx + %08llx]: unknown owner\n", node->start, node->size); continue; } - depot_fetch_stack(node->stack, &trace); - snprint_stack_trace(buf, BUFSZ, &trace, 0); + nr_entries = stack_depot_fetch(node->stack, &entries); + stack_trace_snprint(buf, BUFSZ, entries, nr_entries, 0); DRM_ERROR("node [%08llx + %08llx]: inserted at\n%s", node->start, node->size, buf); } --- a/drivers/gpu/drm/i915/i915_vma.c +++ b/drivers/gpu/drm/i915/i915_vma.c @@ -36,11 +36,8 @@ static void vma_print_allocator(struct i915_vma *vma, const char *reason) { - unsigned long entries[12]; - struct stack_trace trace = { - .entries = entries, - .max_entries = ARRAY_SIZE(entries), - }; + unsigned long *entries; + unsigned int nr_entries; char buf[512]; if (!vma->node.stack) { @@ -49,8 +46,8 @@ static void vma_print_allocator(struct i return; } - depot_fetch_stack(vma->node.stack, &trace); - snprint_stack_trace(buf, sizeof(buf), &trace, 0); + nr_entries = stack_depot_fetch(vma->node.stack, &entries); + stack_trace_snprint(buf, sizeof(buf), entries, nr_entries, 0); DRM_DEBUG_DRIVER("vma.node [%08llx + %08llx] %s: inserted at %s\n", vma->node.start, vma->node.size, reason, buf); } --- a/drivers/gpu/drm/i915/intel_runtime_pm.c +++ b/drivers/gpu/drm/i915/intel_runtime_pm.c @@ -60,27 +60,20 @@ static noinline depot_stack_handle_t __save_depot_stack(void) { unsigned long entries[STACKDEPTH]; - struct stack_trace trace = { - .entries = entries, - .max_entries = ARRAY_SIZE(entries), - .skip = 1, - }; + unsigned int n; - save_stack_trace(&trace); - return depot_save_stack(&trace, GFP_NOWAIT | __GFP_NOWARN); + n = stack_trace_save(entries, ARRAY_SIZE(entries), 1); + return stack_depot_save(entries, n, GFP_NOWAIT | __GFP_NOWARN); } static void __print_depot_stack(depot_stack_handle_t stack, char *buf, int sz, int indent) { - unsigned long entries[STACKDEPTH]; - struct stack_trace trace = { - .entries = entries, - .max_entries = ARRAY_SIZE(entries), - }; + unsigned long *entries; + unsigned int nr_entries; - depot_fetch_stack(stack, &trace); - snprint_stack_trace(buf, sz, &trace, indent); + nr_entries = stack_depot_fetch(stack, &entries); + stack_trace_snprint(buf, sz, entries, nr_entries, indent); } static void init_intel_runtime_pm_wakeref(struct drm_i915_private *i915) From patchwork Thu Apr 18 08:41:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906763 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 91C36922 for ; Thu, 18 Apr 2019 09:07:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7ACC128857 for ; Thu, 18 Apr 2019 09:07:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D707289DA; Thu, 18 Apr 2019 09:07:03 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1254928857 for ; Thu, 18 Apr 2019 09:07:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DE1EA6B0277; Thu, 18 Apr 2019 05:06:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D71436B0279; Thu, 18 Apr 2019 05:06:40 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C33546B027A; Thu, 18 Apr 2019 05:06:40 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by kanga.kvack.org (Postfix) with ESMTP id 6FF306B0277 for ; Thu, 18 Apr 2019 05:06:40 -0400 (EDT) Received: by mail-wm1-f71.google.com with SMTP id n11so1552041wmh.2 for ; Thu, 18 Apr 2019 02:06:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=jB9SA5hdGExIFIDrZWtnR9KIYGIDvN3B6de51Ujrkgo=; b=Jgh7tC+Q2uiai4wGEofz/2sUDk27A2cfRENmvFEO39a0F0VvBHX9lT66kMV8+PptoW DHnpe5UPh+BqO3TRNyWs6p8/l1drxgGH+czsjFuGwwwTnyJAtC2+5jrTsDTdl3lx09RN SqpdT27fWY/cGIW5Nr2MrJxuSYhxKde0X+mlWB9lF+hmgR5dK+/ADkTB7kJJAECaxUQF wtgsN1v4LVP2wP25I7KveMWfSDgPAPECpe7Aco208eAN2FVsSCKoOrKWOmbctd5bCzHL 2ntDTANgVFXGFn9EqK2TAOBe4NgiNzoL/GZJmmXLEzSC6yHvloo7dSBmPK7buBT86U93 4Gbw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAV5NF0kcYECFXzZ24FWa6kZ8W2nn602RR8iPpCwoOH4IiPk8HvI WWxhhlbpb4u9Y4pAQjJQJSmI6pyUX5QtB0k5MvubtUoVCNl6LlLjJHuXKdx21Vjwy0N2ZGVLwOQ SyVneYgTGEPthv0mFEuC/RQXTWZF+sik7vZOBdJaqd9mI5221AgIKaMkHk8o2DZ9Npg== X-Received: by 2002:a1c:dfc5:: with SMTP id w188mr2141770wmg.79.1555578399987; Thu, 18 Apr 2019 02:06:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqyGtMszvfXNQETW6cehLJ1GwAO4Tw8UBFE8vN9u51eFcMeCtKIgNI9UYS4qbGxffwR5nItk X-Received: by 2002:a1c:dfc5:: with SMTP id w188mr2141710wmg.79.1555578399052; Thu, 18 Apr 2019 02:06:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578399; cv=none; d=google.com; s=arc-20160816; b=i4eZiK50NnqYCD8gSaEM//Fp3VsPvv0nfWzzrl+8eeEyduGwqYMwwkD9d3tk1S6vAc 8GsIb6Ou3qspzoP5PrOQVZqQJVkRHS/fojaMExqszTrYDywcfshKpahuL/wwMy4HiJHI brueGu8veNnGqAJOtYpBwGyOyIwQeKZfXRSl8Ny0yvcGt4akkTpYPdQLWgWlNJZXv5sh 6ewePKR/8rm0Tnc0wiw7Tmc79USfzqcxkZ/0Qga5KFBPuKZSAeADk8g0DgFqg+r4I0uq 8foUt7jjHlhB5T995gVm3j/6cFVRe6MQ6/hqM6aVAKDzxVK0YKr0BLA5r0c4SZlx8E7G GBVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=jB9SA5hdGExIFIDrZWtnR9KIYGIDvN3B6de51Ujrkgo=; b=c6Ca0TBRn9RKMS+xKb4jBITUQyMbAJfYpzxdEAm5IxX9LYdHTQIVStnT/f4/Tm1xHU q2I372EpSOxVcn9daNd0uyQGwm+bEFJUjFzr1HoEMraUpt9d+8POY5gA2i44GG9T/0/6 BIN1bS6Y2glAy1W5lgCnp/zGPDzNhuach0O38p00aJllwUwy5+JVM3z4F22PHcYnmCka FKrsYK4PbVJr7VsWLQH5T/ku+hqLf+HJLgJ+dPmXMGrmoLRVpv4JK5XqXcegGn6pPnzz G22sF96vjpe8ZkYK2HIgKW9kmfpKI9GqHONC8ejk8BA9d7tzNPvIDBmKL94g4A5Z+BwE k1/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id j145si1091466wmj.95.2019.04.18.02.06.38 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH307-0001sE-IN; Thu, 18 Apr 2019 11:06:35 +0200 Message-Id: <20190418084254.639634107@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:36 +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 17/29] lockdep: Remove unused trace argument from print_circular_bug() References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Thomas Gleixner --- kernel/locking/lockdep.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -1522,10 +1522,9 @@ static inline int class_equal(struct loc } static noinline int print_circular_bug(struct lock_list *this, - struct lock_list *target, - struct held_lock *check_src, - struct held_lock *check_tgt, - struct stack_trace *trace) + struct lock_list *target, + struct held_lock *check_src, + struct held_lock *check_tgt) { struct task_struct *curr = current; struct lock_list *parent; @@ -2206,7 +2205,7 @@ check_prev_add(struct task_struct *curr, */ save(trace); } - return print_circular_bug(&this, target_entry, next, prev, trace); + return print_circular_bug(&this, target_entry, next, prev); } else if (unlikely(ret < 0)) return print_bfs_bug(ret); From patchwork Thu Apr 18 08:41:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906767 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 F3F1E161F for ; Thu, 18 Apr 2019 09:07:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D9ED0289AF for ; Thu, 18 Apr 2019 09:07:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDEA428AC4; Thu, 18 Apr 2019 09:07:07 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A460F289AF for ; Thu, 18 Apr 2019 09:07:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E0DB16B0279; Thu, 18 Apr 2019 05:06:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D92E16B027A; Thu, 18 Apr 2019 05:06:42 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C0DCD6B027B; Thu, 18 Apr 2019 05:06:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by kanga.kvack.org (Postfix) with ESMTP id 6C9F76B0279 for ; Thu, 18 Apr 2019 05:06:42 -0400 (EDT) Received: by mail-wr1-f70.google.com with SMTP id o16so1522563wrp.8 for ; Thu, 18 Apr 2019 02:06:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=L604RDNDUsLtrdMvm5f1LPj2+7anAgRuVAW4n/LwM/A=; b=IU4cztcda3WBlFlw1joVtNF5wNllEkzIh291/fVO9An4TTF5rjiGUDDyj3QaCMaFXz F04mtHGUjSGKxayNvc2YynsJaXpu5NbomqpBRZfisUcRGRkWgWA93nefvG05hLXqKYMG gxXWzG4oiWhYIhI98MXG3wy0gdiyBis+BncmphoLUE5dwtTihsVFH6KuHfTgLwZyDm2r 3g79F7w6dWNaQgBtho5MB4Ha6npexxIsuhROhL7tGQ+RYlC9QVEFW+RKtYjHTKkn6D83 8IEZqdkC2TjfJ+RjZfEu39beQLHYScVEgzBHHboJsAYGoUQ0unEHdPH4tzkre24HAWnk iUxw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAXBxUzxfqBouTljkJ6+snYgPLWF7t0pJPm4G+byfVjgzofNYCTq izcSwgAQofmbTQV7lwQtkD02klIxlv53/+kzfXLJbjwGwRuDWnrGDR+ftTU/A3AGSFmgnvtx3ub +tjatmZUMpD9WCC41M5Xar45VqrdN1NMk6yug1aZUmjBjD6/oxVNy+DRM0HTwWv5ZvA== X-Received: by 2002:a1c:4844:: with SMTP id v65mr2199874wma.139.1555578401853; Thu, 18 Apr 2019 02:06:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqxrns+ZOQca+6QkSxf/SThso4L9L/TZMqTqwhuOthfFv58D1bM7lnxDx65STrzozQZq3Rmn X-Received: by 2002:a1c:4844:: with SMTP id v65mr2199812wma.139.1555578400908; Thu, 18 Apr 2019 02:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578400; cv=none; d=google.com; s=arc-20160816; b=S0R6kGTAKDnjoe2Hly4bTx572vjgs2emSqgyw8w/NlQA80M8oBukNANUjonHNZ5VCI pvUWAVqQsl6YhMZv5P9P2lYHCF1kdqhNVHJoiBrMDDhfh3a3F4HJqz0UMfbufwK10KC3 4tWjoCyOUL47LxMWk+71QrP5JKCLVlnY4VikPd6kF923o1WrnIia7/yuHARjl2VbMR4L YSOoe3MKITIsT/0OSaLioRzU8Kdi7mIf2i7WIqak8d7+4wAc5m8oQuzq9j3di6xaic5y FaJaATep9A+bvKE4FKlbbkg++0ViOJLVFIOACfAUVryDTZywJkAM3xpqJy0S4EJmrBxO e7jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=L604RDNDUsLtrdMvm5f1LPj2+7anAgRuVAW4n/LwM/A=; b=ftNjoqRnSzkDu/HIgl8cfjR236UWRzOnEG8O2e6QjXFeApB0qi7Y9E/r1YwQRxdjgt ujFWhIyh34YOii+NC+6Cy1ZMl/eLYnyakK85hFHdQbOY8U3IWAcpoHNRRZw9iKquFxdy ehbZ6AMnarWNFkoonR3D1jSbfUMHokXNzea0Ctw04owER27Bio3m4NWYwXzhOUobb4GZ sHjnl4u2jw0rQB088AR3yV5fWzFGJpUPuBFEkMwAMThtFL3M3Xa52bfotGRMgAkoTtI0 5gyN0dO5D7vqdYxse3XVqULs+mKla081JWUYL889fCDX/SzPD06BY3AKOluaJ7GBJB8W xqoQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id z186si1171505wmb.5.2019.04.18.02.06.40 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH309-0001su-Qw; Thu, 18 Apr 2019 11:06:38 +0200 Message-Id: <20190418084254.729689921@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:37 +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 18/29] lockdep: Move stack trace logic into check_prev_add() References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP There is only one caller of check_prev_add() which hands in a zeroed struct stack trace and a function pointer to save_stack(). Inside check_prev_add() the stack_trace struct is checked for being empty, which is always true. Based on that one code path stores a stack trace which is unused. The comment there does not make sense either. It's all leftovers from historical lockdep code (cross release). Move the variable into check_prev_add() itself and cleanup the nonsensical checks and the pointless stack trace recording. Signed-off-by: Thomas Gleixner --- kernel/locking/lockdep.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -2158,10 +2158,10 @@ check_deadlock(struct task_struct *curr, */ static int check_prev_add(struct task_struct *curr, struct held_lock *prev, - struct held_lock *next, int distance, struct stack_trace *trace, - int (*save)(struct stack_trace *trace)) + struct held_lock *next, int distance) { struct lock_list *uninitialized_var(target_entry); + struct stack_trace trace; struct lock_list *entry; struct lock_list this; int ret; @@ -2196,17 +2196,8 @@ check_prev_add(struct task_struct *curr, this.class = hlock_class(next); this.parent = NULL; ret = check_noncircular(&this, hlock_class(prev), &target_entry); - if (unlikely(!ret)) { - if (!trace->entries) { - /* - * If @save fails here, the printing might trigger - * a WARN but because of the !nr_entries it should - * not do bad things. - */ - save(trace); - } + if (unlikely(!ret)) return print_circular_bug(&this, target_entry, next, prev); - } else if (unlikely(ret < 0)) return print_bfs_bug(ret); @@ -2253,7 +2244,7 @@ check_prev_add(struct task_struct *curr, return print_bfs_bug(ret); - if (!trace->entries && !save(trace)) + if (!save_trace(&trace)) return 0; /* @@ -2262,14 +2253,14 @@ check_prev_add(struct task_struct *curr, */ ret = add_lock_to_list(hlock_class(next), hlock_class(prev), &hlock_class(prev)->locks_after, - next->acquire_ip, distance, trace); + next->acquire_ip, distance, &trace); if (!ret) return 0; ret = add_lock_to_list(hlock_class(prev), hlock_class(next), &hlock_class(next)->locks_before, - next->acquire_ip, distance, trace); + next->acquire_ip, distance, &trace); if (!ret) return 0; @@ -2287,12 +2278,6 @@ check_prevs_add(struct task_struct *curr { int depth = curr->lockdep_depth; struct held_lock *hlock; - struct stack_trace trace = { - .nr_entries = 0, - .max_entries = 0, - .entries = NULL, - .skip = 0, - }; /* * Debugging checks. @@ -2318,7 +2303,8 @@ check_prevs_add(struct task_struct *curr * added: */ if (hlock->read != 2 && hlock->check) { - int ret = check_prev_add(curr, hlock, next, distance, &trace, save_trace); + int ret = check_prev_add(curr, hlock, next, distance); + if (!ret) return 0; From patchwork Thu Apr 18 08:41:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906771 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 154DE922 for ; Thu, 18 Apr 2019 09:07:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED1AB289AF for ; Thu, 18 Apr 2019 09:07:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD40B289DA; Thu, 18 Apr 2019 09:07:10 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E07F28857 for ; Thu, 18 Apr 2019 09:07:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 927B26B027B; Thu, 18 Apr 2019 05:06:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8D81F6B027C; Thu, 18 Apr 2019 05:06:45 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 704296B027D; Thu, 18 Apr 2019 05:06:45 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by kanga.kvack.org (Postfix) with ESMTP id 1C2E46B027B for ; Thu, 18 Apr 2019 05:06:45 -0400 (EDT) Received: by mail-wr1-f70.google.com with SMTP id c8so1527424wru.13 for ; Thu, 18 Apr 2019 02:06:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=rBbw/B8vKuggCTtV3dXjHcZsr7Bz0dXo78wjpzpGLbU=; b=PJSOKWmULtJl7zW6xUGwFDCbhYY2BsXF9ouzA9D5NfSzWaAT2XZj4peWDYKzJ4jm2n D43+GikEigD44zYU+3LlXuMvfpua0jukzULOacX58vLozZdVKSAnigh3UDNOfua/zHrd 1bjngggLS7fDlrx3QWQfDycVYmNxKFOPVKBNnRHFrttmeCCa3GdMNcdr+k5KheH/P5DA GITcg/go6o4aJr7gcoJoxyla178SrfHdMmDX88Si71JNbRNjMb+Q4kJuUHCOVjjqF+dO 6g+yfc4Gc510qVq2+VntbY362H3mQXeYtfZxlcoYdwXff7562dpGGjoB5nybe+I1U5J3 D/9g== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAUD+oaZcpWh9WLxT4eFhbc/HLp3aAGbPemSRCINFwhsNL0NqtcB KKG0i5pR4VL061C08rdY6bieTXrlV1/eBz7kXFHpkIhKdRVLg0M4iJ4TUtdS1zu3sXHozwRr2TW OF8yxEHGJnT4CqzZ45a9kgOGOBdJYleXzhTjbRex9ZKxxyx3tzLge/YcN0eX4WPqURQ== X-Received: by 2002:a1c:c504:: with SMTP id v4mr2304875wmf.45.1555578404615; Thu, 18 Apr 2019 02:06:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqzT85ANkDDabNj0BL87zPPGuFqg5gsXp+KLsGM+DLcpy9m1Edw+6vqBQLxH0dp/9JU8teDr X-Received: by 2002:a1c:c504:: with SMTP id v4mr2304773wmf.45.1555578403046; Thu, 18 Apr 2019 02:06:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578403; cv=none; d=google.com; s=arc-20160816; b=d/YM3kYcdEwBOZZc7T8Ww55H7qB7G9qNNUtvZB4A7oi+662DqKzrgjI3dmatVFejiA Lw1oTX1Nd8LFzh5LLVsNcEZBwt/M3K33g+3pc1Fn+2gKYiw7aXpHTviwhhwYWFNZxb5K fQdHPqciLAauigbK65N/gp6xhpRHV602KeOUm+ZzUH9yL7t7GYtFZO6oh96S9o5PvffF RTeGr7Fa2+xS3B8tiqUeMluqFQLUNl/b4clSgLrHRBNPkUfPFfzv8iOXe6YaLbJQC6oC A1dX6ROrHnS2CYl99MW1qRho6Ohw87vSD600TUs0bjMhi+1AYUI4lD6qZGNLgxIfwyDv Qu5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=rBbw/B8vKuggCTtV3dXjHcZsr7Bz0dXo78wjpzpGLbU=; b=J/INp3ATpMxDqLgnXcoEBb4IP3HsZ18YTiFehK9Ol+EBBIw044luHcEQaTmIgwig5G lYJEY5bZOgjjOJ0m9nytgXZjT8M72xDFNNCyTalbPMhNbA1UxlWjfrDHbyJUu3ZHBnpk 9peN0255ve+2/lI6y8upKWlf1mvRrO663NPG3msabQ6o/HM1P6MZOlNmoOZC3LaELR7Z 3PeaoLOTw6fMpUMWYGAe1wPBUXTxeGOixaWwBXO2+0WNVsPdt20W1BaAMP4dl8k11pNQ +mOEyTGotoRS0phCFR92SSHZlcHuYz3pvJ1bdrsVkLp4og3t0vzOyuncepdsyPurAfLm DBHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id x10si1272799wrp.198.2019.04.18.02.06.42 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH30B-0001tP-SF; Thu, 18 Apr 2019 11:06:40 +0200 Message-Id: <20190418084254.819500258@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:38 +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 19/29] lockdep: Simplify stack trace handling References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Replace the indirection through struct stack_trace by using the storage array based interfaces and storing the information is a small lockdep specific data structure. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- include/linux/lockdep.h | 9 +++++++-- kernel/locking/lockdep.c | 44 +++++++++++++++++++++++++------------------- 2 files changed, 32 insertions(+), 21 deletions(-) --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -66,6 +66,11 @@ struct lock_class_key { extern struct lock_class_key __lockdep_no_validate__; +struct lock_trace { + unsigned int nr_entries; + unsigned int offset; +}; + #define LOCKSTAT_POINTS 4 /* @@ -100,7 +105,7 @@ struct lock_class { * IRQ/softirq usage tracking bits: */ unsigned long usage_mask; - struct stack_trace usage_traces[XXX_LOCK_USAGE_STATES]; + struct lock_trace usage_traces[XXX_LOCK_USAGE_STATES]; /* * Generation counter, when doing certain classes of graph walking, @@ -188,7 +193,7 @@ struct lock_list { struct list_head entry; struct lock_class *class; struct lock_class *links_to; - struct stack_trace trace; + struct lock_trace trace; int distance; /* --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -434,18 +434,14 @@ static void print_lockdep_off(const char #endif } -static int save_trace(struct stack_trace *trace) +static int save_trace(struct lock_trace *trace) { - trace->nr_entries = 0; - trace->max_entries = MAX_STACK_TRACE_ENTRIES - nr_stack_trace_entries; - trace->entries = stack_trace + nr_stack_trace_entries; - - trace->skip = 3; - - save_stack_trace(trace); - - trace->max_entries = trace->nr_entries; + unsigned long *entries = stack_trace + nr_stack_trace_entries; + unsigned int max_entries; + trace->offset = nr_stack_trace_entries; + max_entries = MAX_STACK_TRACE_ENTRIES - nr_stack_trace_entries; + trace->nr_entries = stack_trace_save(entries, max_entries, 3); nr_stack_trace_entries += trace->nr_entries; if (nr_stack_trace_entries >= MAX_STACK_TRACE_ENTRIES-1) { @@ -1196,7 +1192,7 @@ static struct lock_list *alloc_list_entr static int add_lock_to_list(struct lock_class *this, struct lock_class *links_to, struct list_head *head, unsigned long ip, int distance, - struct stack_trace *trace) + struct lock_trace *trace) { struct lock_list *entry; /* @@ -1415,6 +1411,13 @@ static inline int __bfs_backwards(struct * checking. */ +static void print_lock_trace(struct lock_trace *trace, unsigned int spaces) +{ + unsigned long *entries = stack_trace + trace->offset; + + stack_trace_print(entries, trace->nr_entries, spaces); +} + /* * Print a dependency chain entry (this is only done when a deadlock * has been detected): @@ -1427,8 +1430,7 @@ print_circular_bug_entry(struct lock_lis printk("\n-> #%u", depth); print_lock_name(target->class); printk(KERN_CONT ":\n"); - print_stack_trace(&target->trace, 6); - + print_lock_trace(&target->trace, 6); return 0; } @@ -1740,7 +1742,7 @@ static void print_lock_class_header(stru len += printk("%*s %s", depth, "", usage_str[bit]); len += printk(KERN_CONT " at:\n"); - print_stack_trace(class->usage_traces + bit, len); + print_lock_trace(class->usage_traces + bit, len); } } printk("%*s }\n", depth, ""); @@ -1765,7 +1767,7 @@ print_shortest_lock_dependencies(struct do { print_lock_class_header(entry->class, depth); printk("%*s ... acquired at:\n", depth, ""); - print_stack_trace(&entry->trace, 2); + print_lock_trace(&entry->trace, 2); printk("\n"); if (depth == 0 && (entry != root)) { @@ -1878,14 +1880,14 @@ print_bad_irq_dependency(struct task_str print_lock_name(backwards_entry->class); pr_warn("\n... which became %s-irq-safe at:\n", irqclass); - print_stack_trace(backwards_entry->class->usage_traces + bit1, 1); + print_lock_trace(backwards_entry->class->usage_traces + bit1, 1); pr_warn("\nto a %s-irq-unsafe lock:\n", irqclass); print_lock_name(forwards_entry->class); pr_warn("\n... which became %s-irq-unsafe at:\n", irqclass); pr_warn("..."); - print_stack_trace(forwards_entry->class->usage_traces + bit2, 1); + print_lock_trace(forwards_entry->class->usage_traces + bit2, 1); pr_warn("\nother info that might help us debug this:\n\n"); print_irq_lock_scenario(backwards_entry, forwards_entry, @@ -2161,9 +2163,9 @@ check_prev_add(struct task_struct *curr, struct held_lock *next, int distance) { struct lock_list *uninitialized_var(target_entry); - struct stack_trace trace; struct lock_list *entry; struct lock_list this; + struct lock_trace trace; int ret; if (!hlock_class(prev)->key || !hlock_class(next)->key) { @@ -2705,6 +2707,10 @@ static inline int validate_chain(struct { return 1; } + +static void print_lock_trace(struct lock_trace *trace, unsigned int spaces) +{ +} #endif /* @@ -2801,7 +2807,7 @@ print_usage_bug(struct task_struct *curr print_lock(this); pr_warn("{%s} state was registered at:\n", usage_str[prev_bit]); - print_stack_trace(hlock_class(this)->usage_traces + prev_bit, 1); + print_lock_trace(hlock_class(this)->usage_traces + prev_bit, 1); print_irqtrace_events(curr); pr_warn("\nother info that might help us debug this:\n"); From patchwork Thu Apr 18 08:41:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906779 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 29274922 for ; Thu, 18 Apr 2019 09:07:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1215C28857 for ; Thu, 18 Apr 2019 09:07:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 04935289DA; Thu, 18 Apr 2019 09:07:14 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9382428857 for ; Thu, 18 Apr 2019 09:07:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A0FE46B027C; Thu, 18 Apr 2019 05:06:46 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9E7D86B027D; Thu, 18 Apr 2019 05:06:46 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B2B46B027E; Thu, 18 Apr 2019 05:06:46 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by kanga.kvack.org (Postfix) with ESMTP id 357C66B027C for ; Thu, 18 Apr 2019 05:06:46 -0400 (EDT) Received: by mail-wr1-f69.google.com with SMTP id s3so359673wrw.21 for ; Thu, 18 Apr 2019 02:06:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=TmdqglcunI4wOAmrjgXMIH7hh4Tcg955OWTpIeEnbW8=; b=jnbDrFGktQkLNaufxdT9DsXopVCch52HNzPMXKnM45LjfcrpUq8Ornh87tQE+Icuef zPMd4Wz5J0bcPZlWlIyRW2gomdqVUfOomkjfxm2/q7E83+3tNtkZeUNRM4utUePJcwal Yjnl8f0E77ZiD7B7KEinJCRH7fIGYNTFqDWwhzN3cVwGlvoFf3D118oqJAnIFme1V2ic iP/t9IuZAx8aAmK8p/yYl+rVisCGZfBiYE2GFZpAjtjY3YnImPOE5LLUcv1LW2arR/A+ czDt9goLtEyDnFcdjEDyJliqz8+4cDjfqonQhPJP9Oaf2xuhvYQ8gxf3Rkwy7aMGwiBY gDjQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAXrdLKtp5J3DkdaT5Kkr1ZH10ji5aLgfgsy1+2LC0wzZw9dOLZJ xAlwJlLRFwYSvNHTD5xOQlbKE8s4TJp9s1KfuDe/RWTETUc9rD30Q6oxcx7/GD1mrcSSWtrTcp4 if4D0HbW+Yxh7niN4uJpOO4OlKwDpYin2gFB84txbpFRupacISgVjbVR/k6WmUuGMCA== X-Received: by 2002:adf:d4d0:: with SMTP id w16mr3332968wrk.318.1555578405755; Thu, 18 Apr 2019 02:06:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXAoFbZ/Pj4k/ND3vXXt8JztC3VmlAe4wn20efWScTjfE4ae2HgqmNZ1JXCRy+erVzwXXP X-Received: by 2002:adf:d4d0:: with SMTP id w16mr3332920wrk.318.1555578405022; Thu, 18 Apr 2019 02:06:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578405; cv=none; d=google.com; s=arc-20160816; b=TCou9CLdKDmVYWu7qduz0kqYxnekh/KGM+tfb/a9hSYltTIuB+EwOU6uLow7xytCIj LuOFc2x/QbZO66jWibeA1S71LMVzEvnEBb5CkqJDkk0idW1tMXwKHSwcQBvihcN89OCq wiqDwh2SH6ebMh4cQEzaUHGWLz7VxkFnKch2V1q9BZYymey9ICwyiNt6QhOvOlrfqMbd gPLKQIEsEjdGhdtLYdI/OF+f9OpdHShRr1FR/NAhYeJCMvnfbrBzvAmC8/OSwgFyEcgk ceKEpFIogd0xIyBIayPiXVCyMesBiqu3WAHT7HBhFlp3FL907oha5mCIym7/yX6ROyw/ AOJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=TmdqglcunI4wOAmrjgXMIH7hh4Tcg955OWTpIeEnbW8=; b=l+cGtEj/F4Z0UD3yLjmnf/Wyw3QfcRalknWzKoEdwgKatRKwucD8W76kWCMHEu1t+M 8JtdCB48DsU0Y6LlM0VlTqQrGW5VWmV+8uH3K/oRN2QI97pwLAOJ/fbd3VjUnwn0Q6ye W5BVnr5zFRFy6vNLnH/GJIUBuEetnqRYGN+K+6Q2oFPwq4UfRWbkfS7b6T629Xb5yYaU EaTNhffo54qlkZTW9t1JGHI2CiA0d9Hr9SsXZ9/dOKyr+DLthYYA9iHi9bgVAQsGBITs tgS/PySVkiqI6VCjLG95iiVhsZb1NR2JNjR8xptcT2Y9exWjUxVXIKDj/vPTEY54G1Dz yiDA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id a194si1103363wmd.192.2019.04.18.02.06.44 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH30D-0001tl-Se; Thu, 18 Apr 2019 11:06:42 +0200 Message-Id: <20190418084254.910579307@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:39 +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 20/29] tracing: Simplify stacktrace retrieval in histograms References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP The indirection through struct stack_trace is not necessary at all. Use the storage array based interface. Signed-off-by: Thomas Gleixner Cc: Steven Rostedt Acked-by: Steven Rostedt (VMware) Acked-by: Tom Zanussi Reviewed-by: Tom Zanussi Tested-by: Tom Zanussi --- kernel/trace/trace_events_hist.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -5186,7 +5186,6 @@ static void event_hist_trigger(struct ev u64 var_ref_vals[TRACING_MAP_VARS_MAX]; char compound_key[HIST_KEY_SIZE_MAX]; struct tracing_map_elt *elt = NULL; - struct stack_trace stacktrace; struct hist_field *key_field; u64 field_contents; void *key = NULL; @@ -5198,14 +5197,9 @@ static void event_hist_trigger(struct ev key_field = hist_data->fields[i]; if (key_field->flags & HIST_FIELD_FL_STACKTRACE) { - stacktrace.max_entries = HIST_STACKTRACE_DEPTH; - stacktrace.entries = entries; - stacktrace.nr_entries = 0; - stacktrace.skip = HIST_STACKTRACE_SKIP; - - memset(stacktrace.entries, 0, HIST_STACKTRACE_SIZE); - save_stack_trace(&stacktrace); - + memset(entries, 0, HIST_STACKTRACE_SIZE); + stack_trace_save(entries, HIST_STACKTRACE_DEPTH, + HIST_STACKTRACE_SKIP); key = entries; } else { field_contents = key_field->fn(key_field, elt, rbe, rec); From patchwork Thu Apr 18 08:41:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906787 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 193C7922 for ; Thu, 18 Apr 2019 09:07:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0101828857 for ; Thu, 18 Apr 2019 09:07:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E905B289DA; Thu, 18 Apr 2019 09:07:20 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5804728857 for ; Thu, 18 Apr 2019 09:07:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 644166B0280; Thu, 18 Apr 2019 05:06:50 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5B0D56B0281; Thu, 18 Apr 2019 05:06:50 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 496A86B0282; Thu, 18 Apr 2019 05:06:50 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by kanga.kvack.org (Postfix) with ESMTP id E684B6B0280 for ; Thu, 18 Apr 2019 05:06:49 -0400 (EDT) Received: by mail-wr1-f69.google.com with SMTP id t9so1512006wrs.16 for ; Thu, 18 Apr 2019 02:06:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=Rfp/Jdoj6ynanVHeLJoJ4T7lo4WNyNtoC/3T8RdTRFY=; b=QfQ4+24BHKAG5SejbkisrwXMdKKxmNpPGiTjoEh7M1xOy9VmVJBVEG9G9y/iUG0IcK vbmWtjGsiVQKWuaXZBGVSQGznQmULTJ0dxevqJpW4uL+G41ThpJ5JtvwtelvB39BWaJs kijYOu5d0Zry1rCneV4wwPJK3xpqfXEjcyq+69EVOdRwLNwOLrOWe5bNQfOF/h4jHMza 9Rm9V/Q3KSlf2NcQBp73uNA44PH5LRkMdri9x8jv98ptGJDvPUFEJc6oJttoSW0fyhdX Ict5ITsDLXyPpksgUfHZpUlUPKjpTtqKuXqrxZ5v2a57ZBgX3cSzhgVp1SOwPCm8WM8J xDqg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAVer0jEysQkGw7+qbsodiMAG93b+MRQfHrV/XfdnKooiFAuwrl6 hngqyzZ/EDkWM+6y5z9ziPMHkTVF07WPkAIQOYvw12XtWGZwMIKIv7UaR2cGTbkeCvlyE/M/Pdw MKZEx2HO+5W4IbyhB/hZvTJGFmcj4K+r8UudqRCgfBmqMQdnSFGJPcSqhxIuVYfw22Q== X-Received: by 2002:a05:600c:24f:: with SMTP id 15mr2131799wmj.48.1555578409429; Thu, 18 Apr 2019 02:06:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqwTY/Uje/Z68lhJp2jw5wPTAHqFg1HqSYzD9QchHqmcjdLzp5+tgcpUJZntfRBjqxPC5dwe X-Received: by 2002:a05:600c:24f:: with SMTP id 15mr2131750wmj.48.1555578408413; Thu, 18 Apr 2019 02:06:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578408; cv=none; d=google.com; s=arc-20160816; b=ePMGmSKlQSOWIMCEuxSFoq4vO7llOfnR9kO76qQRzt8YoXZV3ib0kz2WNE7zLyCU9v ftx7hZKbtxIai1gvr7PKLfRyHI66VxslpP7GfitgJVzBA7q+5m2ABd8NuSZd5RsfR9ml H2oIwhhjwUYMsbNyoL1hufod6AyjFJl1X71W/Yj+QUp2243M64md5boVmYx/W80Wvnws gZIHGB7is8djwq6V8FK5UBmY3i9wiKOMYY0IAMCnLpqlrENfFiB2S1KDJ1lv5ay7VSXh jQuY6CnxtRda9HstusFSUCwR+Gdu9++Q286QGXC700ZpeCwm9UXU+F4CAis0L+6vUiRW +8yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=Rfp/Jdoj6ynanVHeLJoJ4T7lo4WNyNtoC/3T8RdTRFY=; b=VqjL1fz7d8YQC/6qc6NE1cX8kh9aoatB93Jxh049qHqrXasY+VeVJjTsGps4VCmWdN T4J1z3MfW8vlHZL2pyBGSaSMsD+DbyC+QHAGMlBmTZhnwoMCAeYF0Fdff6yfQIeELT0j /HIuk1oxT6HOpiak7y48pz98mHj2itqsod+DlA9o6p/4beI5AhVuhfNOpIKiCnLTGWHz lfUYCTjh41OglfCT73wUi9VLavX93LQgZ+lGx+V5L8mxburazn8yZFC0JDwX9L0cBfUy xCfOnKIcoAuHy3S2NTtalt3j2OqbRZH32X421oK0fU/l0SgzlXm/BrO3ut4Go3YYGeNs V6XA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id e5si1071172wmh.91.2019.04.18.02.06.48 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH30G-0001uJ-9j; Thu, 18 Apr 2019 11:06:44 +0200 Message-Id: <20190418084254.999521114@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:40 +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 21/29] tracing: Use percpu stack trace buffer more intelligently References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP The per cpu stack trace buffer usage pattern is odd at best. The buffer has place for 512 stack trace entries on 64-bit and 1024 on 32-bit. When interrupts or exceptions nest after the per cpu buffer was acquired the stacktrace length is hardcoded to 8 entries. 512/1024 stack trace entries in kernel stacks are unrealistic so the buffer is a complete waste. Split the buffer into chunks of 64 stack entries which is plenty. This allows nesting contexts (interrupts, exceptions) to utilize the cpu buffer for stack retrieval and avoids the fixed length allocation along with the conditional execution pathes. Signed-off-by: Thomas Gleixner Cc: Steven Rostedt --- kernel/trace/trace.c | 77 +++++++++++++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 38 deletions(-) --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -2749,12 +2749,21 @@ trace_function(struct trace_array *tr, #ifdef CONFIG_STACKTRACE -#define FTRACE_STACK_MAX_ENTRIES (PAGE_SIZE / sizeof(unsigned long)) +/* 64 entries for kernel stacks are plenty */ +#define FTRACE_KSTACK_ENTRIES 64 + struct ftrace_stack { - unsigned long calls[FTRACE_STACK_MAX_ENTRIES]; + unsigned long calls[FTRACE_KSTACK_ENTRIES]; }; -static DEFINE_PER_CPU(struct ftrace_stack, ftrace_stack); +/* This allows 8 level nesting which is plenty */ +#define FTRACE_KSTACK_NESTING (PAGE_SIZE / sizeof(struct ftrace_stack)) + +struct ftrace_stacks { + struct ftrace_stack stacks[FTRACE_KSTACK_NESTING]; +}; + +static DEFINE_PER_CPU(struct ftrace_stacks, ftrace_stacks); static DEFINE_PER_CPU(int, ftrace_stack_reserve); static void __ftrace_trace_stack(struct ring_buffer *buffer, @@ -2763,10 +2772,11 @@ static void __ftrace_trace_stack(struct { struct trace_event_call *call = &event_kernel_stack; struct ring_buffer_event *event; + struct ftrace_stack *fstack; struct stack_entry *entry; struct stack_trace trace; - int use_stack; - int size = FTRACE_STACK_ENTRIES; + int size = FTRACE_KSTACK_ENTRIES; + int stackidx; trace.nr_entries = 0; trace.skip = skip; @@ -2788,29 +2798,32 @@ static void __ftrace_trace_stack(struct */ preempt_disable_notrace(); - use_stack = __this_cpu_inc_return(ftrace_stack_reserve); + stackidx = __this_cpu_inc_return(ftrace_stack_reserve); + + /* This should never happen. If it does, yell once and skip */ + if (WARN_ON_ONCE(stackidx >= FTRACE_KSTACK_NESTING)) + goto out; + /* - * We don't need any atomic variables, just a barrier. - * If an interrupt comes in, we don't care, because it would - * have exited and put the counter back to what we want. - * We just need a barrier to keep gcc from moving things - * around. + * The above __this_cpu_inc_return() is 'atomic' cpu local. An + * interrupt will either see the value pre increment or post + * increment. If the interrupt happens pre increment it will have + * restored the counter when it returns. We just need a barrier to + * keep gcc from moving things around. */ barrier(); - if (use_stack == 1) { - trace.entries = this_cpu_ptr(ftrace_stack.calls); - trace.max_entries = FTRACE_STACK_MAX_ENTRIES; - - if (regs) - save_stack_trace_regs(regs, &trace); - else - save_stack_trace(&trace); - - if (trace.nr_entries > size) - size = trace.nr_entries; - } else - /* From now on, use_stack is a boolean */ - use_stack = 0; + + fstack = this_cpu_ptr(ftrace_stacks.stacks) + (stackidx - 1); + trace.entries = fstack->calls; + trace.max_entries = FTRACE_KSTACK_ENTRIES; + + if (regs) + save_stack_trace_regs(regs, &trace); + else + save_stack_trace(&trace); + + if (trace.nr_entries > size) + size = trace.nr_entries; size *= sizeof(unsigned long); @@ -2820,19 +2833,7 @@ static void __ftrace_trace_stack(struct goto out; entry = ring_buffer_event_data(event); - memset(&entry->caller, 0, size); - - if (use_stack) - memcpy(&entry->caller, trace.entries, - trace.nr_entries * sizeof(unsigned long)); - else { - trace.max_entries = FTRACE_STACK_ENTRIES; - trace.entries = entry->caller; - if (regs) - save_stack_trace_regs(regs, &trace); - else - save_stack_trace(&trace); - } + memcpy(&entry->caller, trace.entries, size); entry->size = trace.nr_entries; From patchwork Thu Apr 18 08:41:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906789 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 9C458161F for ; Thu, 18 Apr 2019 09:07:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8495128857 for ; Thu, 18 Apr 2019 09:07:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7863F289DA; Thu, 18 Apr 2019 09:07:24 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB40728857 for ; Thu, 18 Apr 2019 09:07:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DE32B6B0283; Thu, 18 Apr 2019 05:06:52 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D6F7D6B0284; Thu, 18 Apr 2019 05:06:52 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BBF976B0285; Thu, 18 Apr 2019 05:06:52 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by kanga.kvack.org (Postfix) with ESMTP id 6ACFB6B0283 for ; Thu, 18 Apr 2019 05:06:52 -0400 (EDT) Received: by mail-wr1-f71.google.com with SMTP id k17so1527234wrq.7 for ; Thu, 18 Apr 2019 02:06:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=3+9T0z9unofC3pE/39cVnhN7HKt3P3w9oi49TvlpUJ8=; b=KfLlasR6bZlVRjWyt55SPVnoEd2TxJ5pmLTa+bS9dAs/XqqITa5XIrkPLOAgwhhgyD lBSTqgzy139D07/m2J3L8zlZnOv+VXK8fCIcZXRCKrGUE09d3/1keT/myFLNKOoe0tsH ikGy9OBeSbt2XfX60VEuhPhTmC46Ui+p8YU4yd5bn5xOFt9TGEjAN2NJvwryBe8AsrDU KUFh9fvQ6aVCwaTdhmlDIzgOMxu1nPZj3llQ7O5mqk26Ct9fDU3Vs9MJVIwaaQ7vvyFN PdBouKJOndUKfNZZMVtSgAApKGBnQE+WCtpQ09PoYpG9gJ+8xf52sMfrHdg0LRe+JvhK wn+w== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAVzGBHQDBe4EX6w4RmWuoLs88bRCXk/ECYmMIGUYaZB/Wo5M0iX y3QVCX4mFBaOXrdkLtlEbv7QugJx+OqR/EiiB0+1uKsH6ayle6UgAp6YGLhLuY0+A3SQg1EmQs3 QGJPZzazo323lZMWt6rGVkUBEehQvYp0uE48K8MhD1T6CYLveq9l2lhTnG6csSNPzow== X-Received: by 2002:adf:8051:: with SMTP id 75mr5080751wrk.2.1555578411980; Thu, 18 Apr 2019 02:06:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwU0Cdzw441Nuie1pkh0rbGSm0vijjOdsIz+OMz+mbBChLFt0gGKfeh+e+MIt+VIHyRlc7E X-Received: by 2002:adf:8051:: with SMTP id 75mr5080700wrk.2.1555578411224; Thu, 18 Apr 2019 02:06:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578411; cv=none; d=google.com; s=arc-20160816; b=KlJ3L0rL59/ww9fHFdI2YAA7HEIZYDfDNtuxT+xQ1F9LxNEbP1ZW2c1sRN/nicoWVg Gwmwtmu84XoYvuCPP4XF+dpO2y9vMR3ScHeGPPEO3m1WZvZQZnl/9ADn53qd26icuCkk LN/VyaodP/tJHRCMV0cGXfKF+7xSR1jmCr3yPLkfIKLLSmEqJa63v6XMZZ0w/Dh92lBj /E6hE3ZywHgtGqwBGAnqSADctTRb7bFzSRVBH/VnNea2KByqC9rLE/NtlPsUE6WoPjj9 v/tk06bcgaTVhrmGhx0piNfUPbYrS8hpb8GYpIzhTBzDBVesgr3+jBkr5+pD2FrUMXIm XxvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=3+9T0z9unofC3pE/39cVnhN7HKt3P3w9oi49TvlpUJ8=; b=zupzBUmr5wYpRYzXiv7HW/NXP/q3PmJLnTg0q3Ys+/mXws0aysaVvhmmQ+1pVKndi2 7GgApkRTJraV3M7WJX4LHawnCi9iPo99mXjHmQT0N1Xzlbcp3U8LX6IkXmovX4rnLk+K 3puHpyVUsUMQRtblgLbN+usRYqLVYoO8tJBSnYnh23seuNeN1IjIZSsd0tXvMPTaYUyi KvkOjRZl6z18iHs/xsKrvf6jIzVnNBAyMRJzKiXvAGtS+0uiL4JQ+vFBMXNlK8dml22y xiVZTpK0WpMQM5+h7gVeH/uPe/7+tG01ACCQFQX4rYDcnkPw0s6hcaFA0yKy/TlsEMHp 5MaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id w16si1218911wrn.241.2019.04.18.02.06.51 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH30I-0001v7-RI; Thu, 18 Apr 2019 11:06:47 +0200 Message-Id: <20190418084255.088813838@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:41 +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 22/29] tracing: Make ftrace_trace_userstack() static and conditional References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP It's only used in trace.c and there is absolutely no point in compiling it in when user space stack traces are not supported. Signed-off-by: Thomas Gleixner Cc: Steven Rostedt Reviewed-by: Steven Rostedt (VMware) --- kernel/trace/trace.c | 14 ++++++++------ kernel/trace/trace.h | 8 -------- 2 files changed, 8 insertions(+), 14 deletions(-) --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -159,6 +159,8 @@ static union trace_eval_map_item *trace_ #endif /* CONFIG_TRACE_EVAL_MAP_FILE */ static int tracing_set_tracer(struct trace_array *tr, const char *buf); +static void ftrace_trace_userstack(struct ring_buffer *buffer, + unsigned long flags, int pc); #define MAX_TRACER_SIZE 100 static char bootup_tracer_buf[MAX_TRACER_SIZE] __initdata; @@ -2905,9 +2907,10 @@ void trace_dump_stack(int skip) } EXPORT_SYMBOL_GPL(trace_dump_stack); +#ifdef CONFIG_USER_STACKTRACE_SUPPORT static DEFINE_PER_CPU(int, user_stack_count); -void +static void ftrace_trace_userstack(struct ring_buffer *buffer, unsigned long flags, int pc) { struct trace_event_call *call = &event_user_stack; @@ -2958,13 +2961,12 @@ ftrace_trace_userstack(struct ring_buffe out: preempt_enable(); } - -#ifdef UNUSED -static void __trace_userstack(struct trace_array *tr, unsigned long flags) +#else /* CONFIG_USER_STACKTRACE_SUPPORT */ +static void ftrace_trace_userstack(struct ring_buffer *buffer, + unsigned long flags, int pc) { - ftrace_trace_userstack(tr, flags, preempt_count()); } -#endif /* UNUSED */ +#endif /* !CONFIG_USER_STACKTRACE_SUPPORT */ #endif /* CONFIG_STACKTRACE */ --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -782,17 +782,9 @@ void update_max_tr_single(struct trace_a #endif /* CONFIG_TRACER_MAX_TRACE */ #ifdef CONFIG_STACKTRACE -void ftrace_trace_userstack(struct ring_buffer *buffer, unsigned long flags, - int pc); - void __trace_stack(struct trace_array *tr, unsigned long flags, int skip, int pc); #else -static inline void ftrace_trace_userstack(struct ring_buffer *buffer, - unsigned long flags, int pc) -{ -} - static inline void __trace_stack(struct trace_array *tr, unsigned long flags, int skip, int pc) { From patchwork Thu Apr 18 08:41:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906793 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 F3598922 for ; Thu, 18 Apr 2019 09:07:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC8A728857 for ; Thu, 18 Apr 2019 09:07:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF220289DA; Thu, 18 Apr 2019 09:07:27 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5208B28857 for ; Thu, 18 Apr 2019 09:07:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D463D6B0284; Thu, 18 Apr 2019 05:06:54 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CD09A6B0285; Thu, 18 Apr 2019 05:06:54 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD3F46B0286; Thu, 18 Apr 2019 05:06:54 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by kanga.kvack.org (Postfix) with ESMTP id 5836B6B0284 for ; Thu, 18 Apr 2019 05:06:54 -0400 (EDT) Received: by mail-wr1-f71.google.com with SMTP id c8so1527706wru.13 for ; Thu, 18 Apr 2019 02:06:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=lC14wLptSwMX1RfWmgp9otJ/2ZurJIp5t7P26rWm7ME=; b=CEPzxhI8RR3IiwMhfHA2aRgKvp1aCocGtgrHOdRtqTUztZB3lnrStEPeWeVy/W5F5C 73Fjpe8rbDeFFpgyyVTeCiZFTtq6nBqYuOqAfY4NO1QERwGYsZ8EOxoFUmPi/gDCDTuR cbjDM5hVDTnIoqxW1EFElezL8+EoCeHB/pLJovTxZnwRuTGxe2brbm+3C+STm12TxiOg xu14Y3mZorv10E+Y76uo4ja/s4SQP3oCvQt06KTjl1LFW4JPD1dL7xDxy2gTsuFTsU9o XHKHOhXB4N5MSYE4FM8F98GRYDqtgssUxkrpOsxPs6jzhK0UnDGEZ1H7YxvGYYKEzyBf fRXw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAX9qPcjcvwAruat2IuFeJwtP32XNaEGCf9KjMDC/z45i9pUW6TB pUsg/1a6/uL/f3xdjH2C9mJ0uysIFVgjvZlqngPXx6NcMVGquqy23d8jKJKL83H5BH+jdchV1v2 lUv2FHKdeD85jhV2PINxqcl236l+yK+cAf1lQ4detC6b3mzEYYYNeqTe6lvzG7j4uXQ== X-Received: by 2002:adf:fa47:: with SMTP id y7mr42802921wrr.27.1555578413789; Thu, 18 Apr 2019 02:06:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyGkFosDqr4DE+kPsPGvbw/90z+r2rPicUFlanWN1ELw6Mb9wWHpbHrFwSe16MxkOFs7u7T X-Received: by 2002:adf:fa47:: with SMTP id y7mr42802876wrr.27.1555578412990; Thu, 18 Apr 2019 02:06:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578412; cv=none; d=google.com; s=arc-20160816; b=TgbC+N/xw2njeyujSMcDIFgseHZr+ovhLMHiqjc79EF3zVb3HH5+Jv5/5lbLh+kV1D cStDWzbOcd1tg99X/WusW8W1GaeJKzv57JoLfmOrelWJZPmVZnfqHq9WR6MQuXsT9HYz 7OmaaUcoxQRfEByV2ZhkA/r1/dQWEnsux/URr7ZfIherN6hge2f4B6hC1zFYNHxdw0ks 7xuMDLQq4ivzCIwJvTqwbrIad31+Np7Cf3O2EDtFaUddWef5J8JqAY/PLEI6goMt10su JGS3LQsL3psfrvx5+hK/1VmhS+DtmjBcjPuocro3bcCUvZEe/EnAQ8L24TfdYrmJX5fo gbzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=lC14wLptSwMX1RfWmgp9otJ/2ZurJIp5t7P26rWm7ME=; b=GBrbYAYwssHCMjpxiIuQfCmxvUyaTCs7+Gv+NvRGTywI0Pm+ifbS5oTNW0lrIxySrt nIn3wau2O9D26Zx95Rq0y9fXYmEzxdYpYk8pdyyLmsKMJttYs2Lm/BswE+XCHQuseptb 0D8PYo5RmI8H+Mc4kjJwRScvTZyGfRAYRSHqEKRvIakoLvpkk8Zwa7Ds0LN28wDKeQYC pZMBl/CLLlsuUewWJ0B2DcXLFV9BtvvfNKILBKRtfv2KgqIjsd5iIflkkv+b8OPJA3ts 76QtCHK23aLhGhV87yfDXZh3F3AzZggrAocpQvaLRblNDmnL3Gp/39FZ6FZLrNKNbZA9 M/9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id y2si1195736wrs.332.2019.04.18.02.06.52 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH30L-0001w5-1f; Thu, 18 Apr 2019 11:06:49 +0200 Message-Id: <20190418084255.186774860@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:42 +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 23/29] tracing: Simplify stack trace retrieval References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Replace the indirection through struct stack_trace by using the storage array based interfaces. Signed-off-by: Thomas Gleixner Cc: Steven Rostedt Reviewed-by: Steven Rostedt (VMware) --- kernel/trace/trace.c | 40 +++++++++++++--------------------------- 1 file changed, 13 insertions(+), 27 deletions(-) --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -2774,22 +2774,18 @@ static void __ftrace_trace_stack(struct { struct trace_event_call *call = &event_kernel_stack; struct ring_buffer_event *event; + unsigned int size, nr_entries; struct ftrace_stack *fstack; struct stack_entry *entry; - struct stack_trace trace; - int size = FTRACE_KSTACK_ENTRIES; int stackidx; - trace.nr_entries = 0; - trace.skip = skip; - /* * Add one, for this function and the call to save_stack_trace() * If regs is set, then these functions will not be in the way. */ #ifndef CONFIG_UNWINDER_ORC if (!regs) - trace.skip++; + skip++; #endif /* @@ -2816,28 +2812,24 @@ static void __ftrace_trace_stack(struct barrier(); fstack = this_cpu_ptr(ftrace_stacks.stacks) + (stackidx - 1); - trace.entries = fstack->calls; - trace.max_entries = FTRACE_KSTACK_ENTRIES; - - if (regs) - save_stack_trace_regs(regs, &trace); - else - save_stack_trace(&trace); - - if (trace.nr_entries > size) - size = trace.nr_entries; + size = ARRAY_SIZE(fstack->calls); - size *= sizeof(unsigned long); + if (regs) { + nr_entries = stack_trace_save_regs(regs, fstack->calls, + size, skip); + } else { + nr_entries = stack_trace_save(fstack->calls, size, skip); + } + size = nr_entries * sizeof(unsigned long); event = __trace_buffer_lock_reserve(buffer, TRACE_STACK, sizeof(*entry) + size, flags, pc); if (!event) goto out; entry = ring_buffer_event_data(event); - memcpy(&entry->caller, trace.entries, size); - - entry->size = trace.nr_entries; + memcpy(&entry->caller, fstack->calls, size); + entry->size = nr_entries; if (!call_filter_check_discard(call, entry, buffer, event)) __buffer_unlock_commit(buffer, event); @@ -2916,7 +2908,6 @@ ftrace_trace_userstack(struct ring_buffe struct trace_event_call *call = &event_user_stack; struct ring_buffer_event *event; struct userstack_entry *entry; - struct stack_trace trace; if (!(global_trace.trace_flags & TRACE_ITER_USERSTACKTRACE)) return; @@ -2947,12 +2938,7 @@ ftrace_trace_userstack(struct ring_buffe entry->tgid = current->tgid; memset(&entry->caller, 0, sizeof(entry->caller)); - trace.nr_entries = 0; - trace.max_entries = FTRACE_STACK_ENTRIES; - trace.skip = 0; - trace.entries = entry->caller; - - save_stack_trace_user(&trace); + stack_trace_save_user(entry->caller, FTRACE_STACK_ENTRIES); if (!call_filter_check_discard(call, entry, buffer, event)) __buffer_unlock_commit(buffer, event); From patchwork Thu Apr 18 08:41:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906801 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 8F12A1850 for ; Thu, 18 Apr 2019 09:07:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7821C28857 for ; Thu, 18 Apr 2019 09:07:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6AC89289C5; Thu, 18 Apr 2019 09:07:31 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D92E328857 for ; Thu, 18 Apr 2019 09:07:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C5A146B0286; Thu, 18 Apr 2019 05:06:56 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C0CB36B0288; Thu, 18 Apr 2019 05:06:56 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B21EB6B0289; Thu, 18 Apr 2019 05:06:56 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by kanga.kvack.org (Postfix) with ESMTP id 66DB46B0286 for ; Thu, 18 Apr 2019 05:06:56 -0400 (EDT) Received: by mail-wr1-f70.google.com with SMTP id s1so1515110wrv.12 for ; Thu, 18 Apr 2019 02:06:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=DRtEoftaP1MWkVAJr4a/HUTjOvVz6lcHG5vvvFjDf40=; b=aKzj0TcBAmT0rAt0NhZ/zdNKgcPw1e4wZcuEML3PXdVX4NJ6vnXFJSCRkNgKrIt3JS uxjM0hV2ijVPQ8q4NoUPMUFzDF07vFGF9Bw4YbYKmO96DAbD/2/CEtabdmTV46mnbss5 VqmCzodvlBElnctxcduOtf6En1xeIysh7KIe5hI07nPJ5G9H2sq5EEihADgfNLOHgcfS qWHTRl7+7qXiOHv91pkkHGI46V6wk5aIWlPeZK48x0tDCFz3PmpWY2O1mWUPg9jxTfm0 hLxsEBZ02Ir2QIu39WYstGP9c7ASy5jiNXrHV91FYKo387okJSC349RfvcPPwIESUzUZ /G5g== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAU6BiFQLOoOsLmI6vMu3WYUvLJPkDqVV029SuYhkPH9McMsaDPK xnFiKLVQLGdJZb5cQSCw7SqhEOo9HSpWvCf6fZiMjwz3EpTvHfLe2J2v8bsZIDgSRRUG3Q+jUtX 5gP+xZLFR4NmF8PzNc898Ws0RGL09S57kh5lZ0G9AcDZ+yPRiXDcpLP+QSKDNIh+9NQ== X-Received: by 2002:a5d:400c:: with SMTP id n12mr23121663wrp.31.1555578415960; Thu, 18 Apr 2019 02:06:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqy6XgwQNgoFeljioqdvoqIANL4JFxyNglLa2wMSdScEBv339rc7ByZZSzTO16AKygLtpx33 X-Received: by 2002:a5d:400c:: with SMTP id n12mr23121607wrp.31.1555578415069; Thu, 18 Apr 2019 02:06:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578415; cv=none; d=google.com; s=arc-20160816; b=pwGAGMOzX1sGal4zAY7A3FTB2igKgY6K2qwxFR8dDJjlTm6lKE3UaOaCq128ffeNPE nbqxRSWEF3hWMKjKrKAjWTsuJPIbhOOlMhlE8OSZPTXlja2ni+VA3y7mm73fmzIKZ9ri v/4r2iSToLfuJhlbouR6D8FhtiUCNRltyjEL9IQKoknIn9XBPf4IXN35IajF2vSn3A64 i/WK12vQ+kKPZg14IQmhNUiYE3bxcDvVTPQobuo6cwkKCfHiXaH8RElQov0pEIdHQ485 UCXTdp14iZ8lz1r9ZH5WdiNZqhg5il2I4/Nh/P//I0veXlifZAAitR3iZQFieOgfkKIT fZXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=DRtEoftaP1MWkVAJr4a/HUTjOvVz6lcHG5vvvFjDf40=; b=L6a4CB4UPtroh90t+7C2/8uW6hR5Y+01SbwQ6EG27gAxbRyKtJ5ThO84rGMcRi/cTi HozMAHc7/NOgoJ+cbJLzEGVrKOfuc47UabVLPAgPNWFwuxReqArVNmZBVqpfrq95VkE9 pOeWwCbvApDhYt8FSMdk36to4HXdEbbk0YdV0kPRtyl2S78v48br8udvE39QduNzLd8h WJcFAW8RYFtwdlZNeKHsyIt6gRVh34NHP7YuyQKmVtuLPevgQ3NHRlYoV9p5X5RWd5rh JMO+MMzFqAK6B1ose1Zn6T0ue3DRD5ImOmlGTJRTr7GUhkzo6JvAJCvDsurt4GUF/Xj8 RnMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id z77si1130941wmc.179.2019.04.18.02.06.54 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH30N-0001wk-9B; Thu, 18 Apr 2019 11:06:51 +0200 Message-Id: <20190418084255.275696472@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:43 +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 24/29] tracing: Remove the last struct stack_trace usage References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Simplify the stack retrieval code by using the storage array based interface. Signed-off-by: Thomas Gleixner Reviewed-by: Steven Rostedt (VMware) --- kernel/trace/trace_stack.c | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) --- a/kernel/trace/trace_stack.c +++ b/kernel/trace/trace_stack.c @@ -23,16 +23,7 @@ static unsigned long stack_dump_trace[STACK_TRACE_ENTRIES]; static unsigned stack_trace_index[STACK_TRACE_ENTRIES]; -/* - * Reserve one entry for the passed in ip. This will allow - * us to remove most or all of the stack size overhead - * added by the stack tracer itself. - */ -struct stack_trace stack_trace_max = { - .max_entries = STACK_TRACE_ENTRIES - 1, - .entries = &stack_dump_trace[0], -}; - +static unsigned int stack_trace_entries; static unsigned long stack_trace_max_size; static arch_spinlock_t stack_trace_max_lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED; @@ -49,10 +40,10 @@ static void print_max_stack(void) pr_emerg(" Depth Size Location (%d entries)\n" " ----- ---- --------\n", - stack_trace_max.nr_entries); + stack_trace_entries); - for (i = 0; i < stack_trace_max.nr_entries; i++) { - if (i + 1 == stack_trace_max.nr_entries) + for (i = 0; i < stack_trace_entries; i++) { + if (i + 1 == stack_trace_entries) size = stack_trace_index[i]; else size = stack_trace_index[i] - stack_trace_index[i+1]; @@ -98,13 +89,12 @@ static void check_stack(unsigned long ip stack_trace_max_size = this_size; - stack_trace_max.nr_entries = 0; - stack_trace_max.skip = 0; - - save_stack_trace(&stack_trace_max); + stack_trace_entries = stack_trace_save(stack_dump_trace, + ARRAY_SIZE(stack_dump_trace) - 1, + 0); /* Skip over the overhead of the stack tracer itself */ - for (i = 0; i < stack_trace_max.nr_entries; i++) { + for (i = 0; i < stack_trace_entries; i++) { if (stack_dump_trace[i] == ip) break; } @@ -113,7 +103,7 @@ static void check_stack(unsigned long ip * Some archs may not have the passed in ip in the dump. * If that happens, we need to show everything. */ - if (i == stack_trace_max.nr_entries) + if (i == stack_trace_entries) i = 0; /* @@ -131,13 +121,13 @@ static void check_stack(unsigned long ip * loop will only happen once. This code only takes place * on a new max, so it is far from a fast path. */ - while (i < stack_trace_max.nr_entries) { + while (i < stack_trace_entries) { int found = 0; stack_trace_index[x] = this_size; p = start; - for (; p < top && i < stack_trace_max.nr_entries; p++) { + for (; p < top && i < stack_trace_entries; p++) { /* * The READ_ONCE_NOCHECK is used to let KASAN know that * this is not a stack-out-of-bounds error. @@ -168,7 +158,7 @@ static void check_stack(unsigned long ip i++; } - stack_trace_max.nr_entries = x; + stack_trace_entries = x; if (task_stack_end_corrupted(current)) { print_max_stack(); @@ -270,7 +260,7 @@ static void * { long n = *pos - 1; - if (n >= stack_trace_max.nr_entries) + if (n >= stack_trace_entries) return NULL; m->private = (void *)n; @@ -334,7 +324,7 @@ static int t_show(struct seq_file *m, vo seq_printf(m, " Depth Size Location" " (%d entries)\n" " ----- ---- --------\n", - stack_trace_max.nr_entries); + stack_trace_entries); if (!stack_tracer_enabled && !stack_trace_max_size) print_disabled(m); @@ -344,10 +334,10 @@ static int t_show(struct seq_file *m, vo i = *(long *)v; - if (i >= stack_trace_max.nr_entries) + if (i >= stack_trace_entries) return 0; - if (i + 1 == stack_trace_max.nr_entries) + if (i + 1 == stack_trace_entries) size = stack_trace_index[i]; else size = stack_trace_index[i] - stack_trace_index[i+1]; From patchwork Thu Apr 18 08:41:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906805 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 A4FBF1850 for ; Thu, 18 Apr 2019 09:07:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8AEB928857 for ; Thu, 18 Apr 2019 09:07:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E93728A9B; Thu, 18 Apr 2019 09:07:35 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3871928857 for ; Thu, 18 Apr 2019 09:07:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BBE736B0288; Thu, 18 Apr 2019 05:06:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B97F96B0289; Thu, 18 Apr 2019 05:06:58 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A38916B028A; Thu, 18 Apr 2019 05:06:58 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by kanga.kvack.org (Postfix) with ESMTP id 561076B0288 for ; Thu, 18 Apr 2019 05:06:58 -0400 (EDT) Received: by mail-wr1-f72.google.com with SMTP id k17so1527434wrq.7 for ; Thu, 18 Apr 2019 02:06:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=JCj0ux7ByedEKEk5YXz2OvnjUAqieqsVDG1XIhHxw0g=; b=XDuoJZueJGpcXkWIIgLO22vt64/s3PoOnFmpUVL/QBhjYvK8RKeIzoRF2nEFiQeY2o IGCJ0q9fN6+vk33L9nqzgm34CXfA+86mymf5VM106xDPobJGNTmggmovYDdEB1PRhVgb Pl6j+5yt1/DU7A3ycarj8gkU1NnE39c4bbciOmS/S3oRyvxe/HA7hgwqLCeSHhrZ7AnV PouXSUOntqFp8B/CoAz8NC7JbhFKOa8l4XLQ+v7OjLv3UIokfmTqn/D9i0VJWOki0RSc FcW5nBBdB9bS4WBOdHI0mU+u+MCXxyQ8wY5vMH0BwyIouO5wHC/sqXmGoRiI9LXj6DYV Q2Zw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAVsBIuAig1H/eml7+NYe6aiJJBjgfPHKfEOk32c7ZmdUb5Zenp4 8BObpAgyARfvZkEJo98Czlkb6qzqKbeUIZuCYqpSin/7MlwlZI7bvH+KRpjCZ3EPzbJtKczS4Gu E/gDZYMm3RqUI/nIaYOOXncpo1uV1+kLyTDnvWjGC930A2GDhCaoovBXFAFJNSYNNvQ== X-Received: by 2002:a5d:658e:: with SMTP id q14mr6522684wru.52.1555578417887; Thu, 18 Apr 2019 02:06:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWmv/uHcZUcoV+9g4f7SC4aRBls8+W9qA/7T6zP5XJVgFtjmpZ0CkDXMLsw2UYNkzAsIfx X-Received: by 2002:a5d:658e:: with SMTP id q14mr6522634wru.52.1555578417148; Thu, 18 Apr 2019 02:06:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578417; cv=none; d=google.com; s=arc-20160816; b=vpQ6Opsj4bMPpveH6AzG280HRJZa76c1Wgzg3rom2Tds5SF6M25ARbAiVI5mbat1ts 2GxJFToX/6HviVGkuVvviFVaCmMHISBOyEkrZS9PD8J/FfeCyPBScC9AscHiW4mpzGB9 SH+uMXod3LbsNelLGWF/AD4QxR9XIKWoRFp2BJ4F1msYcIF5eIF6WH3+t+A8dkHvkSDV nYJLzIuHgxWs5yQ4KqqWkWckMhAZmNcBjOVCdd3tfflKkHnrqDZKWAI/JNHjBUTn1beQ D0GY8AS8/OKyT7jKhgxXF4jYLZLJNWaJYW4bG7GftlQ3cAiOHh912418qmDtIb4V8KoK WAtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=JCj0ux7ByedEKEk5YXz2OvnjUAqieqsVDG1XIhHxw0g=; b=wD1NYjjDdPqtRr7bH3Wu6cT4XBht5EDfTlKRkMxvAxYqyXDj9UF+3rrA9X3BT4IXgd R/cJ+kNRCLZIkZZ/Gmw+spqt22GzjFPovEyARCoQi/cjxNpGFiGPakS04ncQkHh2wmTS 9k/1uPUeTeyMp38Dvsw2B0frmKBFVZ/YeK3tZx8YmqzJr72Abdt1AHqDRnTFlyWrjoaN qYQMywQT+euSRyCumpk8DUyNZ7ws0fT+IwMg0Zfzy0k+YXEosNkx7C0RZSE7LSF8/xI3 uR3WSyIeJQclIs/bBkGrMRQ9Dh1ALEobUYDD9Vo8esNULt3pm2CSXpvQxZPxACrmOXyb U0EQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id v6si1266619wro.213.2019.04.18.02.06.57 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH30P-0001xS-En; Thu, 18 Apr 2019 11:06:53 +0200 Message-Id: <20190418084255.364915116@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:44 +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 25/29] livepatch: Simplify stack trace retrieval References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Replace the indirection through struct stack_trace by using the storage array based interfaces. Signed-off-by: Thomas Gleixner Acked-by: Miroslav Benes --- kernel/livepatch/transition.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) --- a/kernel/livepatch/transition.c +++ b/kernel/livepatch/transition.c @@ -202,15 +202,15 @@ void klp_update_patch_state(struct task_ * Determine whether the given stack trace includes any references to a * to-be-patched or to-be-unpatched function. */ -static int klp_check_stack_func(struct klp_func *func, - struct stack_trace *trace) +static int klp_check_stack_func(struct klp_func *func, unsigned long *entries, + unsigned int nr_entries) { unsigned long func_addr, func_size, address; struct klp_ops *ops; int i; - for (i = 0; i < trace->nr_entries; i++) { - address = trace->entries[i]; + for (i = 0; i < nr_entries; i++) { + address = entries[i]; if (klp_target_state == KLP_UNPATCHED) { /* @@ -254,29 +254,25 @@ static int klp_check_stack_func(struct k static int klp_check_stack(struct task_struct *task, char *err_buf) { static unsigned long entries[MAX_STACK_ENTRIES]; - struct stack_trace trace; struct klp_object *obj; struct klp_func *func; - int ret; + int ret, nr_entries; - trace.skip = 0; - trace.nr_entries = 0; - trace.max_entries = MAX_STACK_ENTRIES; - trace.entries = entries; - ret = save_stack_trace_tsk_reliable(task, &trace); + ret = stack_trace_save_tsk_reliable(task, entries, ARRAY_SIZE(entries)); WARN_ON_ONCE(ret == -ENOSYS); - if (ret) { + if (ret < 0) { snprintf(err_buf, STACK_ERR_BUF_SIZE, "%s: %s:%d has an unreliable stack\n", __func__, task->comm, task->pid); return ret; } + nr_entries = ret; klp_for_each_object(klp_transition_patch, obj) { if (!obj->patched) continue; klp_for_each_func(obj, func) { - ret = klp_check_stack_func(func, &trace); + ret = klp_check_stack_func(func, entries, nr_entries); if (ret) { snprintf(err_buf, STACK_ERR_BUF_SIZE, "%s: %s:%d is sleeping on function %s\n", From patchwork Thu Apr 18 08:41:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906821 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 548F1161F for ; Thu, 18 Apr 2019 09:07:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A825289DA for ; Thu, 18 Apr 2019 09:07:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2BA3F28AC4; Thu, 18 Apr 2019 09:07:44 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D334289DA for ; Thu, 18 Apr 2019 09:07:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 640076B028D; Thu, 18 Apr 2019 05:07:01 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5C9486B028F; Thu, 18 Apr 2019 05:07:01 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 46E386B028E; Thu, 18 Apr 2019 05:07:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by kanga.kvack.org (Postfix) with ESMTP id EB11A6B028F for ; Thu, 18 Apr 2019 05:07:00 -0400 (EDT) Received: by mail-wr1-f72.google.com with SMTP id s3so360167wrw.21 for ; Thu, 18 Apr 2019 02:07:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=/5xTOz92ynxAhyjYrdXulLIkXELWdxy++vIO1sJln64=; b=fTEFMGcOuFRrEof4YQOyFScsG0uG9sX4T//9lobQqEnRPqbpz3EvvymoweikYXIT7X iVsn0hArLdMPFwjQc94nmlvxfnd0gHr5bvVH+qxNas7zuazNpt3GEdBQ6rXtfI/oa9Ma LY0DEYqfk/t0GhMGXVROE9tjAq9Y1Gs5FIqCiAIIgRrpxvg5HKgeLrC7M3aZZHBryE2I qB08bAxzaF3OPVQBwGutVFMozQh+rZA0d9VCuWRjmcAfPZqtd6XGC6a1J60AKb9uYPB0 AhMGMpHwFfow8CUj83NdEzgPf/lEKEA07CR6r1p/vxxzclJ9VzC6pg3ysBOkoYzeZ02Q Dx2g== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAXqR9dBpSrbHFIw/kts+6043B67JqU85OxqyY+6O32oDgYsa0Gy PFwOhBimJMic4YpqGLFO13G4KDywTxeN43SRaiXrn/Q82wY+4MzJACtZ1jKjT/4Qm32oFxbENJ3 VatyXSPIbZ3jHgz2x/LmuMJmcG2AUz6q+PN8/xiykzYOOfb1le45zRQUy26Cc14g2uQ== X-Received: by 2002:a1c:c18d:: with SMTP id r135mr2174492wmf.112.1555578420480; Thu, 18 Apr 2019 02:07:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyyKi/hRAcb97ak3fZOVtzgXnq/SWSnJ3WFaxqq2c43JsYp1Is4sIoUA1sqIWNSUy9BkWiD X-Received: by 2002:a1c:c18d:: with SMTP id r135mr2174453wmf.112.1555578419701; Thu, 18 Apr 2019 02:06:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578419; cv=none; d=google.com; s=arc-20160816; b=hhoYjMYI8/0Ds5sXGdK0VAZUP9pVcVHOiRCvMALYkV8wd6K8PVt01OX6GVI3/93Oaj HmrbstGe3sjdMVkZucexm48TepxhKEBxpLfvIi0IG8h2hco0T19khDYT3L67jnDL+txG 61gbGk5pz3w36TPT8bGPQ+yO4KE2R5mu6lcsib+0zC19U8VCpbDQNFj9jLvKjwrtwCyt Y1bFdTGzdqiCBjHoeX+RpMkULq5Hj5JJGeFaW/uL/n+F0bmfO3nkLW3f9r7XfeULKbF3 2SQydx5lTyiZ2OeMnoZ4pEknQYSvxn2NV8AuA2mBJgxbpxcGYh4CS4ZEwc4s/nz6KJUx g2FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=/5xTOz92ynxAhyjYrdXulLIkXELWdxy++vIO1sJln64=; b=fsA9ykMv5yh2tzFLo6o9YQRVlysbdzjrscKPA4jAmxKp8JYHNB7RIgH1vlX/y3WdNI rsr+wruVKZn9aEe7nxJnscGdJOSFIhajzcgReZzArvrSpZQeRkStlpQYmPyVpuFVS9Ke S0bNnRuZEss5pW66b7TmastaAiE19cq1zVcNLq7dsLHglyTPzB9wh1km+acwNFqeQyut rTRxKA3jdC6E9sqJLgFxpI6pHF8esqGFFKoK39QA5PHvpFIYk+R0kPCMa1DzDxrIF6JN inJWbaRRyz1MROpfsQr09oCsfueaXvP0YnMLNDv5YpkZsgFAgWEORvx4ihsw96xlbO+N 3/+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id v10si1226069wrt.101.2019.04.18.02.06.59 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH30R-0001y0-Gu; Thu, 18 Apr 2019 11:06:55 +0200 Message-Id: <20190418084255.471038924@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:45 +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 26/29] stacktrace: Remove obsolete functions References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP No more users of the struct stack_trace based interfaces. Remove them. Remove the macro stubs for !CONFIG_STACKTRACE as well as they are pointless because the storage on the call sites is conditional on CONFIG_STACKTRACE already. No point to be 'smart'. Signed-off-by: Thomas Gleixner --- include/linux/stacktrace.h | 17 ----------------- kernel/stacktrace.c | 14 -------------- 2 files changed, 31 deletions(-) --- a/include/linux/stacktrace.h +++ b/include/linux/stacktrace.h @@ -36,24 +36,7 @@ extern void save_stack_trace_tsk(struct struct stack_trace *trace); extern int save_stack_trace_tsk_reliable(struct task_struct *tsk, struct stack_trace *trace); - -extern void print_stack_trace(struct stack_trace *trace, int spaces); -extern int snprint_stack_trace(char *buf, size_t size, - struct stack_trace *trace, int spaces); - -#ifdef CONFIG_USER_STACKTRACE_SUPPORT extern void save_stack_trace_user(struct stack_trace *trace); -#else -# define save_stack_trace_user(trace) do { } while (0) -#endif - -#else /* !CONFIG_STACKTRACE */ -# define save_stack_trace(trace) do { } while (0) -# define save_stack_trace_tsk(tsk, trace) do { } while (0) -# define save_stack_trace_user(trace) do { } while (0) -# define print_stack_trace(trace, spaces) do { } while (0) -# define snprint_stack_trace(buf, size, trace, spaces) do { } while (0) -# define save_stack_trace_tsk_reliable(tsk, trace) ({ -ENOSYS; }) #endif /* CONFIG_STACKTRACE */ #if defined(CONFIG_STACKTRACE) && defined(CONFIG_HAVE_RELIABLE_STACKTRACE) --- a/kernel/stacktrace.c +++ b/kernel/stacktrace.c @@ -30,12 +30,6 @@ void stack_trace_print(unsigned long *en } EXPORT_SYMBOL_GPL(stack_trace_print); -void print_stack_trace(struct stack_trace *trace, int spaces) -{ - stack_trace_print(trace->entries, trace->nr_entries, spaces); -} -EXPORT_SYMBOL_GPL(print_stack_trace); - /** * stack_trace_snprint - Print the entries in the stack trace into a buffer * @buf: Pointer to the print buffer @@ -70,14 +64,6 @@ int stack_trace_snprint(char *buf, size_ } EXPORT_SYMBOL_GPL(stack_trace_snprint); -int snprint_stack_trace(char *buf, size_t size, - struct stack_trace *trace, int spaces) -{ - return stack_trace_snprint(buf, size, trace->entries, - trace->nr_entries, spaces); -} -EXPORT_SYMBOL_GPL(snprint_stack_trace); - /* * Architectures that do not implement save_stack_trace_*() * get these weak aliases and once-per-bootup warnings From patchwork Thu Apr 18 08:41:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906825 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 74FE7922 for ; Thu, 18 Apr 2019 09:07:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E77128857 for ; Thu, 18 Apr 2019 09:07:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 525A028A9B; Thu, 18 Apr 2019 09:07:47 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D096328857 for ; Thu, 18 Apr 2019 09:07:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A3BEA6B028F; Thu, 18 Apr 2019 05:07:04 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9EC336B0291; Thu, 18 Apr 2019 05:07:04 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B20E6B0292; Thu, 18 Apr 2019 05:07:04 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by kanga.kvack.org (Postfix) with ESMTP id 3DA826B028F for ; Thu, 18 Apr 2019 05:07:04 -0400 (EDT) Received: by mail-wm1-f70.google.com with SMTP id y189so1537759wmd.4 for ; Thu, 18 Apr 2019 02:07:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=m0uLU3LRPujTJy61AU5Bi+GjyWpcNWqFl1iAjuUNnqw=; b=HmMq42V4ZvB4CfhCk6lOd8g82QaccULcsuLL75DX61Cc3rDvlazYhckSYiHQ58Sv63 8I/KRj8v5VIO6TUKZGtgCyipIvwF6jRsqfopqGt3fb3CxC9z8vefayk8yeXfNNwmOcNR Dc9DxKM7vra5+FEfJOzx2GOuDjNTjmIDJfPf7fMWQNV41d+W9OvVLgtl5Rf4s5RgulWS fs7eq/n7o2creYobiG2+NPbkyS8QKkgyNVVrFNW0XtOwTxPiiHa+0dHRGDW8NoxwQ2PR iDfTqGcqUlUqz/0Qk+Gmlb/HScl8Ad4EaeAMbGvVhqVHyNvXKZ1K67j1sIpdx5UiZWPG bnvg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAVl3A/Rsk6VXObymN9zU5Ej8/39tO0aGjTIrLQ+LzRcMB/DHe3h PkL1hnH5WNNJ9RLJnv6Zd2E9ODy4EOhXaEoLYZiUYz78vfCwEZ2pGOjcKj8vBLyUUWa/gM2YFmX ZbHsI47oKgQvB1aIEqX851zQYf6Mb7plpxhbPUfTmOFc4AFAv8Qy7EQzKTGIzR1NM/g== X-Received: by 2002:adf:b611:: with SMTP id f17mr1787356wre.162.1555578423785; Thu, 18 Apr 2019 02:07:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqyev1I11FbYoPsoeQMg/tRJGbEpt0OR3wIg1cqKZ3r3wmgjPreKHyXQ3RaUwVLaeT/AKV3U X-Received: by 2002:adf:b611:: with SMTP id f17mr1787253wre.162.1555578422298; Thu, 18 Apr 2019 02:07:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578422; cv=none; d=google.com; s=arc-20160816; b=RvM4wQy4fIvW4Y6/q46sYZJP65sH7soU+X9uD6AuABDHRF4XZvF87gdyDyuXCbhumQ gECf0ufU9oaxE14yePL54D5TOlRSoyjga8W1kYgZtNFhAet9OmfanteUq4BMo80hN1vG Z702FZdWrxl5/oG+AzSsgzJAsZkqSLyeOgb/9qFSqRoH/vzwpW14ABNOu5kkUhy0edcK 238EbvuSWskO7Ms8HO0yNi33ki3EfjDPNkM/yK4MXcHM1eUuAb8hOqfMjD3JPHAbwsHB fxlPio5HbcnRjtU/z8Lrm4iD/HAjSc6D6Wx7hdUnMMobQFnehdeuT8CZQaL4zSCaYwYU pMUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=m0uLU3LRPujTJy61AU5Bi+GjyWpcNWqFl1iAjuUNnqw=; b=meVB7xjSX3qvYJeC+W2n0eAINO0O3v72XrMbl3OgJydR8yGrlZtrg0Q50E8tJKxO8z fjXDbQcuh0bYDFHYhCNyhcg+iFWauVOOAyy+77FTcc+OSTBxgitvFG1xQPOyUXCC4qIL m6I+ossCUYvVsYtoOTa/swVgaThP0aMkbAkGDUVe7jjfb8UtPlD7KznGm1oCQgblim0U SylbZ17F6ZkP8uQYJIUutaBOso5MZ6mtQLPa4i2NthxAGify8Ey2jxfGXM4SJsHHgx2G BhhXhRbH+TL24EV44WxMp1RDlhcmQsXw/+Eo04GzKy614kKOorJBbRHMKDSbj0P5N/Pg ei4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id n7si1052893wmc.96.2019.04.18.02.07.02 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:07:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH30U-0001zE-8G; Thu, 18 Apr 2019 11:06:58 +0200 Message-Id: <20190418084255.561045203@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:46 +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 27/29] lib/stackdepot: Remove obsolete functions References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP No more users of the struct stack_trace based interfaces. Signed-off-by: Thomas Gleixner Acked-by: Alexander Potapenko --- include/linux/stackdepot.h | 4 ---- lib/stackdepot.c | 20 -------------------- 2 files changed, 24 deletions(-) --- a/include/linux/stackdepot.h +++ b/include/linux/stackdepot.h @@ -23,13 +23,9 @@ typedef u32 depot_stack_handle_t; -struct stack_trace; - -depot_stack_handle_t depot_save_stack(struct stack_trace *trace, gfp_t flags); depot_stack_handle_t stack_depot_save(unsigned long *entries, unsigned int nr_entries, gfp_t gfp_flags); -void depot_fetch_stack(depot_stack_handle_t handle, struct stack_trace *trace); unsigned int stack_depot_fetch(depot_stack_handle_t handle, unsigned long **entries); --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -212,14 +212,6 @@ unsigned int stack_depot_fetch(depot_sta } EXPORT_SYMBOL_GPL(stack_depot_fetch); -void depot_fetch_stack(depot_stack_handle_t handle, struct stack_trace *trace) -{ - unsigned int nent = stack_depot_fetch(handle, &trace->entries); - - trace->max_entries = trace->nr_entries = nent; -} -EXPORT_SYMBOL_GPL(depot_fetch_stack); - /** * stack_depot_save - Save a stack trace from an array * @@ -314,15 +306,3 @@ depot_stack_handle_t stack_depot_save(un return retval; } EXPORT_SYMBOL_GPL(stack_depot_save); - -/** - * depot_save_stack - save stack in a stack depot. - * @trace - the stacktrace to save. - * @alloc_flags - flags for allocating additional memory if required. - */ -depot_stack_handle_t depot_save_stack(struct stack_trace *trace, - gfp_t alloc_flags) -{ - return stack_depot_save(trace->entries, trace->nr_entries, alloc_flags); -} -EXPORT_SYMBOL_GPL(depot_save_stack); From patchwork Thu Apr 18 08:41:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906831 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 EA172161F for ; Thu, 18 Apr 2019 09:07:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0FF528857 for ; Thu, 18 Apr 2019 09:07:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3309289DA; Thu, 18 Apr 2019 09:07:50 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E943828857 for ; Thu, 18 Apr 2019 09:07:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D93AE6B0291; Thu, 18 Apr 2019 05:07:07 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D44BE6B0293; Thu, 18 Apr 2019 05:07:07 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C335F6B0294; Thu, 18 Apr 2019 05:07:07 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by kanga.kvack.org (Postfix) with ESMTP id 6AA156B0291 for ; Thu, 18 Apr 2019 05:07:07 -0400 (EDT) Received: by mail-wm1-f72.google.com with SMTP id a206so1459436wmh.2 for ; Thu, 18 Apr 2019 02:07:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=znZSi+CidEAD+gRTreMBXWZFV8FFXCHidn2vjNkjDi8=; b=oy6y2754HHOh8NhtrDq970hwMrhidGv4l9VJVa/l1U3lrNGaZKfXHXE+6Y1K/AU7MF X3IAYBvwmyqkeY1nU0h3scrwrgiuYolTl4h4+l8rjcjsLsikpivozM3QWB8ASIkR2ccj niBiQy/xZiOwXYnSkT0fh6DmQxb9aWCD4qTN+REG/ojIEAHRZV80ZEjQV0ONw4lzzYtN Kc79a0gY34wqmKjZ572dShsf1hoUh1s+HVaiJhXGqR20rVk9VJqsPb4o7L2sx/NPEV7i oDmIra4kVssPkW/bWwk8d96SEpjr1unWANudwxpEHy2VUz00NxgoMbu3DkZiFrnaGari txmA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAVv411TQGF8NU+sq+8SDspq3gFQwNOA4XtisoDpLaofQfXsrTfM vAu7xPxxLcjauAXTu/QGKGYU96Nso4PUalXicWVbPX6GKzliWJwukYnsJXdW/0K8QDns2dB7WPh 9x8HJuTfYnXYzIYJRu7R3f32sCY/PFXOAjceWhAnxCUVN5If8rM6kwT6v/qWIcfD4Ww== X-Received: by 2002:adf:ec0a:: with SMTP id x10mr60169258wrn.193.1555578426940; Thu, 18 Apr 2019 02:07:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqyjiyl907osI3Y/ACe48cly3whHm2x0WohV9yBZB3UKCL0KU/9+IQBh9Hhz7WNZwIxueoCg X-Received: by 2002:adf:ec0a:: with SMTP id x10mr60169148wrn.193.1555578425295; Thu, 18 Apr 2019 02:07:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578425; cv=none; d=google.com; s=arc-20160816; b=o18jGPpeRRXZQsKzXyEE9V2JQcX68njVHabWS+ydNDNwQs1y0XvkpY3TrlNeKiIswf tOJ/AP0j1QTTqedIMx08ddQmpypE5ZPsKOmqnL+/9TbB0JmWfsdFFB/RzIfuG4CiVrWq U67JBLCtwIGKKW2xCfeWkOXDH7aR0fhX5eSdaHyH4hdjsGCVe32qHHD6X3NtmmFTtMsn 9PyHM+NY9fJRT5UsOKx7eaoPSL6Qiq7pT6CWr0CizS6pU80Eg6t/EdhB93Ir0fgMk01W we0nyz1gx9MdEo4ia1Me1ivcBDii9Zg1f2y9kTLEzlDOhG5o14VLCTnnzx5M0aHcYrDu YEmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=znZSi+CidEAD+gRTreMBXWZFV8FFXCHidn2vjNkjDi8=; b=DhhLs2MVUFfXsBrgLutbMZp1ErpLZYShGAT00TNJccSka6F46BZageSaTt/yZykaRK s3ZXoxOUzxXerXxGRODZPUFdwIa2A8WchWl9wbRe85qjF0q5Sn5FPRRorKCrcId/H04Q g9WO2DOjN0Am2t2AYFLNIFFeTsLHh9QGJaRf1LcF+EfbNZWMrV4IWGSAZEoM6S4WQqgP vabKxN+CDsNDU1iI9zkdOnfArBWXn0OFRwNIIFEFguMiW/itsTMzCIWUvXDRCchU3Add i+ZFjpSLDV5P4EPQYmueEMnC0rED/yKIJc1tRaMVfE3adu6UR0dtLmEtx5HUHmZ2T+7/ kpBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id l2si1231546wru.10.2019.04.18.02.07.05 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:07:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH30X-00020X-3n; Thu, 18 Apr 2019 11:07:01 +0200 Message-Id: <20190418084255.652003111@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:47 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , linux-arch@vger.kernel.org, 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 Subject: [patch V2 28/29] stacktrace: Provide common infrastructure References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP All architectures which support stacktrace carry duplicated code and do the stack storage and filtering at the architecture side. Provide a consolidated interface with a callback function for consuming the stack entries provided by the architecture specific stack walker. This removes lots of duplicated code and allows to implement better filtering than 'skip number of entries' in the future without touching any architecture specific code. Signed-off-by: Thomas Gleixner Cc: linux-arch@vger.kernel.org --- include/linux/stacktrace.h | 38 +++++++++ kernel/stacktrace.c | 173 +++++++++++++++++++++++++++++++++++++++++++++ lib/Kconfig | 4 + 3 files changed, 215 insertions(+) --- a/include/linux/stacktrace.h +++ b/include/linux/stacktrace.h @@ -23,6 +23,43 @@ unsigned int stack_trace_save_regs(struc unsigned int stack_trace_save_user(unsigned long *store, unsigned int size); /* Internal interfaces. Do not use in generic code */ +#ifdef CONFIG_ARCH_STACKWALK + +/** + * stack_trace_consume_fn - Callback for arch_stack_walk() + * @cookie: Caller supplied pointer handed back by arch_stack_walk() + * @addr: The stack entry address to consume + * @reliable: True when the stack entry is reliable. Required by + * some printk based consumers. + * + * Returns: True, if the entry was consumed or skipped + * False, if there is no space left to store + */ +typedef bool (*stack_trace_consume_fn)(void *cookie, unsigned long addr, + bool reliable); +/** + * arch_stack_walk - Architecture specific function to walk the stack + + * @consume_entry: Callback which is invoked by the architecture code for + * each entry. + * @cookie: Caller supplied pointer which is handed back to + * @consume_entry + * @task: Pointer to a task struct, can be NULL + * @regs: Pointer to registers, can be NULL + * + * @task @regs: + * NULL NULL Stack trace from current + * task NULL Stack trace from task (can be current) + * NULL regs Stack trace starting on regs->stackpointer + */ +void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie, + struct task_struct *task, struct pt_regs *regs); +int arch_stack_walk_reliable(stack_trace_consume_fn consume_entry, void *cookie, + struct task_struct *task); +void arch_stack_walk_user(stack_trace_consume_fn consume_entry, void *cookie, + const struct pt_regs *regs); + +#else /* CONFIG_ARCH_STACKWALK */ struct stack_trace { unsigned int nr_entries, max_entries; unsigned long *entries; @@ -37,6 +74,7 @@ extern void save_stack_trace_tsk(struct extern int save_stack_trace_tsk_reliable(struct task_struct *tsk, struct stack_trace *trace); extern void save_stack_trace_user(struct stack_trace *trace); +#endif /* !CONFIG_ARCH_STACKWALK */ #endif /* CONFIG_STACKTRACE */ #if defined(CONFIG_STACKTRACE) && defined(CONFIG_HAVE_RELIABLE_STACKTRACE) --- a/kernel/stacktrace.c +++ b/kernel/stacktrace.c @@ -5,6 +5,8 @@ * * Copyright (C) 2006 Red Hat, Inc., Ingo Molnar */ +#include +#include #include #include #include @@ -64,6 +66,175 @@ int stack_trace_snprint(char *buf, size_ } EXPORT_SYMBOL_GPL(stack_trace_snprint); +#ifdef CONFIG_ARCH_STACKWALK + +struct stacktrace_cookie { + unsigned long *store; + unsigned int size; + unsigned int skip; + unsigned int len; +}; + +static bool stack_trace_consume_entry(void *cookie, unsigned long addr, + bool reliable) +{ + struct stacktrace_cookie *c = cookie; + + if (c->len >= c->size) + return false; + + if (c->skip > 0) { + c->skip--; + return true; + } + c->store[c->len++] = addr; + return c->len < c->size; +} + +static bool stack_trace_consume_entry_nosched(void *cookie, unsigned long addr, + bool reliable) +{ + if (in_sched_functions(addr)) + return true; + return stack_trace_consume_entry(cookie, addr, reliable); +} + +/** + * stack_trace_save - Save a stack trace into a storage array + * @store: Pointer to storage array + * @size: Size of the storage array + * @skipnr: Number of entries to skip at the start of the stack trace + * + * Returns number of entries stored. + */ +unsigned int stack_trace_save(unsigned long *store, unsigned int size, + unsigned int skipnr) +{ + stack_trace_consume_fn consume_entry = stack_trace_consume_entry; + struct stacktrace_cookie c = { + .store = store, + .size = size, + .skip = skipnr + 1, + }; + + arch_stack_walk(consume_entry, &c, current, NULL); + return c.len; +} +EXPORT_SYMBOL_GPL(stack_trace_save); + +/** + * stack_trace_save_tsk - Save a task stack trace into a storage array + * @task: The task to examine + * @store: Pointer to storage array + * @size: Size of the storage array + * @skipnr: Number of entries to skip at the start of the stack trace + * + * Returns number of entries stored. + */ +unsigned int stack_trace_save_tsk(struct task_struct *tsk, unsigned long *store, + unsigned int size, unsigned int skipnr) +{ + stack_trace_consume_fn consume_entry = stack_trace_consume_entry_nosched; + struct stacktrace_cookie c = { + .store = store, + .size = size, + .skip = skipnr + 1, + }; + + if (!try_get_task_stack(tsk)) + return 0; + + arch_stack_walk(consume_entry, &c, tsk, NULL); + put_task_stack(tsk); + return c.len; +} + +/** + * stack_trace_save_regs - Save a stack trace based on pt_regs into a storage array + * @regs: Pointer to pt_regs to examine + * @store: Pointer to storage array + * @size: Size of the storage array + * @skipnr: Number of entries to skip at the start of the stack trace + * + * Returns number of entries stored. + */ +unsigned int stack_trace_save_regs(struct pt_regs *regs, unsigned long *store, + unsigned int size, unsigned int skipnr) +{ + stack_trace_consume_fn consume_entry = stack_trace_consume_entry; + struct stacktrace_cookie c = { + .store = store, + .size = size, + .skip = skipnr, + }; + + arch_stack_walk(consume_entry, &c, current, regs); + return c.len; +} + +#ifdef CONFIG_HAVE_RELIABLE_STACKTRACE +/** + * stack_trace_save_tsk_reliable - Save task stack with verification + * @tsk: Pointer to the task to examine + * @store: Pointer to storage array + * @size: Size of the storage array + * + * Returns: An error if it detects any unreliable features of the + * stack. Otherwise it guarantees that the stack trace is + * reliable and returns the number of entries stored. + * + * If the task is not 'current', the caller *must* ensure the task is inactive. + */ +int stack_trace_save_tsk_reliable(struct task_struct *tsk, unsigned long *store, + unsigned int size) +{ + stack_trace_consume_fn consume_entry = stack_trace_consume_entry; + struct stacktrace_cookie c = { + .store = store, + .size = size, + }; + int ret; + + /* + * If the task doesn't have a stack (e.g., a zombie), the stack is + * "reliably" empty. + */ + if (!try_get_task_stack(tsk)) + return 0; + + ret = arch_stack_walk_reliable(consume_entry, &c, tsk); + put_task_stack(tsk); + return ret; +} +#endif + +#ifdef CONFIG_USER_STACKTRACE_SUPPORT +/** + * stack_trace_save_user - Save a user space stack trace into a storage array + * @store: Pointer to storage array + * @size: Size of the storage array + * + * Returns number of entries stored. + */ +unsigned int stack_trace_save_user(unsigned long *store, unsigned int size) +{ + stack_trace_consume_fn consume_entry = stack_trace_consume_entry; + struct stacktrace_cookie c = { + .store = store, + .size = size, + }; + + /* Trace user stack if not a kernel thread */ + if (!current->mm) + return 0; + + arch_stack_walk_user(consume_entry, &c, task_pt_regs(current)); + return c.len; +} +#endif + +#else /* CONFIG_ARCH_STACKWALK */ + /* * Architectures that do not implement save_stack_trace_*() * get these weak aliases and once-per-bootup warnings @@ -193,3 +364,5 @@ unsigned int stack_trace_save_user(unsig return trace.nr_entries; } #endif /* CONFIG_USER_STACKTRACE_SUPPORT */ + +#endif /* !CONFIG_ARCH_STACKWALK */ --- a/lib/Kconfig +++ b/lib/Kconfig @@ -597,6 +597,10 @@ config ARCH_HAS_UACCESS_FLUSHCACHE config ARCH_HAS_UACCESS_MCSAFE bool +# Temporary. Goes away when all archs are cleaned up +config ARCH_STACKWALK + bool + config STACKDEPOT bool select STACKTRACE From patchwork Thu Apr 18 08:41:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906835 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 166AA922 for ; Thu, 18 Apr 2019 09:07:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0C0428857 for ; Thu, 18 Apr 2019 09:07:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3413289DA; Thu, 18 Apr 2019 09:07:53 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4479028857 for ; Thu, 18 Apr 2019 09:07:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 72B376B0293; Thu, 18 Apr 2019 05:07:11 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6B84C6B0295; Thu, 18 Apr 2019 05:07:11 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 534186B0296; Thu, 18 Apr 2019 05:07:11 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by kanga.kvack.org (Postfix) with ESMTP id F26D06B0293 for ; Thu, 18 Apr 2019 05:07:10 -0400 (EDT) Received: by mail-wr1-f71.google.com with SMTP id u18so1515810wrp.19 for ; Thu, 18 Apr 2019 02:07:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=XYjtgkQ+gRYguATgChHdH9FUUx591xA2t7TyaZHD9QY=; b=INmH/8p1hCV9uB0mGwXDBXm1F6vmrGOCvJHYzpz1r2D9te07nWCZH1rl669WFmyb8V jm+8pSBPitb1RcOTEruCCSzSweEVoL1FDE48OL7ZlduwvJtGT/k1k1eJeX6tOV4raWdf 5UQM9m+s5kgC6bHtDWFG4+KpWm/K5woE7VqKycRImqb5sVAt3ElJP9ld/J7xvMXg2AKX hJo1rfZxWEBOabKCbKAVdBJn2BATOK9jSwN4B6l/2RsT3aKBcc2+02Ax5NZ5yeijR26g olk2v3ZYy5ZCcQ8JtDlKyOhot1oxGfan9eBYSJ2TRJNESP9Eg4KwlUboii0uRTEbvA3W VqOg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAXf768kvMutMSpi3Q6iz8T0XI1jxOflNREjVUIX/om/XbCCIABE aeM7e/fqSlzT7jHJdAhXOdCTYxjHxxRu96QUE5toRjDZtvRL0xN5mIfe9e5efIK5y1iPRTg2Z61 RQofp0sWlJvVjmSB7ae/aPBnMzvz/w++2svJAx3EpaBFe3UMyu+to8xQaE3d+XLa5vQ== X-Received: by 2002:a1c:5459:: with SMTP id p25mr2205414wmi.20.1555578430371; Thu, 18 Apr 2019 02:07:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqy2ZdrX+v9OFMYOxX/nrU6WkhAz7yysnxn/7LnG+GAlm1fFg8PSNuqZQeKAuTWq3APBcBVr X-Received: by 2002:a1c:5459:: with SMTP id p25mr2205319wmi.20.1555578428864; Thu, 18 Apr 2019 02:07:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578428; cv=none; d=google.com; s=arc-20160816; b=UK7jGayvBLLixT/opXrz29TFDg1DT9ec9TfsFHsG28tETp+2oNj8rP4A9/Gdm/605r SaZ45S5SD3C+jhxqUVw/TSnV2JZiwLPLI6A5HBnGFGXiwsOBBCm9CCahXNx/KudPXSW3 zxQKZVYHwJB2PRqVkGQGlTDgOoR4q482uEaaQO17yX/ypULdc8lwV84iQPitMi3A9IeG c7VhsRi6m2RCTnw/WgKVZ4FwVKPaZWfooqD+erJKE9PyDF+Q+NbFKKlUmj69Pq76y9WY YjpGTCsZgnJ8uyhnmuO1aPICkJ2f/NyXZBjOH5O6bGTZTNV/s/baDNeGlY8i+rEVhvmR KyoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=XYjtgkQ+gRYguATgChHdH9FUUx591xA2t7TyaZHD9QY=; b=yn7r20SIR0tdTUgIxnvNm609XnvGG3OzfXcjmf1dyZZ9gOFZMV6ePMU2V8WwwwnYQo iczRcqQcyin8HkmaUq49DfForu34ApY0iF354wVCOwJAxMfFJDSTOUcE+ylPw4A7HQ9G Po8KA4o9HCzTh5zCI9+AagGgYRsuVd63hETqE2wLGcwacUfWG6DdOURqXwiVS3EiYb/j oG1hfIrTk3XsWR3XyCr5tvrjE+ye5p+5vUZEQyd8XC5qxxielMJCAv/KXxtwz2ZGAs2q 8l5EqG9wFR0AHwzwKqQZGU0TsJFUj0VCt/aCuLzQ8flg3c2Qk1Z6IPqs8jkrGVg0Xb6N C3JA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id r17si1279230wrq.411.2019.04.18.02.07.08 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:07:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH30Z-00021L-Q0; Thu, 18 Apr 2019 11:07:04 +0200 Message-Id: <20190418084255.740246383@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:48 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , linux-arch@vger.kernel.org, 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 Subject: [patch V2 29/29] x86/stacktrace: Use common infrastructure References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Replace the stack_trace_save*() functions with the new arch_stack_walk() interfaces. Signed-off-by: Thomas Gleixner Cc: linux-arch@vger.kernel.org --- arch/x86/Kconfig | 1 arch/x86/kernel/stacktrace.c | 116 +++++++------------------------------------ 2 files changed, 20 insertions(+), 97 deletions(-) --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -74,6 +74,7 @@ config X86 select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_MIGHT_HAVE_PC_SERIO + select ARCH_STACKWALK select ARCH_SUPPORTS_ACPI select ARCH_SUPPORTS_ATOMIC_RMW select ARCH_SUPPORTS_NUMA_BALANCING if X86_64 --- a/arch/x86/kernel/stacktrace.c +++ b/arch/x86/kernel/stacktrace.c @@ -12,75 +12,31 @@ #include #include -static int save_stack_address(struct stack_trace *trace, unsigned long addr, - bool nosched) -{ - if (nosched && in_sched_functions(addr)) - return 0; - - if (trace->skip > 0) { - trace->skip--; - return 0; - } - - if (trace->nr_entries >= trace->max_entries) - return -1; - - trace->entries[trace->nr_entries++] = addr; - return 0; -} - -static void noinline __save_stack_trace(struct stack_trace *trace, - struct task_struct *task, struct pt_regs *regs, - bool nosched) +void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie, + struct task_struct *task, struct pt_regs *regs) { struct unwind_state state; unsigned long addr; - if (regs) - save_stack_address(trace, regs->ip, nosched); + if (regs && !consume_entry(cookie, regs->ip, false)) + return; for (unwind_start(&state, task, regs, NULL); !unwind_done(&state); unwind_next_frame(&state)) { addr = unwind_get_return_address(&state); - if (!addr || save_stack_address(trace, addr, nosched)) + if (!addr || !consume_entry(cookie, addr, false)) break; } } /* - * Save stack-backtrace addresses into a stack_trace buffer. + * This function returns an error if it detects any unreliable features of the + * stack. Otherwise it guarantees that the stack trace is reliable. + * + * If the task is not 'current', the caller *must* ensure the task is inactive. */ -void save_stack_trace(struct stack_trace *trace) -{ - trace->skip++; - __save_stack_trace(trace, current, NULL, false); -} -EXPORT_SYMBOL_GPL(save_stack_trace); - -void save_stack_trace_regs(struct pt_regs *regs, struct stack_trace *trace) -{ - __save_stack_trace(trace, current, regs, false); -} - -void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace) -{ - if (!try_get_task_stack(tsk)) - return; - - if (tsk == current) - trace->skip++; - __save_stack_trace(trace, tsk, NULL, true); - - put_task_stack(tsk); -} -EXPORT_SYMBOL_GPL(save_stack_trace_tsk); - -#ifdef CONFIG_HAVE_RELIABLE_STACKTRACE - -static int __always_inline -__save_stack_trace_reliable(struct stack_trace *trace, - struct task_struct *task) +int arch_stack_walk_reliable(stack_trace_consume_fn consume_entry, + void *cookie, struct task_struct *task) { struct unwind_state state; struct pt_regs *regs; @@ -117,7 +73,7 @@ static int __always_inline if (!addr) return -EINVAL; - if (save_stack_address(trace, addr, false)) + if (!consume_entry(cookie, addr, false)) return -EINVAL; } @@ -132,32 +88,6 @@ static int __always_inline return 0; } -/* - * This function returns an error if it detects any unreliable features of the - * stack. Otherwise it guarantees that the stack trace is reliable. - * - * If the task is not 'current', the caller *must* ensure the task is inactive. - */ -int save_stack_trace_tsk_reliable(struct task_struct *tsk, - struct stack_trace *trace) -{ - int ret; - - /* - * If the task doesn't have a stack (e.g., a zombie), the stack is - * "reliably" empty. - */ - if (!try_get_task_stack(tsk)) - return 0; - - ret = __save_stack_trace_reliable(trace, tsk); - - put_task_stack(tsk); - - return ret; -} -#endif /* CONFIG_HAVE_RELIABLE_STACKTRACE */ - /* Userspace stacktrace - based on kernel/trace/trace_sysprof.c */ struct stack_frame_user { @@ -182,15 +112,15 @@ copy_stack_frame(const void __user *fp, return ret; } -static inline void __save_stack_trace_user(struct stack_trace *trace) +void arch_stack_walk_user(stack_trace_consume_fn consume_entry, void *cookie, + const struct pt_regs *regs) { - const struct pt_regs *regs = task_pt_regs(current); const void __user *fp = (const void __user *)regs->bp; - if (trace->nr_entries < trace->max_entries) - trace->entries[trace->nr_entries++] = regs->ip; + if (!consume_entry(cookie, regs->ip, false)) + return; - while (trace->nr_entries < trace->max_entries) { + while (1) { struct stack_frame_user frame; frame.next_fp = NULL; @@ -200,8 +130,8 @@ static inline void __save_stack_trace_us if ((unsigned long)fp < regs->sp) break; if (frame.ret_addr) { - trace->entries[trace->nr_entries++] = - frame.ret_addr; + if (!consume_entry(cookie, frame.ret_addr, false)) + return; } if (fp == frame.next_fp) break; @@ -209,11 +139,3 @@ static inline void __save_stack_trace_us } } -void save_stack_trace_user(struct stack_trace *trace) -{ - /* - * Trace user stack if we are not a kernel thread - */ - if (current->mm) - __save_stack_trace_user(trace); -}