From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755828AbdKCJGS (ORCPT ); Fri, 3 Nov 2017 05:06:18 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:57446 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754185AbdKCJGP (ORCPT ); Fri, 3 Nov 2017 05:06:15 -0400 From: Heiko Carstens To: Andrew Morton Cc: linux-mm@kvack.org, linux-next@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Heiko Carstens , "Kirill A . Shutemov" , Michal Hocko , Gerald Schaefer , Martin Schwidefsky Subject: [PATCH] s390/mm: fix pud table accounting Date: Fri, 3 Nov 2017 10:05:51 +0100 X-Mailer: git-send-email 2.13.5 X-TM-AS-GCONF: 00 x-cbid: 17110309-0012-0000-0000-00000589140C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17110309-0013-0000-0000-00001903AA5B Message-Id: <20171103090551.18231-1-heiko.carstens@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-11-03_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1711030113 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With "mm: account pud page tables" and "mm: consolidate page table accounting" pud page table accounting was introduced which now results in tons of warnings like this one on s390: BUG: non-zero pgtables_bytes on freeing mm: -16384 Reason for this are our run-time folded page tables: by default new processes start with three page table levels where the allocated pgd is the same as the first pud. In this case there won't ever be a pud allocated and therefore mm_inc_nr_puds() will also never be called. However when freeing the address space free_pud_range() will call exactly once mm_dec_nr_puds() which leads to misaccounting. Therefore call mm_inc_nr_puds() within init_new_context() to fix this. This is the same like we have it already for processes that run with two page table levels (aka compat processes). While at it also adjust the comment, since there is no "mm->nr_pmds" anymore. Cc: Kirill A. Shutemov Cc: Michal Hocko Cc: Gerald Schaefer Cc: Martin Schwidefsky Signed-off-by: Heiko Carstens --- arch/s390/include/asm/mmu_context.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/s390/include/asm/mmu_context.h b/arch/s390/include/asm/mmu_context.h index 3c9abedc323c..4f943d58cbac 100644 --- a/arch/s390/include/asm/mmu_context.h +++ b/arch/s390/include/asm/mmu_context.h @@ -43,6 +43,8 @@ static inline int init_new_context(struct task_struct *tsk, mm->context.asce_limit = STACK_TOP_MAX; mm->context.asce = __pa(mm->pgd) | _ASCE_TABLE_LENGTH | _ASCE_USER_BITS | _ASCE_TYPE_REGION3; + /* pgd_alloc() did not account this pud */ + mm_inc_nr_puds(mm); break; case -PAGE_SIZE: /* forked 5-level task, set new asce with new_mm->pgd */ @@ -58,7 +60,7 @@ static inline int init_new_context(struct task_struct *tsk, /* forked 2-level compat task, set new asce with new mm->pgd */ mm->context.asce = __pa(mm->pgd) | _ASCE_TABLE_LENGTH | _ASCE_USER_BITS | _ASCE_TYPE_SEGMENT; - /* pgd_alloc() did not increase mm->nr_pmds */ + /* pgd_alloc() did not account this pmd */ mm_inc_nr_pmds(mm); } crst_table_init((unsigned long *) mm->pgd, pgd_entry_type(mm)); -- 2.13.5