Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1572623ybx; Thu, 7 Nov 2019 13:51:55 -0800 (PST) X-Google-Smtp-Source: APXvYqzwGLG1hdP2KFCtK4Kh38N6ZIWHwy1zgxfIS3oUFTQrMQh2BtywJIhSO/w8mnOq/Rhz7fMm X-Received: by 2002:a05:6402:1b90:: with SMTP id cc16mr6491199edb.304.1573163515288; Thu, 07 Nov 2019 13:51:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573163515; cv=none; d=google.com; s=arc-20160816; b=cgVS9j0hl9ykI0sn/92Tws6owbfGcgvTvERvZ7XqhhnmzV5WAVWuRCeEeMkC9VKeKB dL3PlCU31FcSoONdLJ3buSeHWYGzRATEy0CUxOam4esIoKH5zK9epiF/Z9MMB3gUl+YS UxwkR73VU+8PRw3JnEAOY1GUjIPpbs2ZKjlCkFqL+/wXretUL7YsCwJW1ylqMr0Skdkf OwcrMFePBN7kWMZCeDL/oaAJV1PpnBMUHPKef4nT19h7I7CeJFTI5S3xohOvu9mxgGuh 6GFES7YMxabs1nAGcSpnS+y9JDTTo+AzdAlORYmRMN4yUgsGzIE6VJIk0KaXEmvEMKvF trWw== 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:cc:to:subject:dkim-signature; bh=JOiMpIMuzkYYPmC19kfrXihQ9r3/nAyAF0rQELnGtrA=; b=ZgqXPRCHMFumlWXTpahAiykX5woYhE2EN2VpHovKGPsWb//Fmm6wcsIj63iUfxo0H6 XWbVl9BrHbFXEWUjZCETXcIsDsvI2nBKzU+DR27HbwVVaNbg7NfxPVlhd3DmKrrvYClB UVHxqXwkRtqWyrpV93rVPUNBbyP7O4O5A+EQRJfdgMbP400B4fiNVP3dRyeZr2/eyMKF AUp4UkYuuN4KXEnuDK2MDIMwJFoA2zuLq5JMhOgBntMKcgUOnhzPPQrNFrEBKuAnQLh7 WSAIiWiWPPfs6gutN6Hj6xqRgbN40n8wSqYaOGNC5gRx8rcZ8tLgRyB7cWYj8fzHBrdV Ox0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=eR4K+ubh; 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 ce20si2241232ejb.183.2019.11.07.13.51.30; Thu, 07 Nov 2019 13:51:55 -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=eR4K+ubh; 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 S1726504AbfKGVuZ (ORCPT + 99 others); Thu, 7 Nov 2019 16:50:25 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:52764 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725870AbfKGVuY (ORCPT ); Thu, 7 Nov 2019 16:50:24 -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 xA7Ln8UK033167; Thu, 7 Nov 2019 21:50:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2019-08-05; bh=JOiMpIMuzkYYPmC19kfrXihQ9r3/nAyAF0rQELnGtrA=; b=eR4K+ubhN0/lrGO2pFeQKCgt0FG1+3rl3CuT9/oIA8tWurYylZTxlZxgbaCY9hmepMlW xxVXgBqsRTWzM99h2ofljbzzYEDEFmf0htjkCtLm/t7WIWEh7h42DEdIMIaFh/tAniEW lcrs9VKUPd05esnbaK8udEq6aTeMO3LcUutP48+okaqO4CcK4HbFM1vwmzBtvQ+vhj5Z o1VAeOqRTbVej2vhou2sWga3Qy+gbRwA28NP1MHTPneOO0v/+7gp8pBDmJ81CibJNm+J OThpHBFmuVCGyvktuJyi4PpmlANdEc4V7FahmV3uPXbf2C29ZM/9hRCBcqS+efi1ZcBw ag== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2w41w118rc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Nov 2019 21:50:00 +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 xA7Ln6o9181290; Thu, 7 Nov 2019 21:49:59 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2w4k2x5hv8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Nov 2019 21:49:59 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id xA7LnvNK003884; Thu, 7 Nov 2019 21:49:57 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:49:57 -0800 Subject: Re: [PATCH] hugetlbfs: Take read_lock on i_mmap for PMD sharing 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> From: Mike Kravetz Message-ID: Date: Thu, 7 Nov 2019 13:49:55 -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: <20191107195441.GF11823@bombadil.infradead.org> 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=982 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1910280000 definitions=main-1911070201 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-1911070201 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(). 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. -- Mike Kravetz