From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C408EC33CB2 for ; Thu, 16 Jan 2020 00:09:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 68EA422522 for ; Thu, 16 Jan 2020 00:09:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="ZdTbVY4v" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 68EA422522 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 B50A58E0014; Wed, 15 Jan 2020 19:09:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ADA7D8E0003; Wed, 15 Jan 2020 19:09:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A2698E0014; Wed, 15 Jan 2020 19:09:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0113.hostedemail.com [216.40.44.113]) by kanga.kvack.org (Postfix) with ESMTP id 841568E0003 for ; Wed, 15 Jan 2020 19:09:58 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 20283181AEF00 for ; Thu, 16 Jan 2020 00:09:58 +0000 (UTC) X-FDA: 76381564476.20.oil51_39d9e98e4d541 X-HE-Tag: oil51_39d9e98e4d541 X-Filterd-Recvd-Size: 6621 Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Thu, 16 Jan 2020 00:09:57 +0000 (UTC) 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 00G09UDk154774; Thu, 16 Jan 2020 00:09:55 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=CrtbT8Kazqwfc6RF/PI+jT2AInYdBW/0I2+UMWfRcHY=; b=ZdTbVY4vnfBFc9jgEiB0D7DeTbp/AYrtk+KizmCxKnSkNYTDjQqotr4gNLphJ0LoViKD N8DsHpMCEeJcgI3xWsZk6Ztrx8EYG5/vJadz8hTACuwSExh2w0uo0V3SyaMwEkXnM9DY y0fppR5r08IY2YU7EVryagex3uaCPHZ550AwrpXNT5InHOz2zB9XhaSbfN5SN1rmD0yJ hJXFo2eJq8XF+OKlW3HTZZ9JKeOnECLXFi6am3rTiLCyhcMqdFPLP9rHX/NiwvNwz3MN O0X9grgqmA7JkMBXgjSVAvqcUial5C3+6u7A3mcGUHhoqixBduuMbZr7Rco9ZkfgfTmZ 6g== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2xf73tycjc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Jan 2020 00:09:54 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 00G09fF4148524; Thu, 16 Jan 2020 00:09:54 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 2xhy22a94d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Jan 2020 00:09:48 +0000 Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 00G09IaK013098; Thu, 16 Jan 2020 00:09:18 GMT Received: from [192.168.1.206] (/71.63.128.209) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 15 Jan 2020 16:09:18 -0800 Subject: Re: [PATCH v3] mm/mempolicy,hugetlb: Checking hstate for hugetlbfs page in vma_migratable To: Li Xinhai , linux-mm@kvack.org Cc: akpm@linux-foundation.org, Michal Hocko References: <1579095541-32731-1-git-send-email-lixinhai.lxh@gmail.com> From: Mike Kravetz Message-ID: <5eed1e80-bbeb-0f92-61d0-0d7fc8f1699c@oracle.com> Date: Wed, 15 Jan 2020 16:09:17 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: <1579095541-32731-1-git-send-email-lixinhai.lxh@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9501 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 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-1911140001 definitions=main-2001150183 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9501 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-1911140001 definitions=main-2001150183 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: On 1/15/20 5:39 AM, Li Xinhai wrote: > Checking hstate at early phase when isolating page, instead of during > unmap and move phase, to avoid useless isolation. > > Signed-off-by: Li Xinhai > Cc: Michal Hocko > Cc: Mike Kravetz > --- > include/linux/hugetlb_inline.h | 7 +++++++ > include/linux/mempolicy.h | 5 ++--- > mm/hugetlb.c | 9 +++++++++ > 3 files changed, 18 insertions(+), 3 deletions(-) > > diff --git a/include/linux/hugetlb_inline.h b/include/linux/hugetlb_inline.h > index 0660a03..fc07139 100644 > --- a/include/linux/hugetlb_inline.h > +++ b/include/linux/hugetlb_inline.h > @@ -11,6 +11,8 @@ static inline bool is_vm_hugetlb_page(struct vm_area_struct *vma) > return !!(vma->vm_flags & VM_HUGETLB); > } > > +extern bool vm_hugepage_migration_supported(struct vm_area_struct *vma); > + > #else > > static inline bool is_vm_hugetlb_page(struct vm_area_struct *vma) > @@ -18,6 +20,11 @@ static inline bool is_vm_hugetlb_page(struct vm_area_struct *vma) > return false; > } > > +static inline bool vm_hugepage_migration_supported(struct vm_area_struct *vma) > +{ > + return false; > +} > + > #endif > > #endif > diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h > index 5228c62..e9ed49e 100644 > --- a/include/linux/mempolicy.h > +++ b/include/linux/mempolicy.h > @@ -185,10 +185,9 @@ static inline bool vma_migratable(struct vm_area_struct *vma) > if (vma_is_dax(vma)) > return false; > > -#ifndef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION > - if (vma->vm_flags & VM_HUGETLB) > + if (is_vm_hugetlb_page(vma) && > + !vm_hugepage_migration_supported(vma)) > return false; > -#endif > > /* > * Migration allocates pages in the highest zone. If we cannot There are not many ways to work around the hugepage_migration_supported dependency issue. I suppose you could have moved vma_migratable() into mm/mempolicy.c instead of being an inline in the header file. However, it is probably best to do what you have done and hide the ugly stuff in the hugetlbfs files. > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index dd8737a..8ce4a98 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -1316,6 +1316,15 @@ int PageHeadHuge(struct page *page_head) > return get_compound_page_dtor(page_head) == free_huge_page; > } > > +bool vm_hugepage_migration_supported(struct vm_area_struct *vma) > +{ > + VM_BUG_ON_VMA(!is_vm_hugetlb_page(vma), vma); This VM_BUG_ON_VMA() seems unnecessary. The only caller is the one added with this patch which is only called if is_vm_hugetlb_page(vma). Even though VM_BUG_ON() is only enabled if CONFIG_DEBUG_VM, many distros (including the one running my desktop) enable CONFIG_DEBUG_VM in their default kernel. -- Mike Kravetz > + if (hugepage_migration_supported(hstate_vma(vma))) > + return true; > + > + return false; > +} > + > pgoff_t __basepage_index(struct page *page) > { > struct page *page_head = compound_head(page); >