Received: by 10.223.185.116 with SMTP id b49csp8543961wrg; Fri, 2 Mar 2018 03:50:18 -0800 (PST) X-Google-Smtp-Source: AG47ELu67nZfd29FKVwiXhsivxQwJu0+LJeJJPWiIKJpccDf0PLnwQELN5bRPz5m+w9jeQQQObjT X-Received: by 10.98.180.13 with SMTP id h13mr5393477pfn.139.1519991418757; Fri, 02 Mar 2018 03:50:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519991418; cv=none; d=google.com; s=arc-20160816; b=JvaIKPTQAlfFXi3suD3MsJt//CZ0dYvztIbL3dcF8Y/b+A35XOdaI9QzmxrBBO6NCl KYqvj+EWS3ys/X+GlVCiQ7exzLF5ULfrIIOImcneexsVNj9FVlqD9PzmLwBz2zfh3flF 1J2EYz9ZATXEVdFX0dBngvrhqYxmVKHIJpY/sbrE2wheyoZddAnXY2OQLgopjF0HZY9M tNm+LVRy3RuqpbCacB0m/I+5vQXC+5LvgQnggpkj5u/vhV+uxKKEMBDL7Fly92ewuKpq betnnfpwO7irgnr9lRGbHzskmJnPh+CLjCE9carFwXUz88CgWQt9oy6FKgsutNAPAYaO FNtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=vK0F/lpfw0kzipPBbGPbdzhR5b9VXSFvx+P7xkzcIzY=; b=WJzjFhY1Hw4bSk0UY7u4SZhx+ZM2gAITVwzw5doiz8vTlya5FoWLKtmcrj8g3NwuJe X+72qkP9KXfj7hKIZBwNHgHAUNYny/utzg793fejrR9knfr4rDF7Yp4KNkZlylZhl3JD IAIOPWHtAWYo8x2U4FlfW77wmTgLdkuI1tYqDigwoY+O13dx68VCD3safQpqbZU5fyu1 Rapf2lh0n3ri4hX7MxvjyjMijf8+IXXYlX+WR1TKK7h0phzENY4YFN4PHxLCyZf7i+li 2twXk8HOgUcMtnXD98VPf1tCRgZmLNQyR4IA44fEcbr50KvpXWKoew5OPGskqkbk5LLS 8BYw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p7si3874871pgn.531.2018.03.02.03.49.51; Fri, 02 Mar 2018 03:50:18 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1164824AbeCBLsp (ORCPT + 99 others); Fri, 2 Mar 2018 06:48:45 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:59534 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935896AbeCBLsU (ORCPT ); Fri, 2 Mar 2018 06:48:20 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w22Bihrs012353 for ; Fri, 2 Mar 2018 06:48:19 -0500 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0b-001b2d01.pphosted.com with ESMTP id 2gf3wxn1ag-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 02 Mar 2018 06:48:19 -0500 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 2 Mar 2018 11:48:17 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 2 Mar 2018 11:48:14 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w22BmEI957475082; Fri, 2 Mar 2018 11:48:14 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 81771A4040; Fri, 2 Mar 2018 11:41:15 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4A8E4A404D; Fri, 2 Mar 2018 11:41:15 +0000 (GMT) Received: from mschwideX1 (unknown [9.152.212.220]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 2 Mar 2018 11:41:15 +0000 (GMT) Date: Fri, 2 Mar 2018 12:48:12 +0100 From: Martin Schwidefsky To: Guenter Roeck Cc: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, "Kirill A . Shutemov" , Heiko Carstens Subject: Re: [RFC PATCH] s390: Fix runtime warning about negative pgtables_bytes In-Reply-To: <1519944052-19992-1-git-send-email-linux@roeck-us.net> References: <1519944052-19992-1-git-send-email-linux@roeck-us.net> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 18030211-0040-0000-0000-00000439E31E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18030211-0041-0000-0000-000020DCEB95 Message-Id: <20180302124812.5aaab323@mschwideX1> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-03-02_06:,, 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=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803020138 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 1 Mar 2018 14:40:52 -0800 Guenter Roeck wrote: > When running s390 images with 'compat' processes, the following > BUG is seen repeatedly. > > BUG: non-zero pgtables_bytes on freeing mm: -16384 > > Bisect points to commit b4e98d9ac775 ("mm: account pud page tables"). > Analysis shows that init_new_context() is called with > mm->context.asce_limit set to _REGION3_SIZE. In this situation, > pgtables_bytes remains set to 0 and is not increased. The message is > displayed when the affected process dies and mm_dec_nr_puds() is called. > > Cc: Kirill A. Shutemov > Cc: Heiko Carstens > Fixes: b4e98d9ac775 ("mm: account pud page tables") > Signed-off-by: Guenter Roeck > --- > RFC since I have no idea if this is correct (or complete, for that matter). > All I can say is that the message is no longer seen after the patch is > applied. > > arch/s390/include/asm/mmu_context.h | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/s390/include/asm/mmu_context.h b/arch/s390/include/asm/mmu_context.h > index 65154eaa3714..6c8ce15cde7b 100644 > --- a/arch/s390/include/asm/mmu_context.h > +++ b/arch/s390/include/asm/mmu_context.h > @@ -63,6 +63,7 @@ static inline int init_new_context(struct task_struct *tsk, > _ASCE_USER_BITS | _ASCE_TYPE_SEGMENT; > /* pgd_alloc() did not account this pmd */ > mm_inc_nr_pmds(mm); > + mm_inc_nr_puds(mm); > } > crst_table_init((unsigned long *) mm->pgd, pgd_entry_type(mm)); > return 0; The page table folding always makes a knot in my brain. After staring at the code for a while I am now convinced that your patch is correct. On free of a 2 level page table free_pud_range() does a p4d_clear() which is turned into a nop as the page table is folded. But the mm_dec_nr_puds() is done unconditionally and that is where the imbalance comes from. Adding a counter mm_inc_nr_puds to init_new_context fixes it. Applied to s390/linux:fixes. Thanks. -- blue skies, Martin. "Reality continues to ruin my life." - Calvin.