Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp453640ybt; Mon, 6 Jul 2020 13:30:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiXWV59ZNHGVCwkXzcaLu+5+m+AjLyF++bFzldiXbClfwMyWwB/hRoTEA2trFdGBEUkV7H X-Received: by 2002:a05:6402:2064:: with SMTP id bd4mr56334153edb.180.1594067425982; Mon, 06 Jul 2020 13:30:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594067425; cv=none; d=google.com; s=arc-20160816; b=q7c3fsftknCBalAdAc+YnN/8EekBAySlGqHgwJjqB0LcRlfvYahxptQ8X6kYj2Orak i4Nu/qh7avJ+UqpwGEQ3hHu2cYf+T3eob9bacpGR5pXnuoPMCqXdhXyuWyhCClloLAJH XGNE9cNi0mX4R8qfc7njLE5l9mmKYbNvF1M5uZjK4s0lyv6XX/vaeaHp+qdKt04x8j2O egnDK0J3rm8Zho/5ko4EXKvvtk973TpPS/ldx79IlfzqKlwDzJepOd6lZlpa3+FJJtaJ MFlGyJbmcBHE8ddSWSjeRiBJ02DbVHuTTOZOlYFXCpp/eIZRruBElERwxiZNE6zKFFdz +UQg== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uKmjFEnaPpukaqN1TXpY12uCe1K0N+AZzcAaOaTUQCQ=; b=0ekOuQuQ3HTKz9QEf19yuBktNSCkCWLzZ2RCaw5JzmtVLqL4odekNrGRwGXG5+d+U9 hVj8xg/ciXC7UtFRbGxtjK07HhAtND9qP47HjYDOhRhs22IWTV0+vcP+zDxsgj8rWUzT u0cYIcNkLQPQZ+irVbDpzM/n2a1kyEPf5PA21DGVk04n2le6bNPdZjFGshDtzmqLN2Tz lTU3aoWVYQQnNzDtoUD7b5WrJD9cHB8y1uXAPD8vVMU7u18DUjVKCnqN9kdNAp2ji42G UzCsXv8qhz0AYmgIgp1fleiL/n0QL9L1Ary6d97GRFuyPp1jMbgOct9Hn9YOl8gbX/tp W/bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=Gm0J7Utb; 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=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m16si12836897eji.77.2020.07.06.13.30.03; Mon, 06 Jul 2020 13:30: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=@oracle.com header.s=corp-2020-01-29 header.b=Gm0J7Utb; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726936AbgGFU1j (ORCPT + 99 others); Mon, 6 Jul 2020 16:27:39 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:43334 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726280AbgGFU1j (ORCPT ); Mon, 6 Jul 2020 16:27:39 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 066KLpAG016027; Mon, 6 Jul 2020 20:26:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=uKmjFEnaPpukaqN1TXpY12uCe1K0N+AZzcAaOaTUQCQ=; b=Gm0J7Utboy6Tt0uuzT9deg35GgNPktmTb+khP7NkhevKYwHl7AX73eQhQnPFyMs95Snv DjD3JIi4Wbf/GAvf4NrCLA+dlTgV+GTE+Vll6/GItAZY3vtx/khL8OU712qd19O62a0k 5RYjEW7PY0HzgU3G8fEppBCq9Y66q+cd9U8jljXy+W2zqeG3pQlyXhRR+68DOGhCqKA+ S4asQqtW/Mowqg821nrfDxATGd8hr88PkU5Fl7idycavUS/hxLotL1DAeuTGWFbOZxMO 4JKQ8JD/9t0kH/nsQprPL4LBi/sfxo3SWLBOCiFVrHPUO2ZV8P/zEHX5Zzhtv7gEMnQ0 jg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 323waccgdy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 06 Jul 2020 20:26:22 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 066KO9Va126213; Mon, 6 Jul 2020 20:26:22 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 3233pvxa6w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Jul 2020 20:26:22 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 066KQJaj019671; Mon, 6 Jul 2020 20:26:19 GMT Received: from monkey.oracle.com (/50.38.35.18) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Jul 2020 13:26:19 -0700 From: Mike Kravetz To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Michal Hocko , Hugh Dickins , Naoya Horiguchi , "Aneesh Kumar K . V" , Andrea Arcangeli , "Kirill A . Shutemov" , Davidlohr Bueso , Prakash Sangappa , Andrew Morton , Linus Torvalds , Mike Kravetz Subject: [RFC PATCH 0/3] hugetlbfs: address fault time regression Date: Mon, 6 Jul 2020 13:26:12 -0700 Message-Id: <20200706202615.32111-1-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200622005551.GK5535@shao2-debian> References: <20200622005551.GK5535@shao2-debian> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9674 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2007060138 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9674 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 spamscore=0 mlxlogscore=999 adultscore=0 cotscore=-2147483648 suspectscore=0 impostorscore=0 bulkscore=0 mlxscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2007060138 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commits c0d0381ade79 and 87bf91d39bb5 changed the way huegtlb locking was performed to address BUGs. One specific change was to always take the i_mmap_rwsem in read mode during fault processing. One result of this change was a 33% regression for anon non-shared page faults [1]. Technically, i_mmap_rwsem only needs to be taken during page faults if the pmd can potentially be shared. pmd sharing is not possible for anon non-shared mappings (as in the reported regression), therefore the code can be modified to not acquire the semaphore in this case. Unfortunately, commit 87bf91d39bb5 depends on i_mmap_rwsem always being taken in the fault path to prevent fault/truncation races. So, that approach is no longer appropriate. Rather, the code now detects races and backs out operations. This code "works" in that it only takes i_mmap_rwsem when necessary and addresses the original BUGs. However, I am sending as an RFC because: - I am unsure if the added complexity is worth performance benefit. - There needs to be a better way/location to make a decison about taking the semaphore. See FIXME's in the code. Comments and suggestions would be appreciated. [1] https://lore.kernel.org/lkml/20200622005551.GK5535@shao2-debian Mike Kravetz (3): Revert: "hugetlbfs: Use i_mmap_rwsem to address page fault/truncate race" hugetlbfs: Only take i_mmap_rwsem when sharing is possible huegtlbfs: handle page fault/truncate races fs/hugetlbfs/inode.c | 69 +++++++++----------- mm/hugetlb.c | 150 ++++++++++++++++++++++++++++++------------- 2 files changed, 137 insertions(+), 82 deletions(-) -- 2.25.4