Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2915740ybx; Fri, 8 Nov 2019 11:13:26 -0800 (PST) X-Google-Smtp-Source: APXvYqxwJSKbRw+IJODg6SdK+xRA+BN6lzr7OulCx+EjrCsnFqkB3RViX6xKAWiTNi2AJQtvOiDs X-Received: by 2002:a17:906:27cc:: with SMTP id k12mr10397860ejc.181.1573240406627; Fri, 08 Nov 2019 11:13:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573240406; cv=none; d=google.com; s=arc-20160816; b=dhuNcARJcgELLTWSRNmuY66WzOw5ijR71USAfnsnW7/oNb2LbghQGWXuGjOPG3QaCg f5wXZN/k1lwBqboexTTcO1UkvOyYPAK+F+vmt1u4kWk+Ao1ETkeAb0Bvb+sTOso2uQWS EbL1Rofqd0zomKI5zNnHn2sBicZMjTJJo7MGwKvU8x/Gz0/b8L6wAHbKR/JCrH7yYWC2 n0hi0YDMUeTWJFii0ofY2dGqm1J2XuuHnQF9+91Rnu232vllB6O2XVghv3XSg1z34URv seEu4MmmRfu8qaOO2LALQvo7309fhp8soa6Uttn45WUsttxglShMXyKv1VpNIhq9SNsE UwfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:dkim-signature; bh=hbg3DDTni8M/rgsCn9U3MFMumS+aykGsqnuwmha715Q=; b=c91qAbrMnrkWY09lba3atH/7+tKluuTzfgREMHwsgGEDFGaI/B7Shuzk2KW6lU5W2Y Lky7IjbGXcNyDCNiPHEVEbaqfsnHbKnDD8jSpEkPExFMLVzMnYaa0NDqIR/aNRqkrJq7 PYNJAdHoi1dKwavfjiazy3niEnhmhM+dWJsI7W/+7RXxwUzatqoudsYphK7bYTPLO0h/ 2iEvPPYoT8rE0eA8xClHO+nRYg4W4ARh94XD59fI8XTy5nLP15lm/KgVtOJh2uUp6W0F ZxHJAWR6JaeQAhvKUEeyK9Nx53fCjAv1Joan3g3icRnlhH/r+HMKUuh7P9b5bWIghjrN ZkfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=SgKfRGUD; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f11si4355589ejk.336.2019.11.08.11.13.03; Fri, 08 Nov 2019 11:13:26 -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; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=SgKfRGUD; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391947AbfKHTKz (ORCPT + 99 others); Fri, 8 Nov 2019 14:10:55 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:57512 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388018AbfKHTKw (ORCPT ); Fri, 8 Nov 2019 14:10:52 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xA8J3vtK078095; Fri, 8 Nov 2019 19:10:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2019-08-05; bh=hbg3DDTni8M/rgsCn9U3MFMumS+aykGsqnuwmha715Q=; b=SgKfRGUD9CKmat/E11tN9oQZS82RkjlOAlHJdjRXdGBhN1Tajtr1paOCnZPHrzzyiJfG ry+0wQoI8ZLUMr23Jtr1TRf/qofz1gX+sf27/uQf0LU7a+nITKZi8Q5aL0pbutvVMj/B 3TaiK6BG3Mjkmg67LwGFuAWBNBdsRtRFFSItHSUPUuW7bHjiN4v+mgEFME5pcBTuU5A/ nobU0FqHHrDxCJvsn9zqw9DrBP2u0DOCpMMZYc1q+GR7yARCnRvA3tYJ0OC3FptNteax 8LV0pZzBbQ1/kostYEQcloeuUzuPHU1D8CGNFlMNZSUriMj2yWv06/9hCMA7cA2pP9LU /A== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2w41w175sr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 08 Nov 2019 19:10:27 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xA8J2q8w117672; Fri, 8 Nov 2019 19:10:27 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2w4k33v07c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 08 Nov 2019 19:10:26 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id xA8JAOBA010812; Fri, 8 Nov 2019 19:10:24 GMT Received: from [192.168.1.206] (/71.63.128.209) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 08 Nov 2019 11:10:24 -0800 Subject: Re: [PATCH] hugetlbfs: Take read_lock on i_mmap for PMD sharing To: Matthew Wilcox , Waiman Long , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Peter Zijlstra , Ingo Molnar , Will Deacon References: <20191107190628.22667-1-longman@redhat.com> <20191107195441.GF11823@bombadil.infradead.org> <20191108020456.sulyjskhq3s5zcaa@linux-p48b> From: Mike Kravetz Message-ID: Date: Fri, 8 Nov 2019 11:10:22 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.0 MIME-Version: 1.0 In-Reply-To: <20191108020456.sulyjskhq3s5zcaa@linux-p48b> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9435 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1910280000 definitions=main-1911080187 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9435 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default 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-1910280000 definitions=main-1911080187 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/7/19 6:04 PM, Davidlohr Bueso wrote: > On Thu, 07 Nov 2019, Mike Kravetz wrote: > >> Note that huge_pmd_share now increments the page count with the semaphore >> held just in read mode. It is OK to do increments in parallel without >> synchronization. However, we don't want anyone else changing the count >> while that check in huge_pmd_unshare is happening. Hence, the need for >> taking the semaphore in write mode. > > This would be a nice addition to the changelog methinks. Last night I remembered there is one place where we currently take i_mmap_rwsem in read mode and potentially call huge_pmd_unshare. That is in try_to_unmap_one. Yes, there is a potential race here today. But that race is somewhat contained as you need two threads doing some combination of page migration and page poisoning to race. This change now allows migration or poisoning to race with page fault. I would really prefer if we do not open up the race window in this manner. Getting this right in the try_to_unmap_one case is a bit tricky. I had code to do this in the past that was part of a bigger hugetlb synchronization change. All those changes got reverted (commit ddeaab32a89f), but I believe it is possible to change try_to_unmap_one calling sequences without introducing other issues. Bottom line is that more changes are needed in this patch. I'll work on those changes unless someone else volunteers. It will likely take me one or two days to come up with and test proposed changes. -- Mike Kravetz