Received: by 2002:a17:90a:2044:0:0:0:0 with SMTP id n62csp527146pjc; Mon, 20 May 2019 11:16:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqybc8Gm8J58a04/puBnBlxnbV5YIApc1faKk0xtn8FfG/U5g5WRTQFo4mxy7xvVwwEcm3Q2 X-Received: by 2002:a17:902:aa45:: with SMTP id c5mr76547932plr.144.1558376190121; Mon, 20 May 2019 11:16:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558376190; cv=none; d=google.com; s=arc-20160816; b=PJvgEpCX58N9WXzzgOjQNCpechs0eqlzgB/b+bJy0abRKxaghhpCWNjmxFfapJSavl oThX4WCCDBcEb2JPaXh2g0f1tvt6fpntjW4a7f8m4ByC3NccxjzJBI/0ATUz1flYeAIK Z+XOW9fOCsyAIIqUxfIzrRFBXYuyLUFni1YyEg0b1+YzBQ44oAdDPLhS6bpC2qdhdKmG a/1KgENzQ2eAwRjhAidsaxJ4bCiVmmzjYAeAnM5kJfuknZzmy1ts0c0XKltZgqxTlB7P hc2MjBRJIwOkfVM0E4VFmu/k7EhV0cTANzs61LUXdgnM/8sJ6U5ETowkdEXhrwaIQPtX C9vg== 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 :content-language:in-reply-to:mime-version:user-agent:date:from :references:cc:to:subject; bh=VYYW0VUuSy8odQPI6IncSJ3/YLiQpqEJUiaqC0EC7UA=; b=VQyQL1I4SkBqtUq5lMqT9OAcJE3aHmI044viJDmXm5xEjy+u2Zlc1SKA8Q7jGH2qZP BXNUIUuvxzspl69zV5w73tLFMhacc7/8ag0wyghDmADO7VIL3hrdwfzXYOYcnnZBBPHY vJDuIIby5PYCTaOMO8DaZWUYrqJzeX0spS7xbNTyZxTxmKfwfjEITeFNlFLA1mRHh2nN VkHj1jQQfVWkUp3lIgwLDJxTrnRD1/0JgLOhnGj9MKwzlTp7ru+xFIGfoRYezNrm6Zeb KKxOEAoPZHCAKbU6ivqb69uI95nXbMxELxHU5+4s7PWPOQRArO4+VWZv56DN7P28knwp 8UNA== 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 f88si18554175plf.397.2019.05.20.11.16.15; Mon, 20 May 2019 11:16:30 -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 S2390568AbfETPUv (ORCPT + 99 others); Mon, 20 May 2019 11:20:51 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:35666 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728819AbfETPUu (ORCPT ); Mon, 20 May 2019 11:20:50 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4KF3GAL141719 for ; Mon, 20 May 2019 11:20:49 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2skxh00w16-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 20 May 2019 11:20:48 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 20 May 2019 16:20:48 +0100 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e31.co.us.ibm.com (192.168.1.131) 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:20:45 +0100 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x4KFKiRf8257808 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 15:20:44 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 47F5EC605F; Mon, 20 May 2019 15:20:44 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 36682C6069; Mon, 20 May 2019 15:20:25 +0000 (GMT) Received: from [9.199.54.74] (unknown [9.199.54.74]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 20 May 2019 15:20:22 +0000 (GMT) Subject: Re: PROBLEM: Power9: kernel oops on memory hotunplug from ppc64le guest To: Nicholas Piggin , bharata@linux.ibm.com Cc: bharata@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, linux-next@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Michael Ellerman , srikanth 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> From: "Aneesh Kumar K.V" Date: Mon, 20 May 2019 20:50:17 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <1558363500.jsgl4a2lfa.astroid@bobo.none> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 19052015-8235-0000-0000-00000E99A357 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011131; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000286; SDB=6.01206080; UDB=6.00633288; IPR=6.00987040; MB=3.00026972; MTD=3.00000008; XFM=3.00000015; UTC=2019-05-20 15:20:47 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19052015-8236-0000-0000-000045A3F2CD Message-Id: <3ec09ffa-e3d8-5ba2-cf1e-c0d47cfc2332@linux.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 5/20/19 8:25 PM, 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. > >> 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. I guess we need to do something similar to what x86 does. We need to walk the init_mm page table again and re-init struct page and other data structures backing the tables? -aneesh