Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1581095ybx; Thu, 7 Nov 2019 14:00:57 -0800 (PST) X-Google-Smtp-Source: APXvYqwko//izjyrhYZlXOmZzWRg+vGFSsTI4ZeZODkcqC222eUq3j/kVOOdZJMtEhjtdvPUno/w X-Received: by 2002:a05:6402:1b04:: with SMTP id by4mr6485983edb.218.1573164056988; Thu, 07 Nov 2019 14:00:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573164056; cv=none; d=google.com; s=arc-20160816; b=v7ciYti8fHUZgtQdY5aSLBziGd+acAJcCIrsFOHZj65uPQtOSYTlZy1syIDSs1pboA eT8icre2i9rfwk0l7ydV48yE3sv6rWHp9rwXO/xqgOHrVdLYpIw+Mqg2hw3R+0tkn4/O xQS8KcbmfchOkvh+i8QE14qK9IhBJXBGu59zoD5mm7ywzwfO/gDYII3s5FzKKt0Xo3b3 sCZQXLbvXq5Lxw9sS5o6tMIMFkzDTQOdi1Iq25B9E7pVbnP97/TlGu15fRVhYQoVCwJb +XWkczoAi4Vb7WsirNBfM1DuWG5pemDyqEkvWE710KFleTTyB3xymqY0mq5UNO7RrpnC AUWg== 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:references:cc:to:from:subject:dkim-signature; bh=Dik0Wbe8xfvCNxL25I+EKXZS20yL32hP2fDZMMFGX1A=; b=trD0g4puQVPVcpE6eajlKepLjacbd2taHYyN8ydFTLD+ck9qwKr5kTdv18Ru+YUthS BQsSd8zTXRHa9mb2byRlIAn83pOOak8odGvsEk9keNc5WbKA2doVcK09DLwLbj0QS/K2 DG9SMI8lqm28kMfM4l5cr5lTVRf33Lz/mgryhWDW26ytJnT8xv3t2Oi80sHHc11SI8Lf gF9AatMrMKB1HOl6ABVEBLz+PohWF4WmHYb4Y+S1+6QXAOiEq7HfE6DRcb/2g4uxdROD i8Khbwg5Fcrt7MCa7Io7d++lbKkkyJSk3gP1fRInErVheiLm0yGvuzVvtXAQI0kYOBtv narw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=lyUHD3j2; 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 rv12si2299131ejb.372.2019.11.07.14.00.33; Thu, 07 Nov 2019 14:00:56 -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=lyUHD3j2; 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 S1726932AbfKGV5Q (ORCPT + 99 others); Thu, 7 Nov 2019 16:57:16 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:55112 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725882AbfKGV5Q (ORCPT ); Thu, 7 Nov 2019 16:57:16 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xA7LsAw3049731; Thu, 7 Nov 2019 21:56:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : references : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2019-08-05; bh=Dik0Wbe8xfvCNxL25I+EKXZS20yL32hP2fDZMMFGX1A=; b=lyUHD3j2VvWy9gKAnjTce0sXewOpRzlQTUJ9AeNzq3S8JE8VbPdto+CmegDOGxZPrQsk rCvSF9tWOvzTcHYbot4PgSVMW+iafPntyHSunac96TSKI4r7IuVJSqicr8Wo8XRcoMiq MuGODM6I8qtYIvQJAn+JWS7uoLqpyyugVL4qGsT3HkzVp555bWIZzzawexDcRgkREhVf SEzpRiavA9o7VBbC1cjAdEbJL3/TpX0NuNqKj+SydMUEd9muzxE3RLfj3/zJsrCZ1mDd NBuS6G0H2VLavVDOviaDWktdJoK0Tt030WwyJ+bkipfGtPS1ICQLqwSO5TGe81owuvU3 aQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2w41w19a7p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Nov 2019 21:56:48 +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 xA7LsG4p196563; Thu, 7 Nov 2019 21:56:47 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2w4k2x6egg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Nov 2019 21:56:47 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id xA7Luj0B016191; Thu, 7 Nov 2019 21:56:45 GMT Received: from [192.168.1.206] (/71.63.128.209) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 07 Nov 2019 13:56:45 -0800 Subject: Re: [PATCH] hugetlbfs: Take read_lock on i_mmap for PMD sharing From: Mike Kravetz To: Matthew Wilcox , Waiman Long Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Davidlohr Bueso , Peter Zijlstra , Ingo Molnar , Will Deacon References: <20191107190628.22667-1-longman@redhat.com> <20191107195441.GF11823@bombadil.infradead.org> Message-ID: <136eb24b-049e-9ebf-598d-1292d61d49fd@oracle.com> Date: Thu, 7 Nov 2019 13:56:43 -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: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9434 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-1911070202 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9434 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-1911070202 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/7/19 1:49 PM, Mike Kravetz wrote: > On 11/7/19 11:54 AM, Matthew Wilcox wrote: >> Are there other current users of the write lock that could use a read lock? >> At first blush, it would seem that unmap_ref_private() also only needs >> a read lock on the i_mmap tree. I don't think hugetlb_change_protection() >> needs the write lock either. Nor retract_page_tables(). Sorry, I missed retract_page_tables which is not part of hugetlb code. The comments below do not apply to retract_page_tables. Someone would need to take a closer look to see if that really needs write mode. -- Mike Kravetz > > I believe that the semaphore still needs to be held in write mode while > calling huge_pmd_unshare (as is done in the call sites above). Why? > There is this check for sharing in huge_pmd_unshare, > > if (page_count(virt_to_page(ptep)) == 1) > return 0; // implies no sharing > > 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. >