Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6485476ybi; Wed, 31 Jul 2019 15:29:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxniYC/CX/EcAYj1/pUNykfJvyjU7WXoq/5zOK6ilOGL0BZvaJ2j854iKstvxyFZyt3GqzW X-Received: by 2002:a62:3283:: with SMTP id y125mr50532946pfy.83.1564612165921; Wed, 31 Jul 2019 15:29:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564612165; cv=none; d=google.com; s=arc-20160816; b=HK3mqLKKo3001aDF+Is4ftBpB6DVUz7HZpqBMs4Jzvha03QGbG8fkTbguFSgDsMXbz q4uhaXAhMosfRwAUS3kmhfmrT1j3L9mCfvCbeVxnoxMFyRehVyK+tEqt7fVq0hgA4qtm VCiI99feyLqGRtMv81MPztWzyJR5fllmw1J8llKYiO12TLufYedIhr1AAfog+TtNU9Vr FJtliqlZAhz8pq0zMEARUo5U05EczFPsjFCqPXjqkd+x1g/mCTN6y4jePTzzCc+Yz3I7 zuZzrQxaP4I7K3izzA5Hu0c1DcImQABCueG59okbBUi+D2I4qGx9+1lNHfTnZHOfztIQ k16g== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=nwcJ3sQwPY3LTO7gF5g6MU8bAtfGsVtclFQFC0wg+HA=; b=CxXcJkpY5XEdIAzpZA9xIQrwTt6De8IWc990OCI8LakbxdzHsoC7JYRWwzP1YsjM1J SmRvtp4GZ+6sdMEl/fI3avX7UXbBZ6DHIF5bkyFHxQyR5zEP4lAdBw1dOFvBa78ca3Nh 1FiiMXMCgUrsTSHaN8oTrnaAtEuf6ArFK8qziIASvT0A6eVrNANH96qL022USvHUm8Eb FkcVVPTQCTN4R2vgzY4ARHn8SWhF/pdLZKtg5cRNn4heufxnvBd7JiQhX9Lt/NQkvfG4 0gW4jDyf4+pTsPdBVh6B68R3AX5Sgy+W8j10HB4HBUTD/ApWlyl6cEHuNG0MgUOz2f4a IfHA== 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 g4si2464241pjt.70.2019.07.31.15.29.09; Wed, 31 Jul 2019 15:29:25 -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 S1729092AbfGaW16 (ORCPT + 99 others); Wed, 31 Jul 2019 18:27:58 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35570 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726073AbfGaW16 (ORCPT ); Wed, 31 Jul 2019 18:27:58 -0400 Received: from X1 (unknown [76.191.170.112]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id BBC45416B; Wed, 31 Jul 2019 22:27:55 +0000 (UTC) Date: Wed, 31 Jul 2019 15:27:53 -0700 From: Andrew Morton To: Sai Praneeth Prakhya Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, dave.hansen@intel.com, Ingo Molnar , Peter Zijlstra Subject: Re: [PATCH] fork: Improve error message for corrupted page tables Message-Id: <20190731152753.b17d9c4418f4bf6815a27ad8@linux-foundation.org> In-Reply-To: <20190730221820.7738-1-sai.praneeth.prakhya@intel.com> References: <20190730221820.7738-1-sai.praneeth.prakhya@intel.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 30 Jul 2019 15:18:20 -0700 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). Hence, improve the > error message so that it's more informative. > > 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 Seems useful. > --- a/include/linux/mm_types_task.h > +++ b/include/linux/mm_types_task.h > @@ -44,6 +44,13 @@ enum { > NR_MM_COUNTERS > }; > > +static const char * const resident_page_types[NR_MM_COUNTERS] = { > + "MM_FILEPAGES", > + "MM_ANONPAGES", > + "MM_SWAPENTS", > + "MM_SHMEMPAGES", > +}; But please let's not put this in a header file. We're asking the compiler to put a copy of all of this into every compilation unit which includes the header. Presumably the compiler is smart enough not to do that, but it's not good practice.