From patchwork Thu Apr 18 08:41:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906793 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F3598922 for ; Thu, 18 Apr 2019 09:07:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC8A728857 for ; Thu, 18 Apr 2019 09:07:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF220289DA; Thu, 18 Apr 2019 09:07:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5208B28857 for ; Thu, 18 Apr 2019 09:07:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D463D6B0284; Thu, 18 Apr 2019 05:06:54 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CD09A6B0285; Thu, 18 Apr 2019 05:06:54 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD3F46B0286; Thu, 18 Apr 2019 05:06:54 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by kanga.kvack.org (Postfix) with ESMTP id 5836B6B0284 for ; Thu, 18 Apr 2019 05:06:54 -0400 (EDT) Received: by mail-wr1-f71.google.com with SMTP id c8so1527706wru.13 for ; Thu, 18 Apr 2019 02:06:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=lC14wLptSwMX1RfWmgp9otJ/2ZurJIp5t7P26rWm7ME=; b=CEPzxhI8RR3IiwMhfHA2aRgKvp1aCocGtgrHOdRtqTUztZB3lnrStEPeWeVy/W5F5C 73Fjpe8rbDeFFpgyyVTeCiZFTtq6nBqYuOqAfY4NO1QERwGYsZ8EOxoFUmPi/gDCDTuR cbjDM5hVDTnIoqxW1EFElezL8+EoCeHB/pLJovTxZnwRuTGxe2brbm+3C+STm12TxiOg xu14Y3mZorv10E+Y76uo4ja/s4SQP3oCvQt06KTjl1LFW4JPD1dL7xDxy2gTsuFTsU9o XHKHOhXB4N5MSYE4FM8F98GRYDqtgssUxkrpOsxPs6jzhK0UnDGEZ1H7YxvGYYKEzyBf fRXw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAX9qPcjcvwAruat2IuFeJwtP32XNaEGCf9KjMDC/z45i9pUW6TB pUsg/1a6/uL/f3xdjH2C9mJ0uysIFVgjvZlqngPXx6NcMVGquqy23d8jKJKL83H5BH+jdchV1v2 lUv2FHKdeD85jhV2PINxqcl236l+yK+cAf1lQ4detC6b3mzEYYYNeqTe6lvzG7j4uXQ== X-Received: by 2002:adf:fa47:: with SMTP id y7mr42802921wrr.27.1555578413789; Thu, 18 Apr 2019 02:06:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyGkFosDqr4DE+kPsPGvbw/90z+r2rPicUFlanWN1ELw6Mb9wWHpbHrFwSe16MxkOFs7u7T X-Received: by 2002:adf:fa47:: with SMTP id y7mr42802876wrr.27.1555578412990; Thu, 18 Apr 2019 02:06:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578412; cv=none; d=google.com; s=arc-20160816; b=TgbC+N/xw2njeyujSMcDIFgseHZr+ovhLMHiqjc79EF3zVb3HH5+Jv5/5lbLh+kV1D cStDWzbOcd1tg99X/WusW8W1GaeJKzv57JoLfmOrelWJZPmVZnfqHq9WR6MQuXsT9HYz 7OmaaUcoxQRfEByV2ZhkA/r1/dQWEnsux/URr7ZfIherN6hge2f4B6hC1zFYNHxdw0ks 7xuMDLQq4ivzCIwJvTqwbrIad31+Np7Cf3O2EDtFaUddWef5J8JqAY/PLEI6goMt10su JGS3LQsL3psfrvx5+hK/1VmhS+DtmjBcjPuocro3bcCUvZEe/EnAQ8L24TfdYrmJX5fo gbzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=lC14wLptSwMX1RfWmgp9otJ/2ZurJIp5t7P26rWm7ME=; b=GBrbYAYwssHCMjpxiIuQfCmxvUyaTCs7+Gv+NvRGTywI0Pm+ifbS5oTNW0lrIxySrt nIn3wau2O9D26Zx95Rq0y9fXYmEzxdYpYk8pdyyLmsKMJttYs2Lm/BswE+XCHQuseptb 0D8PYo5RmI8H+Mc4kjJwRScvTZyGfRAYRSHqEKRvIakoLvpkk8Zwa7Ds0LN28wDKeQYC pZMBl/CLLlsuUewWJ0B2DcXLFV9BtvvfNKILBKRtfv2KgqIjsd5iIflkkv+b8OPJA3ts 76QtCHK23aLhGhV87yfDXZh3F3AzZggrAocpQvaLRblNDmnL3Gp/39FZ6FZLrNKNbZA9 M/9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id y2si1195736wrs.332.2019.04.18.02.06.52 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH30L-0001w5-1f; Thu, 18 Apr 2019 11:06:49 +0200 Message-Id: <20190418084255.186774860@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:42 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Christoph Lameter , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , iommu@lists.linux-foundation.org, Robin Murphy , Christoph Hellwig , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Daniel Vetter , Rodrigo Vivi , linux-arch@vger.kernel.org Subject: [patch V2 23/29] tracing: Simplify stack trace retrieval References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Replace the indirection through struct stack_trace by using the storage array based interfaces. Signed-off-by: Thomas Gleixner Cc: Steven Rostedt Reviewed-by: Steven Rostedt (VMware) --- kernel/trace/trace.c | 40 +++++++++++++--------------------------- 1 file changed, 13 insertions(+), 27 deletions(-) --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -2774,22 +2774,18 @@ static void __ftrace_trace_stack(struct { struct trace_event_call *call = &event_kernel_stack; struct ring_buffer_event *event; + unsigned int size, nr_entries; struct ftrace_stack *fstack; struct stack_entry *entry; - struct stack_trace trace; - int size = FTRACE_KSTACK_ENTRIES; int stackidx; - trace.nr_entries = 0; - trace.skip = skip; - /* * Add one, for this function and the call to save_stack_trace() * If regs is set, then these functions will not be in the way. */ #ifndef CONFIG_UNWINDER_ORC if (!regs) - trace.skip++; + skip++; #endif /* @@ -2816,28 +2812,24 @@ static void __ftrace_trace_stack(struct barrier(); fstack = this_cpu_ptr(ftrace_stacks.stacks) + (stackidx - 1); - trace.entries = fstack->calls; - trace.max_entries = FTRACE_KSTACK_ENTRIES; - - if (regs) - save_stack_trace_regs(regs, &trace); - else - save_stack_trace(&trace); - - if (trace.nr_entries > size) - size = trace.nr_entries; + size = ARRAY_SIZE(fstack->calls); - size *= sizeof(unsigned long); + if (regs) { + nr_entries = stack_trace_save_regs(regs, fstack->calls, + size, skip); + } else { + nr_entries = stack_trace_save(fstack->calls, size, skip); + } + size = nr_entries * sizeof(unsigned long); event = __trace_buffer_lock_reserve(buffer, TRACE_STACK, sizeof(*entry) + size, flags, pc); if (!event) goto out; entry = ring_buffer_event_data(event); - memcpy(&entry->caller, trace.entries, size); - - entry->size = trace.nr_entries; + memcpy(&entry->caller, fstack->calls, size); + entry->size = nr_entries; if (!call_filter_check_discard(call, entry, buffer, event)) __buffer_unlock_commit(buffer, event); @@ -2916,7 +2908,6 @@ ftrace_trace_userstack(struct ring_buffe struct trace_event_call *call = &event_user_stack; struct ring_buffer_event *event; struct userstack_entry *entry; - struct stack_trace trace; if (!(global_trace.trace_flags & TRACE_ITER_USERSTACKTRACE)) return; @@ -2947,12 +2938,7 @@ ftrace_trace_userstack(struct ring_buffe entry->tgid = current->tgid; memset(&entry->caller, 0, sizeof(entry->caller)); - trace.nr_entries = 0; - trace.max_entries = FTRACE_STACK_ENTRIES; - trace.skip = 0; - trace.entries = entry->caller; - - save_stack_trace_user(&trace); + stack_trace_save_user(entry->caller, FTRACE_STACK_ENTRIES); if (!call_filter_check_discard(call, entry, buffer, event)) __buffer_unlock_commit(buffer, event);