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);