From patchwork Wed Jan 15 13:39:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Xinhai X-Patchwork-Id: 11334639 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 866A213BD for ; Wed, 15 Jan 2020 13:41:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4626624671 for ; Wed, 15 Jan 2020 13:41:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="h+Yra6CB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4626624671 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7AF518E0005; Wed, 15 Jan 2020 08:41:09 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 761538E0003; Wed, 15 Jan 2020 08:41:09 -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 678378E0005; Wed, 15 Jan 2020 08:41:09 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0117.hostedemail.com [216.40.44.117]) by kanga.kvack.org (Postfix) with ESMTP id 525F38E0003 for ; Wed, 15 Jan 2020 08:41:09 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 1C370440B for ; Wed, 15 Jan 2020 13:41:09 +0000 (UTC) X-FDA: 76379979858.17.start05_614b9eb4f6804 X-Spam-Summary: 2,0,0,275956c0a8389c88,d41d8cd98f00b204,lixinhai.lxh@gmail.com,::akpm@linux-foundation.org:mhocko@suse.com:mike.kravetz@oracle.com,RULES_HIT:41:355:379:541:800:960:966:973:988:989:1260:1345:1437:1534:1542:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:4321:4385:4605:5007:6261:6653:7514:8957:9413:10004:11026:11473:11658:11914:12043:12297:12438:12517:12519:12555:12895:12986:13255:14096:14181:14394:14687:14721:21080:21444:21451:21627:21666:21990:30054:30064:30070,0,RBL:error,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:26,LUA_SUMMARY:none X-HE-Tag: start05_614b9eb4f6804 X-Filterd-Recvd-Size: 4947 Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Wed, 15 Jan 2020 13:41:08 +0000 (UTC) Received: by mail-lj1-f196.google.com with SMTP id y4so18602043ljj.9 for ; Wed, 15 Jan 2020 05:41:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=USBbzR08Y4J4IaaUVEcsEjDq9jOnObKjvLQE8VBT9n4=; b=h+Yra6CBKr3L/51q6ZqVf1SD9129qJty9+oqOuSR9WigfQTw/rgBRlAqz5zcvZQPX2 zF63YCmwX8x7PRPJkdBNyUzINWinzWV4GJ5pEfbXEmMnc5LMVudmvU0lhvRUwWNq6Pwz TOS0KKpDCX8RPraPBrV9WeLL783H+cTlIyZ+KzGhz0wBlxpeqVJqPWIA16KL2E+OxvMg Q8NopGzcAA/lxUJ+WT4FhlHUOzmboGcukg2cpDC5chkO8wsOGuktQjBwcYnUnyvBoDQ+ nxtoab7Ia6k+tS4U1wVyOkb+f//9KTjQaB52PZE9w1kN3TnyaMJKcRh5ystfJVxZtS5r WCEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=USBbzR08Y4J4IaaUVEcsEjDq9jOnObKjvLQE8VBT9n4=; b=tv8RmBGrA6QAzzTa38VsqrxGkn5T2fPXtWe/C0JhMfd4M60SuUB/pj5MEh6jtf3SAm Vfb1KB2zjng8t5nNie8IYnMfSa94YOC8p/+n5JWsedDtg8WDLtKR1SyhcCK3EJ7OtaAk EZ1/FyyXfScoxWDtTJMiKuGKNCWizzfUvObF6TEDqA4lNhua0XSZyzFDEDfZQECBB/Mb fpxicqyUWPPB7/plHDbgGTbROrSTkQ8L4342fr8nVaT3YAnp2JX3z1F2tVwIVBvNn3h1 R3xnukFWdtoRHPZknBsMR+mpi2ei+N5VjvjzyEq+DLt/ko2mgdvUrI4bd9l63Nr3rRZU TEtA== X-Gm-Message-State: APjAAAXLLdE6Qc092I/j2PUSgNvk4OGldRvF7FTx5xpwJrGX9b9KJ/kM cHU32EXylSzh9mSG6/8Un3Zas2Qo X-Google-Smtp-Source: APXvYqz+IDG062FNwBWSJz2HcdyJsenFtej5Zr9jfWgF0tiQI87nNvMRpPPrDFJG6z8K9bbuL3MG+A== X-Received: by 2002:a2e:461a:: with SMTP id t26mr1797680lja.204.1579095662048; Wed, 15 Jan 2020 05:41:02 -0800 (PST) Received: from localhost.localdomain.localdomain ([131.228.2.21]) by smtp.gmail.com with ESMTPSA id u66sm9394284lje.7.2020.01.15.05.40.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Jan 2020 05:40:52 -0800 (PST) From: Li Xinhai To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, Michal Hocko , Mike Kravetz Subject: [PATCH v3] mm/mempolicy,hugetlb: Checking hstate for hugetlbfs page in vma_migratable Date: Wed, 15 Jan 2020 13:39:01 +0000 Message-Id: <1579095541-32731-1-git-send-email-lixinhai.lxh@gmail.com> X-Mailer: git-send-email 1.8.3.1 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: 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 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); + 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);