Received: by 10.213.65.68 with SMTP id h4csp1204589imn; Mon, 26 Mar 2018 03:01:35 -0700 (PDT) X-Google-Smtp-Source: AG47ELt7Q+0XtePaHkdh+tEE5p0QGE8Ct4jKq4Wh9XOJvJA7Pq4XX2lrSnVqKY6gYbjPh0zkX7Nw X-Received: by 2002:a17:902:51ad:: with SMTP id y42-v6mr36950934plh.314.1522058495486; Mon, 26 Mar 2018 03:01:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522058495; cv=none; d=google.com; s=arc-20160816; b=Hjs2sNYRLVUQV6ZfiQSMG+q30sUcQgbYzyGjUN62cd+sd0HopR0eiiAVzSK7SyL4FC PO2KXc0cN0QTkwmD+EAVTp9dOL3LOtdpP/PANeO3ZjJJcanAH3XHMdiPi1XhtGU9yRir xrjnU+zkKmYjjPVpIPTmT3QkCPVdGTUCXt/PXaIYFbsubKx7u1diNHM6YngVt8JxWzp+ Sjx0Xh6ZHjo6P1gSQ+7DlU7udWOMvHTukWbOVuu8Sqmm/XH3AQ46DXfPmf586Sf4aN4T Nqa52hIdMDeSdC5l1GegdqVqVhVvW7Cs1S1JTWrlFSIuYgtik9x+BRlZamFI2sHFKP3k f37w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:dlp-filter:cms-type:message-id :date:subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=Fw4tYXjekgzZ+WvSkqJFnHW5+XAs+NHgRWtXJaRPgNw=; b=emZLwtmn4my2HdcfAWAcNXTNDv+SPKBmNr49MX5RKxukrcEPvaZfOerZMm84q6f2/A DVm8gHO7Dq075gpWsCfZaRy7dAYwz1XAkFkn7HN1rTC3Mqa0PoSdOZYyneLkN6WOclVo gVrgQBCtL9p85MpKpoHz4jN5wtNYeZ8IWzHmbXo/86p6wR+W3AO0y5k9burtks6k8phn Aw9zCS9xEV+lU4W/oXwjgxAPXbtSIOzgBbEe2GntRQKa9Gy1fBjmf/iOpCr9+uohOJkZ sD5FJP1WVANAFT6pz560r0NA4sID2/EbL42FNuWPB9K0j861DwFMM5onQ4bM5t6Kzwgz V41g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=UcXG49oD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s17si9908378pgq.421.2018.03.26.03.01.20; Mon, 26 Mar 2018 03:01:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=UcXG49oD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751132AbeCZKAZ (ORCPT + 99 others); Mon, 26 Mar 2018 06:00:25 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:49714 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750989AbeCZKAX (ORCPT ); Mon, 26 Mar 2018 06:00:23 -0400 Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20180326100021epoutp04e317ba6e243dc57ea9c646ee58166034~fcBH9_Hjy0879308793epoutp04J for ; Mon, 26 Mar 2018 10:00:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20180326100021epoutp04e317ba6e243dc57ea9c646ee58166034~fcBH9_Hjy0879308793epoutp04J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1522058421; bh=Fw4tYXjekgzZ+WvSkqJFnHW5+XAs+NHgRWtXJaRPgNw=; h=From:To:Cc:Subject:Date:References:From; b=UcXG49oDW4Qcn3OB1+WLvJB3o6vo3RM6ATw4I4tWJQuCUO7PmYnMMuL4+S+LSPZLC 91yZeaRBM8o9QcFIpeyNy7vxNRz8vl+vt1fL5/i3NValAgv0Pc38IWofKOk/wkoMlE DpBVz5A7m20ij3YsaRijnxYm2fbvyeyFSc3Ss0pE= Received: from epsmges5p3new.samsung.com (unknown [182.195.40.72]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20180326100020epcas5p41f2cc71903198be5d76d3838ac7cd78a~fcBHEAjgd0773307733epcas5p4J; Mon, 26 Mar 2018 10:00:20 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id CA.B2.04070.4B4C8BA5; Mon, 26 Mar 2018 19:00:20 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20180326100020epcas5p2b50b7541e66dccf4e49db634e5fe6b41~fcBGhdzGr0787307873epcas5p2R; Mon, 26 Mar 2018 10:00:20 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20180326100020epsmtrp22715b7c61ab8e6edcc9f7d8ebaad7dd9~fcBGfG37M1856418564epsmtrp2h; Mon, 26 Mar 2018 10:00:20 +0000 (GMT) X-AuditID: b6c32a4b-fb3ff70000000fe6-05-5ab8c4b46b62 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id BD.97.03842.3B4C8BA5; Mon, 26 Mar 2018 19:00:19 +0900 (KST) Received: from localhost.localdomain (unknown [107.108.92.210]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20180326095933epsmtip227b0447e49b3f901e5abc6cba1185202~fcAasf5Qf2094620946epsmtip24; Mon, 26 Mar 2018 09:59:31 +0000 (GMT) From: Maninder Singh To: aryabinin@virtuozzo.com, glider@google.com, dvyukov@google.com, kstewart@linuxfoundation.org, tglx@linutronix.de, pombredanne@nexb.com, gregkh@linuxfoundation.org, akpm@linux-foundation.org, vbabka@suse.cz, sfr@canb.auug.org.au, mhocko@suse.com, vinmenon@codeaurora.org, gomonovych@gmail.com, ayush.m@samsung.com Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, a.sahrawat@samsung.com, pankaj.m@samsung.com, v.narang@samsung.com, Maninder Singh Subject: [PATCH v2] mm/page_owner: ignore everything below the IRQ entry point Date: Mon, 26 Mar 2018 15:28:24 +0530 Message-Id: <1522058304-35934-1-git-send-email-maninder1.s@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA0VTf2wTVRz33V3vCrFwKRCfU2Y9hViSdb3abq/IGMRFL2FgFyKJMzgu27lN 2+vSazfmH6ZjyyAEKq0YCGxsyh80dVJytLJfzUw7lQWtW+aS6QRccI2Cm26DDd3i7O0w/vf5 fN/n8/nmffKeFtdPkDnaWtEreETeyZBric9TRmNebLC73Lz47fNopE9AbdEuEt0PzVDo+6UB Cp2abKXQ0dkEjlKT0xrUfDFKonDmNoZOtB0BaLS3jUS3ulY0KNXRSqDbgV3o1u9xDK0spTUo nhij0FX5Ixwlh9oBOt8UACga/4LatYlrGh8nudHASYzrOXeT4jplH9cfHCI5eS5EcTPpNMVd P7tEcAPtXRR3qcfKBWIRwEVjYwT3Tecgxc3Ludy9gSRwrC8XdtQIfJXgMQhipbuqVqwuYvbs r3i5wlZgZvNYOypkDCLvEoqYklJH3iu1zuzVGUM97/RlRw5ekpj8nTs8bp9XMNS4JW8R8ybL WkysudBksVh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ZZapG+XwJXxbPcKloJfShUrvp5ma2Dske1i5OSQ EDCRaN/wjQnEFhLYzShx8YYqRFxa4ue/9ywQtrDEyn/P2bsYuYBqPjFKHH93jB0kwSagJ7Fq 1x4WkISIwDUmiQONk8GqmAVOMUqsvbIWrEpYwE9iavsKsFEsAqoSj9/3s4HYvALuEq8fnmaD WCEncfLYZNYJjDwLGBlWMUqmFhTnpucWGxYY5qWW6xUn5haX5qXrJefnbmIER4yW5g7Gy0vi DzEKcDAq8fBKMO2IEmJNLCuuzD3EKMHBrCTCyzcfKMSbklhZlVqUH19UmpNafIhRmoNFSZz3 ad6xSCGB9MSS1OzU1ILUIpgsEwenVAPjsq8zfJc7HhTeopWXk/Kju+lgMMO3hP2nYq5KTyy6 afT34tfPDcJMf25cPLtZpmbSqUhWnaBnFzgKPmqFCOyXEPCbkTx7x4w5Uy+ciOBT+fYxelMp u/2umPY+37gp/J1WRWbXz873/flawlVa0ZprulrTdv0t+5OZPz6ct1xCVCljie+dXWv1lViK MxINtZiLihMBj8poTpQCAAA= X-CMS-MailID: 20180326100020epcas5p2b50b7541e66dccf4e49db634e5fe6b41 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-MTR: 20180326100020epcas5p2b50b7541e66dccf4e49db634e5fe6b41 CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20180326100020epcas5p2b50b7541e66dccf4e49db634e5fe6b41 X-RootMTR: 20180326100020epcas5p2b50b7541e66dccf4e49db634e5fe6b41 References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Check whether the allocation happens in an IRQ handler. This lets us strip everything below the IRQ entry point to reduce the number of unique stack traces needed to be stored. so moved code of KASAN in generic file so that page_owner can also do same filteration. Initial KASAN commit id=be7635e7287e0e8013af3c89a6354a9e0182594c original:- __alloc_pages_nodemask+0xfc/0x220 page_frag_alloc+0x84/0x140 __napi_alloc_skb+0x83/0xe0 rtl8169_poll+0x1e5/0x670 net_rx_action+0x132/0x3a0 __do_softirq+0xce/0x298 irq_exit+0xa3/0xb0 do_IRQ+0x72/0xc0 ret_from_intr+0x0/0x18 cpuidle_enter_state+0x96/0x290 do_idle+0x163/0x1a0 After patch:- __alloc_pages_nodemask+0xfc/0x220 page_frag_alloc+0x84/0x140 __napi_alloc_skb+0x83/0xe0 rtl8169_poll+0x1e5/0x670 net_rx_action+0x132/0x3a0 __do_softirq+0xce/0x298 Signed-off-by: Vaneet Narang Signed-off-by: Maninder Singh --- v1->v2: fix build break for tile and blackfin (https://lkml.org/lkml/2017/12/3/287, verified for blackfin) include/linux/stacktrace.h | 26 ++++++++++++++++++++++++++ mm/kasan/kasan.c | 22 ---------------------- mm/page_owner.c | 1 + 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/include/linux/stacktrace.h b/include/linux/stacktrace.h index ba29a06..3d3e49d 100644 --- a/include/linux/stacktrace.h +++ b/include/linux/stacktrace.h @@ -4,6 +4,8 @@ #include +extern char __irqentry_text_start[], __irqentry_text_end[]; +extern char __softirqentry_text_start[], __softirqentry_text_end[]; struct task_struct; struct pt_regs; @@ -26,6 +28,28 @@ extern int save_stack_trace_tsk_reliable(struct task_struct *tsk, extern int snprint_stack_trace(char *buf, size_t size, struct stack_trace *trace, int spaces); +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 void filter_irq_stacks(struct stack_trace *trace) +{ + int i; + + if (!trace->nr_entries) + return; + for (i = 0; i < trace->nr_entries; i++) + if (in_irqentry_text(trace->entries[i])) { + /* Include the irqentry function into the stack. */ + trace->nr_entries = i + 1; + break; + } +} + #ifdef CONFIG_USER_STACKTRACE_SUPPORT extern void save_stack_trace_user(struct stack_trace *trace); #else @@ -38,6 +62,8 @@ extern int snprint_stack_trace(char *buf, size_t size, # define save_stack_trace_user(trace) do { } while (0) # define print_stack_trace(trace, spaces) do { } while (0) # define snprint_stack_trace(buf, size, trace, spaces) do { } while (0) +# define filter_irq_stacks(trace) do { } while (0) +# define in_irqentry_text(ptr) do { } while (0) # define save_stack_trace_tsk_reliable(tsk, trace) ({ -ENOSYS; }) #endif /* CONFIG_STACKTRACE */ diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c index 405bba4..129e7b8 100644 --- a/mm/kasan/kasan.c +++ b/mm/kasan/kasan.c @@ -412,28 +412,6 @@ void kasan_poison_object_data(struct kmem_cache *cache, void *object) KASAN_KMALLOC_REDZONE); } -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 void filter_irq_stacks(struct stack_trace *trace) -{ - int i; - - if (!trace->nr_entries) - return; - for (i = 0; i < trace->nr_entries; i++) - if (in_irqentry_text(trace->entries[i])) { - /* Include the irqentry function into the stack. */ - trace->nr_entries = i + 1; - break; - } -} - static inline depot_stack_handle_t save_stack(gfp_t flags) { unsigned long entries[KASAN_STACK_DEPTH]; diff --git a/mm/page_owner.c b/mm/page_owner.c index 8602fb4..30e9cb2 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -148,6 +148,7 @@ static noinline depot_stack_handle_t save_stack(gfp_t flags) depot_stack_handle_t handle; save_stack_trace(&trace); + filter_irq_stacks(&trace); if (trace.nr_entries != 0 && trace.entries[trace.nr_entries-1] == ULONG_MAX) trace.nr_entries--; -- 1.9.1