From patchwork Fri Mar 8 22:48:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 10845547 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A34A54B69 for ; Fri, 8 Mar 2019 22:48:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 904AD30773 for ; Fri, 8 Mar 2019 22:48:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C506307C3; Fri, 8 Mar 2019 22:48:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1423307D8 for ; Fri, 8 Mar 2019 22:48:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F19BF8E0006; Fri, 8 Mar 2019 17:48:53 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EA18A8E0002; Fri, 8 Mar 2019 17:48:53 -0500 (EST) 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 D90A78E0006; Fri, 8 Mar 2019 17:48:53 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 998C08E0002 for ; Fri, 8 Mar 2019 17:48:53 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id e4so23768177pfh.14 for ; Fri, 08 Mar 2019 14:48:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=O5EHSkQ/u9+Ox2Mr2Uq0ikS/eyXYPl8wihZ948OlhZ0=; b=E/fu8Ny4gHedZIJ0i0bhUbidL25pFjdZsG3nWo46vwSF8fNZs9rMehsbK2yQnaWIr+ ww3e1lfU3ActCYyFG2RL1b+baLAG/Ra4Q8qchUYEDJ/7bRirOI8AuU0FoRWmUVpCG2r4 PwtTKmVhdQLBVJ62kaVC8WLiELmB6RfhNAtAc98QgHlVO19Lt8FPa13pKU8F2DyV5APq rjo5xK3VlqVzHDHTJTG+KsrMs5gBjaMjer7DLRWEfxnHZLqgXosEMghZ93MRyC3r/jbL lXaIlLJOjOztwU3KoxJpvQU2UvE7opFsuT+dk2f33V1+7rUHUTnnnmtjQe6+5qnXbakz /0Rw== X-Gm-Message-State: APjAAAU/f6cPw+jlSMm7/fGFzFAeb9PI2FSkJHoba9LjCeABjEEjCAYY NI8KpNV13myLbd2mKUmdRb0UaqGP4CQ6pKpT4oowmRJY+5IBApsKFveRNRJC1pIYpANlitdmy0u P0veZ4hPBxa6SqDkb1LFKPguoe3CoHJGG3ApcZmI0cGqUJ1p5E8yH7GtFrcOaGPNxUw== X-Received: by 2002:a63:2d5:: with SMTP id 204mr1793340pgc.407.1552085333287; Fri, 08 Mar 2019 14:48:53 -0800 (PST) X-Google-Smtp-Source: APXvYqxpfJbqLxVUxPmr4ayczYGNCYCXX1hCHEw0gKoemM1wLuxbo9t/hpc8F/xhVSKGHUv8yYD8 X-Received: by 2002:a63:2d5:: with SMTP id 204mr1793302pgc.407.1552085332402; Fri, 08 Mar 2019 14:48:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552085332; cv=none; d=google.com; s=arc-20160816; b=fFVdi7+5n6Huo37/O9bVwSFyNeGejrPslGkE3kUr+zajHfPU4eYX5UmQ637SAKe2LU vFsSv+JJ+OVbxyTGOY7AeZ6VhYvd/Sw1FKJNuJ2L5A+g6NCukc5vSEU96HCDnxt8T5UG KpO1aLlY8M9jbxby1Tpx7zNOe54amo2/9JAGMn53bsTt5S2bCTgAj+wE2nEUmnUUEqP1 rXbX+L9oG5/D1uoVEMyWA/Kwg46w6L67oMVhwjGCL0eDyfyCFq0/5HLx7rk5hL8EM1/G 5oZiicVftI506LEP8UmCu6ZbWo920/R0uIV0zQY0Cjcx/6vBZx/o8nTfNqgSVKx3/IlG cLhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=O5EHSkQ/u9+Ox2Mr2Uq0ikS/eyXYPl8wihZ948OlhZ0=; b=LbHW+NVUYf/TXaetdRPEWP3wl2SeD3KWxFaNikZhj0UQLGn9+DtB1K67OVMv0w6znf 2L7FL4XRXdinTqvo0OETSh/9EEYZ82wFziG6T46g25euOHmFyojKw6TU2+9Gz1F/6qQb i3rxwIhhgwNL2V8AqLZS/zRNpOR1aKRyZpD3ohhA6I8h0wlYODcwyUGzDIwN1cogzf1e gRvb332KO1AqX4Iw8+4Ti6Ux/VF8AvNkaKyEVjdVLvL1tWA+0Ah/hKxDaUPcGKwiMACE +CBDjT3zJBPWQ35f6u53EuVhuF+ltrji2HB7wMN3Nm5kGb0iqsUxPlISA4KYtjno8yVG mnqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=cPBtA15q; spf=pass (google.com: domain of mike.kravetz@oracle.com designates 141.146.126.79 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from aserp2130.oracle.com (aserp2130.oracle.com. [141.146.126.79]) by mx.google.com with ESMTPS id m6si5694373pgq.24.2019.03.08.14.48.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 14:48:52 -0800 (PST) Received-SPF: pass (google.com: domain of mike.kravetz@oracle.com designates 141.146.126.79 as permitted sender) client-ip=141.146.126.79; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=cPBtA15q; spf=pass (google.com: domain of mike.kravetz@oracle.com designates 141.146.126.79 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x28MjIg3055924; Fri, 8 Mar 2019 22:48:48 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; s=corp-2018-07-02; bh=O5EHSkQ/u9+Ox2Mr2Uq0ikS/eyXYPl8wihZ948OlhZ0=; b=cPBtA15qK2/F168SBEZ+z7296XCrKvDYA9dCZ7BC1hmaZsAgpKaYCNw+nR1umxdgUFzB BsqwwVFqXv1doaaG2tN1P35Euo9dMadG8mwvqb3Bs/21Pg3miTNm7S0SwZZhFgU56te7 6qs5LcAT5hkU9g1ijsbSWLQcI5bn0lfxrdN0yG2h/nMAtUuHOV1+NWw0RzpUhpiNY5Rx h+1/lH5q3dDcPEbjHZemaORGLDkToIFD/nhoUl867Cje5jU8+xZ6OzxCZ/RjE9xrEDom 4hKTcFC+nzmnjfjmgmaWTRsBHVMP1b9k848Do5sqLkjhoNvC7qv5ZA73r6PMGdTcy2An tw== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2qyfbeu3w0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 08 Mar 2019 22:48:47 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x28MmfV0019849 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 Mar 2019 22:48:42 GMT 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 x28MmfTb027797; Fri, 8 Mar 2019 22:48:41 GMT Received: from monkey.oracle.com (/50.38.38.67) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 08 Mar 2019 14:48:41 -0800 From: Mike Kravetz To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Davidlohr Bueso Cc: Joonsoo Kim , Michal Hocko , Naoya Horiguchi , "Kirill A . Shutemov" , Andrew Morton , Mike Kravetz Subject: [PATCH 1/2] huegtlbfs: on restore reserve error path retain subpool reservation Date: Fri, 8 Mar 2019 14:48:22 -0800 Message-Id: <20190308224823.15051-2-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190308224823.15051-1-mike.kravetz@oracle.com> References: <20190308224823.15051-1-mike.kravetz@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9189 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 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-1810050000 definitions=main-1903080157 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: X-Virus-Scanned: ClamAV using ClamSMTP When a huge page is allocated, PagePrivate() is set if the allocation consumed a reservation. When freeing a huge page, PagePrivate is checked. If set, it indicates the reservation should be restored. PagePrivate being set at free huge page time mostly happens on error paths. When huge page reservations are created, a check is made to determine if the mapping is associated with an explicitly mounted filesystem. If so, pages are also reserved within the filesystem. The default action when freeing a huge page is to decrement the usage count in any associated explicitly mounted filesystem. However, if the reservation is to be restored the reservation/use count within the filesystem should not be decrementd. Otherwise, a subsequent page allocation and free for the same mapping location will cause the file filesystem usage to go 'negative'. Filesystem Size Used Avail Use% Mounted on nodev 4.0G -4.0M 4.1G - /opt/hugepool To fix, when freeing a huge page do not adjust filesystem usage if PagePrivate() is set to indicate the reservation should be restored. Signed-off-by: Mike Kravetz --- mm/hugetlb.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 8dfdffc34a99..64ef640126cd 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1257,12 +1257,23 @@ void free_huge_page(struct page *page) ClearPagePrivate(page); /* - * A return code of zero implies that the subpool will be under its - * minimum size if the reservation is not restored after page is free. - * Therefore, force restore_reserve operation. + * If PagePrivate() was set on page, page allocation consumed a + * reservation. If the page was associated with a subpool, there + * would have been a page reserved in the subpool before allocation + * via hugepage_subpool_get_pages(). Since we are 'restoring' the + * reservtion, do not call hugepage_subpool_put_pages() as this will + * remove the reserved page from the subpool. */ - if (hugepage_subpool_put_pages(spool, 1) == 0) - restore_reserve = true; + if (!restore_reserve) { + /* + * A return code of zero implies that the subpool will be + * under its minimum size if the reservation is not restored + * after page is free. Therefore, force restore_reserve + * operation. + */ + if (hugepage_subpool_put_pages(spool, 1) == 0) + restore_reserve = true; + } spin_lock(&hugetlb_lock); clear_page_huge_active(page); From patchwork Fri Mar 8 22:48:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 10845543 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A5D1A1390 for ; Fri, 8 Mar 2019 22:48:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92BEC3075D for ; Fri, 8 Mar 2019 22:48:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 907A730701; Fri, 8 Mar 2019 22:48:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 116CF3075D for ; Fri, 8 Mar 2019 22:48:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 294DC8E0005; Fri, 8 Mar 2019 17:48:50 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 274B78E0002; Fri, 8 Mar 2019 17:48:50 -0500 (EST) 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 15A718E0005; Fri, 8 Mar 2019 17:48:50 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id C982E8E0002 for ; Fri, 8 Mar 2019 17:48:49 -0500 (EST) Received: by mail-pg1-f197.google.com with SMTP id n10so8440583pgp.21 for ; Fri, 08 Mar 2019 14:48:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=3IApX+ff+PN7FBEvogPd9vgxa4QqAsqb3qIGJTQfIzQ=; b=NRB+BcwiZSfsB2t/AVMh9BPRxjDwiV+1gBXx7ZYut/JLlfOSSdK/NhssQunCz+iNJr hqx2DUwsamOaoTu8Wlaoq5+dhjDaPFahljhagBcsNy8wt2x8+dDoLC1MyMe4AsXNl6lZ BJ7GyY54+rZnTz44ubIKjpPmTeThVmQKX6Y5JkfycL2MS6abn+pgj2DsbgFRPjye1Pro OJ9k02YFfEiC/aXik2SlFzx5czdtW8v9SMngKe4kCwrvhh+l1xUCi2SAoR2nF8TWKiJj sa7IAyxisXgrG7jnp4ACFJNyoyiiLF1LCFnqnYgFNX+mzC+yWxnPtjXeGLngODrMB3ki qkKg== X-Gm-Message-State: APjAAAUXi5v8oEN/ijXfAHkuaV4gN8JJtoJtkaHPTRTI75R3n61St+pm 2G2KAeDF5CmRfABO570+jYGzC0hLzgKWQpGlmSUSQ8v0BYxx5MglH4LiRcFzBfw18ox1Ewc0LTW kss8P4N4QYyN6pYXCx2zPbxiUBPHswMM5q3mGqzk1MM1DACaBq9WZz1Li2giSJothMw== X-Received: by 2002:a17:902:403:: with SMTP id 3mr21354823ple.48.1552085329455; Fri, 08 Mar 2019 14:48:49 -0800 (PST) X-Google-Smtp-Source: APXvYqx4HxpfFPJznTAn1xckhFajjkmf4uXmXp8Ax2DNXprGi4odfpEfa/eeWi0NsAOJu6btptcs X-Received: by 2002:a17:902:403:: with SMTP id 3mr21354735ple.48.1552085327747; Fri, 08 Mar 2019 14:48:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552085327; cv=none; d=google.com; s=arc-20160816; b=g7Ts9AD39L005pdGwdk5cUAGAuVa7ZHCC0dcoLb/0nUMO0opUchnMq6de3mmYuEuRH cehJXZvtSFaamFu97+dzF+vpIx+nE4fPxm2JwA9KKNG2oF4nzU6HHzqer/yql8Vn8nNm Q/Im4F+x2MsxfNrjxX6wpuxEHx2oAxwo8kDwPov6Z2TtCgunAhdYZj91PiaqwCrxKf1x w2sWrA2MFMdWCZ3Maixg815tjIj7mDywY/MK/U9RNQh0Brfhky9Qk8GvLM4LwRTjtkv5 m0X1hprjiPV4NymPYN880nUDf7GkI77ipBBaIw6Cox0DiokcmrLYmKCreYO6VM6cynGE jyng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3IApX+ff+PN7FBEvogPd9vgxa4QqAsqb3qIGJTQfIzQ=; b=n+dDisBOQMElpkhLSjNWbvV08C7Pf8nepdYv2KWKFhJnbPvJ5YUPtRuvpf3VOUZ+yx v63p16+uJ/tTRBqQ/bcVm+wRuwiE2GUPQA9dhCJiK5Nj4ebVH7eFKAE64zVvCDYXN0Id 3fIbE4ieIz4G2+HKdg7MgAKgPYrG+igARcyqVXajLRfiNUjs19xSZsFW67v5tPsbSFMa XczZl9oOLXr3vIjI8kpJ/g/e97MHwVI0hmEktl0/K2MYktfhjBquJnhA/BYJdWTR3F9V PGpiaFvELrDayySRVJ+qsPfa/HllbRLDZo+zJ8S8UYFeLy1Ps6uCFeztaXPctPLXr8nO F+aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=LXSg3pRS; spf=pass (google.com: domain of mike.kravetz@oracle.com designates 156.151.31.85 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from userp2120.oracle.com (userp2120.oracle.com. [156.151.31.85]) by mx.google.com with ESMTPS id m7si7415229pgp.187.2019.03.08.14.48.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 14:48:47 -0800 (PST) Received-SPF: pass (google.com: domain of mike.kravetz@oracle.com designates 156.151.31.85 as permitted sender) client-ip=156.151.31.85; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=LXSg3pRS; spf=pass (google.com: domain of mike.kravetz@oracle.com designates 156.151.31.85 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x28Mhaic022226; Fri, 8 Mar 2019 22:48:44 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; s=corp-2018-07-02; bh=3IApX+ff+PN7FBEvogPd9vgxa4QqAsqb3qIGJTQfIzQ=; b=LXSg3pRSyzoFxVwwJJj6ZyK/EgUfqoJe1+3eSW24zye2++DcnRnvgE2e3fChV8tR7Fo6 kEUhAv775oyvS3cu0ertrbN9BJ/xm5/L0KnMnzvhv+/rhPlziEZZomryG+SqjQhCeiC5 okqbFeviivTh/4zG5uIkZzTUgYlWXWxoxlJaZqKiUyK5TgJ2rE6+a9RgWCu+8Ya5qPgw NraN1d+71QYuq8X7TeNfszD4/X2CtV3ND7GaX3kseyfCXipJIIQc5hFkBCBZ86QvxVWw ZEW9R+hPfSROA3AQJtVKhOLUYO6Xg047jB6TXJ9eBrW8PTtsuEWrcXXyp/xbnt1Plfwf ew== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2qyjfs2r3s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 08 Mar 2019 22:48:44 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x28MmhpL009210 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 Mar 2019 22:48:43 GMT 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 x28Mmhrh027803; Fri, 8 Mar 2019 22:48:43 GMT Received: from monkey.oracle.com (/50.38.38.67) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 08 Mar 2019 14:48:43 -0800 From: Mike Kravetz To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Davidlohr Bueso Cc: Joonsoo Kim , Michal Hocko , Naoya Horiguchi , "Kirill A . Shutemov" , Andrew Morton , Mike Kravetz Subject: [PATCH 2/2] hugetlb: use same fault hash key for shared and private mappings Date: Fri, 8 Mar 2019 14:48:23 -0800 Message-Id: <20190308224823.15051-3-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190308224823.15051-1-mike.kravetz@oracle.com> References: <20190308224823.15051-1-mike.kravetz@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9189 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=734 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903080157 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: X-Virus-Scanned: ClamAV using ClamSMTP hugetlb uses a fault mutex hash table to prevent page faults of the same pages concurrently. The key for shared and private mappings is different. Shared keys off address_space and file index. Private keys off mm and virtual address. Consider a private mappings of a populated hugetlbfs file. A write fault will first map the page from the file and then do a COW to map a writable page. Hugetlbfs hole punch uses the fault mutex to prevent mappings of file pages. It uses the address_space file index key. However, private mappings will use a different key and could temporarily map the file page before COW. This causes problems (BUG) for the hole punch code as it expects the mutex to prevent additional uses/mappings of the page. There seems to be another potential COW issue/race with this approach of different private and shared keys as notes in commit 8382d914ebf7 ("mm, hugetlb: improve page-fault scalability"). Since every hugetlb mapping (even anon and private) is actually a file mapping, just use the address_space index key for all mappings. This results in potentially more hash collisions. However, this should not be the common case. Signed-off-by: Mike Kravetz --- mm/hugetlb.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 64ef640126cd..0527732c71f0 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3904,13 +3904,8 @@ u32 hugetlb_fault_mutex_hash(struct hstate *h, struct mm_struct *mm, unsigned long key[2]; u32 hash; - if (vma->vm_flags & VM_SHARED) { - key[0] = (unsigned long) mapping; - key[1] = idx; - } else { - key[0] = (unsigned long) mm; - key[1] = address >> huge_page_shift(h); - } + key[0] = (unsigned long) mapping; + key[1] = idx; hash = jhash2((u32 *)&key, sizeof(key)/sizeof(u32), 0);