From patchwork Fri Oct 18 09:42:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11197971 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 1B94B13B1 for ; Fri, 18 Oct 2019 09:43:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CEFDB21D7C for ; Fri, 18 Oct 2019 09:43:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="FJVwfg26" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CEFDB21D7C 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 A9FFE8E001E; Fri, 18 Oct 2019 05:43:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A50B08E0003; Fri, 18 Oct 2019 05:43: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 966418E001E; Fri, 18 Oct 2019 05:43:24 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0125.hostedemail.com [216.40.44.125]) by kanga.kvack.org (Postfix) with ESMTP id 755648E0003 for ; Fri, 18 Oct 2019 05:43:24 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 246A98120 for ; Fri, 18 Oct 2019 09:43:24 +0000 (UTC) X-FDA: 76056417528.08.woman04_74efd37b7322b X-Spam-Summary: 2,0,0,4faec83f417ea76f,d41d8cd98f00b204,3oompxqykcounspklynvvnsl.jvtspube-ttrchjr.vyn@flex--glider.bounces.google.com,:glider@google.com:vegard.nossum@oracle.com:dvyukov@google.com:aryabinin@virtuozzo.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:1730:1747:1777:1792:2393:2559:2562:2904:3138:3139:3140:3141:3142:3152:3353:3865:3866:3867:3871:3872:4117:4321:4605:5007:6119:6120:6261:6653:7901:7903:9592:9969:10004:10400:11026:11232:11233:11473:11658:11914:12043:12291:12297:12438:12555:12895:12986:13255:13846:14181:14394:14659:14721:21080:21365:21433:21444:21451:21611:21627:30025:30054:30064,0,RBL:209.85.128.73:@flex--glider.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: woman04_74efd37b7322b X-Filterd-Recvd-Size: 6050 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Fri, 18 Oct 2019 09:43:23 +0000 (UTC) Received: by mail-wm1-f73.google.com with SMTP id g67so2082155wmg.4 for ; Fri, 18 Oct 2019 02:43:23 -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=SsMz7eFltn0ZjkiCW0+3yiX/vX8A/Koa4q1zO46yHhw=; b=FJVwfg269wcr/WgBNlPHCjiYAL+Qtg2aXTbwHjxbp7Br4i9h9bG67UiqfWEstLIsJl DuoILMT3SyW+Uu9OKnxEeZTL4CGJQ4yVa7ffWH37Ew5YWe4+zF5tsVKQarrkK7QZOw4t CnxcZp/kDbnUqVmhDL1wlwfLCEuHc/f+Kg/8U58iCN/tPtm67xeMTLbNZe+GJYbP+FRY dKBFv/GZVewemNqvBG/TWOozOOhG8ZTcYc38H1ZyW6UXluypomHr6/rWCS3UG+VubqTO q4Nr5+clCaJKI5+w0kvKsI2cn5fparsCpSY7Tv2BWkbYEhEr81JpdN4SKRt+CcQKngQX QHDw== 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=SsMz7eFltn0ZjkiCW0+3yiX/vX8A/Koa4q1zO46yHhw=; b=GgT6F782IWWtpEPzv469XE1MDUiHS+Xr1L7+B45gyLNj4Jd/wTV/F4c+xGqehWAFHC 6qk+428lp5ETofbrVEJ/LhcBoUaL9wxh9g6up2HidSQVKU0a2nOGBLQMBbL5746gsHJ4 JhSJaq/jFEcdSqr2p55RFePnoFK6PxFvrIIw1sdV5cdHjIy5s75I629OZcR7dT2fQ4Jj gtc61NEMjSAP/1zR/r02la9WErMY/G8/qTAOjmjA8wXIuk74eprETSZlUtDBwAsGD+OX u+1OioQSgpAGdTZbBNw3WG3rr/AF3WH7H0rZpwanoUr09z8Us+UVTeDwChhlVUQIyWAX F3dA== X-Gm-Message-State: APjAAAWdaTXIGNVxQ7HOZEp39MIWzhPuXG9OJBt7V3kMLciyFLFa1ZEn 30sfWNeHa1j+XFmVqFv2q81ta0awopY= X-Google-Smtp-Source: APXvYqy27kntIt5Ffh34kSohXEXc5I8BmwVtkfzGNd632Jhc7GpN9lL0PWOdUQpoj8i6qrGZSvMaJvY2yRE= X-Received: by 2002:a5d:63cf:: with SMTP id c15mr1423996wrw.89.1571391802198; Fri, 18 Oct 2019 02:43:22 -0700 (PDT) Date: Fri, 18 Oct 2019 11:42:41 +0200 In-Reply-To: <20191018094304.37056-1-glider@google.com> Message-Id: <20191018094304.37056-4-glider@google.com> Mime-Version: 1.0 References: <20191018094304.37056-1-glider@google.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog Subject: [PATCH RFC v1 03/26] kasan: stackdepot: move filter_irq_stacks() to stackdepot.c From: glider@google.com To: Alexander Potapenko Cc: Vegard Nossum , Dmitry Vyukov , Andrey Ryabinin , linux-mm@kvack.org 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];