From patchwork Tue Oct 13 23:10:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 11836179 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6248E61C for ; Tue, 13 Oct 2020 23:11:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EAEB022227 for ; Tue, 13 Oct 2020 23:11:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="RKqzoRIW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EAEB022227 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1417C6B005D; Tue, 13 Oct 2020 19:11:16 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0F46A6B0062; Tue, 13 Oct 2020 19:11:16 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0069B6B0068; Tue, 13 Oct 2020 19:11:15 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0043.hostedemail.com [216.40.44.43]) by kanga.kvack.org (Postfix) with ESMTP id E7BED6B005D for ; Tue, 13 Oct 2020 19:11:15 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B42A08249980 for ; Tue, 13 Oct 2020 23:11:15 +0000 (UTC) X-FDA: 77368450110.22.water04_2e004f527207 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 90BBB18038E67 for ; Tue, 13 Oct 2020 23:11:15 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,mike.kravetz@oracle.com,,RULES_HIT:30012:30054:30064:30070,0,RBL:156.151.31.85:@oracle.com:.lbl8.mailshell.net-64.10.201.10 62.18.0.100;04ygiizhp4w47c3558cfdbmskmkjryc4hoys7juzaj6s9oqp76aznt3sj3gid7r.6i6whmkgmuhxxogaxz4b3uob3o59chnkybueh1uue5hfqgckhparydrzx74a1yy.g-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:20,LUA_SUMMARY:none X-HE-Tag: water04_2e004f527207 X-Filterd-Recvd-Size: 5946 Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Tue, 13 Oct 2020 23:11:14 +0000 (UTC) Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09DNAnXd123793; Tue, 13 Oct 2020 23:11:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=ocyR4HOoQb93ftTFzkO/TrEL+TOkJdPALBqHk8lypSA=; b=RKqzoRIWLDkKvU1mxwKxaBBRRZOduCTKNzpTNqdBTuqn1FEDbvcO+PiS6H2rAX4p2ytn xV7lVnrphIHwKvO3gMFJ0nK0cfSiz1zJZ1NI7QHm+YiMlwQivYwojRlm+i9t/uPHcGwT Yfb115/p1J44podgcaIXnveWpiUNIhDJ5w+6234V8oRrnUOIdSKbvD89ilorQwzFyNb6 ks6x9HLOvHTmmuNmOWzNiAig0YACvu5KtfxldKdbI+5N6ZUqqXdvcD0FwGhjROWyOqQG ybq7che782AqPXrcJFkU+Pr5iUaS/NjLubNfCnZiJFygXVUxox/3CQfoxb+HxZ0elUm5 Kg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 343vaeb4sn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 13 Oct 2020 23:11:09 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09DN5F3Q023581; Tue, 13 Oct 2020 23:11:08 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 343puykkq1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Oct 2020 23:11:08 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 09DNB5fp028202; Tue, 13 Oct 2020 23:11:05 GMT Received: from monkey.oracle.com (/50.38.35.18) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 13 Oct 2020 16:11:05 -0700 From: Mike Kravetz To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Hugh Dickins , Michal Hocko , Naoya Horiguchi , "Aneesh Kumar K . V" , Andrea Arcangeli , "Kirill A . Shutemov" , Davidlohr Bueso , Prakash Sangappa , Andrew Morton , Mike Kravetz Subject: [RFC PATCH 0/3] hugetlbfs: introduce hinode_rwsem for pmd sharing synchronization Date: Tue, 13 Oct 2020 16:10:57 -0700 Message-Id: <20201013231100.71013-1-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9773 signatures=668681 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 spamscore=0 adultscore=0 suspectscore=0 phishscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010130161 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9773 signatures=668681 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 clxscore=1015 impostorscore=0 phishscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 mlxscore=0 suspectscore=0 spamscore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010130161 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: In commit c0d0381ade79, changes were made to use i_mmap_rwsem for pmd sharing synchronization. This required changes to mm locking order that are hugetlb specific. Specifically, i_mmap_rwsem must be taken before the page lock. This is not not a huge issue in hugetlb specific code, but becomes more problematic in the areas of page migration and memory failure where generic mm code had to deal with this change to lock ordering. An ugly routine 'hugetlb_page_mapping_lock_write' was added to help with these issues. Recently, Hugh Dickins diagnosed a migration BUG as caused by code introduced with hugetlb i_mmap_rwsem synchronization [1]. Subsequent discussion in that thread pointed out additional problems in the code. Adding a rw_semaphore to the hugetlbfs inode for this type of synchronization was mentioned. Such an approach is actually 'cleaner' as it can be inserted in the lock hierarchy where needed. And, there is no issue with other parts of the mm using this rw_semaphore. This series adds a rw_semaphore (hinode_rwsem) to the hugetlbfs inode. The first patch reverts all commits having to deal with the current use of i_mmap_rwsem for pmd sharing and fault/truncate synchronization. The revert of 5 commits was combined into a single patch. I am looking for feedback on this approach. I considered: - 5 Patches to revert the 5 commits - Reverting patches depending on c0d0381ade79, then having a patch to change from i_mmap_rwsem to hinode_rwsem. To me, a 'clean slate' approach seemed best but I am open to whatever would be easiest to review. [1] https://lore.kernel.org/linux-mm/alpine.LSU.2.11.2010071833100.2214@eggly.anvils/ Mike Kravetz (3): hugetlbfs: revert use of i_mmap_rwsem for pmd sharing and more sync hugetlbfs: introduce hinode_rwsem for pmd sharing synchronization huegtlbfs: handle page fault/truncate races fs/hugetlbfs/inode.c | 72 ++++++------ include/linux/fs.h | 15 --- include/linux/hugetlb.h | 72 ++++++++++-- mm/hugetlb.c | 243 +++++++++++++++------------------------- mm/memory-failure.c | 34 ++---- mm/migrate.c | 34 +++--- mm/rmap.c | 17 +-- mm/userfaultfd.c | 14 +-- 8 files changed, 220 insertions(+), 281 deletions(-)