From patchwork Thu Apr 25 09:44:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916551 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 33B1B186D for ; Thu, 25 Apr 2019 09:59:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 249E928C4E for ; Thu, 25 Apr 2019 09:59:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 178EF28C50; Thu, 25 Apr 2019 09:59: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 6FF7128C55 for ; Thu, 25 Apr 2019 09:59:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BD2CF6B0008; Thu, 25 Apr 2019 05:59:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BA8BF6B000D; Thu, 25 Apr 2019 05:59: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 A46C16B0010; Thu, 25 Apr 2019 05:59:18 -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 586976B0008 for ; Thu, 25 Apr 2019 05:59:18 -0400 (EDT) Received: by mail-wr1-f71.google.com with SMTP id n6so335735wre.18 for ; Thu, 25 Apr 2019 02:59: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=gI0lw/Aq38cqAHkWGoFTdkB2SUTaV8zZIWgmwzBAOqU=; b=evN5dQe0vj9BbhLqI9zzjoPr7GBGgbdNf1OiyXVe3AV5Bt6Fi/NJNuVG+2WcNJoUsW Md2TDKyU/FWiYSy0qNq3DZi9FFkbK/BGjOKJK6i6L890plQfiYvB72O9UwyRlXvXgyL4 ZQumZ3vVkRwp33+JEFL4sIAeDaOZ66x0MFqyio/cyXSfPmBNbtuTlcLrz97m2kIJyS4H KcVmqv/AJKwqA4SogSfR5k0fmpHs5nFK5g9K57JFlwkzIOKH/qcBLZsTkfdC6ztCKSI9 IiriCBYICkPvSKDWujz+0jMdrb9rup+l4v6BFeOyvhAZguE7ROoKkL7kOmxS0y8Wws1/ 7SnA== 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: APjAAAX4rRili/JpF9OUc6JtpgLT94VMYGHJSWtsdX8vBiQE4dzma6NX soo3P5PJ+ScjZURM4aDa+uv+s/dT4INHYqSb5pzlz7qpyVquDTNIhcYQYMhSaFPq24Ro9NW1JIA v9Ank6hRGwMgPj4KbGY9amQPNI2s8hx2zjSYRj+gTaHxgCsrWnRdn3OEvDhbq5ElAgA== X-Received: by 2002:a05:6000:12c7:: with SMTP id l7mr23728396wrx.4.1556186357871; Thu, 25 Apr 2019 02:59:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqzaU7HsGeVkufgNySs42O1zz23hgUEWfTD5hfmx3lYpcLAbFheKvbZL/eBRPCOoiWuTulR6 X-Received: by 2002:a05:6000:12c7:: with SMTP id l7mr23728298wrx.4.1556186355976; Thu, 25 Apr 2019 02:59:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186355; cv=none; d=google.com; s=arc-20160816; b=PYsItyJcUrtjrNc9KP1dC9dQGBtY8C2DdwYHIzDY42445b+CCnxYicXv/mpD/QIwGB 5fzqqiSmd0YK8oEJphUQeFZPvYP5Pne4D3nWcVp+kUJ3ufbv8DBVKaFFD+wlH28yUgfU 5d7+0aCCNIPD+shNBVm9t0qbdbGPPlc/NfD+fWXq9RrI1aPwQUf8VviACOjKE1YA8bPH FBb5iqloZfmQS34PZAwKnIo8UWJYYC4jyDv+w3mt/mGIqBtTt3mJdXubjK6kNR98ST69 SzvMYHTOnu2ahTQGZG6cRCr1AF7zkohVz7Yy57Rq2x5ROhAlACaktj+C6Qd36AcrzcVu tIcw== 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=gI0lw/Aq38cqAHkWGoFTdkB2SUTaV8zZIWgmwzBAOqU=; b=n+J4w0ce/QJTBzqF0A6cwRFK/X9cTHASR3/BDSHsRkXsUOr4ZrNB1liFFP+J+TNsC3 MSzfoHoXOl7SMvbo0MgvlaBXW+IyAPFq0grEUWaWWUzY8Rn04SDFtAX1BDEjx2EU05Ss V7GqXN1mSTNl08laGs6DUiKjnVIrN9E1tVxwhqJUrcJxMppdNhCK8yiye2NB8BO7myJf N/UBI8lGbzBpsw639+ntE7S+OL1KTviCnKRkwoisRyTSBwNZyCWQKSpXHACI87eSNhtQ +e4sHVO8XL4TJtOEIxZb45SWR2lr/D5i/N0JS0vqnA48AgwRyQ1BInIWPtY+9b9ofgCg IJqA== 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 d18si11376954wre.185.2019.04.25.02.59.15 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59:15 -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 1hJb9k-0001qX-9I; Thu, 25 Apr 2019 11:59:04 +0200 Message-Id: <20190425094801.230654524@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:44:54 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 01/29] tracing: Cleanup stack trace code References: <20190425094453.875139013@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[] along with the ARRAY_SIZE - 1 initialization for struct stack_trace :: max_entries. Both are historical leftovers of no value. The stack tracer never exceeds the array and there is no extra storage requirement either. - 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 Reviewed-by: Steven Rostedt --- V3: Remove the -1 init and split the variable declaration as requested by Steven. V2: Add more cleanups and use print_max_stack() as requested by Steven. --- include/linux/ftrace.h | 18 ++++-------------- kernel/trace/trace_stack.c | 42 +++++++++++++----------------------------- 2 files changed, 17 insertions(+), 43 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,30 +18,26 @@ #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 - * 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, + .max_entries = STACK_TRACE_ENTRIES, .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 +57,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 +166,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 +399,21 @@ stack_trace_sysctl(struct ctl_table *tab void __user *buffer, size_t *lenp, loff_t *ppos) { + int was_enabled; int ret; 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 +429,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 25 09:44:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916561 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 4798313B5 for ; Thu, 25 Apr 2019 09:59:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37E9F28C4E for ; Thu, 25 Apr 2019 09:59:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2BCBF28C53; Thu, 25 Apr 2019 09:59: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 58AEC28C4E for ; Thu, 25 Apr 2019 09:59:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 481366B000E; Thu, 25 Apr 2019 05:59:23 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 435696B0266; Thu, 25 Apr 2019 05:59:23 -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 0FC876B000E; Thu, 25 Apr 2019 05:59:23 -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 A7BE16B0010 for ; Thu, 25 Apr 2019 05:59:22 -0400 (EDT) Received: by mail-wr1-f72.google.com with SMTP id t9so20481402wrs.16 for ; Thu, 25 Apr 2019 02:59:22 -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=qnhBsTZhFAarvtIna8uPcw7wy2NCTXLowgukOB6j3ZA=; b=GP27ChaGFh8DSu8BXOu212Us5kZlWwMzP9JbnQ777r/FAYqjOwZc9RVUjlZLr/UtF7 NSoG2xeS9oyQcu3Vx+UgvPNqQmS172U+p+QRhwaPWQW+o5xXo+llEypDXkBjRRLdk/ns 7m8Lds0bqvFQx1OL9zvnPXwQoyVLOK2HQstT/nWyCSDpEp+9M6wfX5bOnahMrizACMYk TJNwzeREbUxFc2wslQR0JVy7d2J1zp9EvG4kEHLWZZQ2l0HYgqJGj6UXQpPmoDMZu0jP Z0COc9aMmfyELP25ns6uBKc4GD7XYNvGQxqG4pYFX8XPde+JFW9U1gJMgyL6kFnAxX/7 LJjw== 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: APjAAAWLeowqYI8iiGp/UahSHXS3qCePcvL4w66wZovfX4Mq9YYjmkLK 1MTUZi6Lm5ZG1egwsDDBVausNw0SuIqMkmaS/8lBnHdOY1uukrAfmKT1NwDiDWCLql5uWKsgfiW rHpQVwZC46ptPAimEMCoKNC2fYLlVu/lYs2JqcRoFFf/PyQ3s/CPXRB+ChredejHtNw== X-Received: by 2002:adf:eb44:: with SMTP id u4mr12112010wrn.83.1556186362188; Thu, 25 Apr 2019 02:59:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqyxCbpFNPcd2pGB9twG6IwG6oQSx3RfHb0lLox3UO3JCjIY/j0zboBtX6uxJ1bbYFy7hUGY X-Received: by 2002:adf:eb44:: with SMTP id u4mr12111948wrn.83.1556186360993; Thu, 25 Apr 2019 02:59:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186360; cv=none; d=google.com; s=arc-20160816; b=vx+JISlYZo5kZFePe+UdatRTTe/Zc34TcQNTSsQeBR/PBhiXj7FNDRin9Gkqk/AOVe pQSmxxRyeEnFnlCM3+Gad7hI3qGOeGpCNbh2qYJXTB5wAHDO3VfhaW2oyDZ8FieL6kT6 YZSxy50sUPJEf3Y5H4uqMXAQFVpZiE9v0CuA8rM722gqxsniezopMxR6D9hjzjd/K9wg g1CRsYmctgCwdHyBuq+hRIGzuCOXEL6u3Fxde6fDmZPTkg1dlxez9YYwqwxk4a+BzdHy 9vv4dLlYocaNsBmmiD3myirksOY6dBgBBGGPBcteWyeObG3Z/4VofPHTxE4S0jaKwfXv QM6A== 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=qnhBsTZhFAarvtIna8uPcw7wy2NCTXLowgukOB6j3ZA=; b=SNwCoyxDXbDQ8OXSe7Fg2feUX0CHkZfCGCwWPF2uIqAZtzAZ7k/u4HSMZrpwFYEbIt 3MEbYT6vhRZNO/+jKWlZjbNae7/yNto6dyMvS+SBjriZI+Cfgp57jVl7h/h6ajY4LrbF z7tGHP5WBjIi/MxR6aK0wLHnWjYRUiIGRUgDp5dHqyCx3IWlKXNUMKG/Kgmf2abIkQjm oKRn4/Jrw9EEJ++AzAWl9+fjIve/bDDfHigpH5sJrj5FOKT4GKMQMscNwpe/0hKGvZTx gUwRFPyqQPS9ldoHHH/qFwFSZC/7nXvOwERurs42MJ+K4V07EJS4vTIQIY8O6k1NOkvy yRmQ== 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 q124si751090wme.156.2019.04.25.02.59.20 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59: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 1hJb9l-0001qa-F3; Thu, 25 Apr 2019 11:59:05 +0200 Message-Id: <20190425094801.324810708@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:44:55 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 02/29] stacktrace: Provide helpers for common stack trace operations References: <20190425094453.875139013@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 --- V3: Fix kernel doc. --- include/linux/stacktrace.h | 27 +++++++ kernel/stacktrace.c | 170 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 182 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,54 @@ #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 + * + * Return: Number of bytes printed. + */ +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 && size; 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 +70,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 +104,116 @@ 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 + * + * Return: Number of trace entries stored + */ +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 + * + * Return: Number of trace entries stored + */ +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 + * + * Return: Number of trace entries stored + */ +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 + * + * Return: 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 + * + * Return: Number of trace entries stored + */ +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 25 09:44:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916567 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 6456D13B5 for ; Thu, 25 Apr 2019 09:59:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5380528C4E for ; Thu, 25 Apr 2019 09:59:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4631C28C53; Thu, 25 Apr 2019 09:59:49 +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 A40C128C4E for ; Thu, 25 Apr 2019 09:59:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7DA116B0010; Thu, 25 Apr 2019 05:59:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7B4F36B0269; Thu, 25 Apr 2019 05:59:24 -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 628ED6B026B; Thu, 25 Apr 2019 05:59:24 -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 16B446B0010 for ; Thu, 25 Apr 2019 05:59:24 -0400 (EDT) Received: by mail-wr1-f72.google.com with SMTP id v5so8962417wrn.6 for ; Thu, 25 Apr 2019 02:59:24 -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=SWVpljAJlRyQ2pHyFaFTM+iox7zGbwrS4ZeDsD0I3io=; b=ZL9obtIn6YUeObRdRwhGBnGy2NncQGA5DT0aWFkGs3uZ9TTIffpWypB1ANmqjXhrXf rQ1ol6s+ZkJQ2naguiQe2wOsNrUeqEpHcufP8um+E5+o4rm7E1Xr8tnCRRNaqga5jGpn l6BfuS7TkuqcmiHBGUzfPsDw/ulRiMVB4mVR18hCe+GHHWhmuqXg+qloVELBTThXQRbG DctN62q4XJq0K1+/hjMwda/6h9vyE9DjifYKBBrA7+aUYELmqwroXldDj6difZg99kh5 +odxGptrUALyvFs3oo+HIq2bg5sb173Sfdu3XU0VA5vPkwpe6hGGY+YK/0jThpuhftYP zW3Q== 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: APjAAAVFKyZfpHi1x5+9LSnYqi5rHhZEzL8JSenydZKtN2vUJyIgTLJX MmIR1cAGUpKB0Stu2jjEYXWZW1yZeG/TvVPRp2NnJr6KDGipAX9x40GmRIHYj0T7OQQIIncjorB qVwANoSxIYjl9/ei5r+Uu89MXt2LZX4xHZFoh0xRjXj9wSNhfLTGHK+yLATa2qeriXg== X-Received: by 2002:adf:fc49:: with SMTP id e9mr3375271wrs.269.1556186363592; Thu, 25 Apr 2019 02:59:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEMupvkbuHcmSzDr8dpYNQp787ulhyEbeowOEDQ6690XkNIRfbN2JRf4xggMXft4WCRjKd X-Received: by 2002:adf:fc49:: with SMTP id e9mr3375197wrs.269.1556186362100; Thu, 25 Apr 2019 02:59:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186362; cv=none; d=google.com; s=arc-20160816; b=dqfMrLfdM22gYXqQccKhsgjuon1PesisGt8OGNYR8j+LDfnh1XMxsrdg9nQ3/SYr+o SrX9BRahKygl6oVNnFhsUOHZI/6/0PKL5hicKja/7B3uBPXCJaf43UgJzyO5atTWrdze 1qgp9AfIPAsOLoqy6sylLERRGKzAjrowMGkQ0iLzFT/H3u+kkFj2ASEW1V2gMDx7fLiW kJheN3zwkyA7qedfYBbDnX49cXaZfaNgqmjhsExeK2tN39EQ1g45ctCiSs/SMfS0/U+A r+V87tg9Wic1O1KztqzjO7l86JDxY/Qhe9omYOUqRjBenW7p2VYaZww9LNs/nIH5owsG skvg== 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=SWVpljAJlRyQ2pHyFaFTM+iox7zGbwrS4ZeDsD0I3io=; b=UZxyLEzhUJs7dhoe82gVIC1wtRQlBkajUmv8sd2kpthcB31uCY8uDS0nvQqciixdCB viYADMwbu3WbqHiT4eMg9jP84eaKvgrDmRsFZYCTPLYLVGYTMA3m2BihxP7DqF3FpUGs tYmfxIugfB6zhVfy0v4GYx0gDI4rqXPt8z1G8DODyJKylIehuvBbVdkKTQUlvLbot+w2 xSBU5hgJ6Qmi9OUd3+GQSTOrldQgDo1PFIR2XasOpeJe49KIrTf3SVJprwnz6VMzrrQk 1i8S86PsmJxYOQZQZ7DBomNrCLpg0GT5/CHV+9hFT0tPO5DWKcYR0NWTzJxwJ3+Fl93r Q3Qw== 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 r18si16143317wrv.176.2019.04.25.02.59.21 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59:22 -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 1hJb9m-0001qd-PK; Thu, 25 Apr 2019 11:59:06 +0200 Message-Id: <20190425094801.414574828@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:44:56 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Alexander Potapenko , Steven Rostedt , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 03/29] lib/stackdepot: Provide functions which operate on plain storage arrays References: <20190425094453.875139013@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 --- V3: Fix kernel-doc --- include/linux/stackdepot.h | 4 ++ lib/stackdepot.c | 70 ++++++++++++++++++++++++++++++++------------- 2 files changed, 55 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,60 @@ 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 + * + * @handle: Stack depot handle which was returned from + * stack_depot_save(). + * @entries: Pointer to store the entries address + * + * Return: The number of trace entries for this depot. + */ +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 + * + * @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. + * Return: 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 +255,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 +284,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 +317,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 25 09:44:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916545 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 BC722161F for ; Thu, 25 Apr 2019 09:59:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADD1A28C4E for ; Thu, 25 Apr 2019 09:59:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A1BB228C53; Thu, 25 Apr 2019 09:59: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 4324828C4E for ; Thu, 25 Apr 2019 09:59:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 265996B0007; Thu, 25 Apr 2019 05:59:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1979C6B0008; Thu, 25 Apr 2019 05:59: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 018586B000C; Thu, 25 Apr 2019 05:59:17 -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 9611A6B0007 for ; Thu, 25 Apr 2019 05:59:17 -0400 (EDT) Received: by mail-wm1-f71.google.com with SMTP id s18so233242wmj.1 for ; Thu, 25 Apr 2019 02:59: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=p1GV5L4kXkwF513RFzbpeqJMhNCAHm0+rLW65qR5s04=; b=J1PGYdk14PXO244nnMBHMDoFDH3AmpD9+LKxFmcIVxBLHUrEzi5RxNe0cVQROzRo3j RuY/wFR+azObBeojbaDfHpGOhFKchy0wwtN7i/K5NtNE18BdyFGMtxQKDqcoZuq9X9DK W+A5hpg2V9jTfF1i9qo6WJM1m3GxVcPfvMcaF2vQyUV0mq83LhXNW1QQFEfGgSmQpJ80 eX+tHNYxZP+8yTdBJVdL9pgLZOvYrCg3EcMZXXlA9NSAdPysSRoi3bdznrsqctb9aXnE D8GzmXQA42yJs9itrU57z3/LXyoUaQ8Gs0d/0zN4fXzujeid/Lld2jy/rx+0KVx+8rKo uoqA== 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: APjAAAVISk0LSQdWCL/Pf6PRGs0AWS8PB1+dLWyPirAss4Mpa/8F1/bp Ne65QJkp2724vDAiaoe/2qFx39jN4QO31IwPMpmSyEzbeg3nldvDMytqqI6D2enIGzvb0TeKi2e sXmVhpDTWc4ncopY75affYDvcbJTZ4RQhr1CQvboBurD7rNct5JXV49xpBuUYaz+/Ug== X-Received: by 2002:a1c:a184:: with SMTP id k126mr2794429wme.71.1556186357085; Thu, 25 Apr 2019 02:59:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqyd15NonHsPxtknua9o3BcuwW3ZyG02YPtW03aHY8Xa60wxPt/6Jxzp+Tw2tUXaQ1pKb5TC X-Received: by 2002:a1c:a184:: with SMTP id k126mr2794365wme.71.1556186355981; Thu, 25 Apr 2019 02:59:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186355; cv=none; d=google.com; s=arc-20160816; b=kN1Bw49tCpxjEI7q1Fx4wVYFjXofY4QWX0m0PlUfBlpm70MH4+zUeVPll2K6V0jA8F 1SJEI4UKVN1J82lJX/NurlItBL90q/fJAR38bJgQb13ib05HbHnrv5uSz2glefTBzlLJ RTJBDqVlJoQagezErcoIZ0mT2r9AFm4hPdBAJS13ik6k5I4DRbAg/NboYwABZLA0Bg3Z 9fDLaifZKSLwCu2R4DX3iMKxOmb/qOF0mWPjsYxeNHysuaj8Qg8XIVvCtU1wSlB1IASY 6uwrkqNbEmL1A7LMRllrIzsz+V5MhsNR5+G5SjxkJL8WRIADN7LVNWWV5namaBCE03t6 rrBw== 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=COLKkSUGr2jGP1A03NLHrDGwn+X3uaB0BMCs4ccwNYhyRKPwAliSYemKmuaLiWAyJa JNhBNncASQpxEVnGLIpLfxIoiG8XWCfiZqfkseEyI1QdD365VMNiXd87D40NWPcKIKDW i2dR1AvHj1robPn65QxdlhnL1aCH0+SmpExjGVREiUevOqw4SZ03uwBPD7ZMTXvqbIL5 YLxkM7gRHJ3mEIRKQxkr0n1bjQerkWkWvPYSVyiACffzG9B0aC4SbMjbhHWxy4n66Sdc eC7C4WolgkN6aNVtY10TLIPe6xg++E3gLz/WFC9Q/TFEW8hECdggVjcZDqw7VgUIdYZM TCIA== 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 y12si13912334wrh.351.2019.04.25.02.59.15 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59:15 -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 1hJb9o-0001qh-0J; Thu, 25 Apr 2019 11:59:08 +0200 Message-Id: <20190425094801.501919093@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:44:57 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 04/29] backtrace-test: Simplify stack trace handling References: <20190425094453.875139013@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 25 09:44:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916557 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 EDFF1161F for ; Thu, 25 Apr 2019 09:59:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDEB228C4E for ; Thu, 25 Apr 2019 09:59:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1CA228C53; Thu, 25 Apr 2019 09:59: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 4C0C528C4E for ; Thu, 25 Apr 2019 09:59:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 101F46B026A; Thu, 25 Apr 2019 05:59:23 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F2D446B0266; Thu, 25 Apr 2019 05:59: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 D809C6B0269; Thu, 25 Apr 2019 05:59:22 -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 8A4736B000E for ; Thu, 25 Apr 2019 05:59:22 -0400 (EDT) Received: by mail-wr1-f72.google.com with SMTP id n6so335855wre.18 for ; Thu, 25 Apr 2019 02:59:22 -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=pI0v2UBWyshIZ04hdeoBI5JpEraIM9rskIN/bsxWXj12MgnPi+DXZTcNIS/xaHwOJf XXCd5oOXTQ9RTxm/JsSESsIKpWN+eW2FPM/Rfow1c39KVhVJvUUFV7ErbK2gY7fil20+ +aWhgncijghjwM/FQnGbOyo2z56n2+S0RTMxL89nC+SQSjF/rRFaGEYANmloa2EGx1Pb UWkoYTdj4tGFb5st3YrcCZc7ZzmOV9ZtI7gwuvDABC0D3YckQJjqLbigZyNv9CAB/k6r 9iFKFsjh9hg/7bruSy60cAmSdM5b+fQ2K2k9BVT3Fd4mI2+a/1lNysMUJNH0DJBUXztS zOMg== 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: APjAAAVf3/80VgUS0cPvZQPfehND+LdJ4xRH6q+WGe+PgJ/SOmu1uxsz IUkUIclGbPv0Iov5VgN9Tqo+HsUO0FnJnNThyVlbL0Jt6tGWILwxziLNmN/ks8NGR20hav+vFUz 7eX0aRhOjh0ZsE5FPhWNMJvhcNe9OBOGVYui9NbTwbnl1NatQn9d+SojAnJ+0pWyA0A== X-Received: by 2002:adf:fb09:: with SMTP id c9mr2578323wrr.137.1556186362115; Thu, 25 Apr 2019 02:59:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqznGRdygfVj0B9BtdW3lfFl/HmF3Ll0t12rd72w47tw/QqU+JU8rwBgPnOBlr64sXOoVXbv X-Received: by 2002:adf:fb09:: with SMTP id c9mr2578266wrr.137.1556186360976; Thu, 25 Apr 2019 02:59:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186360; cv=none; d=google.com; s=arc-20160816; b=Ehc3xhVHa/A6RozmQsiMDeH53ffdzp+kfhgskjFhsC0g1zohldF9jWFyArFiDDx95P zt8cxtNCM69exr2WSMBskXjJKgMhqwHnxU1Ubj0uU4swnzJbJZa2X73kiD6FSsW4SCrg mblCkSse9us4WF83lrj1foBGpUC6Tz1t0MgwiSVfY4fisFMH450wkG5Pz80Eb7cGWnVd MoMrK7WeRaU4+fZ2lLPkm/0PWA1G5qb0kb91/Z1Nm3FU1rUXjE+89xzPrEjRdFFWy+S5 hsLPcj3Xpd166XpY8pslT1/MYs+IwEn+9wt9Qe7fQM8vmgHszADmoTsrWc95danr7gj6 I41Q== 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=uIMI9+yLZNrVjHMDFNPTYS+rcCFAbkpLhLqR3pMcldSBfFh64/p0W9dGonrClwBKvV EjpE5KoE5GuPit/RT3f9XwFLNR9kBqYUr6phPxf7vgK1gUJzVrVMm1lS1HI1On8W+l6U ripjkHJ0fGC+StnneeeY7KZDJdH8lh16+nacXIIIHRiUoouezTkO7xo2KP00CVKg0m2M cyDMUrYA7urcXDEsSqnWuYWMxQzgqox51Qec7A4PDDraGOLxqKKh6CZfa6rWCnNUQPkP dm06t9Xu/NVHXPHSgTl6tcNox8WPBMref/iZm1LR/rE7XQIE0v2mtF6TRpALbuh7i9ZT o7zg== 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 q17si2316172wrr.64.2019.04.25.02.59.20 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59: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 1hJb9p-0001ql-4x; Thu, 25 Apr 2019 11:59:09 +0200 Message-Id: <20190425094801.589304463@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:44:58 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Alexey Dobriyan , Andrew Morton , Steven Rostedt , Alexander Potapenko , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 05/29] proc: Simplify task stack retrieval References: <20190425094453.875139013@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 25 09:44:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916563 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 16860161F for ; Thu, 25 Apr 2019 09:59:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07BFA28C4E for ; Thu, 25 Apr 2019 09:59:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE67328C53; Thu, 25 Apr 2019 09:59:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-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 8D08A28C4E for ; Thu, 25 Apr 2019 09:59:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1E5066B0266; Thu, 25 Apr 2019 05:59:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1BE256B026B; Thu, 25 Apr 2019 05:59:24 -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 EE9896B0269; Thu, 25 Apr 2019 05:59:23 -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 9860E6B0010 for ; Thu, 25 Apr 2019 05:59:23 -0400 (EDT) Received: by mail-wr1-f72.google.com with SMTP id r7so10963537wrc.14 for ; Thu, 25 Apr 2019 02:59:23 -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=R1uaiaJJjZdtbFwLDGfkjKtalV5J6ECJ5shb7PTa+c569UwrCMtJUhwIp4EN0ESBS+ ihEaUsuvrlnFFpoUeX+u+DtGMWAlNpeY8t/igPd4MYP0xelrqFt+UWVBouZg7I5y0cpZ lKeZGHTuBfgb6pzrICSJH6KBZcPY/Dw/2Imx/sMXRl2h4rC49/zzX6Thkt0mqjEXPHt9 er11ocTSgbGnnS9hLAXCR9C6BMO2ADhw4HTVjFIJLKyUujRwj5nO1qPnUCQspKf17oi0 K+NzOLMDRL8UNWejj9fkNPdmB2bITriRrfTHrQpWOhUoCCkyztgAYgqNcVHbCcG3hsRb hvIw== 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: APjAAAWSl6IHwr2izuDMaEnAy4kDigxH94GFd8omoiBex+mGegAbcyGf nNdZaHlI9LGwvYfvt/mn0x6508ErBVA9IcV8rXOYUT/piU6Q75FvUAOnewS489M1paxVXcU8rzn 0c+dbD14rHFPJUuY9Y56V2X/7l3oAKe0bEH/EDCttsWU01eZI6mRleqK1DLNz2C8z+Q== X-Received: by 2002:adf:e684:: with SMTP id r4mr11172645wrm.169.1556186363073; Thu, 25 Apr 2019 02:59:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqzyFzmcjgSFFs7ziXWDgu7DRnYCO+nyHBqWVwgoEiWsCHiUhJxtilhtgw2NNQr+BhYqRpKu X-Received: by 2002:adf:e684:: with SMTP id r4mr11172574wrm.169.1556186361664; Thu, 25 Apr 2019 02:59:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186361; cv=none; d=google.com; s=arc-20160816; b=pRR823lUtQGKKCjJ6sp4vthrs1GIoDqWZMwNx3F6CIRpcAQdrAKd+2Crt2N2awLQ7E bdrANlcmTjefiDTKALRX6auNAoHpHWS8QauDuWo9WaYkPyVobFzNAGR++SnNydXeSvfo 2VTXZ3mDv6YWVyOT9j9bDq2XzogdbBkwXvZkj5x4FFWWJvyRkUBJ3Xi86pOpHnT2Ml2i B/XoclufjnJz1ZS2HofJoj34GbPrxcLELIw3UtmArPCxYAzXjYE8IEBSJN5KR4uJpcfH hk4PiD3mVHPOTLc0MYmG91vAqH7/rgG+Mr9812Lfa57gssj1ehDkI/cphfFTbUSZqm2P RCHg== 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=w4IMxoGV1ihoWEwTTSARuFIr8+iObJnHBKzm7srn9JMDU2PvmWCyvIY+4CMOvcj/pl g1ancYRniU5tUV9aSiqqIk7ginKLkgPXiv8yUZrLuBzrgrqf6GxViwe0WiBs0aMhveDu 7litg9dWfzDpiJmQxIagGOSgBSYPsvt5rlvf3MaJHFPmvYmt7xf8FTNZSR00ApxPrpTi aiBVHHsse3NEJI71yM0FCy+S1Spugu5FW3uB3ZAjJ0d+FGqK5BinAVxn4imd3w04MvE3 Uj+fPOegRcjR/Neonm27m2cgv/c/pPJ3HGmChQTEfQdpQnFO4XpXfsrnVgkYJJTe+ikb Qkiw== 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 88si15749302wra.283.2019.04.25.02.59.21 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59:21 -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 1hJb9q-0001r1-8n; Thu, 25 Apr 2019 11:59:10 +0200 Message-Id: <20190425094801.683039030@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:44:59 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 06/29] latency_top: Simplify stack trace handling References: <20190425094453.875139013@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 25 09:45:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916543 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 29F4313B5 for ; Thu, 25 Apr 2019 09:59:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1920028C4E for ; Thu, 25 Apr 2019 09:59:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0BDB728C53; Thu, 25 Apr 2019 09:59: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 8C19B28C4E for ; Thu, 25 Apr 2019 09:59:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3BB4A6B0006; Thu, 25 Apr 2019 05:59:17 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3699A6B0007; Thu, 25 Apr 2019 05:59:17 -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 27EB16B0008; Thu, 25 Apr 2019 05:59:17 -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 CF79A6B0006 for ; Thu, 25 Apr 2019 05:59:16 -0400 (EDT) Received: by mail-wr1-f70.google.com with SMTP id b3so3791672wro.7 for ; Thu, 25 Apr 2019 02:59:16 -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=Pgnot/JY/GhCv5DRtMhbab03iCecPXTf4pubBhqngy0=; b=TzyLiujkpsIZUrR/IM6a9TFKSK1+8K8qIowvrEcjgnbvbOQoRLvbcwSlnn+MlGpAEj 0IECrq+ueRE/Zq+0TpTPqUHSTspbq4/RnA3J7zNbFZn2Qi3MoCHpM+h6E5LL9RUbIkb8 WB50F1bZPRIWb1vMbTQXiw5mLVh6FBhKgw8MCcftlCmEHF25MLPhGvq+l3PUGAToM785 fhl9GAimJIYocunHmioUwR141MvilWPlo5bCzvinBwVXrfl3mRA1DWRbGi6/+M2c5IAX hVDpf1aJRuPLzeEhm8Ye87ppI8f4eX2+QQ+ef0qjnrgwxlAgrTjPnWC6aeUUv29+C7u5 0ArQ== 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: APjAAAVqhyEThyFn9XBsqJqZ7/rhuQhvPB9j1w8xio6F/+qD1KTA5P+J ByfeNyPAaW87HsULktNdFXUI8Ayyse1N1/QuuSfTFFqFzBjBOi5AxiCCJU8IWQUqwQFBfqinlng HOfHfiehhcnDQnsZwRPF3DnOamL1aZdZyhcro9gE23FegsfWaudIQyzbzPxYYqq5TPw== X-Received: by 2002:a5d:530e:: with SMTP id e14mr25084599wrv.18.1556186356283; Thu, 25 Apr 2019 02:59:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvGy3urh+0EJy6CdNjvWRyKS/KLimgkISyvIaHdMqQyEMsPAX7mREP+ER3nd8JPsbgoRE/ X-Received: by 2002:a5d:530e:: with SMTP id e14mr25084528wrv.18.1556186355011; Thu, 25 Apr 2019 02:59:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186355; cv=none; d=google.com; s=arc-20160816; b=u7ljINjzYPUmbQAzMROV/YAWJDvnyD5CbBlEeYYfxy3hJelYSZRsa3I2mfZWQA7cTo a7BU7qa2vjAPJGHh1xZfmYKafvSaxw0rX0m6nwxaYa4klH7O/lew3TypPu99TgV3B7cM +yckfhMf3mIFIM9ztN5576VtPgB5CIV6lfUj5nTxjmcCkLRnM9zZRPGUHEhIEV0cYf/E PTQYlgObXem1HElYUTf7SR4Bib5/Aq5wpEwqSB8Ue/T4uwcxOe73QMXA0g/Hs7SlXFVq CvD9cLFYRYbSQDCFP0zI8/9JwU5XZ1Rjq2XxA6/b+j6iwfHZLiNJ1+0v1Ie/0v40PodP Nbag== 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=Pgnot/JY/GhCv5DRtMhbab03iCecPXTf4pubBhqngy0=; b=TEiTEaQkY5z2WGsrvAy7bsRfNugfiP0JXl+jqVeGFSjFeRKcDTZ+/vvWdT+xlh2KXW m/akGbaqz/Hdv8CbWekvn5Gq4Ol/rPKfoiPtHgdrYq3aZwiKidDI62iazdSQE3Y5OwSM bmn6SnxhfGkA0PQYgY2PyGfvRvgOlref91r2XrCMhFdOaAHMdSc+X6YvWFehKbxlv0Gh yFBPKOQxgdoQ+QDMBLOE11tKePd9AbEbV3sK/tNctjxAdbeHjebGxhrwZR/98yhMatL6 xvDtihcNP7Gs8KxbiQEqy7h/L2bAGgBy49JpZRWUJKA7zl6rcE2YX+wZ/H7CiZ3Q16hD TnpQ== 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 b142si5333007wmd.37.2019.04.25.02.59.14 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59: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 1hJb9r-0001rD-Kz; Thu, 25 Apr 2019 11:59:11 +0200 Message-Id: <20190425094801.771410441@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:45:00 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Christoph Lameter , Andrew Morton , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 07/29] mm/slub: Simplify stack trace retrieval References: <20190425094453.875139013@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 Acked-by: Christoph Lameter Cc: Andrew Morton Cc: Pekka Enberg Cc: linux-mm@kvack.org Cc: David Rientjes --- 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 25 09:45:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916541 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 F3F3E13B5 for ; Thu, 25 Apr 2019 09:59:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D823528C4E for ; Thu, 25 Apr 2019 09:59:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C80A928C53; Thu, 25 Apr 2019 09:59: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 2B3FF28C4E for ; Thu, 25 Apr 2019 09:59:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 010DD6B0005; Thu, 25 Apr 2019 05:59:17 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F03216B0007; Thu, 25 Apr 2019 05:59: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 E19F86B0008; Thu, 25 Apr 2019 05:59:16 -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 94B9F6B0005 for ; Thu, 25 Apr 2019 05:59:16 -0400 (EDT) Received: by mail-wm1-f70.google.com with SMTP id b12so5714688wmj.0 for ; Thu, 25 Apr 2019 02:59:16 -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=YabZpxn7mRZSzbNRVFW/2KaxGhb8DuUKqYC4gVtFav0=; b=YuTecPbdIcBN51NiNMLHuZOiI9pncdrgBOdg1TLlQhdOiSFVl49bvFDcNl7DbzWXOZ PwrzLUZ7gG/PpMDBNR+Qt7HM6pU8AGZTRcdoUGQVoWM+lVFnawC6tMPYTHFnTZXiwBgJ rugsShF6lQ40DTX3he013c8TGpB6wihaabyGMd+w8f45VGDWkELtp01g7t/t0q3+VL3i z0ylDRqzh4IblZM1OuYBxmAy1Tnc3yH59y5QOmnRoRnxCCU/11BhvhKl46fm9GYuV03S qLZd+f39s10bf9SDyh4KP/cn0w3OLT22jM8LamzETkHb4DfPC1jwoV5dxDK6Bz2yu6dN bFIA== 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: APjAAAUaWdrwDnEF5fCValwWsiuJ+PJxSAiolHKR+XI7fFK8ULYPJ6AU vB1Y7K5xIGARsT2UheZHOEDpj+zPJg9ge2C6W6qGtcKOpt2ov9SgC7fImwIIa/5KGgyNOlb+Ecw FYYgGNYzqhX7yM11diwvd2bVljJTOD9MAEUeQosWqmzzbtXeGIkjzJI37mWJLgfUpUg== X-Received: by 2002:a1c:d1c5:: with SMTP id i188mr2852258wmg.8.1556186356103; Thu, 25 Apr 2019 02:59:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQqcuDPACjbMbb4QxWUxAl4UZfkGtffPJ5Tx5g0fOBJeDTuSgES7EhL8Hd0hB8sxnGuSc0 X-Received: by 2002:a1c:d1c5:: with SMTP id i188mr2852182wmg.8.1556186354473; Thu, 25 Apr 2019 02:59:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186354; cv=none; d=google.com; s=arc-20160816; b=0wJWOl74aMiyb7jKHPVlBYVpMVg6KiHdy3XTLVUA7+jgQh2oKD/p+JsO/G+2yt+hQU 9O529LZ/tm0M6uEMCe97zyL5fxkM6EjycfoHG5YUj3/oUDwe4mcArxso2HgOww3eMDMS x0MJvxePHhImPnGTAws0JC/1LCjtvnZQXr3zZYDloj04uWERy8LyCXnEQ/8S/ouM/LeZ O1jV8/bUFBe6XtaaJaUkAM0CqVrOlsriDpxee/BGTY/7y14aASqF2qAfGj7oZ10+IA9m 9OGKqudakdYgvsas76OHLcRv+/izS7LhgWbeScDy64LsDhpcv1lSt+gpC7zubzAni9jI +ByQ== 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=YabZpxn7mRZSzbNRVFW/2KaxGhb8DuUKqYC4gVtFav0=; b=yyRFoqXrPJn88kKBe3VgyZ4Aoad7xv5OIPWwYsPZpBmLduy7US/htf5cuE+hwDQzHH k6TfzyfHoS2skBWeyu3Bf9Ge3pmMQiQW+BffxJvY3+WNWNYg8Dbikwi3yOlXlkCyvko3 qToOXuwIgJcqjtMxNKzTXCS66FjjDQdDSzgEAWsQAZfLGe9flNdbVyF6RfdxNP0tD+iR LbZVeyvuNBE9oiOtnDc/AxFwqP6BTzj5fAqhDogO2OVbW309PV8PC+cJfjnppmh9eGpb FjDW7L717JOMLeNQwxKd7/qyrOGUrS3mTNpWkwoRcqqHkBaTD8sieg/BOHL8CS88FBM6 0hmQ== 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 x7si14932980wmj.16.2019.04.25.02.59.14 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59: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 1hJb9t-0001rM-4A; Thu, 25 Apr 2019 11:59:13 +0200 Message-Id: <20190425094801.863716911@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:45:01 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Catalin Marinas , linux-mm@kvack.org, Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 08/29] mm/kmemleak: Simplify stacktrace handling References: <20190425094453.875139013@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: Catalin Marinas Cc: linux-mm@kvack.org --- 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 25 09:45:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916555 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 A4013161F for ; Thu, 25 Apr 2019 09:59:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9379328C4E for ; Thu, 25 Apr 2019 09:59:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86D7C28C53; Thu, 25 Apr 2019 09:59:37 +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 7D12B28C4E for ; Thu, 25 Apr 2019 09:59:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 395896B000D; Thu, 25 Apr 2019 05:59:19 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2B0316B0266; Thu, 25 Apr 2019 05:59:19 -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 F047C6B000E; Thu, 25 Apr 2019 05:59: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 8A4C76B000C for ; Thu, 25 Apr 2019 05:59:18 -0400 (EDT) Received: by mail-wr1-f72.google.com with SMTP id j22so3963035wre.12 for ; Thu, 25 Apr 2019 02:59: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=alIh8rahgpiXntod9mcGH1EU5xt1zZgE1HpQXO2eGOc=; b=sa2za0KH8KjcLdHVS1hox6vyRvc/JEeftO/iGqfeKFQedtuRgyEdTsENNiCMX5YGXB t0F4sy0Lk09ka7j3ovlsvHpLdN7How5DZRnBDSjoyUY5fF2ulU+EhYr5gAd/tziGD96r FyOemkYrZHrfsAY6YALuy+OKtWqylO3UEYIE3jJSMCHXcOYRXmzn+oQceoSO1MraKXTO YNE0gKM6oQgL7n14h2+k8HlU8hCzswI+cB3A6QrGlMeQCWBivzgBQyg5hrRxU7iVz5mU 4/vhKsBLSJ/tillDTMdtumThslCjvQC9nQ9ySecLPDYPGr/Zm1hJLQmUlDH1kD8zbRm+ dMRw== 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: APjAAAWI6n1oOrEswMYAkZFGLf3GFufD+DmwmT++FJjxha/vYwKMatsN i3W0J2Ic/zbh300EOVKgZEw1LQGBToqxxd7F0IUyn2u8LLxjQQKvhCzUG5yDivFyz3DdfmqtGsJ iHWm8fZLYn6BdbyeAGXNVoP+tEWwgH/nPd5QB5FMgqfHaLTqpzrAebmE7eWpKYTV+KA== X-Received: by 2002:adf:d850:: with SMTP id k16mr18787096wrl.35.1556186358013; Thu, 25 Apr 2019 02:59:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/NMhbS3tp2m1BXiOzL+RUPNvOkTCWFD2A2bXvi3bIvddn5CDnj2w+vhqqvS1RaYs1gl9l X-Received: by 2002:adf:d850:: with SMTP id k16mr18786991wrl.35.1556186356117; Thu, 25 Apr 2019 02:59:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186356; cv=none; d=google.com; s=arc-20160816; b=V9NPt6jm0gbsPIx+2F8P5TRljYPZHFmM7/3IJoySaX3+b+OPmZtg60anP0mx6nKiFR EZM30d37+6ThU0CNqZN2Py+7DcFkwdHQWSjmMEB/ZoQSNeCRHHdjhFH2Ls2LDxoLYRvd IEerrHKgOcmKtnqbyCaLI+EQMqrfzfKJg+fpEzwpMS3D+daIXP2NFOe6EkotrPvqEuP4 GXXCFB08uuJdUlFfA+B4Lb5ttpLgzhnDnR0lECDHN1EQHxHnxhzslJZ2IcCXWACGf+Nm 7CjVo8QqPZWS3STxCpfEhKWPGl8xM2zqgPzvR7xSa8xr2u99pKCiLj4YBp6TjgJYIBBf zr9Q== 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=alIh8rahgpiXntod9mcGH1EU5xt1zZgE1HpQXO2eGOc=; b=HUhp5mW07PWVEhebZL8qvEtZNlzWc0xIpkjxzYDdFgMx373RHKUSmyiejERpgQ6s1k 7d03La8OVdCHRlIrFslni2YMXmtuH68+mHWChoiWCG+4EgPbQvSbaQ52zrGXHTLUP/5S zjp9K4UfLTUwjz9RsNQTRahkXj/qJ3ft43P2bKZjgbxW6r9HmWcdNZWLhnOj/HoG7Wd+ iblUNA0NuncCNRT1jonzJBrJfqIsY1BkhVEhGv6zH4+ha4/yGIRFHICmfJJAbP0jVszo NjWZbvIfjwwqNyZVCvmcAcdngrrVde7a4HSu95dru32T/m+XJAbgq8xifXxjU1XyMlXz O0qg== 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 g18si339838wrx.87.2019.04.25.02.59.15 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59: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 1hJb9v-0001rW-1P; Thu, 25 Apr 2019 11:59:15 +0200 Message-Id: <20190425094801.963261479@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:45:02 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Dmitry Vyukov , Andrey Ryabinin , Alexander Potapenko , kasan-dev@googlegroups.com, linux-mm@kvack.org, Steven Rostedt , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Catalin Marinas , Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 09/29] mm/kasan: Simplify stacktrace handling References: <20190425094453.875139013@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 Acked-by: Andrey Ryabinin Cc: Alexander Potapenko Cc: kasan-dev@googlegroups.com Cc: linux-mm@kvack.org --- 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 25 09:45:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916553 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 D89BE13B5 for ; Thu, 25 Apr 2019 09:59:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C52FE28C4E for ; Thu, 25 Apr 2019 09:59:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B57DE28C53; Thu, 25 Apr 2019 09:59:34 +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 7F93228C4E for ; Thu, 25 Apr 2019 09:59:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0AC726B000C; Thu, 25 Apr 2019 05:59:19 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 036146B000D; Thu, 25 Apr 2019 05:59: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 DF0A16B0010; Thu, 25 Apr 2019 05:59:18 -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 8F4996B000E for ; Thu, 25 Apr 2019 05:59:18 -0400 (EDT) Received: by mail-wr1-f71.google.com with SMTP id o16so20463515wrp.8 for ; Thu, 25 Apr 2019 02:59: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=0y/QyUdaOvECJaR4ueRYQdFEB+ebIhDutCtUQ6iFeT4=; b=D4kUwv+Ekm5xrPSSxIYGgj6m7dCylJvfZ474xwGMXCv6Z/HtPM0eyIs1zkZ8TCr4+g 4o2RaVC++C9nnwqrs8QNdBlfft7+usVUPVml7Gn8BR7zOZqHrqsB+Qp7Y0hYokLRBkM/ B8ARoRaze9csxgJSkvdV09OK35M2R1tdRKm2iXnI/YhyOr/QMgBP7JSINoDg3mH/UJnQ AIXkepzq9sTa3ZbFruCiX3C5Nyq7B34CRViGD+Gi/SA4PLgO84c6tqT47CpYLGplagMX P8eiW73XC6YSeWIQqUZ9qgnczWQYZmWt0LX2FiPBgYHUXauwQjIZcWZ44XkSogG5C5kA l5QQ== 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: APjAAAWbp1cnlcirZdSnldci2DkGv2bAMt46PG1PCcEYzgz9ayy2taEG k0lVD7HUs0pKPApFgOhnx4yRsVNYBpNbj2KF4UP3XczoxnSMzkdQYylHpWT2BRQuDWaiL5yYheV WyfIdMzv0UfrW3FclubAqM1TcT6+Z5UhYVgumR6AEHCY4ipW/V2nvblvxST0dS4W0ZA== X-Received: by 2002:a5d:624d:: with SMTP id m13mr1458096wrv.305.1556186358115; Thu, 25 Apr 2019 02:59:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqy2T3U+r5nKczI31XcbLDNzkeGchVGNK1wt976iiC6z4ZMQ9VWJgMsPGMiQygS18/GRFZGu X-Received: by 2002:a5d:624d:: with SMTP id m13mr1458049wrv.305.1556186357239; Thu, 25 Apr 2019 02:59:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186357; cv=none; d=google.com; s=arc-20160816; b=jlbNTJYYnajdWi6xTu0w029Py+LRliHTnGp80W2Ji/8JRaVl64p3ZLkbwwWg04kJHy 2gYjSRM3nuZL7ploZEXuSyTiD11WdOzKBPKgkwM1NMeKHJoxUsvz8aYe9EBG+tkrOcMC xpCJ04dlY9ICxEFsGi+yk5vrcCyWbihfpGdTrvjZiY4mXFD3cvwouG4KwgLravGMQcql JhXJpSiyL3eu2/QHP1pOjiG9PAcvZkET/XAqyg9hY+lg9JuL05PP8nnnDV1Q1fG9lnZK s9qEcWhWsraSo/zTc3jEqaW/Vr+gH+VI86Yt3Zs3iLOJH89gOqHOunFhOHfPRgtBhO4g tM8Q== 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=efdg/4UtvEuoEyxyYBilLf5WWA38ns5PIcImyhqdxu8bTRmF0svpox6no/4WyxNOuJ 0WCkZyjLWGX+2yoxSewHLoClUppw6fX2YPzNGf9vk0stZ/unorLsAekb8qIGPi4vTU2N yMgz291aZVLcVPmBeMSYGCU8duUogIFq/QVTM18Wi/oqbzqBBJl7ymJmFmO03OFVTXpG EDuUDUhe5zrGHzYDsd5WPUTqy5odvQi5EPKGHbhIwBy8q0yd2IcbsqQG8ebfYtH7qY2+ 6b9iHqd9lvsTsakEayH3YYOona6+Now8QMnn8o7A6PTDbbt2/Gs2mMXCV/SezqNemRUW IWjg== 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 n21si11690141wmc.171.2019.04.25.02.59.17 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59:17 -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 1hJb9w-0001rd-FT; Thu, 25 Apr 2019 11:59:16 +0200 Message-Id: <20190425094802.067210525@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:45:03 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , linux-mm@kvack.org, Mike Rapoport , David Rientjes , Andrew Morton , Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Christoph Lameter , Pekka Enberg , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 10/29] mm/page_owner: Simplify stack trace handling References: <20190425094453.875139013@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 25 09:45:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916571 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 90C6713B5 for ; Thu, 25 Apr 2019 09:59:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8125A28A08 for ; Thu, 25 Apr 2019 09:59:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7459A28ABC; Thu, 25 Apr 2019 09:59:52 +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 08C4028A08 for ; Thu, 25 Apr 2019 09:59:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 65EF96B0269; Thu, 25 Apr 2019 05:59:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 56D6B6B026B; Thu, 25 Apr 2019 05:59:25 -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 344D66B026C; Thu, 25 Apr 2019 05:59:25 -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 D83CC6B0269 for ; Thu, 25 Apr 2019 05:59:24 -0400 (EDT) Received: by mail-wr1-f69.google.com with SMTP id r7so10963586wrc.14 for ; Thu, 25 Apr 2019 02:59:24 -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=A1rpuNG/uyb02nGT6zbPvWZH4G9tsM/3fkuQPAkp8EvSFTPtu09qX3NWao3K9LTNI7 9J3fmeVPtQRshtQQP3ZC6VM8WyONt+vB9AKCvDfWT+7DmNpFP2nqOBC1YuUNfhzjyVwu TQAeJQzyYgmdH+x+zySzKjmSFLALfmmSIRuk6SqD//101eaf4jar5FVcz55kIjwqgsou ZyIz0Y83naRo+65K8w0PriGFZGvGxk0HqZK2g09+GpcfkImw5+TtWQGbKOUr74LyMXcU 8iT7S5+sv/TIT5PeETdp/Kxkp1x2ZtzBLDqQOsIFZEkf3X2mkteTsuVYUzumRyah2vAi kZsw== 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: APjAAAXFhgArCKLd+UX41CiT2ulFYNKSxfjqc/9tdSgph4xTWji0VmzW sYUwfbK98qs+W0Q+9eCj9dNR3in860GwTEFJRtYrhfH1MN01F2TgRFCXIM0sMtoiKfPSwOWTjo8 KUxLFpiMcZXnxI8Lkm2cfYeTK89he6q2nC59q4K6SsRY3p70GDtvvEJULxr8yq2ZNRw== X-Received: by 2002:a5d:56c6:: with SMTP id m6mr24251646wrw.211.1556186364442; Thu, 25 Apr 2019 02:59:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDkhAJ0MuEQPmxvi1qhm0TA0ZwuYzXI4QatFOhHFmrJgFOSyn7WtHRH63cGc/vGzEE0eAH X-Received: by 2002:a5d:56c6:: with SMTP id m6mr24251590wrw.211.1556186363413; Thu, 25 Apr 2019 02:59:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186363; cv=none; d=google.com; s=arc-20160816; b=lXvjvlJWjwIxibiJ4cmW4/GJ4xT50MuL8A3c4z0btj4WIssncwBPjQpviri6INOnN+ C+40IFQ1fyNyEISHx+mDGWgL/j3ZhovPx6JcdB+K7jClkDgJmUWMIyLeaIFIAdsgaLgq +L7NAOG/tl/c6jD8qArVl3Gx90yrjupSYXiA4/hOfUpuDm40DY98Zi/BfAQyINWGqDXt 4XmIbzSe5A9q3kkekfXk7FGBSNC32ptbAW01cOwiq1vOty9sWMWZN0uZXuUlBaF7ggZ7 mPcYrXsv3XmzkMevQyoFl1zTvMTLd0s4+IDJxj8+oE13JftSS0Z511tO9zD3w2FIebkr typA== 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=Orzxc7MyZ8t1gVdLHnShpwqsxEPjeFAoFdZrPrUAMrgR+S65nJXD9FAeJph5Kv1oLv 9Oj654aHLjz4yVxIb2PLMdm6BMQnTaXmK32N6zYRGY2JZBrVPAQwZSJwMg/T+vCBcDjh JyNACUZgh1IKA5l0VqEpwcqssXdbOvjZUpwf+R2wf8BGlVw0bwyzwdkVGaErsR17C00X BQ7I9U1S4AAcoAuylZCE9F0srbG1IjWbPaLfT5Hwk4ogfW/zR8crV1nt6HQKbzSXl93J 4tAeKz4vOdh+Coje8SrhMC8jrjNshJoaCYvzRgad7UuiEpLLGpkDQYxmUpdaFPJjEQzL In9w== 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 f11si15094986wme.107.2019.04.25.02.59.23 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59:23 -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 1hJb9x-0001s1-P6; Thu, 25 Apr 2019 11:59:17 +0200 Message-Id: <20190425094802.158306076@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:45:04 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Akinobu Mita , Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 11/29] fault-inject: Simplify stacktrace retrieval References: <20190425094453.875139013@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 25 09:45:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916579 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 6600513B5 for ; Thu, 25 Apr 2019 09:59:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 552F628AC2 for ; Thu, 25 Apr 2019 09:59:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 473AD28ADC; Thu, 25 Apr 2019 09:59:56 +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 989D728A08 for ; Thu, 25 Apr 2019 09:59:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0B6E36B026B; Thu, 25 Apr 2019 05:59:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F29436B026C; Thu, 25 Apr 2019 05:59:28 -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 DCCAC6B026D; Thu, 25 Apr 2019 05:59:28 -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 850D46B026B for ; Thu, 25 Apr 2019 05:59:28 -0400 (EDT) Received: by mail-wm1-f69.google.com with SMTP id u19so3838084wmj.5 for ; Thu, 25 Apr 2019 02:59:28 -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=kJJhZXYPA2qJMO1ppX8IXP4MrK33nsCABoVXTwlvXT4=; b=XwSc9T9VqCPYKTkFY3gTH41qOVzZN28yJ810tbNi5InsRWtAeVb/esi06/llV6eAah TSmGfHJ6NQS0ws6ahmL3dyOet4QD4G9qP5urH9vX4OAUdvT/76+SVkVFy4Nh0Am5N/Ff vgtgyTxvwZ55t124q3GmWQo6ZQXMgs63/A7DEcA4kkt2TasYBUcfaabS8MIYrK9N3r8y NVD+78gV5TmqCZLMd1xbKQuW9R5sq1Q3EVTNRtMte81IEHnTvg9g0SkJRWNLfnxct1Nv bnBo+uMDFoCWCCIHHb0V/Q+ztKLA46agt35ES7FOl7X3URdfIkZ+R+E2YW/zB6QbTHxN FJfQ== 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: APjAAAVW9lkqMeuuXguIL5OTkeleoomTg7ATxGlBi+OErroZbnVbIP2q 7hOwtXhaDGRajr17wMXgz2oO3iTGv4t3Pu/b1xa0pIc1OU/sN8hVsT7/+5pkOo11uDWdaf9Di1Q BopSqAWdcpZh2VxCJUGlu06dl/a0BSA4W78b5kUUVrYx2CIhmr0Hq64V7vVsIz6sSUQ== X-Received: by 2002:adf:f405:: with SMTP id g5mr24413714wro.310.1556186367976; Thu, 25 Apr 2019 02:59:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5c8zqF3egP98RCoCwnm6QJ47aR+/tKVG1fWg7BRuqP+3LdLtY6BnCYDvwwLt0GBxuL4oy X-Received: by 2002:adf:f405:: with SMTP id g5mr24413659wro.310.1556186366867; Thu, 25 Apr 2019 02:59:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186366; cv=none; d=google.com; s=arc-20160816; b=mAUJ2GHq9udnD+vqdjLK+yz0TPhgRwzJ0TgVvx8PvjLuDzdvyCR5pxKd0gWCY+F6Se qkUMlxg0Kt3OEqLoaDfnEegS8Ik7Yy7anx9uoMxXz5/rDV4gwZxiKvhEUb8eNqCtMmk9 ezWYjB1HBrkqv8JjDXWZdhkRZ9kc3nO2DA5LXhdmxBrfSUyRPVP2GvWqInB6m++wUf3Q /IKpFgDI6NoVZyOCQRUDMJ34507KE9DXVzjhfwjAXTYYRDWzYNzfApfCOV3MFo9zhwdh B8DgfndHBWUBR3oIVBKISG3d0CpO42wu4EJtwAVsMi6sy640hmkZJLj8SLwzzCaDYe2+ 1sBQ== 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=kJJhZXYPA2qJMO1ppX8IXP4MrK33nsCABoVXTwlvXT4=; b=VFBm5ubbf8BcGG6yx1Kzz6qWU1Oj57Q3IchV5ENO+gQhkznw048fbd44/f1qni0XbX xH5L1X6AAI0cemmQlScw3xvZnt0CBvjMf+g8clmSl5IFNFlb6jEolhWYOzFuJXdlwkr8 QYF7J6qWuQ9QSrJutTBnk1bvf14v4CUtdfr30SccNY4+552UPnwXOANeU3TEamxQPg4Y XjV7HbrF8W1CUHB/2V8trUDWndl8TqkFFgMm7Fi1d/IC59ZtDqwbTprwXk5YQwlMHrS+ 9vcyMDoLciPa4bL8HgGPRy/RCNZRjVkk33Nbkns7YH4LEkQZUggC31/sF+ZtHRRk57rG JN/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 x26si15089950wmh.166.2019.04.25.02.59.26 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59: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 1hJb9y-0001sB-TT; Thu, 25 Apr 2019 11:59:19 +0200 Message-Id: <20190425094802.248658135@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:45:05 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , 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 , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 12/29] dma/debug: Simplify stracktrace retrieval References: <20190425094453.875139013@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: Christoph Hellwig Cc: iommu@lists.linux-foundation.org Cc: Robin Murphy Cc: Marek Szyprowski --- kernel/dma/debug.c | 14 ++++++-------- 1 file changed, 6 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,10 @@ 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 25 09:45:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916595 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 4C64D1805 for ; Thu, 25 Apr 2019 10:00:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D80F28A08 for ; Thu, 25 Apr 2019 10:00:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 312C828AB0; Thu, 25 Apr 2019 10:00: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 BB13628A28 for ; Thu, 25 Apr 2019 10:00:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 458776B026D; Thu, 25 Apr 2019 05:59:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 408116B026E; Thu, 25 Apr 2019 05:59:33 -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 25A0E6B026F; Thu, 25 Apr 2019 05:59:33 -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 CDAA76B026D for ; Thu, 25 Apr 2019 05:59:32 -0400 (EDT) Received: by mail-wm1-f71.google.com with SMTP id w13so5290802wmc.6 for ; Thu, 25 Apr 2019 02:59:32 -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=KNI6uApvMrqoAUUu0FFzppptgUSL0YNOF4ZqIFlQZuRlxp35siX3wh/T+LWx/qfL2Z cMpFp7lVcixqEsOmZVdPKvcAXwnWLusEv1Y/w2Z8/C2l/dTv1vC/HtTcW7KPma38TCsl NE4hLpGPXKsgUODxHPbPO4eTc6hJiJmIEpu8Z/Hg3aHg/enPkqszz1LdmjmWJQDCb6KF CpgOS4yn5XzbrReFjQB/RUwq5A7LtKRtYeqE1miWt1szUJ/+Dtm39TLx6Do2959hteAH P09AMxnOLWGlosXXKBFs60k57699DtsdWUiWtLXlWBv3/VPsezMZ+6rC0eJW+jnl0lQe Tw4Q== 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: APjAAAUvAnz1liFoJnCfCgXG0BOGAKG5tiy3PXlTweuzw7SAH0NU49Z5 pCgzvWM52KkN396E/+4DCIk+TmtMb6ZcV5OcHOJqpZaiB6+5LtZLHp5JmjxIuT11XM2vTLP8S9M +jTdi4wAwiNkLMvWtFYCNPp+zgqm5taPJs1ibdy+8xVstLPOApUksdvO/cdG36ZkIpA== X-Received: by 2002:adf:b646:: with SMTP id i6mr11765829wre.12.1556186372392; Thu, 25 Apr 2019 02:59:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqyDUl1DNu2xjPVvVtGRNIeRZ2XnIW/QOa5nv/SsUytOUN0nJsaN1LrQo89PpFtpmt95t0fO X-Received: by 2002:adf:b646:: with SMTP id i6mr11765774wre.12.1556186371384; Thu, 25 Apr 2019 02:59:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186371; cv=none; d=google.com; s=arc-20160816; b=qTKBKiDCZIhVbz+zjv7ruP6qlOiWjOHhdkf3j7eXB9G8W5wSLEi9GYkdrqTpKXI8Kw kimiZO8zXOWJymx5muTo8ikkKzLaEdTxTjaVLCPXXYEb3iR8a6wg3ja2oc2KnM5jXXbH ktaROIShsNEzWi3H+3RPnkjuRPy8GmnZd/DL7r+huTnTaqeLkmPCoQdP7YQubffCpiXF J2IRfDlUUA9osX1UKB0lgticOI3qFHwUCXxOwn87qpwisB42OZ9G5NQob8WyChUnQdnU p/Aqp+Eb5E5FslQ8P81vUUvIG7NPQjORpDKcv2SVwLqEyQgue2z8eGIBGSng7tsZpoR9 skWw== 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=Awmul4j8PwenMIonI/uX8p6sbLRDhr+y2jmFcMR0uaYPgSHdZqsi5l3cHEwoWsLYAx Oh5TIdUcNkvhmy3APsYow9FQ3FhH/qdGaRlv+nar2a5TlVka8DRNipROdECoTV3LTO+T o4Ct67akIG+BvBg7iwHclFovv9NPtrn9NLsKv5E3SNieT+5KzNXxHKiWSU1Q2lg5dKdp rDoRjV/CYGJBfvpw1vP3k8ny+vnGPzTkIBP3Z5q9YgBOPEJ5Ki/22Wtfru7RsOOi51GE JjRRuYMtRISQKClaWk6i46CH2wXKZwcFw0rJ5uLQg8ZEqzd6CUHS8YLz58QWb/QDrrbu S8lA== 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 k12si132784wrn.4.2019.04.25.02.59.31 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59:31 -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 1hJbA0-0001sR-AQ; Thu, 25 Apr 2019 11:59:20 +0200 Message-Id: <20190425094802.338890064@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:45:06 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 13/29] btrfs: ref-verify: Simplify stack trace retrieval References: <20190425094453.875139013@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 25 09:45:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916587 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 B7BDA13B5 for ; Thu, 25 Apr 2019 09:59:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A935828A08 for ; Thu, 25 Apr 2019 09:59:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9BE5E28AB0; Thu, 25 Apr 2019 09:59: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 273F328A08 for ; Thu, 25 Apr 2019 09:59:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0373E6B026C; Thu, 25 Apr 2019 05:59:32 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F2C106B026D; Thu, 25 Apr 2019 05:59:31 -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 DCBF26B026E; Thu, 25 Apr 2019 05:59:31 -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 8EDA96B026C for ; Thu, 25 Apr 2019 05:59:31 -0400 (EDT) Received: by mail-wm1-f70.google.com with SMTP id u6so5301914wml.3 for ; Thu, 25 Apr 2019 02:59:31 -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=NX5Hn+JSbM+A7qd8XXfrYm7CX1p8FnfLmx7966W7ejHUiYSzn0OPXeqGNoE+ZEzvIj R8TiqdL/P8/0xsew14iKU7uz2FjJ8rJDCN8NKilUZqHGmIyEMxhadcNRIS7tP6UxHg7w HDVPAUE8PyKIeiB1DQlVYQxuJasfDpGjzpUuzKV85Solsr+BLr+2kCsC8+qw8/iVjuRh aQFlkqK8OllAQ4eOToCOTZ8uEie5Inqvbh7Z8TupZtDRMxzOYlgsMf19koFrPymXMXhk leZM+NWiMJoVNbtj0DvLGtAVlLacLB9ujvYVCc2YAnS3n/B0Jp9DQ17MMt5iPJO2ZcYJ /uQg== 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: APjAAAUXltzJznQkbvNvUuwFwVFQ9zM72/0mt3vnZhUGJIgCsmwKDcG7 9sQWmDiALQ8/t/rbdAVIUgU29g/g0BCpmfYQXaFnmL9RLKsFBU74HoaoOIK9dbSw1FbiJdbsYDU 8DpmWsIkHg6JIuJqQP3MdqVqcxVxyxuK3LITweoj83TUphcwL5frjr/ocOOuWzKCYaw== X-Received: by 2002:a1c:6a0d:: with SMTP id f13mr2785977wmc.76.1556186371090; Thu, 25 Apr 2019 02:59:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwaaIbT1znNxUk3TXF30NzrWWqcPHxihy90i6jm3tcJF6lbIxS6NMh24+C2zRBfqhgH19qS X-Received: by 2002:a1c:6a0d:: with SMTP id f13mr2785913wmc.76.1556186369877; Thu, 25 Apr 2019 02:59:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186369; cv=none; d=google.com; s=arc-20160816; b=xH8wnHICp5Unw9MoA4Ryd34QUrPoO+r6W1CHGeqL6/2X1VdvnHOYrqTm2Qv2yen2Yx gM+uzBHdOfLQZvPEr6RnaOcmKQZ8vFVMMDDppaeQ3tqCds8J6+mkgNCJVOJGSAcsT8Z6 IeFUDg7wNRaFeNZ/bT2JYUWiPWzoARAVsYfjGyfaKWYPEdFyCM+UoVoR8BaEmO1A+Cji hnKGbx8XtRBGRKl0DkXN33aLji3loHikgKkl08LaArNUN1PEuKv9yUlDIhHoPWqI2c6z MuoD9qNrFg4CJ78Chi/fZk/VdcBD/zDjk8DhhJv8ijGsbhAbHur2CECbu4W4EcKNXOkD YM5w== 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=jtEut9frT0OBVGCVwLf+hZV2AU+4mTH0IDt92R5Aazm/DDDAF8sXoCl1f0E4gmLMlR QTX4pitwAsy0JoTtI39fHx9h2fTpNmifrxTBs7MIxxS3gxAOrONPzdFt/H5KM5CC7b71 6aM8u2EBlotzq6xng7JYbUwH8vrOSpOXehAw+VEM1IeLhMubgwa5RKiuWGGDAGHBXIGp UDoJqEQ554Vfi1usjcwjW0fdXqTn5U9GBUBtvTmJ//+8XST9/ZIgSsDHVPlTxqNPgLlI mBCGtSQqI5yq2WzAiqRZhM2MisJpdbq5T2nGmj+jBJx2+o6b62x4Yi1wfjyNO62032ja /B3Q== 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 6si14765049wmo.109.2019.04.25.02.59.29 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59:29 -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 1hJbA1-0001sk-Us; Thu, 25 Apr 2019 11:59:22 +0200 Message-Id: <20190425094802.446326191@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:45:07 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 14/29] dm bufio: Simplify stack trace retrieval References: <20190425094453.875139013@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 25 09:45:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916603 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 EDCC514DB for ; Thu, 25 Apr 2019 10:00:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D9DFC28A08 for ; Thu, 25 Apr 2019 10:00:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6E8928AB0; Thu, 25 Apr 2019 10:00:11 +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 4C6BB28A08 for ; Thu, 25 Apr 2019 10:00:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A21B16B026E; Thu, 25 Apr 2019 05:59:34 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9FB276B0270; Thu, 25 Apr 2019 05:59:34 -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 910126B0271; Thu, 25 Apr 2019 05:59:34 -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 4072B6B026E for ; Thu, 25 Apr 2019 05:59:34 -0400 (EDT) Received: by mail-wm1-f69.google.com with SMTP id s18so233583wmj.1 for ; Thu, 25 Apr 2019 02:59:34 -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=BFhEcNMaiKNUQ9iTu7Uj+7MoGu6/pxNhQX9iwJkaC7rihTYpZngfBFrZBLFH6ww6ep yzECAO+np36qFWVPFh70v3uk/EWAXv+FPzs0gnoyA2va588MpkWa+o/ePL4J0NsZdifd NJ83g7hqaPsoXYY7xMZVjCVtyY12p7Bu0opnJ7fh3Zub98UQyRrDeDsfkIIN50NH2I4f 7O1DQ3JSja1SkOSg8t7n8Iahq2LC6Tf7SZ/C2/ZaHIJFoJwA7J2t6VYuhrxIyInD6SRt JC/kFU9mg7So5zTcW8ZE6GOQ+uTOSrLqQ2qNrWTL/RLIx5YAmU4VwEhey4JpSznpfLgA C9Rg== 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: APjAAAVIVlYKDFw/eAkGCMMbIEjwz9jicJsDaK7+F5uVhJcPztaye0fI zvNVKwTOEFPE79+ikmV0yGBWvTo3xuTk0xUFmYe9FileXyoWP4GpVQAB5PrHwtkWda/7ah1GqKJ kaZpMj/8VPzmo+HLxu2bjkxcrsBFRq4rN2167FAEO2x7rYczLl5z4vJyEwO7udoRHMQ== X-Received: by 2002:a1c:80c1:: with SMTP id b184mr2841344wmd.109.1556186373790; Thu, 25 Apr 2019 02:59:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqxNHCLLrhVLjD9kEyNuxxO+1GlCy3/taIOOLdF2M6i8TS/5AXWPwT9GPEt6OyihTdkeRmGs X-Received: by 2002:a1c:80c1:: with SMTP id b184mr2841282wmd.109.1556186372543; Thu, 25 Apr 2019 02:59:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186372; cv=none; d=google.com; s=arc-20160816; b=uDpxwpl0lhP2JsSfdw8cW/yRRs8ndCdW2KEtMUdRsdvW2m9xG4ZGqL6LSF2NQR71jq +CSa3RSYxpwC8RwncjSiQ1nxea0mVLR+Pg7QNYe8WJlPDUzT57kWm60xnP6ixtb2j2T4 qIBd7wOgtvB12IeN6Oaf1cmJEfVp2Pwsw3A2eZnF0L6/mP556kP4C5QbSkTsa9PVMQGI rIe1DXs9fOpadZQ4P4IBpmbcZLTTTgZlL4gYEMeLs0oTkDH1fxeqWff50St04nOtQdIl 7RDCWwud9q/5pVnhMzjB3hcJYk0OFHLiObkHsI5C0hbKimXt5JA4cX/6P/VrP90O2Lss whOg== 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=lN4XzsL9dBaC1x0DZdEP0ub+9L7s3LJONlSYHaCXXMWH86ZD8oTPlKhFNWdRUrxcrT p9jiwkn7Xa8YJZEn8b49sZnecm0QWeySZ+FVFHPZXgg3aoEhRLaxWLXc8xH7WlqkrpZi 2GwS/TLHh+Y2fUXQUEpomGRwGmWQ3FShgolmsuhOh7+oCx2DMruLtIniqez0ZjnUUJNl c5bEdn8ShjDoF6apJOM0X000waQFQH6Prguv55J+pE+VS1P8ogk1iEWGxGdUchokZcoo vY3ce8mxnafX/WK3iD4av2qwccnsJsxWBiMlHrdZuKH4JizIqEAg5lFAhkrlvbC0j1JT E3kA== 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 w7si15061518wmc.15.2019.04.25.02.59.32 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59:32 -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 1hJbA3-0001t5-BV; Thu, 25 Apr 2019 11:59:23 +0200 Message-Id: <20190425094802.533968922@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:45:08 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 15/29] dm persistent data: Simplify stack trace handling References: <20190425094453.875139013@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 25 09:45:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916615 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 AD58A14DB for ; Thu, 25 Apr 2019 10:00:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CFBB28A08 for ; Thu, 25 Apr 2019 10:00:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F9B128AB0; Thu, 25 Apr 2019 10:00:19 +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 658B228A08 for ; Thu, 25 Apr 2019 10:00:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 78CA46B0271; Thu, 25 Apr 2019 05:59:36 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 73C206B0272; Thu, 25 Apr 2019 05:59:36 -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 5B47C6B0273; Thu, 25 Apr 2019 05:59:36 -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 0F1916B0271 for ; Thu, 25 Apr 2019 05:59:36 -0400 (EDT) Received: by mail-wm1-f72.google.com with SMTP id b12so5715112wmj.0 for ; Thu, 25 Apr 2019 02:59:36 -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=a3gSsDswxxkaod1waPwbx4k12fNeIbCoQTluUl86z/c=; b=TpveH84JCGnuTxB+qIQVlAxIZfSG83ccXjcGhnqam6j0pJ484hYqeyrJv5kPErPB3C z7aNh/i9eVPdZIcQaODBAxxeePWStP3zVJnhdOJciU4Tuvh+SafRVw1q1NYxdJm0JYqo BqyP9uKFjhxLqtdAhUMNe+GuPl/bYeiRSU+CZ3BLULwtGM60ttCJtHRYLbSBPBodDkMW QitDxQyZYvbruFOQ+ze5skcsNWBxPsg5PaUIDQLGCk/sP4aSqByNb5+xnpac6N2/3X2J o9Odz/di4iFj18tm7Xas2MGtfewoHuAdsEnbndG7kB5w1fT/wUxIQD+a8mOhtVH9mvHG /raw== 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: APjAAAWONypdY9IAIeLS2W112/E/Z6JbOTImSgluJqsSaOBCoxJntXPg Rn0d0MfiTGf0comsPJ7fQhdtwTIaqxD2roCczlBZ8IwnkvdzceAu1z6lSBdT0Pl6/ofejW5lEPN Ck0D4IEfqCTp747BqShmgcxRKJ9nwYFKM1rYoM3jha7qowgnBNv2cHToik4y1L/iKWA== X-Received: by 2002:a1c:6783:: with SMTP id b125mr2731419wmc.79.1556186375505; Thu, 25 Apr 2019 02:59:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxUZ2/B/E7lOwVOuLOLIMbPKoWg+vMN88CO3tiG9dSBg5+S7gGDJduEJ54a3HpHzdT8dL4x X-Received: by 2002:a1c:6783:: with SMTP id b125mr2731334wmc.79.1556186373748; Thu, 25 Apr 2019 02:59:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186373; cv=none; d=google.com; s=arc-20160816; b=dYDyewPZaaxV6KpCkiwfG61GLJCSjWS5TfeNUA2btnAoQBPreowbWyKr755YZU4ZJy 1AV983uIfbMVqhhdjifYb65uLDlDGsXqDDuJoGPZufKPKtAJ/ltyxkJXfb/06JOrnjKm ReXQHstcEjsb/UQ26O1d81KZdc96R/bN4PNGl+o6ZvRHHoTyPW63KH3LwDh1BejrUetq vjXT2Uffjjoy5x/R4JyjlGwxf/ZTff3u0R/GJnFylsPhD6Wtv4vhAQZniaAKffmgp5US Vul/Od7C9x/38UTKzcD4EFL6IQGjXpg+SfwlFBCHoi7Vwa0+1zORgg51zPgGSIuoHCt9 lMrw== 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=a3gSsDswxxkaod1waPwbx4k12fNeIbCoQTluUl86z/c=; b=eha6Hqi7niguaiRgoJQ6bv3IMNf+Z9XrdQOqpAzuamDj3skBVWUjD6Y21hgVOcw9O2 n3vKpnxgu5/p9CxaiFn3CkLKXXumqX8vL/5YbwSw+qDMgp3V1U8FfkM6RrLLygPfMXzh XDyla/Uxlu2ohmjXACVdgorWS0RiopAaUrEUOn393OR6qQ9wxsfgNvDcot/VLt+Kw/2/ c6Rctmfw38ZqHZ809FhD8frYe6ypl/kP3KV47yS4PbeKfluMB+OrLzpVWkorX0WJW+FU kj+A/xapQ2Ufwip2NjYGVl7xfrDiNNaq8a6pSGxWB4dDp7BPJbaTnV6oKV9vOk0FbmmO /cJw== 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 r2si10610591wrn.398.2019.04.25.02.59.33 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59:33 -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 1hJbA4-0001to-VQ; Thu, 25 Apr 2019 11:59:25 +0200 Message-Id: <20190425094802.622094226@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:45:09 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 16/29] drm: Simplify stacktrace handling References: <20190425094453.875139013@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 Acked-by: Daniel Vetter 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: Rodrigo Vivi --- 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 25 09:45:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916599 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 C20A213B5 for ; Thu, 25 Apr 2019 10:00:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B29E228A08 for ; Thu, 25 Apr 2019 10:00:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5BE828AB0; Thu, 25 Apr 2019 10:00: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 3A18D28A08 for ; Thu, 25 Apr 2019 10:00:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F3D46B026F; Thu, 25 Apr 2019 05:59:34 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 47B646B0271; Thu, 25 Apr 2019 05:59:34 -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 394366B0270; Thu, 25 Apr 2019 05:59:34 -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 E39FA6B026E for ; Thu, 25 Apr 2019 05:59:33 -0400 (EDT) Received: by mail-wr1-f69.google.com with SMTP id x9so20463660wrw.20 for ; Thu, 25 Apr 2019 02:59:33 -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=baZfy2EtMBUdPrfnVvEdMdG7EG4k5ewGCC793lut3rX0j35Vwa/rkjwLupcyks726k JtrHQ+ggHDM8bi7ZztlBzarY9l7BQw1v51paVGdR+FPwrmK+U4+e2HK7Oh4Ek6TC3+df gaUfP9RgLwnZwDxi5USLaFYkrT7yaIOcvwNmYTI1KgGSewX1TJmku4Rpv1PzIr5n0lSS rrniIzIOWz/SG4z/ylU7DCCpmO4b22DBCqtyjqLkcZu74W3nqH9zN0oEWsmlgKFhQse4 ybvTdeev6xKHEQP7XW+h53aoHghtF5CZ+85lEszOqwb5uOITOczQhfRb1rAG0BI1S/s3 8Uzw== 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: APjAAAUTkR9ngMgZA2v7Hx3u1VycAkWI6CYxD8QxNOFGZWPhP1/TYMdl PQdhRqUtY2SFGRRL0pVQFfAiMx1WO6iaBfVnEgam354JW5lglHFDaXqd4ZhYAyLpcBSoiXX4Oxe gBIVqzgNjgiz63F9kuwlWjzvqCRPArh25iG5UypueZwkR0VJ6sVaJcT5quGilIcgAnA== X-Received: by 2002:a1c:9950:: with SMTP id b77mr2589899wme.133.1556186373464; Thu, 25 Apr 2019 02:59:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzj8Izz9ICHCbUCysEraF/HZK04aVhdtPYarRJECqCCFPbOotD+ls1IhebUCwXGXDJdGjb3 X-Received: by 2002:a1c:9950:: with SMTP id b77mr2589825wme.133.1556186372204; Thu, 25 Apr 2019 02:59:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186372; cv=none; d=google.com; s=arc-20160816; b=FOcmv9jtuJ1tWeITsYl7LlXrRXEvfsujTLg+TeXGgFe1vdu69bs39nKSMiD+pC2Y+z fkjuFSUX0dfPTLsCIdgAn7tBL80oH3IC5uEFsNZzG0kTN1iXD8TrcAWAvEQWABfESK+L 6kvKz2UzIoag58O5kjdyzw9Nky1hOgRK2rpPgmSsDzTXWYgn2Pb9KBuPZTa2S+acyCAU gWG6HD0bl5mBugbz6bMyZvyp/ZYe1IbQrd5x1UsYurngyR7aAHKyQGkOpIDHFJaJ25AY v8NGG+2uf86O35JWOHiTcNXq+zehm7aRFI2Oyn6QzYIH8EyL+aYi29dAaARM7TXzp8fo YZiw== 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=nYS0DxvgvqriCTQQNV3E4KP2QHi3kVchSxRzmJISHVhO1Vj+NksFWRPgCHLstX86uU qSSIkDbkvAoZaIZV3qF49lwNDxeUdMpv+PMWmfUc38VpqvRRSarOdtzfyabTfEcnH3Ku b67+sUU0Vk76pFWaeLtIuLs4cxZ4gc22gTCKIJvf5mr1YY/JRVZM90fg5j0+uSq2U90h fgwuoJ+nBDcX9Ul8JLIy0Vj2OLrjdP4jmV4pzoHsKmcGnz1TX+LMxjvINQIkoK+ubJwo yq7RNUUOzoBKHTlqbFYR1uIQH/szYa+DQKMFN3jBSHIezYykVuTnZwyXCTK7wtcf44il jl7Q== 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 o14si16519334wra.84.2019.04.25.02.59.31 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59:32 -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 1hJbA6-0001uB-F4; Thu, 25 Apr 2019 11:59:26 +0200 Message-Id: <20190425094802.716274532@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:45:10 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 17/29] lockdep: Remove unused trace argument from print_circular_bug() References: <20190425094453.875139013@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 25 09:45:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916611 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 98EB31805 for ; Thu, 25 Apr 2019 10:00:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8789B28A08 for ; Thu, 25 Apr 2019 10:00:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79EA828A28; Thu, 25 Apr 2019 10:00:15 +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 EC90528AB0 for ; Thu, 25 Apr 2019 10:00:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D31136B0270; Thu, 25 Apr 2019 05:59:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CE1976B0271; Thu, 25 Apr 2019 05:59:35 -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 B5C4A6B0272; Thu, 25 Apr 2019 05:59:35 -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 5D7876B0270 for ; Thu, 25 Apr 2019 05:59:35 -0400 (EDT) Received: by mail-wm1-f69.google.com with SMTP id u19so3838283wmj.5 for ; Thu, 25 Apr 2019 02:59:35 -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=2k7lB3zYSqZ589filPfBZRV80I08rj+3gKaU91f/H30=; b=KynXkcsYLx6l/vACjoHkGe98r7SSW8Z8/DhiL338CKmK8Z/kGIKMn4tRIR0/VCx77w RlYdCsXzR7P+MVUNy0VnvJf0YL6OOZPD/ITrJAdENH7efLbwQIWUxEvqYgWVl4KGijXk Rp3m7TgbQjnJogBbu4EQbvD9nToH2+RViBSXmREbwTvG0qQu84clRjWpw9jcEyx4dqRo aCrStAmejzHzXC5N/uzqAeUsSpXyB4esVZTx1uFnqUIJra1DcBOq/14AIgc2tlhcJkpq Yn+oYIJxLOIZ06gvKPidUup6HPhQ3qIH+kNP0cs67OtOwNRtSsftl9qYogK6dsjAIe0A jfYg== 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: APjAAAWDAIMx4hM6emHh13Ju9o89HUHrhzdDD679aqL57ZYmx9r+n1dI 4s/bmav9H+Ofan24zEN7ZCoorADI8PAU+DuRAQH4O0KmvX8pU+FE6azpSgOmkYFjBsoT1FhMxPM I8mpu/z9u4fnZnkaUFVrPpwXvkFBRrHtwPHt53WmapV8H7B4g67WX6htnq5r6sr7QiA== X-Received: by 2002:a05:6000:cc:: with SMTP id q12mr14285544wrx.251.1556186374933; Thu, 25 Apr 2019 02:59:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJ4XTLAy0T42SZ7d20gu4KYdDN4rN7HKSYkltRw08iJ7iZSp3Y8EJVNCQdDGgATX61mhWg X-Received: by 2002:a05:6000:cc:: with SMTP id q12mr14285492wrx.251.1556186374107; Thu, 25 Apr 2019 02:59:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186374; cv=none; d=google.com; s=arc-20160816; b=UOC+/JMi1qJSsH8NHpnz1EDioDLk86ZfbaOGnoMh1y8EiwRCDb7j7s9LcKCZ7zzPuw AsGq0ZGuTCqN0+oTCR9q4VO2TbfK4xnFtlGyhjNoujBsjrvnTF3Y+FiLfPu7ZJUFpIhQ 2fHHZQaplv3bD3Nuh8++kQJwSRk4wJqyevItq2W1Yj79HUzLpwUG1u99qeybonV80bLE Mm/36lN6915cHTU9SttWUy8Syt45Qh+64/2omjSAgwcsYIWaDam+ENbDz6Ht9XObDWjD aqFJ1sRicu4JlzRzRGNTSw+172kWUJ5peDl+Pli5auGfCSONRBNQ0otFvsjrZfV6+iLp v88g== 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=2k7lB3zYSqZ589filPfBZRV80I08rj+3gKaU91f/H30=; b=VJp7jHrw2ZuLhan+OuTXwNlE3zsFVFkjsSgUd/NfKD3Tpq0SG9FKSUaskDD8WMXked 7MVdldctptS5l41CFqBZe9P/k03seG7l4WBmHW+7xpYSfc0UWIXjYOZziO6x3A6OJF2y UovY4am8tE5c7MzaTGqwHaiJo13mVjUMoxpgES9C4p77B3IDdQmq7LuEKTxSiZjXTsHp BrBlyXGZYa0o95mZqtHWp1LIJoqNMU6jpS9zsfbEoUNEu5b5PBykhf1AkGGu9v0DyVN/ nS0aNuwGGq2/MJ4EJcxZHiCwfwlVyO+2B0bmuCfr+muQlxdtTxqvMNLcJLJnWmI0E7Ih QPEA== 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 b144si1903237wmd.20.2019.04.25.02.59.33 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59:34 -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 1hJbA8-0001us-4y; Thu, 25 Apr 2019 11:59:28 +0200 Message-Id: <20190425094802.803362058@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:45:11 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 18/29] lockdep: Remove save argument from check_prev_add() References: <20190425094453.875139013@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 which hands in save_trace as function pointer. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/locking/lockdep.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -2158,8 +2158,7 @@ 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 stack_trace *trace) { struct lock_list *uninitialized_var(target_entry); struct lock_list *entry; @@ -2199,11 +2198,11 @@ check_prev_add(struct task_struct *curr, 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. + * If save_trace fails here, the printing might + * trigger a WARN but because of the !nr_entries it + * should not do bad things. */ - save(trace); + save_trace(trace); } return print_circular_bug(&this, target_entry, next, prev); } @@ -2253,7 +2252,7 @@ check_prev_add(struct task_struct *curr, return print_bfs_bug(ret); - if (!trace->entries && !save(trace)) + if (!trace->entries && !save_trace(trace)) return 0; /* @@ -2318,7 +2317,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, + &trace); if (!ret) return 0; From patchwork Thu Apr 25 09:45:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916621 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 DEE4313B5 for ; Thu, 25 Apr 2019 10:00:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEC2D28BAD for ; Thu, 25 Apr 2019 10:00:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C05F028C50; Thu, 25 Apr 2019 10:00: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 0A5DD28BAD for ; Thu, 25 Apr 2019 10:00:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0869B6B0272; Thu, 25 Apr 2019 05:59:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 00E856B0275; Thu, 25 Apr 2019 05:59: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 DA4E26B0274; Thu, 25 Apr 2019 05:59:38 -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 8DE316B0272 for ; Thu, 25 Apr 2019 05:59:38 -0400 (EDT) Received: by mail-wm1-f70.google.com with SMTP id b133so5296298wmg.7 for ; Thu, 25 Apr 2019 02:59: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=g7UiZ86l/rpvc7UwmOSqOho8N206ZA+wIfZ1mTqsix4=; b=dOwHq/Ccg9D1jAe2JKQYKCXl9ytLgkUC6ynNuz5P+sTwTuyljylFU0Ybq2YoeMQAUR v5zFgJGStctT4vZagJydtJTsBw2IIEFdJJcmfr4SPSTifLPsdo1gL/ppNtw4U90VX+Bf sHgr29UaiUkv7wYzaf0rQmNogS8l5mzVOZf6CZQFvU+3K5WbZe+HIcc5SnaIcHBen9tZ M/a6byxvGZYXzFrjgboTPDkVFzcl/Oni2s3W0vbHiGWpbuuorkTwa9VhCaYgnXX/vvOP B0/9HmCHaGljIlU74Jvkc+1G47PW2zYtoS8jkjYBCKU7fq6Yo4dikRMlkM25ObMrITgH sczQ== 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/xQXwyu9aKkd2TlMK/rKJx56Bh++iU8xnXMw8byYMQOB1i9bN XWbpsr4+zaP6It+mZGK+J/iXC3ajj+7SXzALCa5z8OOi+UO4tocIn7aPXNMIgc5vePyWPMqLypf 9+vXBsLtbsYAg2pkeCbipaKPRVizet9YT9V15a5T2j+6HJUfPkaZGee3GpEkT/bpG+A== X-Received: by 2002:a5d:6384:: with SMTP id p4mr24440787wru.208.1556186378092; Thu, 25 Apr 2019 02:59:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBoX+UE6w+U6YfOoS/P9hvnyB/diAgb6VIObGq3Ucx2u6+kSPrZG7/85h8yHHnMsrLylXI X-Received: by 2002:a5d:6384:: with SMTP id p4mr24440718wru.208.1556186376584; Thu, 25 Apr 2019 02:59:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186376; cv=none; d=google.com; s=arc-20160816; b=t9tfNhw2YIMA5DsV+Vd7jgAIMikLnLm5GNPTn1FgLi+dyOwaDaRQiV8VtS7mitDcIb l70Abz+d7vESl8+n2I3Hw92ShRMpjWfUfpLBO64AGxg53fNKpQIYl9StyHCkCC0SIIHf zQn+pKDvIrxYJKzSfXazEJU6wV63TqGBFdkqK1LizwYMatiK6U0DZMIeXBRMGC0UMa0q 8I4VW4ijMEhusQWv+3NcWcPmjWTGnrDckxhs0cYU4JzyVMV1EVyn0D2/FVhR90V2DrwT A/CFLtmHFR/ubworXnclpMbACVFQnP4lzkszPPmpgZhQDovUZr3AiC+j+JXvNYaxZ+VC 9DHw== 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=g7UiZ86l/rpvc7UwmOSqOho8N206ZA+wIfZ1mTqsix4=; b=ti1O/Bq3E4D07/ElCT0uf6zJXQJEQLFzdJxp5xOG/J2a0M2FuZB7VyfRSXN0ZZ+9D3 qfVyqmwy+OutP4UbEyR+mDUr5Nv74hx2ZiPsDfhLdInoHWAsCz1zs0j+nDFciyMGUqBo A76LwDqwSg8MQEDMYUzDwDXF2RurQI6D5P4DRPb5o6+agzjnzpqWBif1HjZPq42+gPfu L5atghAlU/AJW7UDWYV5u/fATRrVeYLGxPAIlDtuqwqeKENf6bEL7LMuU1CWtjJkwsSD 7k098AT4Q9QKqDBi4c51ol6QWO+Uvu+2FNRHLbaG6z3qdbqQQDbvN6dHK8IEAsr0OnlA 1kSA== 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 b15si14162789wrq.75.2019.04.25.02.59.36 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59: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 1hJbA9-0001vH-Ry; Thu, 25 Apr 2019 11:59:30 +0200 Message-Id: <20190425094802.891724020@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:45:12 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 19/29] lockdep: Simplify stack trace handling References: <20190425094453.875139013@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 | 55 +++++++++++++++++++++++------------------------ 2 files changed, 35 insertions(+), 29 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, @@ -2158,7 +2160,7 @@ 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) + struct held_lock *next, int distance, struct lock_trace *trace) { struct lock_list *uninitialized_var(target_entry); struct lock_list *entry; @@ -2196,7 +2198,7 @@ check_prev_add(struct task_struct *curr, this.parent = NULL; ret = check_noncircular(&this, hlock_class(prev), &target_entry); if (unlikely(!ret)) { - if (!trace->entries) { + if (!trace->nr_entries) { /* * If save_trace fails here, the printing might * trigger a WARN but because of the !nr_entries it @@ -2252,7 +2254,7 @@ check_prev_add(struct task_struct *curr, return print_bfs_bug(ret); - if (!trace->entries && !save_trace(trace)) + if (!trace->nr_entries && !save_trace(trace)) return 0; /* @@ -2284,14 +2286,9 @@ check_prev_add(struct task_struct *curr, static int check_prevs_add(struct task_struct *curr, struct held_lock *next) { + struct lock_trace trace = { .nr_entries = 0 }; 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. @@ -2719,6 +2716,10 @@ static inline int validate_chain(struct { return 1; } + +static void print_lock_trace(struct lock_trace *trace, unsigned int spaces) +{ +} #endif /* @@ -2815,7 +2816,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 25 09:45:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916629 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 AD0B214DB for ; Thu, 25 Apr 2019 10:00:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EACC28C50 for ; Thu, 25 Apr 2019 10:00:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 918E528C57; Thu, 25 Apr 2019 10:00:26 +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 0D36B28C50 for ; Thu, 25 Apr 2019 10:00:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 656726B0273; Thu, 25 Apr 2019 05:59:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5DB186B0274; Thu, 25 Apr 2019 05:59: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 4CC3C6B0275; Thu, 25 Apr 2019 05:59: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 F214A6B0273 for ; Thu, 25 Apr 2019 05:59:38 -0400 (EDT) Received: by mail-wm1-f72.google.com with SMTP id u6so5302112wml.3 for ; Thu, 25 Apr 2019 02:59: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=RsuC700IyFocvKBWm+t5JYl3HGqgBnb9GUExX2P7h50=; b=QKwc2jjmoMkikQ8TV00wkKsyyRMK7+iwKK4p/Hxw5KxGkH+ruYKNojh3JknoKBkVxb 30ZHu7Rti0DruNJpghIL6x+x5S6BXQ5hM4ztcFtF+DnjI+eBjRXwbv2NvnnDPYh2r4/+ 8sSwaiMGGEXa+oxi+960YKOhlKFx2SqkOjWRGJ7uWvTajtsFJP2xrfl8ItU4/0d8hsjC E5H5652DLv8c6pBUJ12wF+24vhiff+d//6snj8NmoxOjykAFy9K98LMlNdRYxjo3qJhx +ZRxVxrOSsmREsVbJ8nWqLg9bJMoWaJ0TVWhAIaFvtMifHA0BQzKuujMuA55AgqbRtcj 6GEg== 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: APjAAAVe1TwZIvKkiO1OVLzw6khx1ggyFEpQnQrtTIA6HyOp+cpcyoYY ppjIB5cHSxDwgvyvkczBFFz6ikD2xre4PBtgmXLk05Ull8PKcYNzBlCQ2R2a4MiDCz1Ycwug5LI ubT7/58bQv6l8Y35VW1PSkzM7SryvGSLPqGojfzykY1m8rcJ5ml2dBHOQpi2jcmmj9g== X-Received: by 2002:adf:dbce:: with SMTP id e14mr24745711wrj.249.1556186378529; Thu, 25 Apr 2019 02:59:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqz2YuNmmrQwXeR4UKtzm84x8sQ45gO6qQi6Ki/a0T2TEcsH+Ed1dhMoTGvsl/bpr1pE5Es6 X-Received: by 2002:adf:dbce:: with SMTP id e14mr24745649wrj.249.1556186377434; Thu, 25 Apr 2019 02:59:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186377; cv=none; d=google.com; s=arc-20160816; b=UEEMPvseGF3oqU+BlpT3nmjq7R1Kbl53vBbG0b7uDxk/YMiiM6rdGsnOFcpr31S8sG 6oEyyu2DlIVjPBkYt1k0Y9lOJJ/qdDuM1EsB2KKbDd6ULKKtr04iz85371egj65UyAn/ FZiFdrq5g3s5c7VtiGqiTs3uraaN/Tm6LimFhPLhlxpZxTxrkndRLtViN7UrSEkJCrkw ZI8ew4GGnovt45dM6ZfFHQ8rdnA6Vvq0gHXTn31BXpAIia0UXQOEwie0f2ZpITXEpy/d rlH07ECYQwOKUfV0f4s3JqgIJc3MXza9d0AlTeW+vQPEX4YIzyt6yQssSS2XYPQMo766 nVIw== 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=RsuC700IyFocvKBWm+t5JYl3HGqgBnb9GUExX2P7h50=; b=bQ/wNFg82Qw3EK3cPR5O2X+RenXja/rvheDDPMUcFt/RKavcaqX5L+sGGzna7+hRDl 8vCvkmwymM+eemxY25siI9IVMvu3Xy/30iP6bHkAa8h4+DJFcdj7AUPtItOZc4DdczTt N3NnS0sZmD0Jjs1JtXvmh/P2vEIiYG5hMu0cDhiq6BaldveqR0T+N0B7BGTx/0oDrE9Y /Nrl1sHxtfj4LzUxvQJFHOe722038HLAxTHbujrxKDHLZNFrovlIZIxtrCD5nNuRSgET cGCyMAC3A7iksYrbEHRvh50QDtecHktAFTKckzU/HHcq1higUXTMRDeS7DDfkl2m/Xam 97RA== 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 88si15749706wra.283.2019.04.25.02.59.37 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59: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 1hJbAB-0001vz-NK; Thu, 25 Apr 2019 11:59:32 +0200 Message-Id: <20190425094802.979089273@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:45:13 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Tom Zanussi , Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 20/29] tracing: Simplify stacktrace retrieval in histograms References: <20190425094453.875139013@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 Tested-by: Tom Zanussi Reviewed-by: Tom Zanussi Acked-by: Steven Rostedt (VMware) --- 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 25 09:45:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916637 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 36D3414DB for ; Thu, 25 Apr 2019 10:00:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2755428A08 for ; Thu, 25 Apr 2019 10:00:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1AE8428C50; Thu, 25 Apr 2019 10:00:34 +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 7BF6E28A08 for ; Thu, 25 Apr 2019 10:00:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C9CBA6B0275; Thu, 25 Apr 2019 05:59:41 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B816F6B0276; Thu, 25 Apr 2019 05:59:41 -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 A6E366B0277; Thu, 25 Apr 2019 05:59:41 -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 5B8586B0275 for ; Thu, 25 Apr 2019 05:59:41 -0400 (EDT) Received: by mail-wm1-f72.google.com with SMTP id w9so2409174wmc.5 for ; Thu, 25 Apr 2019 02:59:41 -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=vMJ6lIE+mW5bTpuFqwrQHdPM8CwRJaic0N+RE5m4tOc=; b=bAkq05bG7Qv1QAJlCJ4Yiez4Rr25r1gfTvufpWsrDjo6ZoN8D3W3RHj90AEgv6IF2E c/Y58+wYpx2jrLBUunHHUp++NHkqAhZqs5UnSvDGcDwbRepVAJeDZVKQL5ujXeK7jriP XBWCzKKjAVFwT67UAFne6MKABmbMa2NkL8RjkfSSfRWAU/4gq+rfb6VZMtcPW04/4S/6 0f/Z6eSxE4k0wcU/wtu5v15Y385DCxJSto4tz/fbsYE3RJTjfsJIWuOTqDvTokURR/Xz x/+yboEE9/3m2zfcQFEd6aB1vWDrsXws/h3TvHg+rxFSCmcIJs2N3xGxVUWeLMnheuko KbrQ== 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: APjAAAV9x7ewrl07leANhgH3irvOVJQD+scHRHmR6qEGa3N5Zi/NHLV1 OtdiLZG8cGXTvVQ9FWoVyB/gy5BBg29VcpTbHrnY4Hpu3bAsaAKPK8Oq6/lvFKeXaSzhuwLAlg3 fqelklm5JNP9i6nUPPKzMoMCRImT4Fz5V+sh2xLXnxxldUy3azzQ4LIGtUnvpNmNqrg== X-Received: by 2002:a1c:1903:: with SMTP id 3mr2798396wmz.103.1556186380885; Thu, 25 Apr 2019 02:59:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzWxpFy3AsLx/y72G3P8vSU57shnLvN98gtGQMGmQwJI6+ZkoFBC9SDBdiFASn3l8XViB/4 X-Received: by 2002:a1c:1903:: with SMTP id 3mr2798336wmz.103.1556186379911; Thu, 25 Apr 2019 02:59:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186379; cv=none; d=google.com; s=arc-20160816; b=waY0mz2JaCBlskcWgqakysNwxB2kqRvxRoizJlkb0iXwR+abwFhu0Ii6VIYD93uihC cUQngwtbBxd9BMCcm92qMcV/YG3Y68WSJ/DgevNjCNOthK60JjIB6DvbEoD7XPspysYn DyPfpMU3WTlZjWJ9lPYulIuZiiSMCnB6FlYV1uMKZkQk21eM7VcIjS/PEO9pAuohkJaX ChaqNppzWJuapI0JR5+WDioVgv78geXsDnxEEoULf2c34WFuY6mJ3ZNFz15qS3mZzWwm yjlASqUiXRrI64pTccfS13QVNVa1yKSWgfDyotJmKe2HfpQ+EaxJICOuEyY+3xJr5KtD nJpg== 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=vMJ6lIE+mW5bTpuFqwrQHdPM8CwRJaic0N+RE5m4tOc=; b=tjd5A2By8w2IKNwwDsa19kLI+dDgp1jF/+3u7izLfHAY6mD+4PFbm/B1Y/MDnxZiau vz5gC4iQn0/uBTMETHrLkzYqG4gtdiRKv5dKY4pALESd3CRapsv5C7F4wLU7cF+IuBQt TDLIdnRgtOstOrDKWqDd5g3CfzHlqgv1alOZHHJujkMDjzy794UE9WqjpX91l8M0w1Qd pMgHWI8HLTD2CkyC3aIGL9kxPXEEmRPXt1SH3iX2CbdT8/HwZ9wuC2iWwtsVZT2bin1Z IvEZkiuLdQ8G2/CozKJrEiwOi/ronlyLDSmQAOKlrlgQEt/xLT7gzDAoCh7KaBtOsG28 Kr+g== 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 x184si14896500wmg.6.2019.04.25.02.59.39 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59: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 1hJbAD-0001wo-Fc; Thu, 25 Apr 2019 11:59:33 +0200 Message-Id: <20190425094803.066064076@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:45:14 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 21/29] tracing: Use percpu stack trace buffer more intelligently References: <20190425094453.875139013@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 4 nest levels, which are 128/256 entries per level. 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 --- V3: Limit to 4 nest levels and increase size per level. --- 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)) +/* Allow 4 levels of nesting: normal, softirq, irq, NMI */ +#define FTRACE_KSTACK_NESTING 4 + +#define FTRACE_KSTACK_ENTRIES (PAGE_SIZE / FTRACE_KSTACK_NESTING) + struct ftrace_stack { - unsigned long calls[FTRACE_STACK_MAX_ENTRIES]; + unsigned long calls[FTRACE_KSTACK_ENTRIES]; +}; + + +struct ftrace_stacks { + struct ftrace_stack stacks[FTRACE_KSTACK_NESTING]; }; -static DEFINE_PER_CPU(struct ftrace_stack, ftrace_stack); +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 25 09:45:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916633 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 4725413B5 for ; Thu, 25 Apr 2019 10:00:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36F0628A08 for ; Thu, 25 Apr 2019 10:00:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A9B428C50; Thu, 25 Apr 2019 10:00:30 +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 98DDB28A08 for ; Thu, 25 Apr 2019 10:00:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2F8356B0274; Thu, 25 Apr 2019 05:59:41 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2AA5F6B0275; Thu, 25 Apr 2019 05:59:41 -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 0FB256B0276; Thu, 25 Apr 2019 05:59:41 -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 B3B566B0274 for ; Thu, 25 Apr 2019 05:59:40 -0400 (EDT) Received: by mail-wr1-f72.google.com with SMTP id t9so20481995wrs.16 for ; Thu, 25 Apr 2019 02:59: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=YyoaysuntdWse+rzlTM8zXy679ccU9UxwPcaNstXB8E=; b=IVYvX7UlRLj97Se8dsWxNszEKse5U1Pk3Cgxcs0CF9Cx4VGElwDv8najCxnkEPq85h PawmrmqGdBDi3Gjqh3s6iJCzwkkMITyhZPDNPbYVX00kWFmJlprCuqhTCH+aCW5s27eS p+Om3LNCcX883OPlGm8Byg7ztYVpxl9ASpYHYuqw/zhzvkFCs68CLZEP5msiolXkEWhI KsHXEYntfKGrZ3hCkJLQnSwzfyUDrBECHPXMTOxlYMuDWtrQyDcVAS2AkZX9m4Ul9G3Y HCyIkN+2PGugOF3YLM5er6O2PLRditBfF5Q7dFedrFMTauk0HU8F+DBUUxnTAedJozcW 4QsA== 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: APjAAAVEOGhqr8ojAAwLNdZmh6hqBufawM+e71NTwK68xqajCDxfwvf7 jG/dfIqNbebrWrd6gdSMDqbYd3Na2XESZAYQvK/YXel55SsQ3Wo0bGRErZzEIqK5FaWVGu0Gakh bDO1/cEtCmkbr94Jr/xTF5EXzLidSLo4BurKHY+TaFZoFhKzs7iEjMw+EB+zebW/ZSQ== X-Received: by 2002:a5d:6291:: with SMTP id k17mr26240628wru.223.1556186380272; Thu, 25 Apr 2019 02:59:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzUrVvrvyrP3UPcI8V03waNwPXXdPhNr7GD8te+hngnaHFbwutLll6QrRk9xWpE09D6npgx X-Received: by 2002:a5d:6291:: with SMTP id k17mr26240585wru.223.1556186379435; Thu, 25 Apr 2019 02:59:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186379; cv=none; d=google.com; s=arc-20160816; b=V5U9rEx2Z+VAftvvpEqGNavjS30KVQz+XEKmYJJgTSpxEmy9OvWTIHJt6DafsQAp1e olmO51pBWs/htSXWDFPUbvfw03i8aUK5N1OabG3IbXcLONV8qKB67hHzuyGd1nGTtfpx ZvynEky6EPOX5Ownfkj2DJRJgY0B4AewPY6iMU9H1xkpS74BOkGUtd2zKxQrS9PGOjN8 702HmOStEKPOAE7Itvpgeb4PTPmWju7JcjieGASmdLxgfGxgSe9OQJNX5z8fj1TmEtL6 8uisiC8AfPA/6pOZvjqXDFouErdX3S/zY8xFd0RXaHS0FwVC3wGgOIbnOFv2taLRLbrp fi4w== 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=YyoaysuntdWse+rzlTM8zXy679ccU9UxwPcaNstXB8E=; b=QVIz4/o/5JDxgqIXVY5pJzci6gBjRup7HRL9WuvznoKpYWE/QncxHouGoiUWvE5KBY UUz6YExD6XVbtUYC1lnjVNNmvCHBJf9S0i3Y4ZiiWwKS3QuREIo6BRN+vlMNm8mXFx2h 28w+3zSc95dViKm564GVCKO/KNAPMEjHmOq7pFdOGMzgtM2e+HSfkodbWbX+fUeRbQX/ E5EykEIRCjQ1+XrxLFp9ticrPQ30lzlNbJd/USSX35OchDhh/pgVRnVI3XEzTJ1JmP4a rj4Os1h7KKYo9JCk7TjL4Mm+hCSKGt9d+/G0Qau67My40px7YSdL/h2PTao24cwYkngA J8Bw== 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 v7si15802782wrw.367.2019.04.25.02.59.39 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59: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 1hJbAF-0001xP-E1; Thu, 25 Apr 2019 11:59:35 +0200 Message-Id: <20190425094803.162400595@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:45:15 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 22/29] tracing: Make ftrace_trace_userstack() static and conditional References: <20190425094453.875139013@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 Reviewed-by: Steven Rostedt --- 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 25 09:45:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916643 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 611451805 for ; Thu, 25 Apr 2019 10:00:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5191E28BAD for ; Thu, 25 Apr 2019 10:00:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4477E28C55; Thu, 25 Apr 2019 10:00: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 B86AD28C50 for ; Thu, 25 Apr 2019 10:00:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BF8336B0276; Thu, 25 Apr 2019 05:59:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BA8B26B0277; Thu, 25 Apr 2019 05:59:43 -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 A715D6B0278; Thu, 25 Apr 2019 05:59:43 -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 567876B0276 for ; Thu, 25 Apr 2019 05:59:43 -0400 (EDT) Received: by mail-wr1-f71.google.com with SMTP id x9so20463951wrw.20 for ; Thu, 25 Apr 2019 02:59:43 -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=fAbXkfpdfdNbQ6xUI1nmmQHB0FsWJN2R/uu7ZoH1zKs=; b=HvAin2WfFi6+pTYxr+rFkFFFekDiNlfePFJKmAYpUAC17tfo7VnawVFmoVKJfr1Yh/ XLAvWzyP7Ja9fkH4EoQtDU9xvbPnjUeGiaEGdh/zIZdGbEZ5WllkxMsSsW7fMqwjMVcX o0vuA0QvkOJWmDX0M+sgMa+M6syYYPDqPPPOi2K6g6UGAdpEpTzVsdfmgXvI27CPdVed AMZxbNxnp5TNriwbHftIm6sedZ67U/hzAuzRX5QI/v5QXzWPVYo7Wet8Rh31O1curG8Q 8lM+sFwM9vnq+SAcw/ArBLGznIxXctQJ1srLmzS+vkpe5CDsesZESJxcOI7g5wUfHMrr wbDg== 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: APjAAAVKzxdKdikJ6PM/LWrypw67SSwKluTbby8bRWBGnuYksP7y5+iO o16SzHROaRsqsqFuWJIDSL9oYw2oFK3SMRbFZggMvhfFiLki4LXNNkvq0JqSl8rKlKO6CEj1ln6 rq9lseKtU85tdsywQHsR57mbt2yESiLRLqw4nuzcBXhqz4LC4YOVQiO4J+yxrCIoPMA== X-Received: by 2002:a1c:20c1:: with SMTP id g184mr2921965wmg.137.1556186382896; Thu, 25 Apr 2019 02:59:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqwrmk6QkOl8a1haNOV1lLySM6J0WMDERFp/dcAvLNeUYbWo6KGZKlnsMqC/Idi/oF2zRtri X-Received: by 2002:a1c:20c1:: with SMTP id g184mr2921904wmg.137.1556186381726; Thu, 25 Apr 2019 02:59:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186381; cv=none; d=google.com; s=arc-20160816; b=S8DuZ7SkJHK7CiLIJ8LJbj3BNa9AZvwUgVv7Ec+FtcgZVpB9gPh3m5D5yzFn0705p0 5vnFXj0WM6Zj/IpyrW2oN2WZi8f3FPfixzo8Q151qoa14CeQd7nXcXXzGbp7cNxYo/Kq DKRNaseyXbv8pGE4KkWnhGMR6rKFYzDKHK6ynl87ecljWreqLEPJAxGOjAnW9twKN3TR MoCxkb9wYSkwSilMJnFQK7Jr4kJyhrQD53ofw0fWhvzsHOQxajyMndxW4Dk33OK8GW1e szQVWcOAE1luB8mnnrNAS926NzOH2j7vOZbsW8ohy5P2gh79JWTeBMnmeCvzBvI1ebhq jHkg== 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=fAbXkfpdfdNbQ6xUI1nmmQHB0FsWJN2R/uu7ZoH1zKs=; b=FwrtBadm5bnknFsCKkNIijlJKlTlI5A5so7YBNR7F8FRHoiQTvVlW1yPvp8+riFkKH PIMAhPnuZBcyD00piSr79+bCj/qlHHU/O1d6ECUYY0QAuTejSOwNBefBvxA2yTxOrJJU y5qfYyqsLONOMYeBlPEA6evtlgPj60FCCtzNND0pYRv6p10mIW0lF03NXuhFXKAdxL8f zmoEmk2zbYT4DgO40Z2Et4max7QXHWv2dmhCiiMjjim8qFWNgMegiqDaoxKLswZa+ezG C8NJ8Tmqz9vNQ90gz8EC319RYPbqFGExDUCH0Y7rGwebSqy5Z9J6brzFinIwuRfRO84B yyLQ== 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 s5si10175807wru.317.2019.04.25.02.59.41 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59:41 -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 1hJbAG-0001xi-T6; Thu, 25 Apr 2019 11:59:37 +0200 Message-Id: <20190425094803.248604594@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:45:16 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 23/29] tracing: Simplify stack trace retrieval References: <20190425094453.875139013@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 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 25 09:45:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916649 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 965D613B5 for ; Thu, 25 Apr 2019 10:00:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D5F928C6D for ; Thu, 25 Apr 2019 10:00:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7AE6C28C7A; Thu, 25 Apr 2019 10:00:42 +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 E2FCA28C6D for ; Thu, 25 Apr 2019 10:00:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0ADB06B0277; Thu, 25 Apr 2019 05:59:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F2C1D6B0278; Thu, 25 Apr 2019 05:59:44 -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 E199F6B0279; Thu, 25 Apr 2019 05:59:44 -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 8EC9D6B0277 for ; Thu, 25 Apr 2019 05:59:44 -0400 (EDT) Received: by mail-wr1-f71.google.com with SMTP id v5so15998694wru.4 for ; Thu, 25 Apr 2019 02:59:44 -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=iIZ12KmXgTMRqrmPXZq94HRmBBw6/nFl7NjLs7VR6aM=; b=KtVKnTzUVhrU7mx0bbJv5nhQwIXkP6VyRhufvZNSojkBIool0Taa9jwPqR7DogSwRb GUB7fXQdeqeDs//I50TMvVtM9mGDzbjZpaLNvp5eo8zC8BS+HzoFOyh36fVoV/0dfgyg Pw7ZRbJhBT+5/H4JJjw5JaUhFMOCUuJXeIQ1T+9KzZsmD6/tcIzpJkqUOrcwLMX1LYDX AmDHZMTK3CJtdhbEfef094PYVtAuX+w4g/KBJLpeoA4wBehH406DvjAqByQEGkR/xH7R N3zOuqyZ18/pX2B4S2TH9ifoeSiDjQ4vkmoySR6Zs7GU2sydoqtrSTdAka6U0W/4DRK1 veVw== 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: APjAAAVHLaGFv7AwunbkbgrYb7i3wLNmO5cAkO1lJWxsmdYTxXPWOdAV hKMVn3bm1Br3yieirS0WT/GqVv+1VXxr/4gSWnUvbcARKVEL/UJt7KBGikMUpy+wNy10WB7/1Oc niDCM22Vfy+1qAcpihpFNKaNUOWT04avTbBL4YzkU4X5GtkqIfltjLUlVMy3Y/hRoZw== X-Received: by 2002:a5d:6352:: with SMTP id b18mr10312368wrw.24.1556186384119; Thu, 25 Apr 2019 02:59:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqwNzIQKvx5Wg4AslR95Odf/E5q5/pQyHiOMNJMO4SsLlRLcfU5ow7bY4vT2hgjYr99N63mo X-Received: by 2002:a5d:6352:: with SMTP id b18mr10312292wrw.24.1556186382786; Thu, 25 Apr 2019 02:59:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186382; cv=none; d=google.com; s=arc-20160816; b=w3nd5d1MyyJgYo8AI5XBLEImMWBuFt6rURXhaw2y+Ido16zVOn6pHm+o1+oE4PbIlS zdm0NDK6FGR7JF8+WCCZENei65B5ijzAwRYF9cfDf2zXePA7f4nHPY6Od+mEBhvDYiKo 9E59/YWpYgtECgSGf7CIW90l3h+XQmhUDMVuQ3yQ/9nrj/vD4oz+s0ZxwHkDPlONaFQj uQNbJPvtQ1oLK7dKrVoFwM5eElb4ASStmrs0FE2Whoh3np6bRzDO936H/gNNpItVYE0u Nyl+wHaLe5iYcy9atQz5XmM5dQVnIavQDqaL+w9RvwHHgc4RzLWxCy1VSUdEciF9EDLI Tzng== 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=iIZ12KmXgTMRqrmPXZq94HRmBBw6/nFl7NjLs7VR6aM=; b=FpQPNYeUVe9pYY6Asq+8M3V1mZQeJbav+H+S4xeZi1Dd4Z4PDk5i1h7OFl5S5Us/fU 0sMNiIkE6uSm7dWl7W8z7w5uET8usVsDgDkdw2SvHXmbdDBBdjca/mr8/O89fYraugL5 A4N6E6bMbprcsvSm7NSMFcaJp02YiLThaIiU3debzEe/gyobv/K6fhDD1iet5P7VbuCA /ZBze0bo6Pe95DJpU8xwubcDFFjUu/siQposLK+7hG5y3b+WeX2um9O6vwYK10N+PNwT juMq9GBZra8PJpxmDHSaTZsrFvaEAoh7UYvIzshxR/pHnztwlFlnPVEmZZtes8PRbewF Tl7g== 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 a8si798242wrr.413.2019.04.25.02.59.42 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59:42 -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 1hJbAI-0001yH-Jz; Thu, 25 Apr 2019 11:59:38 +0200 Message-Id: <20190425094803.340000461@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:45:17 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 24/29] tracing: Remove the last struct stack_trace usage References: <20190425094453.875139013@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 | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) --- a/kernel/trace/trace_stack.c +++ b/kernel/trace/trace_stack.c @@ -23,11 +23,7 @@ static unsigned long stack_dump_trace[STACK_TRACE_ENTRIES]; static unsigned stack_trace_index[STACK_TRACE_ENTRIES]; -struct stack_trace stack_trace_max = { - .max_entries = STACK_TRACE_ENTRIES, - .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; @@ -44,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]; @@ -93,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; } @@ -108,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; /* @@ -126,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. @@ -163,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(); @@ -265,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; @@ -329,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); @@ -339,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 25 09:45:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916657 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 997E21805 for ; Thu, 25 Apr 2019 10:00:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8746828A08 for ; Thu, 25 Apr 2019 10:00:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A47C28C50; Thu, 25 Apr 2019 10:00:46 +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 F1FEF28BAD for ; Thu, 25 Apr 2019 10:00:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 08DC46B0278; Thu, 25 Apr 2019 05:59:47 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F2C6D6B0279; Thu, 25 Apr 2019 05:59: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 DF7DA6B027A; Thu, 25 Apr 2019 05:59:46 -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 8FC6C6B0278 for ; Thu, 25 Apr 2019 05:59:46 -0400 (EDT) Received: by mail-wr1-f71.google.com with SMTP id u14so20601064wrr.9 for ; Thu, 25 Apr 2019 02:59: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=Du/uj/cd28Qr7pRRJQwOs0SgQerLJnpQKao5Hutj7cE=; b=KM/z8zaYzFJq0APPoapgMt7STu5G+hMK6mSn207FSVr0AYYes4alGUVypgL4EJIDCw r7fM302UFKjzneg07wfb17Pk70IHS2X9unpAsQw97W4XMD2ouECkgJ2N83UIvxbCx5/K Hm3l2WmUGQeUm1VgWN4sbOREXTfJcX2RsVn0wFp9+wRlFanYuk+XsBNh8XRvc9MP08ts ILJdyBht1xZyDUICK5oP4ACRP+f1ACPlk+zed78h8jVjkIsIcPcHEvJ/ucPDuEf5NuES pEdL5uaudN3iFMXwwNmrupcLAhfNrRkKTQ7n6jb0y47+ntLMjZI3W5nkqd2BKrMoMvSh ZhuQ== 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: APjAAAW3Jk4GXK3rVZWRZFvRJOoLIjLUshlL3YGwte9zZjVLZPUJ0ijZ lS3qGYNOAmeE7en8gsqWqq/DDoMZkBk7tfkU/jGaO4lX+TvUb5b9rALwUwKszuSJQKlotqLu6tG r3/Ga327GwGmAodg3JjBhkWtt7cYpgE5xt6GQO+qtO0tcjahG2Hzd+A3R0VvkQiOSkw== X-Received: by 2002:a1c:7518:: with SMTP id o24mr2817228wmc.42.1556186386123; Thu, 25 Apr 2019 02:59:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzOI/dLX81SrdhJli7aCsK/ivYD7VXp3uDSYB5IZjCmlMdcyEm4x4d5iu7UU3VXPznvL110 X-Received: by 2002:a1c:7518:: with SMTP id o24mr2817186wmc.42.1556186385371; Thu, 25 Apr 2019 02:59:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186385; cv=none; d=google.com; s=arc-20160816; b=K8Hqa8QBSu8iJYKNC3iuQcumS+KubUVpslDpP0wczex9Pjj8HvHUUwe/08ySJlLjWy Wc6Hm01ZNRwiDW84oR4lOzpWGvXsMkMgFxE19k3eZyq5jlX9FWbeg/FsGRu8ppxN88ep 4+FhMmJZI24clBWusOMCeLd9SS0CykredCn16cHQe2bkhN9FM3BQGBj4XHBbCtzhcyTv jE55kQo21zUypmWXizr3on4ua5UnM0FUwgYb1vk+TH9vUaOOxOgDhNBOO42ibAio+F2M i6AvQwCVOi+Efq+h3IFvHD7tVFapB2IDNpa1zwji8xx98fmPMbY9VXRSltiFT+ZsAtNF cqYA== 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=Du/uj/cd28Qr7pRRJQwOs0SgQerLJnpQKao5Hutj7cE=; b=Jcb/90stK/WizTM0YwCu/OYuNX+Wj6848cS8Sl6CtrNFSEa/c/G/GWmEmjkZi/GhAf cehNi3S8TthKY0VeKlIfKD14EpZB/TODsZNTrcqTr2FfwTLOo3oD4Ulmqx+jlZ0I5dc7 hBY2rueuITKfmThva4sxVWp2c1VX9JxY8PYztxSmbEwXndkXf8Y4rMEREv+ZoSdm+VI8 K0fRq2jXcyM69yV35jiELQOw9EVuWoU2K0ALuvJI8BcAebsYgJYyjNH6vfg/y24tlbzf jKie62G8bXn45NwWsvSqIy1vbD3h2MMOjhsbcxFy5YEbW1Ih1zlERtJEEiFvLL/WH0bt vhfA== 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 t6si10491435wri.430.2019.04.25.02.59.45 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59: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 1hJbAK-0001yx-7e; Thu, 25 Apr 2019 11:59:40 +0200 Message-Id: <20190425094803.437950229@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:45:18 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Miroslav Benes , Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , linux-arch@vger.kernel.org Subject: [patch V3 25/29] livepatch: Simplify stack trace retrieval References: <20190425094453.875139013@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 25 09:45:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10916661 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 EFA931805 for ; Thu, 25 Apr 2019 10:00:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0A0A28A08 for ; Thu, 25 Apr 2019 10:00:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D478D28BAD; Thu, 25 Apr 2019 10:00: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 44D6028C50 for ; Thu, 25 Apr 2019 10:00:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 064D26B0279; Thu, 25 Apr 2019 05:59:48 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F29B86B027A; Thu, 25 Apr 2019 05:59: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 E40CF6B027B; Thu, 25 Apr 2019 05:59:47 -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 96F816B0279 for ; Thu, 25 Apr 2019 05:59:47 -0400 (EDT) Received: by mail-wm1-f70.google.com with SMTP id l1so1708509wme.1 for ; Thu, 25 Apr 2019 02:59:47 -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=AbGWBfsmiBtGe5Q12XU2KARDGzfPBnL23OmriG/Tdzg=; b=tm30XNqn3ovaEmLo0MZkjsLVMYMNtmh3BvLFUAFHFZccyuCADT9Q9FB/CHuCM5aJKO Yg0NewQU4hptMTLiTShhaI7n0gfRDxfhY0/eLN7XunH76unXmBdu6pO8LPZnYuwXjWT3 8MuIhr90ADlILiAYV0Ascz6CB9DaLQCEOBAr0DcmgiYYlPoKqPtF/5kTPRJvKfq7T4KY 1p0cX7L2dXCYvNjJ0ZiZ/WXEL3mCX6lqwA/1gkxzx5UyZBJlPnBsPcKB8/oAJYWdY0Gx 7RG4+KA6J9miccrpClz9mEsl1NzSJLJ1b+gCFj3lkGUJ4QGAOEKs0qk1JR2ZPS48NdKo esUg== 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: APjAAAVq6GYuL4nLkbxXfaQTFeLwDtcyTG6hFCogEaDrBoeYe4UZjO5Y k/IUDtNAUyIv1z2q6RSOlnn97nYMjsPQQIfw94UlZ3AQuEBqoUnNGSKkfiNGmDUzffKdOa6+IMs m92OnhcGQSmZ9WRAaCh/wTBh9RQz0AULhQZNtWE7UqVzdTguro/YCTKPt2o4Ahu0Jmw== X-Received: by 2002:a1c:f70c:: with SMTP id v12mr2747557wmh.86.1556186387132; Thu, 25 Apr 2019 02:59:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwiuxI86MtxfLO6beW0Som5MhFbckgVBTop9Llx5NI02tzpsz7mgHy07ckk1O96us4U4/UY X-Received: by 2002:a1c:f70c:: with SMTP id v12mr2747504wmh.86.1556186386299; Thu, 25 Apr 2019 02:59:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186386; cv=none; d=google.com; s=arc-20160816; b=ATBaH4SIcIVJ12wbLpma+0iTw8Qi2tkYMw7qohtR72V3PZFbC7AciGbR/RhZVeiYlk sDCcXl5Un98FGPXL2RPOATzp8c/56sIPf9ZmjUjtQGiTWFC7DY9FIgDeOGIRZ8KTWjND zWR7FdIFRVV+il+P5CXzumQ7ZKOaHg59NLRRj0NV5PuV7DWmQmQnjMYbk9XGurXnCWti LAVSOqNJGBWQa4wvgG8lAxBLsYukJJwziSril8R0C8lHpmNCHOaDx4yChOEx+gti27Oj mRAbJPyTwNKbHFOnzx3e9jkeVtJp0Ys8nyZjxhYAHMZ5fdYh55VUVCz2/fSWrNS7fWQh mrhQ== 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=AbGWBfsmiBtGe5Q12XU2KARDGzfPBnL23OmriG/Tdzg=; b=xu27a479TVqDmg8ZtKo6EESUt1GpPJmBcpZa8mSZiImDPUwxvDgsqZNLgERkEYL9UU tC2TgI3Vgf2D9R+DcE18zXU8LvoVK3s/9wv/kVSXlaT63tNiiF4VJnezW7Jo68JEIB5P WavNI6iSBd+2WuzZdtI+8J9yRBQhVM7yrQ25MlCz+y2r7qqWNx8m4xBO06th8HhfHogx KRG6PgVxH5HR0U75wB4JVscoD0bpoq2QdnHv7R9wjF4gJdm4279FVsRwqhqR4LOyDkfx 4M45GBSDQHH+94gC2VLAZTaYTu4PijC1CMw/XyEwH2dZl9h4tyi4XOzppzecLy7uPKRF L+2w== 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 z23si2940255wml.135.2019.04.25.02.59.46 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59:46 -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 1hJbAM-0001zT-1S; Thu, 25 Apr 2019 11:59:42 +0200 Message-Id: <20190425094803.524796783@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:45:19 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 26/29] stacktrace: Remove obsolete functions References: <20190425094453.875139013@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 @@ -72,14 +66,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 25 09:45: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: 10916665 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 2ADAF14DB for ; Thu, 25 Apr 2019 10:00:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B47928A08 for ; Thu, 25 Apr 2019 10:00:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F6C728C55; Thu, 25 Apr 2019 10:00: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 8CD1E28A08 for ; Thu, 25 Apr 2019 10:00:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5496A6B027A; Thu, 25 Apr 2019 05:59:51 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4C9466B027B; Thu, 25 Apr 2019 05:59:51 -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 390D96B027C; Thu, 25 Apr 2019 05:59:51 -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 E36406B027A for ; Thu, 25 Apr 2019 05:59:50 -0400 (EDT) Received: by mail-wm1-f71.google.com with SMTP id b133so5296633wmg.7 for ; Thu, 25 Apr 2019 02:59:50 -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=dtwsC8n4B8GouCY2f1douEN0y/UMZvMUJmpbBiyuz7o=; b=mhuuAUbANNu/SqvbAygpL7pXBuB/dGudlq8yGqDVOjqMsz2viKaRvY1T5NMFeznfoZ OAnGDwJGepvWt8FCKlxhlU0NCfOY3PYkuthd8xOzDc2J44RTDpRwacuGiNnMWAjvO9U8 qOcOtPZbIzAX6nzXANZ4p5tEO0miB3BYNxRImt+0x1jBTKtjuDfSEvaavzDOF/4P9a05 eNJw7n0pOgLtqQ8eezVVzFWFyPa148+DfoUSTyhsfhuxpozlZjrvd51aYJOo/Eo+iZrI Vzr9xsawWFu/sjb++AI2o6M4tThSqYMz3XEZ3J3jsY+JvSiGmQwKGnvL1frXwUZMGRLl arPw== 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: APjAAAV2WJHPnfBiEboviXK5//4WsEFZBmkJFy/MJAUtKBZu/eR5LGhB MwIcf6sgCbK8dDPEnxxKcvUb9Aj9ZSYO4SMYXoit2LHC3fddQr2eB5y/CUmfMgLgmBFKGjNyvJD q8AC7GMEeSLdbpFNz7iu09CnqH7WuoYsSpK2XjvchXZ0F80XdYXMyy0hcTgzS0BZWgQ== X-Received: by 2002:a1c:67c4:: with SMTP id b187mr2757788wmc.148.1556186390458; Thu, 25 Apr 2019 02:59:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwMAB9JX1y98M5c9ObK0pFWBLmWNfbtMh5csZ6VU10y01WI/vbAJARLb8bmlDu2UjSU8UZD X-Received: by 2002:a1c:67c4:: with SMTP id b187mr2757726wmc.148.1556186389308; Thu, 25 Apr 2019 02:59:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186389; cv=none; d=google.com; s=arc-20160816; b=xUUNw3neFUmwIqWo2Y/t3aX4dTSkiZfM0DBN7HmWdfoLst1bPBk+4CnYi3+Lj0U2/m HV7oiwtoUsqyhVF27aj/chJ23niexz6tCNVeaC1hlwKy23cQ+xO3xC3ynV4yqZtTjovR m8jhTedTCTk8l2kYIfbx2dDEYGOzy8queoXA6wNeyE47DDyJsKJyImaXpydlNHKl8dUf +pvDKW2FG/YPPM3mThDuAmd/oiangyAigMg2cuvoxCFPgU6NiiZS8xPndhG4WglDmkSZ F3hrIe4RKDgMMhclkzSrm/xCFxQxDGKR4xCtZQWFFC439WShtLJCMXVIgww39aIFl9UI nTDg== 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=dtwsC8n4B8GouCY2f1douEN0y/UMZvMUJmpbBiyuz7o=; b=sXpXJQB68LZXxnlYcGhlNBrsT5GVibFgnCJRup4chegmwktNCUi7QSr6y6vDlQbj/n KhYmcuhsrJk+BvdBTGNqamnNtlWXYkRKsF9lpILfXjw9qFgKoAlbaJY1w9kmMrKFkkzY xv9A8Wlx3q92aRBCbWiFbOnI4Ey3s7Nr7LzqLlMAmjV1mBZVz3TyFqqQ/FjvR3oLwMf0 aeIm/MDzgwBkKNyFC6GPRt2UwoucRQ9Mx6GFN82kbyoPJlGouLtKScmsZ5H/uXlqW3sR eO1WcY2rSRRgVC2IXR+XDiPG1sP98GyPc+Nma+jrw0HrW0v+BgRtBqnrM981jppffRJU C+Kw== 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 d15si7113304wrv.294.2019.04.25.02.59.49 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59:49 -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 1hJbAN-000201-Iv; Thu, 25 Apr 2019 11:59:44 +0200 Message-Id: <20190425094803.617937448@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:45:20 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Alexander Potapenko , Steven Rostedt , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes , linux-arch@vger.kernel.org Subject: [patch V3 27/29] lib/stackdepot: Remove obsolete functions References: <20190425094453.875139013@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 @@ -216,14 +216,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 * @@ -318,15 +310,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 25 09:45: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: 10916675 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 A56A813B5 for ; Thu, 25 Apr 2019 10:01:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94CFB28BAD for ; Thu, 25 Apr 2019 10:01:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87B9E28C55; Thu, 25 Apr 2019 10:01:00 +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 ABA2A28BAD for ; Thu, 25 Apr 2019 10:00:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 283796B027B; Thu, 25 Apr 2019 05:59:53 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 232036B027C; Thu, 25 Apr 2019 05:59:53 -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 1216F6B027D; Thu, 25 Apr 2019 05:59:53 -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 B128F6B027B for ; Thu, 25 Apr 2019 05:59:52 -0400 (EDT) Received: by mail-wr1-f70.google.com with SMTP id j5so6771314wrw.23 for ; Thu, 25 Apr 2019 02:59: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=ByC7dXta38CLHUD8h1047Y83UVgHTC0qMNuuteVS9Z4=; b=Lms2pvyxF7iizTQCZTjFCAbd/+xV5pyhoVY7arq+tnc0Y70WHa9N7wkvbfD9REYRe+ Pq2ypTQ/BSontdPAl03QCugv0x6fo55315VR/MrnCMsJAeSb0tuA13DU4WtItBuEV361 KzXMh/AxTR7Q/46HiRiQoy8DTVOwwtxvg4e+FB3M6cPGcO6aKSX0a9ww9WEr1EaL2TD9 OeLc3f46elpX1CsjFJKOJZcpyMlNKhlCd8LxxUjUfXqdRfA8q6+TRtcRN6DQEoRcW4HT gBLMuJ1IiwdjKd9XaF17in4xXJkiLsOhIZ7DjpGwOmtb21Fzn+dk32AekKn+fTVsjZYD 1e0A== 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: APjAAAVjOikihVzNLIBaLjfzJmXKVVPmFyCFUP2n6zz3sy6dYYN+3DPw L5tnH8kW5+nHWZOJBRvUjItrKf7e+euOWxs2MqMElULLTgvke0ciqOEuaJL3yq1siQaUG7QvS7P K0TOED0dVaGdggYEzu0sYgpe/OXz9+WhfV3WzLEvCMtS801e58aZjmfNkzdGnk5GN0w== X-Received: by 2002:a05:600c:21d3:: with SMTP id x19mr2825726wmj.2.1556186392209; Thu, 25 Apr 2019 02:59:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqyD/vTx7MKhnpiB4NQGgaFnXQV9+nKWOEr9fHPQwx00sfJ4WFgtSUMzb+GK+Nk2UBPOQhCg X-Received: by 2002:a05:600c:21d3:: with SMTP id x19mr2825640wmj.2.1556186390609; Thu, 25 Apr 2019 02:59:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186390; cv=none; d=google.com; s=arc-20160816; b=wEEFLP71rIROsMkJm2RTDEkwpUeyvJzmJOtpVboEJM0W39yvirdMNiBRwTFn7C5rdl dZaiHV8g2VuctJ/kKSBi4aLxmNGZJv1yk9oS321cLXwG68IwyHPXjqTOfsQtztMW0DOx RTSdOeMRbYRxfdFtxZpNmvrnObf4UXFWLv9TH585fLACcb4ugAlT5sfcZL5ZSkjk6kpo xESIGw7j0K7zU/noyNaQuivAwHOGOgB5POzwpEf1Qxozjds2KCgvQkQjAh7lX7vk5D7/ zu0EZbiWKFPoCr0WcayEaJ9AqzySWx3vKYKpJxwOkmA42Ac9BhCf2IJILTFhiE8UU63P 11hQ== 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=ByC7dXta38CLHUD8h1047Y83UVgHTC0qMNuuteVS9Z4=; b=nAh2HFLwTjVEBymzYhuwaYIRT8DUAZkztXixgQWhOZkU9HX/Y0de8KS7F5g7tngoNd qfny5AKIBeOSjSfm7tpfOFu1g7GnYyb6WfyqmLsZAhwgbiygQD9+wBr5cuwoPW4Y2KBj uIuC8IhI9ICoH5wjKssO2xZy3juFD0w5yeT9O0DS0yclZPnRI4RlJT58M8KrlB07HbIO +3Kg4w8VQ4CWMsleYPT7+Ss8mMvXyZ4nlSOTl2hdjehUv4i7h2KSYZqggyIKeeD+yXcj 2FoV9+oAh0vD1WS+/XiTEy4b7Kqk49DaSz8t3mXW2l8cIt8f1jALz15UDuOqHH4GpNpX vPOg== 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 z17si8177561wrw.327.2019.04.25.02.59.50 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59:50 -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 1hJbAP-00020j-QB; Thu, 25 Apr 2019 11:59:46 +0200 Message-Id: <20190425094803.713568606@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:45:21 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , linux-arch@vger.kernel.org, Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes Subject: [patch V3 28/29] stacktrace: Provide common infrastructure References: <20190425094453.875139013@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 --- V3: Fix kernel doc --- include/linux/stacktrace.h | 39 ++++++++++ kernel/stacktrace.c | 173 +++++++++++++++++++++++++++++++++++++++++++++ lib/Kconfig | 4 + 3 files changed, 216 insertions(+) --- a/include/linux/stacktrace.h +++ b/include/linux/stacktrace.h @@ -23,6 +23,44 @@ 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. + * + * Return: 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 + * ============ ======= ============================================ + * task NULL Stack trace from task (can be current) + * current 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 +75,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 @@ -66,6 +68,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 + * + * Return: Number of trace 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 + * + * Return: Number of trace 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 + * + * Return: Number of trace 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 + * + * Return: 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 + * + * Return: Number of trace 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 @@ -203,3 +374,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 25 09:45: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: 10916679 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 E0EC613B5 for ; Thu, 25 Apr 2019 10:01:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0BC328A08 for ; Thu, 25 Apr 2019 10:01:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C327228C50; Thu, 25 Apr 2019 10:01:05 +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 1775A28A08 for ; Thu, 25 Apr 2019 10:01:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CBC506B027C; Thu, 25 Apr 2019 05:59:54 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C6AD26B027D; Thu, 25 Apr 2019 05:59: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 B59E46B027E; Thu, 25 Apr 2019 05:59:54 -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 6511B6B027C for ; Thu, 25 Apr 2019 05:59:54 -0400 (EDT) Received: by mail-wr1-f69.google.com with SMTP id u18so8588276wrq.2 for ; Thu, 25 Apr 2019 02:59: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=XYjtgkQ+gRYguATgChHdH9FUUx591xA2t7TyaZHD9QY=; b=H9s7hDqgjY0zavmFN3p5MWezgcQfHhihtoqqvzbdUiRkv1Jw6k1RM7wDrRJ7maSwJ4 zkRLm2LiuQ7h+rvysh9ScsiPq7mwXfV9VMhood558ZYqQnykDwno3zq5r24HtALLmIHt PvK7E+fD0BGH0340FQdKYlr0W8/L01bxo43ACRv5JW9KLtgvgsnY49j09mW7c96uIgwz DvBvkMCCcIpJQIUYMJwQBofnzEDKlINKxLDtpYexwnDAtVJ3bOvHXOm+tZ80MgO/MG0q EnwOep44GYqr08FiibNjJotZlILTERtFcrplBwnNv96FT0q4Mwb2UEfeEj0KfTDSZz8q /tPA== 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: APjAAAXfBi35D6iVqV0GeEBt/HanoBrXX/djQTLpLGBP6UxXY0lxMuWZ zVSngLnvLK1l5p7ctlAZt01dn4YVL1VyZkeZnxO/SqungqRvad5agXvTBPhwTwPwGS6kGTb2USg g8qVGmLShpyvzCUqM8XPyj/545mCduA24Wd5XqebLqtxllL48g3AvL9tIrz+C7NJ7Kg== X-Received: by 2002:adf:c002:: with SMTP id z2mr26160124wre.177.1556186393937; Thu, 25 Apr 2019 02:59:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqxgssI0YM3P9mNxtsk+0TMqofQzix8pDLZDxdTTpHDNoYPBzqYvIo7/PwoCoPdEv/wuS0Nj X-Received: by 2002:adf:c002:: with SMTP id z2mr26160016wre.177.1556186392173; Thu, 25 Apr 2019 02:59:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186392; cv=none; d=google.com; s=arc-20160816; b=AaON6M82y1o8HKA7fbnAX22nyzrU1OGsQ1XbXGdvCIban+5x930W4Hw+qqwohvIsPy g2xyIdZI6Z2frayWz8Rm5NcmXJ8uFWIgVQ/Iv4+VC84+zsbBx5vEKD7oKF443p36JbHc wzU29de0WOsx5NGmxZgctKi8/FMoC19F5dHuf0fp06eSexZH95RZnLOf9kmfMEiZCw76 DSfv/1XrZ3XMYx5O9WDdLr4dxmgLvQreLdshccAOEpZGbtxxVhMI49Eeo8WXBguutyb1 UXhnwUuJZNPK/qa5CL6HeXfLZG9ga+ZDIi/BlIKYMLFIoBSQSsYmA3W2RuwonhV82s0C LpQQ== 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=vXcY0/m91lp4oC/l2PlIesi1asbKNKflvb0JOo4cmAhl3Pzpalp4Wzjp77AElyH5/F p9XFqf/wr1Ub4k9xbthKHz5aQwlUWlF4UJKrj/ovXrPZMlhBIvloJ9cBBPveb/xJZsPZ YmWtROV+LX1nMCwh1Yi/u8fSBrHH4yb9LvyD2TBQ5WjQ+sdurdsvBiZ8wNbGfjfotHzK z+XSAc5H+EeBB2lCgeJNj46erFOBpejVCc4PNCa4UObBAG2yyqW9KPN6F1kjS7mQqfrP Fl0G7Z8otdWyIrF6BlcllrnDTTX46CMx8U+chXIebli4TJ7JfV9u0eVqS8r3JYwS/sB+ T2Yg== 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 q13si16412095wrf.218.2019.04.25.02.59.52 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Apr 2019 02:59: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 1hJbAR-00021P-Dx; Thu, 25 Apr 2019 11:59:47 +0200 Message-Id: <20190425094803.816485461@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 25 Apr 2019 11:45:22 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , linux-arch@vger.kernel.org, Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Christoph Lameter , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , Christoph Hellwig , iommu@lists.linux-foundation.org, Robin Murphy , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Rodrigo Vivi , Tom Zanussi , Miroslav Benes Subject: [patch V3 29/29] x86/stacktrace: Use common infrastructure References: <20190425094453.875139013@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); -}