Received: by 10.213.65.68 with SMTP id h4csp558195imn; Tue, 27 Mar 2018 04:44:26 -0700 (PDT) X-Google-Smtp-Source: AG47ELtbzoTcmk2ouFaNE4aTUv4w7SUthPN/ydOTebrdRJ0MTu4tZdjxrkoDvyuhpcBdoXFEnYyd X-Received: by 10.99.110.133 with SMTP id j127mr31500407pgc.79.1522151066829; Tue, 27 Mar 2018 04:44:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522151066; cv=none; d=google.com; s=arc-20160816; b=Iuk0IRQIizIZs9cWyc3m7mNpx7WY8k7KHmO0tq1KDiPOxGfZwCc+f/y0lH0DXyQ7so f2TG0ABne4jBVkEMt1OWtj+740A7gjLftbR6iKCBY9eOlUwy6RwsrbGgmTOepsQxUjjh t2Why1sZbJm4bGHozdBRGPgcbbAX8GpHRyGP42PhoYYHRNQ5ks4S8phTj4bqJMxwrYiR +HFwfLaAtdLzGvb+ESbFUh4wwCZnYJRzRh0sUqltZQT2oUnwByVCuqHtkIXOt4yP2kDR xIV2PYvjv9SjnN/dtitWCVv0MYE+VHvLHkqnWuGKV3O+CZ9FECb8T9Z4EL0al7nrd48o r4Zg== 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=tFTHsGSTB4qUVqRtp0EqPz5ncJrEQziiw0bIP2KWZ/I=; b=hwY6CHLTLrndRrnsrJf54UCl11US+3bYu+uXbnuK66B+/1PUEk/zmkQW57OeXFIPhF GqkLGijDBAAgblBKvQ7qes1eRD6wo/EEbsYL36MytHjGa20u2e2VLeBSs16EmmDjUX56 y03D2BRhOACa7w8Pa1jQKrseOhX1kHuHTYzDouk6w8rRAtKv1SrMLA+A3lW7xVZ9s1Pk 5/YOOQBLiCjGkCUoWRzufc3XewzmY54b2uzdLGw1VQKYdgtPfkQP7JNtglFh20A5xfuO gsTKa2gsmIIr6TnK+C8s/X69YHOKuMGeV6ZJBrGnsT+I8SVG1G8KWrAVJp3OxS3P6rou HUvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=TN/DHojq; 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 v31-v6si1126234plg.157.2018.03.27.04.44.11; Tue, 27 Mar 2018 04:44:26 -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=TN/DHojq; 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 S1751207AbeC0LnM (ORCPT + 99 others); Tue, 27 Mar 2018 07:43:12 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:36604 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751063AbeC0LnK (ORCPT ); Tue, 27 Mar 2018 07:43:10 -0400 Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20180327114308epoutp01cfe25a99a365dd4541741b5cbf61a8ef~fxEJxeGzv2227222272epoutp016 for ; Tue, 27 Mar 2018 11:43:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20180327114308epoutp01cfe25a99a365dd4541741b5cbf61a8ef~fxEJxeGzv2227222272epoutp016 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1522150988; bh=tFTHsGSTB4qUVqRtp0EqPz5ncJrEQziiw0bIP2KWZ/I=; h=From:To:Cc:Subject:Date:References:From; b=TN/DHojquz+p+3g1BLTMRD76lQbAfzBRgfUfjg+JKSZf/npnDnTM7P057VgWygFT5 U6GfghYrQu1c/rifbveGLYiwnG/vNlhJfDHBlw6Z3ZfC+lkoLoOcKV7ApI08fQ7wqN UjlrU2gQcEu7GrptdqtRMbuZdBOCe1LT9dz4ctgM= Received: from epsmges5p2new.samsung.com (unknown [182.195.40.73]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20180327114307epcas5p4e33db57fd33e027dbb5247ef522c3cf1~fxEI1f-ah3176731767epcas5p4S; Tue, 27 Mar 2018 11:43:07 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 76.0A.04077.B4E2ABA5; Tue, 27 Mar 2018 20:43:07 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20180327114307epcas5p100770b64c770cc5bfb98ef1f820434ef~fxEIRdCD_3008930089epcas5p1L; Tue, 27 Mar 2018 11:43:07 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20180327114307epsmtrp2498991ebabddb268a3111d18c15869db~fxEIPL53X2624426244epsmtrp2Z; Tue, 27 Mar 2018 11:43:07 +0000 (GMT) X-AuditID: b6c32a4a-d07ff70000000fed-48-5aba2e4b059b Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id D2.95.03879.A4E2ABA5; Tue, 27 Mar 2018 20:43:06 +0900 (KST) Received: from localhost.localdomain (unknown [107.108.92.210]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20180327114250epsmtip14f305a8bd85680b9672355eadf49caa1~fxD4lZaeP0904309043epsmtip1L; Tue, 27 Mar 2018 11:42:49 +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 v3] mm/page_owner: ignore everything below the IRQ entry point Date: Tue, 27 Mar 2018 17:11:47 +0530 Message-Id: <1522150907-33547-1-git-send-email-maninder1.s@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA0WTfUxTVxjGc3pv761k3e7q1xmLrLmZMehae5sWDk4UIpnXj5huy7JY5uoN PQEy2rLeVsb+mUUFY7ABP7ZGIOBc1DQsNRWMFJu6ttukI42Ibl1wOhYdQxgRUEkGk7Xcmv33 vO/ze/Ke8+YcBaEaoXIV1XYXdtqFGpbKIa/E8vM1u7Qhs84fX4eG+jFqD3RT6MmJKRrdno/Q qGW0kUZN02ECxUb/lqND5wIUuvjnfRlqbm8AaDjUTqF73YtyFOtsJNF9bwm6N9krQ4vzSTnq Dd+h0eXgaQJFBzoAavN4AQr0XqdLVvKeVIrih73HZXzfmd9ovivo5q+1DlB8cOYEzU8lkzR/ wzdP8pGObpq/0GfgvT1+wAd67pD8YFec5meDefxEJApMr5jx5iosWLFTje0VDmu1vbKY3fW+ ZZvFWKDjNFwRKmTVdsGGi9my3SbNO9U16auz6gNCjTvdMgmiyG7cstnpcLuwusohuorZco7T azldoVav12sNxn2b9MY0sh9XzV0Pymon3/wskWqiD4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yn5LoYOTkk BEwkns84xNjFyMUhJLCbUeLghkvMEAlpiZ//3rNA2MISK/89Z4co+sQoMWveZ3aQBJuAnsSq XXtYQBIiAteYJA40TgarYhY4xSix9spasCphAT+J/dvPsoHYLAKqEgsbJ4CN5RVwlzh0ejY7 xAo5iZPHJrNOYORZwMiwilEytaA4Nz232LDAKC+1XK84Mbe4NC9dLzk/dxMjOGa0tHYwnjgR f4hRgINRiYd3BsfOKCHWxLLiytxDjBIczEoivJmCu6KEeFMSK6tSi/Lji0pzUosPMUpzsCiJ 88rnH4sUEkhPLEnNTk0tSC2CyTJxcEo1MOqcn7xikc+rg96W6TrvAncbnZ2U8bzQbp/s0R+v 9y+3vyF7N/l5p/VmyXT5BTt0/gSwcC7/Fuv6XuOy8+QSd4XPWf83OBz3+xodfeuq1pKX1nrR 7BrpjkU3Xn674/d18YktDlbPXDxDL03hXnRI9vNmxa9veW4aNP38x5UpI/Fw0a8qga+rfh9W YinOSDTUYi4qTgQAwgx/x5UCAAA= X-CMS-MailID: 20180327114307epcas5p100770b64c770cc5bfb98ef1f820434ef X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-MTR: 20180327114307epcas5p100770b64c770cc5bfb98ef1f820434ef CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20180327114307epcas5p100770b64c770cc5bfb98ef1f820434ef X-RootMTR: 20180327114307epcas5p100770b64c770cc5bfb98ef1f820434ef 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) v2->v3: remove inline as functions are larger, Declarations for __irqentry_text_start and friends are redundant. include/linux/stacktrace.h | 3 +++ kernel/stacktrace.c | 22 ++++++++++++++++++++++ mm/kasan/kasan.c | 22 ---------------------- mm/page_owner.c | 1 + 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/include/linux/stacktrace.h b/include/linux/stacktrace.h index ba29a06..1a37fcae 100644 --- a/include/linux/stacktrace.h +++ b/include/linux/stacktrace.h @@ -26,6 +26,8 @@ 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); +void filter_irq_stacks(struct stack_trace *trace); + #ifdef CONFIG_USER_STACKTRACE_SUPPORT extern void save_stack_trace_user(struct stack_trace *trace); #else @@ -38,6 +40,7 @@ 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 save_stack_trace_tsk_reliable(tsk, trace) ({ -ENOSYS; }) #endif /* CONFIG_STACKTRACE */ diff --git a/kernel/stacktrace.c b/kernel/stacktrace.c index f8edee9..b28c4e1 100644 --- a/kernel/stacktrace.c +++ b/kernel/stacktrace.c @@ -77,3 +77,25 @@ int snprint_stack_trace(char *buf, size_t size, WARN_ONCE(1, KERN_INFO "save_stack_tsk_reliable() not implemented yet.\n"); return -ENOSYS; } + +static bool 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); +} + +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; + } +} 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