Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp260295pxk; Thu, 24 Sep 2020 05:11:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8JKJ5EdIWbI0DIb1E088FGSF+C5O2Pb6cjtEGFhDRlNV0La7IPSQhRFCvqyvIB4ko4qJJ X-Received: by 2002:a50:fa88:: with SMTP id w8mr685130edr.179.1600949485133; Thu, 24 Sep 2020 05:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600949485; cv=none; d=google.com; s=arc-20160816; b=XdTiuExuzqUrWGDIIWhoQHjX6W32sATyWB9WkaKLvPnUiH/5fTXcsJSxUdBskofQjS 2wgTKwMLNAg3sKUHYsV6C6gzCvLI9ppA0A+QFxIQCvXqdwi7e0uEehUMEqb5zXVnrz28 h7XzG32INmYFvolVz7jgq8Sh3Y2FuPzmd5P7Q+4BOV6UGoERz+QNHtMMOu1JONG2HHur PbEU35xXsjPze0TH7HerMw9IP4YHsC8R9NSp1p4lroHBHGrAS+TyH3MXOwLCdRjOM/tS i9SrQ3TBW4N6mib2+p60RbI3LtgXMs2Qa2uxfifs3ieyg3+j571dOgrArAbf1+2vIqbo odXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=V2HPM/eFjC6UZ7YckSVpOnkHlLRlQCxKJD3TO9C078U=; b=r2EAoh7e+3TIe/TBEZ1DthcblHTREDgu+oJrvIzT/KZAmxkhk9DBThSwPKsu0iIB5m EUAlKA5gnPl6o1tQq0ftIxUbwTwIMnCB1tiLTmd5I0rorGoZYlex5e9uN/ZXN4xh43yJ Lf8k4PFogepNO2AVhdfq4R1rV5BPypaTOYA7mGe0BrTPUc6clzQuIvdSXY272CIOIbL3 /6q8PnTf9omjEX02Bat3uSB/EW8ixBqx36DySDFdWA+ZTkPxOFiOifqnGeomaN/bHHvm kZZqQdwh1X1c8HUq7/5WAVMnNAif+40b5J1c5Z1b/17AcUXgYsFK52xcQAMx3+pvU89G 3qSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="r+2/xhDi"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gg23si1843027ejb.327.2020.09.24.05.11.01; Thu, 24 Sep 2020 05:11:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="r+2/xhDi"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727661AbgIXMGz (ORCPT + 99 others); Thu, 24 Sep 2020 08:06:55 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:64938 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726406AbgIXMGs (ORCPT ); Thu, 24 Sep 2020 08:06:48 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 08OC3hp4089660; Thu, 24 Sep 2020 08:06:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=pp1; bh=V2HPM/eFjC6UZ7YckSVpOnkHlLRlQCxKJD3TO9C078U=; b=r+2/xhDiGSbcvRbYkT/w/sKa9nPJT5apngrZYZ7th3cWEluWLCEEKJusNELHH4lAX/NB WJ+3yR8AA2eXDqYOuNe0OI0kuK6GR12M5c0d3/HQvGzVkgQw+wg3go15DCFT1yqUkyWB 3AGNDZ1RakQLF9v5Sr+fobcANImvMmE1j4QPG5iYQtRk2t/JXnLuNRu6iUr3T/Qvihzl /SFat/Vd7kxG5DjajWyLJ82kq8WkCucwflIpC9oyPd6EV3hFI/cCzbKhnIofuTnfAgsH 2nPZucg+qsf3TwTJB/TIlJg0ZOKeX0OFjXYKD8skrkGYZdrMzbXhthPa6BuFe7gI+bTo hw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 33rtnh11u2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 24 Sep 2020 08:06:45 -0400 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 08OC4Rhe093837; Thu, 24 Sep 2020 08:06:45 -0400 Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 33rtnh11sw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 24 Sep 2020 08:06:45 -0400 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 08OC2MTm029894; Thu, 24 Sep 2020 12:06:42 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma06ams.nl.ibm.com with ESMTP id 33n98gw7tm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 24 Sep 2020 12:06:42 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 08OC6ebv30998850 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 Sep 2020 12:06:40 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F1BAF5204E; Thu, 24 Sep 2020 12:06:39 +0000 (GMT) Received: from thinkpad (unknown [9.171.54.160]) by d06av21.portsmouth.uk.ibm.com (Postfix) with SMTP id 8A81552051; Thu, 24 Sep 2020 12:06:39 +0000 (GMT) Date: Thu, 24 Sep 2020 14:06:38 +0200 From: Gerald Schaefer To: Linus Torvalds Cc: Peter Xu , Heiko Carstens , Qian Cai , Alexander Gordeev , Vasily Gorbik , Christian Borntraeger , linux-s390 , Linux-MM , Linux Kernel Mailing List Subject: Re: BUG: Bad page state in process dirtyc0w_child Message-ID: <20200924140638.7bcb7765@thinkpad> In-Reply-To: <20200924000226.06298978@thinkpad> References: <20200916142806.GD7076@osiris> <20200922190350.7a0e0ca5@thinkpad> <20200923153938.5be5dd2c@thinkpad> <20200923233306.7c5666de@thinkpad> <20200924000226.06298978@thinkpad> X-Mailer: Claws Mail 3.17.6 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-09-24_08:2020-09-24,2020-09-24 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 suspectscore=2 spamscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 mlxscore=0 mlxlogscore=999 impostorscore=0 phishscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009240095 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 24 Sep 2020 00:02:26 +0200 Gerald Schaefer wrote: > On Wed, 23 Sep 2020 14:50:36 -0700 > Linus Torvalds wrote: > > > On Wed, Sep 23, 2020 at 2:33 PM Gerald Schaefer > > wrote: > > > > > > Thanks, very nice walk-through, need some time to digest this. The TLB > > > aspect is interesting, and we do have our own __tlb_remove_page_size(), > > > which directly calls free_page_and_swap_cache() instead of the generic > > > batched approach. > > > > So I don't think it's the free_page_and_swap_cache() itself that is the problem. > > > > As mentioned, the actual pages themselves should be handled by the > > reference counting being atomic. > > > > The interrupt disable is really about just the page *tables* being > > free'd - not the final page level. > > > > So the issue is that at least on x86-64, we have the serialization > > that we will only free the page tables after a cross-CPU IPI has > > flushed the TLB. > > > > I think s390 just RCU-free's the page tables instead, which should fix it. > > > > So I think this is special, and s390 is very different from x86, but I > > don't think it's the problem. Ah of course, I got confused by freeing pagetable pages vs. the pages themselves. For the pagetable pages we actually use the generic tlb_remove_table_(sync_)one, including the IPI-synchronizing smp_call_function (CONFIG_MMU_GATHER_RCU_TABLE_FREE=y). The "s390 magic" then only starts in our own __tlb_remove_table, where we take care of the special 2K vs. 4K pagetable stuff. Thanks a lot for this very valuable abstract of "who is who and why" in pagetable memory management :-) > > > > In fact, I think you pinpointed the real issue: > > > > > Meanwhile, out of curiosity, while I still fail to comprehend commit > > > 09854ba94c6a ("mm: do_wp_page() simplification") in its entirety, there > > > is one detail that I find most confusing: the unlock_page() has moved > > > behind the wp_page_reuse(), while it was the other way round before. > > > > You know what? That was just a mistake, and I think you may actually > > have hit the real cause of the problem. > > > > It means that we keep the page locked until after we do the > > pte_unmap_unlock(), so now we have no guarantees that we hold the page > > referecne. > > > > And then we unlock it - while somebody else might be freeing it. > > > > So somebody is freeing a locked page just as we're unlocking it, and > > that matches the problem you see exactly: the debug thing will hit > > because the last free happened while locked, and then by the time the > > printout happens it has become unlocked so it doesn't show any more. > > > > Duh. > > > > Would you mind testing just moving the unlock_page() back to before > > the wp_page_reuse()? > > Sure, I'll give it a try running over the night again. It's all good now, no more occurrences with unlock_page() before wp_page_reuse().