Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp3764101ybh; Tue, 6 Aug 2019 00:55:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJSZYq7GpgKCOOC9TaDcaqJvv9emSrvV2fxJQoQT2mLz6yLyjWFexinjMeRgXu7GPlzMXX X-Received: by 2002:a65:4546:: with SMTP id x6mr1847664pgr.266.1565078117917; Tue, 06 Aug 2019 00:55:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565078117; cv=none; d=google.com; s=arc-20160816; b=vK5QC5QYo6uTs5ZrhT0uMzQ/bGxVpyXMbHu8Q9TqChgx0HCE5gVhVSft5P7vQrhhJ7 Ph82jtdnizIDrrKp+LY0GVbTBOiMsH3Pjzjpe38mbrqEbADBlDIhfq5YLwMvNMfBdx3T J4MpMbx3boBAZbKK6DOMCgXhqRUxf0amf0kHk1svnR5UKF+UeJVYufdlXpWcfWEXUUjh 2nQnjWMv4qOo0wJOkBwTSmCCu+dZ+/KH/NFABm7PDvCdFS2ltHua2qjtcXC1EuyqHp6U +r14q6HHTuLwSu/8+f+ls61aHnQbL1HzK8LX7fMRq3rcx2d7DC84zW80B/9/vrHlN0Pb 1QxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=dUQpSTRSkme2qCFPs7T/GiUjxsKsRdExsttZXy7UD+Y=; b=g/d6rVq0kF8oawuT8NRHcxEm2NXkItmoL+FBiIJxL7c9vmW1JTdRMB+H7TcVQ7dGQZ W2QtVWX5AQ1h+793CF7E9zWgmx5gdJyCfXwfmgKa7+kZHjeGRZgVerXe5zvSIvZjz+n7 +Fl+H0fr9Q68k7ekm1fJIsKieHUzgIh7Q4R06b4esu3XnC/PP21EamMXwg1QrkCPqDOK 5wOH/oQAfzbtjpyATj9q/uieBXAS6WxuKWH0433k9K2R7kTvH4pZA/uwJUwk2VBoHrKO Z1PBN6UIQuaKUmILScrD5fE+v0WUOUpm1Htz7cldinDCWdtKnrcJz+3hl0ETt9L6AJkv OxEA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r14si45341193pgm.406.2019.08.06.00.55.02; Tue, 06 Aug 2019 00:55:17 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732159AbfHFHxt (ORCPT + 99 others); Tue, 6 Aug 2019 03:53:49 -0400 Received: from mx2.suse.de ([195.135.220.15]:42958 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726834AbfHFHxs (ORCPT ); Tue, 6 Aug 2019 03:53:48 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 84A25AD29; Tue, 6 Aug 2019 07:53:47 +0000 (UTC) Subject: Re: [PATCH V2] fork: Improve error message for corrupted page tables To: Sai Praneeth Prakhya , linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: dave.hansen@intel.com, Ingo Molnar , Peter Zijlstra , Andrew Morton , Anshuman Khandual References: <3ef8a340deb1c87b725d44edb163073e2b6eca5a.1565059496.git.sai.praneeth.prakhya@intel.com> From: Vlastimil Babka Message-ID: <5ba88460-cf01-3d53-6d13-45e650b4eacd@suse.cz> Date: Tue, 6 Aug 2019 09:53:46 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <3ef8a340deb1c87b725d44edb163073e2b6eca5a.1565059496.git.sai.praneeth.prakhya@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/6/19 5:05 AM, Sai Praneeth Prakhya wrote: > When a user process exits, the kernel cleans up the mm_struct of the user > process and during cleanup, check_mm() checks the page tables of the user > process for corruption (E.g: unexpected page flags set/cleared). For > corrupted page tables, the error message printed by check_mm() isn't very > clear as it prints the loop index instead of page table type (E.g: Resident > file mapping pages vs Resident shared memory pages). The loop index in > check_mm() is used to index rss_stat[] which represents individual memory > type stats. Hence, instead of printing index, print memory type, thereby > improving error message. > > Without patch: > -------------- > [ 204.836425] mm/pgtable-generic.c:29: bad p4d 0000000089eb4e92(800000025f941467) > [ 204.836544] BUG: Bad rss-counter state mm:00000000f75895ea idx:0 val:2 > [ 204.836615] BUG: Bad rss-counter state mm:00000000f75895ea idx:1 val:5 > [ 204.836685] BUG: non-zero pgtables_bytes on freeing mm: 20480 > > With patch: > ----------- > [ 69.815453] mm/pgtable-generic.c:29: bad p4d 0000000084653642(800000025ca37467) > [ 69.815872] BUG: Bad rss-counter state mm:00000000014a6c03 type:MM_FILEPAGES val:2 > [ 69.815962] BUG: Bad rss-counter state mm:00000000014a6c03 type:MM_ANONPAGES val:5 > [ 69.816050] BUG: non-zero pgtables_bytes on freeing mm: 20480 > > Also, change print function (from printk(KERN_ALERT, ..) to pr_alert()) so > that it matches the other print statement. > > Cc: Ingo Molnar > Cc: Vlastimil Babka > Cc: Peter Zijlstra > Cc: Andrew Morton > Cc: Anshuman Khandual > Acked-by: Dave Hansen > Suggested-by: Dave Hansen > Signed-off-by: Sai Praneeth Prakhya Acked-by: Vlastimil Babka I would also add something like this to reduce risk of breaking it in the future: ----8<---- diff --git a/include/linux/mm_types_task.h b/include/linux/mm_types_task.h index d7016dcb245e..a6f83cbe4603 100644 --- a/include/linux/mm_types_task.h +++ b/include/linux/mm_types_task.h @@ -36,6 +36,9 @@ struct vmacache { struct vm_area_struct *vmas[VMACACHE_SIZE]; }; +/* + * When touching this, update also resident_page_types in kernel/fork.c + */ enum { MM_FILEPAGES, /* Resident file mapping pages */ MM_ANONPAGES, /* Resident anonymous pages */