Received: by 2002:a17:90a:2044:0:0:0:0 with SMTP id n62csp525348pjc; Mon, 20 May 2019 11:14:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+L+pE98gTRd2x10IaTqHkxU4dKnP+qBunfmy+rCug81zAFFX7s8+hacUye/CC52c6cJ5s X-Received: by 2002:a65:5cca:: with SMTP id b10mr77226347pgt.444.1558376097075; Mon, 20 May 2019 11:14:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558376097; cv=none; d=google.com; s=arc-20160816; b=hTdOmBGcctiLyk/nEN2E+qTp9FmLC50civ6rIJaQLZj+owPHgsbKOqMhqsUzNi6aJT z8zdfimiJJI/AsZdLlfsIw8FGWj57R/twnDRerCDpaTKoHOj8ICXQLWkCNwUnMKMtxgX 6n8JH+ENuWuiX/upvk9TeND+DylHLWOxxIxCjcF/XQniEgPqjXiXblO6SIf43XRbrvhI Jb3RoWvObDQIyEct4N1iUGYuT4wfWYPKJOSGOb8DrTu7/S8slgJF8LufHSBVnnEBY86b eBocPfihnr8ZNiBcqu7yNwhpDSz+gW/lb63akQ/ACiSX7UvFU++tv4bhKZyFrYxtIWg2 xphg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:subject:cc:to :from:date; bh=TeVHesTA7wASYHx4iTyKdAYO1xI4STUxvk+09fsRgus=; b=xoBpFvU+dwGk/I/P3VR8fYY0452qqk1qaqUylsoeVvr9pljDf8SpTTxMvhuTQvDOKl Begd2cHjymqruViG+hfothcQOhcHTj700e9JmmsYW5yfz9sCzWe8N+8sj7rzhKbKZ8mg 5wMkmf+dQws3L3VNilSWdyC96ayGfTmKFfn2kMBjFHav5Juc85+mvvQoGQmweUAzQLuJ pTEKDRaBRaP8YZf8w+/1pdQedEulRF46mLWZsMCxbZGOhWAw7ZjtOnhJm5nZghbumDIn mXoMGMPJzTsXkRBOq+5/HvZnEz1ebVCBgpYm9OI8dvMpACxYp0K6NFYuwyH7KCyDA+Ou B17g== 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 d4si20101248pla.358.2019.05.20.11.14.41; Mon, 20 May 2019 11:14:57 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388663AbfETPMN (ORCPT + 99 others); Mon, 20 May 2019 11:12:13 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:50684 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733009AbfETPMM (ORCPT ); Mon, 20 May 2019 11:12:12 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4KF6I3r090368 for ; Mon, 20 May 2019 11:12:12 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2skwvv27se-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 20 May 2019 11:12:11 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 20 May 2019 16:12:09 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 20 May 2019 16:12:07 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x4KFC63D61014040 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 15:12:06 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5801BA4055; Mon, 20 May 2019 15:12:06 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D2684A404D; Mon, 20 May 2019 15:12:04 +0000 (GMT) Received: from in.ibm.com (unknown [9.199.42.100]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 20 May 2019 15:12:04 +0000 (GMT) Date: Mon, 20 May 2019 20:42:02 +0530 From: Bharata B Rao To: Nicholas Piggin Cc: aneesh.kumar@linux.ibm.com, bharata@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, linux-next@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Michael Ellerman , srikanth Subject: Re: PROBLEM: Power9: kernel oops on memory hotunplug from ppc64le guest Reply-To: bharata@linux.ibm.com References: <16a7a635-c592-27e2-75b4-d02071833278@linux.vnet.ibm.com> <20190518141434.GA22939@in.ibm.com> <878sv1993k.fsf@concordia.ellerman.id.au> <20190520042533.GB22939@in.ibm.com> <1558327521.633yjtl8ki.astroid@bobo.none> <20190520055622.GC22939@in.ibm.com> <1558335484.9inx69a7ea.astroid@bobo.none> <20190520082035.GD22939@in.ibm.com> <20190520142922.GE22939@in.ibm.com> <1558363500.jsgl4a2lfa.astroid@bobo.none> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1558363500.jsgl4a2lfa.astroid@bobo.none> User-Agent: Mutt/1.10.1 (2018-07-13) X-TM-AS-GCONF: 00 x-cbid: 19052015-0028-0000-0000-0000036FA4D5 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19052015-0029-0000-0000-0000242F4AE2 Message-Id: <20190520151202.GF22939@in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-05-20_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905200099 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 21, 2019 at 12:55:49AM +1000, Nicholas Piggin wrote: > Bharata B Rao's on May 21, 2019 12:29 am: > > On Mon, May 20, 2019 at 01:50:35PM +0530, Bharata B Rao wrote: > >> On Mon, May 20, 2019 at 05:00:21PM +1000, Nicholas Piggin wrote: > >> > Bharata B Rao's on May 20, 2019 3:56 pm: > >> > > On Mon, May 20, 2019 at 02:48:35PM +1000, Nicholas Piggin wrote: > >> > >> >> > git bisect points to > >> > >> >> > > >> > >> >> > commit 4231aba000f5a4583dd9f67057aadb68c3eca99d > >> > >> >> > Author: Nicholas Piggin > >> > >> >> > Date: Fri Jul 27 21:48:17 2018 +1000 > >> > >> >> > > >> > >> >> > powerpc/64s: Fix page table fragment refcount race vs speculative references > >> > >> >> > > >> > >> >> > The page table fragment allocator uses the main page refcount racily > >> > >> >> > with respect to speculative references. A customer observed a BUG due > >> > >> >> > to page table page refcount underflow in the fragment allocator. This > >> > >> >> > can be caused by the fragment allocator set_page_count stomping on a > >> > >> >> > speculative reference, and then the speculative failure handler > >> > >> >> > decrements the new reference, and the underflow eventually pops when > >> > >> >> > the page tables are freed. > >> > >> >> > > >> > >> >> > Fix this by using a dedicated field in the struct page for the page > >> > >> >> > table fragment allocator. > >> > >> >> > > >> > >> >> > Fixes: 5c1f6ee9a31c ("powerpc: Reduce PTE table memory wastage") > >> > >> >> > Cc: stable@vger.kernel.org # v3.10+ > >> > >> >> > >> > >> >> That's the commit that added the BUG_ON(), so prior to that you won't > >> > >> >> see the crash. > >> > >> > > >> > >> > Right, but the commit says it fixes page table page refcount underflow by > >> > >> > introducing a new field &page->pt_frag_refcount. Now we are hitting the underflow > >> > >> > for this pt_frag_refcount. > >> > >> > >> > >> The fixed underflow is caused by a bug (race on page count) that got > >> > >> fixed by that patch. You are hitting a different underflow here. It's > >> > >> not certain my patch caused it, I'm just trying to reproduce now. > >> > > > >> > > Ok. > >> > > >> > Can't reproduce I'm afraid, tried adding and removing 8GB memory from a > >> > 4GB guest (via host adding / removing memory device), and it just works. > >> > >> Boot, add 8G, reboot, remove 8G is the sequence to reproduce. > >> > >> > > >> > It's likely to be an edge case like an off by one or rounding error > >> > that just happens to trigger in your config. Might be easiest if you > >> > could test with a debug patch. > >> > >> Sure, I will continue debugging. > > > > When the guest is rebooted after hotplug, the entire memory (which includes > > the hotplugged memory) gets remapped again freshly. However at this time > > since no slab is available yet, pt_frag_refcount never gets initialized as we > > never do pte_fragment_alloc() for these mappings. So we right away hit the > > underflow during the first unplug itself, it looks like. > > Nice catch, good debugging work. Thanks, with help from Aneesh. > > > I will check how this can be fixed. > > Tricky problem. What do you think? You might be able to make the early > page table allocations in the same pattern as the frag allocations, and > then fill in the struct page metadata when you have those. Will explore. > > Other option may be create a new set of page tables after mm comes up > to replace the early page tables with. That's a bigger hammer though. Will also check if similar scenario exists on x86 and if so, how and when pte frag data is fixed there. Regards, Bharata.