From patchwork Wed Oct 30 14:22:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11219611 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 404BB112B for ; Wed, 30 Oct 2019 14:22:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F38C22087E for ; Wed, 30 Oct 2019 14:22:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="IDkLsl0H" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F38C22087E Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CBB796B000C; Wed, 30 Oct 2019 10:22:54 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C463C6B000D; Wed, 30 Oct 2019 10:22: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 B35386B000E; Wed, 30 Oct 2019 10:22:54 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0142.hostedemail.com [216.40.44.142]) by kanga.kvack.org (Postfix) with ESMTP id 88D016B000C for ; Wed, 30 Oct 2019 10:22:54 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id F00394DA3 for ; Wed, 30 Oct 2019 14:22:53 +0000 (UTC) X-FDA: 76100667426.25.bears49_3650a6d34452d X-Spam-Summary: 2,0,0,822ba077cada1bc3,d41d8cd98f00b204,3u5y5xqykcm4052xyb08805y.w86527eh-664fuw4.8b0@flex--glider.bounces.google.com,:vegard.nossum@oracle.com:dvyukov@google.com:aryabinin@virtuozzo.com::viro@zeniv.linux.org.uk:akpm@linux-foundation.org:luto@kernel.org:ard.biesheuvel@linaro.org:arnd@arndb.de:hch@lst.de:dmitry.torokhov@gmail.com:edumazet@google.com:ericvh@gmail.com:gregkh@linuxfoundation.org:harry.wentland@amd.com:herbert@gondor.apana.org.au:mingo@elte.hu:axboe@kernel.dk:martin.petersen@oracle.com:schwidefsky@de.ibm.com:mst@redhat.com:monstr@monstr.eu:pmladek@suse.com:sergey.senozhatsky@gmail.com:rostedt@goodmis.org:tiwai@suse.com:tytso@mit.edu:tglx@linutronix.de:wsa@the-dreams.de:gor@linux.ibm.com:iii@linux.ibm.com:mark.rutland@arm.com:willy@infradead.org:rdunlap@infradead.org:andreyknvl@google.com:elver@google.com:glider@google.com,RULES_HIT:41:69:152:355:379:541:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1431:1437:1516:1518:1535:1543:1593:1594:1711:1 730:1747 X-HE-Tag: bears49_3650a6d34452d X-Filterd-Recvd-Size: 6761 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Wed, 30 Oct 2019 14:22:53 +0000 (UTC) Received: by mail-wr1-f73.google.com with SMTP id 4so1391104wrf.19 for ; Wed, 30 Oct 2019 07:22:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=4iI5KVL9+jQTau4pHL/7v6XfJMmusyma1xyeyxplPt4=; b=IDkLsl0HBsPt63OF+cCGz8SicUYJsNuGkRDLKiePNuepxOyKxJan0SklgcUa0ASURb cAZj4zrvDxQs1shKbaSXHpTUos+VqjaqmDitnSNPXHESAcgo5CtKuLQ2WzYu1ke839AD mQeU2WLQFHTpQ72DvlHYKjVyLeHDaXxU6eKJRgk0719aKmM7ozF1aIywsoHQb/F9alrn Bj1izZaIxfA/JoBnQf6u9rLpR3HlTrNmrOpouoTmYdVGRnWEUDcryCaMRGap0YIUsRIg urq334gP/ONmjOUEXYI+ZGCjpkH9jl2hu8e2u1jA3+946NCzhkxGY0HUi9zMs6P0cyNM L3Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=4iI5KVL9+jQTau4pHL/7v6XfJMmusyma1xyeyxplPt4=; b=U8hZO6TBu5kq/uahUXyly9nKxD1LVkf2oxfBluh5G5qEoQVO0ntED4oZe9ah9yptDy Eb/8skjqKDw8T3gZ+4CjU0/6qgbp6pEK53S/zaOVCNQhTOjeFyPlRT8T/EwuJjWvxHC9 G2Kh5NixmykzdFTDOLpYj3XUxQ1txT8q7OvBM3CrE7tpsqywgX23ofjqnryooFm/EexO aAk14H9UaBUhhcEGS4D9C5hMsHsJ2F9NHtSW1Me+ShQZZKS+xMBQAMVRwJx+b/AcW/im /8kDZcOF9ZCM8ucdS51J0xfJGLjOX8qJxNHUqN2v3cdboJDgwE8vf3E0Q4HEFYl8ImYu 4zKA== X-Gm-Message-State: APjAAAWYlB4RvL+UuyLLTGgLsZekJkLmjWgv9hcf89ps4gCZ3EIwdgoU RkCPRaDyJDFGa8i4PWF+cBLOmnj14Dc= X-Google-Smtp-Source: APXvYqzf5VWF/vghfT5EXuODI75zBnydtoKmea0SagtgsSyNLxdP+fQoMSyR2QciHaRW14/naviVW83ehOY= X-Received: by 2002:a5d:55c2:: with SMTP id i2mr134672wrw.176.1572445371706; Wed, 30 Oct 2019 07:22:51 -0700 (PDT) Date: Wed, 30 Oct 2019 15:22:15 +0100 In-Reply-To: <20191030142237.249532-1-glider@google.com> Message-Id: <20191030142237.249532-4-glider@google.com> Mime-Version: 1.0 References: <20191030142237.249532-1-glider@google.com> X-Mailer: git-send-email 2.24.0.rc0.303.g954a862665-goog Subject: [PATCH RFC v2 03/25] kasan: stackdepot: move filter_irq_stacks() to stackdepot.c From: glider@google.com To: Vegard Nossum , Dmitry Vyukov , Andrey Ryabinin , linux-mm@kvack.org Cc: viro@zeniv.linux.org.uk, akpm@linux-foundation.org, luto@kernel.org, ard.biesheuvel@linaro.org, arnd@arndb.de, hch@lst.de, dmitry.torokhov@gmail.com, edumazet@google.com, ericvh@gmail.com, gregkh@linuxfoundation.org, harry.wentland@amd.com, herbert@gondor.apana.org.au, mingo@elte.hu, axboe@kernel.dk, martin.petersen@oracle.com, schwidefsky@de.ibm.com, mst@redhat.com, monstr@monstr.eu, pmladek@suse.com, sergey.senozhatsky@gmail.com, rostedt@goodmis.org, tiwai@suse.com, tytso@mit.edu, tglx@linutronix.de, wsa@the-dreams.de, gor@linux.ibm.com, iii@linux.ibm.com, mark.rutland@arm.com, willy@infradead.org, rdunlap@infradead.org, andreyknvl@google.com, elver@google.com, Alexander Potapenko 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: filter_irq_stacks() can be used by other tools (e.g. KMSAN), so it needs to be moved to a common location. lib/stackdepot.c seems a good place, as filter_irq_stacks() is usually applied to the output of stack_trace_save(). Signed-off-by: Alexander Potapenko To: Alexander Potapenko Cc: Vegard Nossum Cc: Dmitry Vyukov Cc: Andrey Ryabinin Cc: linux-mm@kvack.org --- Change-Id: I65acecf64930a3658e8c2aa7423801082ded8602 --- include/linux/stackdepot.h | 2 ++ lib/stackdepot.c | 23 +++++++++++++++++++++++ mm/kasan/common.c | 23 ----------------------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/include/linux/stackdepot.h b/include/linux/stackdepot.h index 3efa97d482cb..24d49c732341 100644 --- a/include/linux/stackdepot.h +++ b/include/linux/stackdepot.h @@ -19,4 +19,6 @@ depot_stack_handle_t stack_depot_save(unsigned long *entries, unsigned int stack_depot_fetch(depot_stack_handle_t handle, unsigned long **entries); +unsigned int filter_irq_stacks(unsigned long *entries, unsigned int nr_entries); + #endif diff --git a/lib/stackdepot.c b/lib/stackdepot.c index 785839298e08..decb1e073b58 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -20,6 +20,7 @@ */ #include +#include #include #include #include @@ -319,3 +320,25 @@ depot_stack_handle_t stack_depot_save(unsigned long *entries, return retval; } EXPORT_SYMBOL_GPL(stack_depot_save); + +static inline int in_irqentry_text(unsigned long ptr) +{ + return (ptr >= (unsigned long)&__irqentry_text_start && + ptr < (unsigned long)&__irqentry_text_end) || + (ptr >= (unsigned long)&__softirqentry_text_start && + ptr < (unsigned long)&__softirqentry_text_end); +} + +unsigned int filter_irq_stacks(unsigned long *entries, + unsigned int nr_entries) +{ + unsigned int i; + + for (i = 0; i < nr_entries; i++) { + if (in_irqentry_text(entries[i])) { + /* Include the irqentry function into the stack. */ + return i + 1; + } + } + return nr_entries; +} diff --git a/mm/kasan/common.c b/mm/kasan/common.c index 6814d6d6a023..154eba5700d8 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -15,7 +15,6 @@ */ #include -#include #include #include #include @@ -39,28 +38,6 @@ #include "kasan.h" #include "../slab.h" -static inline int in_irqentry_text(unsigned long ptr) -{ - return (ptr >= (unsigned long)&__irqentry_text_start && - ptr < (unsigned long)&__irqentry_text_end) || - (ptr >= (unsigned long)&__softirqentry_text_start && - ptr < (unsigned long)&__softirqentry_text_end); -} - -static inline unsigned int filter_irq_stacks(unsigned long *entries, - unsigned int nr_entries) -{ - unsigned int i; - - for (i = 0; i < nr_entries; i++) { - if (in_irqentry_text(entries[i])) { - /* Include the irqentry function into the stack. */ - return i + 1; - } - } - return nr_entries; -} - static inline depot_stack_handle_t save_stack(gfp_t flags) { unsigned long entries[KASAN_STACK_DEPTH];