Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754649AbbKLO32 (ORCPT ); Thu, 12 Nov 2015 09:29:28 -0500 Received: from smtprelay0135.hostedemail.com ([216.40.44.135]:50795 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752552AbbKLO30 (ORCPT ); Thu, 12 Nov 2015 09:29:26 -0500 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:3138:3139:3140:3141:3142:3354:3608:3622:3865:3866:3867:3870:3871:4250:4321:4605:5007:6119:6261:6742:7514:7875:7903:10004:10400:10450:10455:10848:10967:11026:11232:11473:11658:11914:12043:12296:12438:12517:12519:12555:12663:12740:14659:19904:19999:21080:30003:30046:30054:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:4,LUA_SUMMARY:none X-HE-Tag: gold61_5237bd3edba3e X-Filterd-Recvd-Size: 3732 Date: Thu, 12 Nov 2015 09:29:23 -0500 From: Steven Rostedt To: yalin wang Cc: mingo@redhat.com, akpm@linux-foundation.org, ebru.akagunduz@gmail.com, riel@redhat.com, kirill.shutemov@linux.intel.com, vbabka@suse.cz, jmarchan@redhat.com, mgorman@techsingularity.net, willy@linux.intel.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH V4] mm: fix kernel crash in khugepaged thread Message-ID: <20151112092923.19ee53dd@gandalf.local.home> In-Reply-To: <1447316462-19645-1-git-send-email-yalin.wang2010@gmail.com> References: <1447316462-19645-1-git-send-email-yalin.wang2010@gmail.com> X-Mailer: Claws Mail 3.13.0 (GTK+ 2.24.28; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2839 Lines: 87 On Thu, 12 Nov 2015 16:21:02 +0800 yalin wang wrote: > This crash is caused by NULL pointer deference, in page_to_pfn() marco, > when page == NULL : > > [ 182.639154 ] Unable to handle kernel NULL pointer dereference at virtual address 00000000 > add the trace point with TP_CONDITION(page), I wonder if we still want to trace even if page is NULL? > avoid trace NULL page. > > Signed-off-by: yalin wang > --- > include/trace/events/huge_memory.h | 20 ++++++++++++-------- > mm/huge_memory.c | 6 +++--- > 2 files changed, 15 insertions(+), 11 deletions(-) > > diff --git a/include/trace/events/huge_memory.h b/include/trace/events/huge_memory.h > index 11c59ca..727647b 100644 > --- a/include/trace/events/huge_memory.h > +++ b/include/trace/events/huge_memory.h > @@ -45,12 +45,14 @@ SCAN_STATUS > #define EM(a, b) {a, b}, > #define EMe(a, b) {a, b} > > -TRACE_EVENT(mm_khugepaged_scan_pmd, > +TRACE_EVENT_CONDITION(mm_khugepaged_scan_pmd, > > - TP_PROTO(struct mm_struct *mm, unsigned long pfn, bool writable, > + TP_PROTO(struct mm_struct *mm, struct page *page, bool writable, > bool referenced, int none_or_zero, int status, int unmapped), > > - TP_ARGS(mm, pfn, writable, referenced, none_or_zero, status, unmapped), > + TP_ARGS(mm, page, writable, referenced, none_or_zero, status, unmapped), > + > + TP_CONDITION(page), > > TP_STRUCT__entry( > __field(struct mm_struct *, mm) > @@ -64,7 +66,7 @@ TRACE_EVENT(mm_khugepaged_scan_pmd, > > TP_fast_assign( > __entry->mm = mm; > - __entry->pfn = pfn; > + __entry->pfn = page_to_pfn(page); Instead of the condition, we could have: __entry->pfn = page ? page_to_pfn(page) : -1; But if there's no reason to do the tracepoint if page is NULL, then this patch is fine. I'm just throwing out this idea. -- Steve > __entry->writable = writable; > __entry->referenced = referenced; > __entry->none_or_zero = none_or_zero; > @@ -106,12 +108,14 @@ TRACE_EVENT(mm_collapse_huge_page, > __print_symbolic(__entry->status, SCAN_STATUS)) > ); > > -TRACE_EVENT(mm_collapse_huge_page_isolate, > +TRACE_EVENT_CONDITION(mm_collapse_huge_page_isolate, > > - TP_PROTO(unsigned long pfn, int none_or_zero, > + TP_PROTO(struct page *page, int none_or_zero, > bool referenced, bool writable, int status), > > - TP_ARGS(pfn, none_or_zero, referenced, writable, status), > + TP_ARGS(page, none_or_zero, referenced, writable, status), > + > + TP_CONDITION(page), > > TP_STRUCT__entry( > __field(unsigned long, pfn) \ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/