From patchwork Thu Apr 18 08:41:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10906741 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 32EA6161F for ; Thu, 18 Apr 2019 09:06:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B933289DA for ; Thu, 18 Apr 2019 09:06:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E3F528AB2; Thu, 18 Apr 2019 09:06:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC229289DA for ; Thu, 18 Apr 2019 09:06:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F1D5A6B0270; Thu, 18 Apr 2019 05:06:21 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EA8C86B026F; Thu, 18 Apr 2019 05:06:21 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D73036B0270; Thu, 18 Apr 2019 05:06:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by kanga.kvack.org (Postfix) with ESMTP id 7EBF76B026D for ; Thu, 18 Apr 2019 05:06:21 -0400 (EDT) Received: by mail-wr1-f72.google.com with SMTP id q16so1500602wrr.22 for ; Thu, 18 Apr 2019 02:06:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:message-id :user-agent:date:from:to:cc:subject:references:mime-version; bh=vo4FaxAT2/1G624q3L+4nrU71S7g/ECh1ZFuY5z36RE=; b=rAuNipPvWzrzA46odsFFI5umCGktXmXro52fFxof4OyEy5Vzl7Ar5tGPHUS/GvmAXp PnXQjXyO6iAt0C21awu3FmxI0DpJMyNq3kymwUJJ8JGMELkZ+FfPCp2hO6EjQP4pMPqx WcWIOXybrpRYGMEJsyYRcuYAEt86uK4PgX3gF2RGVJ0XwSSn4ZTf89o5wQKU+WvTeKzG +WEgZ5I+yJgtofc9N8SpZswmKtTjOMb3XIcAeQB7Xq7KQWxYrBj3Msj4OTRiLRjV3oNt oiKZjjFvQmj8YXlVHf+afNeUka0dMsIeOT2ud1iluGIowlhZbG16foWFlK6AS5bu1WOX X+wQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Gm-Message-State: APjAAAVZZRQkxhDBRRo1uCtE9V/XSrVq3titYKDmpQDa3ir6xMDFYAZm 2zxtjuaKEYj9nQiSMIYPNxYN1fCfzh8vOYiwXf4/8usGN6PLbSDDRZYEfTVv7V7YjNh3DrAY48y 5jNM8xjDjWXH/Ul6NLqpnSck0FBzTTUI6L4egc2Di3uz1ZV9/nj/w6H5WZmtn7RPDNA== X-Received: by 2002:a1c:7dd7:: with SMTP id y206mr2216067wmc.81.1555578381046; Thu, 18 Apr 2019 02:06:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwF+pQ1JF0wQSom4Hs6R8InEQu+xlG97/3RLIAarF7SRJZpyUnNBer/t2gzRb172atcFMpQ X-Received: by 2002:a1c:7dd7:: with SMTP id y206mr2215983wmc.81.1555578379995; Thu, 18 Apr 2019 02:06:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578379; cv=none; d=google.com; s=arc-20160816; b=f7hHESS9qBYBzh8IItm5pBQOJSJwwtTF5JowMUJhts8YNKGBO2ss+MWEitfcHXN5u/ zR/rbiW2rZhsxvxpK3zsVEqPic9PTIGo8KCYtIFrL4dY3KkTyuXfoPHOArxQCasjwWA1 vfVOgKAp5cHGODBlEBSWV4q8V8hKVnV3fqPq17AyIwVbrnvUznd9sZUe3TjQOIUYi/lh T9JgIwzDnp52RMi7+8iA/IKz1uhVGAVpQHtNix/UzgWn62VbhC7tFgmHFe95R12o2gCa 7n77yvx2ghcEpCcd1UJa6ofBSTb2J4LWfPAqOHzOE3Qv9NT/AP2V1uuGdE5aR6DZ2bdo zfWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id; bh=vo4FaxAT2/1G624q3L+4nrU71S7g/ECh1ZFuY5z36RE=; b=Tz/fpPBu+BzJMkr6U60ixmFraOjQepWRC5SC+FLS3L0tPMI4qs/Rw6oDyOjjzYGSsd IuNchivZkuRnydkyV0hHr9qz9YanVh9LzmB+x6pcuitpunPH/bkb0aArClnO8hXiA6ED KxCC/5/xdmtzwwopaxe7hu+Rpj+sUN8JhojjgCpVq0LUtF53iI4JinCUwCpxtF/cW2/4 VWqiO6754+xoU3UTCaTuBoWgug/RzUHwKUceRN5mH8tJbiTAg/Ah4XLJS+nSk0nw2G06 3/CAEU2h3WuJnv9DoXTf2lj+qVVKwyh+obtB2ebHn3lkbyKbbbLA50j2XhFJ4E3c5X2h 3G8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id u10si1222365wrq.57.2019.04.18.02.06.19 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2019 02:06:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH2zp-0001nn-CA; Thu, 18 Apr 2019 11:06:17 +0200 Message-Id: <20190418084253.903603121@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:28 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, linux-mm@kvack.org, Alexey Dobriyan , Andrew Morton , Pekka Enberg , David Rientjes , Christoph Lameter , Catalin Marinas , Mike Rapoport , Akinobu Mita , iommu@lists.linux-foundation.org, Robin Murphy , Christoph Hellwig , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Daniel Vetter , Rodrigo Vivi , linux-arch@vger.kernel.org Subject: [patch V2 09/29] mm/kasan: Simplify stacktrace handling References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Replace the indirection through struct stack_trace by using the storage array based interfaces. Signed-off-by: Thomas Gleixner Acked-by: Dmitry Vyukov Cc: Andrey Ryabinin Cc: Alexander Potapenko Cc: kasan-dev@googlegroups.com Cc: linux-mm@kvack.org Acked-by: Andrey Ryabinin --- mm/kasan/common.c | 30 ++++++++++++------------------ mm/kasan/report.c | 7 ++++--- 2 files changed, 16 insertions(+), 21 deletions(-) --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -48,34 +48,28 @@ static inline int in_irqentry_text(unsig ptr < (unsigned long)&__softirqentry_text_end); } -static inline void filter_irq_stacks(struct stack_trace *trace) +static inline unsigned int filter_irq_stacks(unsigned long *entries, + unsigned int nr_entries) { - int i; + unsigned int i; - if (!trace->nr_entries) - return; - for (i = 0; i < trace->nr_entries; i++) - if (in_irqentry_text(trace->entries[i])) { + for (i = 0; i < nr_entries; i++) { + if (in_irqentry_text(entries[i])) { /* Include the irqentry function into the stack. */ - trace->nr_entries = i + 1; - break; + return i + 1; } + } + return nr_entries; } static inline depot_stack_handle_t save_stack(gfp_t flags) { unsigned long entries[KASAN_STACK_DEPTH]; - struct stack_trace trace = { - .nr_entries = 0, - .entries = entries, - .max_entries = KASAN_STACK_DEPTH, - .skip = 0 - }; + unsigned int nr_entries; - save_stack_trace(&trace); - filter_irq_stacks(&trace); - - return depot_save_stack(&trace, flags); + nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 0); + nr_entries = filter_irq_stacks(entries, nr_entries); + return stack_depot_save(entries, nr_entries, flags); } static inline void set_track(struct kasan_track *track, gfp_t flags) --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -100,10 +100,11 @@ static void print_track(struct kasan_tra { pr_err("%s by task %u:\n", prefix, track->pid); if (track->stack) { - struct stack_trace trace; + unsigned long *entries; + unsigned int nr_entries; - depot_fetch_stack(track->stack, &trace); - print_stack_trace(&trace, 0); + nr_entries = stack_depot_fetch(track->stack, &entries); + stack_trace_print(entries, nr_entries, 0); } else { pr_err("(stack is not available)\n"); }