From patchwork Wed Jan 15 06:43:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Xinhai X-Patchwork-Id: 11333437 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 BD6691398 for ; Wed, 15 Jan 2020 06:45:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7FD832467E for ; Wed, 15 Jan 2020 06:45:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Z8E6UpwK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7FD832467E 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 A94468E0005; Wed, 15 Jan 2020 01:45:51 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A45E78E0003; Wed, 15 Jan 2020 01:45:51 -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 933E08E0005; Wed, 15 Jan 2020 01:45:51 -0500 (EST) X-Original-To: linux-mm@kvack.org 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 7FC268E0003 for ; Wed, 15 Jan 2020 01:45:51 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 3EE178248047 for ; Wed, 15 Jan 2020 06:45:51 +0000 (UTC) X-FDA: 76378933302.27.yard20_6d41284b4d027 X-Spam-Summary: 2,0,0,290bc0740889fa8f,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:1535:1542:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3871:4321:4385:4605:5007:6261:6653:7514:8957:9413:10004:11026:11473:11658:11914:12043:12296: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:25,LUA_SUMMARY:none X-HE-Tag: yard20_6d41284b4d027 X-Filterd-Recvd-Size: 5317 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Wed, 15 Jan 2020 06:45:50 +0000 (UTC) Received: by mail-wm1-f67.google.com with SMTP id b19so16517000wmj.4 for ; Tue, 14 Jan 2020 22:45:50 -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=3DmnjShMl+1+jcYwaKGcIzgWe54a1/E2kPHaq+rRmWI=; b=Z8E6UpwKw3nI93gPdHSOMj8y40BaTCabUQrP6PgD5uiDj+q2g5gzjV0+b5eclYuyqw xn+tG7t5UdAs15Rg7fs7criQKJzdJZ77Ugrmv4BeRjuoE81O90ULbAhFYkTQgkzVBYJR cMUeSgG+YW6/qE8p4dZ5uPjKpSZc66kXh7EmEGFDR4BLoavZvibeZC3iNUqrXrTSJtIS elBnoEpXpizatNgyrohC4Zbb8hAsS3szFp+YSIhwqOtGFN6F+a6n1jY5J4yGIewh2EaM GmvibHFvv4pEoDaTbjDIe8ztER9RBTuQPTJ2XmSB+ugfvt/GbiEWVw0nSf1xVwXRXR0C IPtg== 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=3DmnjShMl+1+jcYwaKGcIzgWe54a1/E2kPHaq+rRmWI=; b=S3MTZ2R2J2tn7uBaAaNP1T0ILT7NW0i8I1Fg6tVwlrOwmC9YKKh4UEcXoPooX+N2xY mRwe0tRV4xD5hN0V1ZmG1qdnBD1QAc08JqcgPCuF1D24HVuXFjqED9Mjc5L6plYT8p7v DRa0Fl2/EQkYejCz0OfheTyxXmD9fJIfyW8NISZJBIpDY9cFT+JduqHdPh7WDqXiq0uk KotvvomDa1A7+sLNcW+q+nYAKI/0HLsDpSsNbpRexpn2ExDBtwUMEAXOUbJAwLuGZSCq fR+ulNoiGfxUFwas8zSgrKZfVqyyiasVeZRv7qQAcEYBFzXBw5CVB4eNIwRF2ez+5BVt E49Q== X-Gm-Message-State: APjAAAXWj9tp+ARK0kdGBGbAmXH2OmTfV7PJXqwCI0aOXzG4z9Z/1RET rVjOOdHD3MWXM5r/Ovh9F/kJZK0L X-Google-Smtp-Source: APXvYqzTkAUV0qmDTm5RcNk4NI7iKzBDP5jAaUmWWBIk8DlRzIkNK7jlbXk/fqssW0cgUq95rhOc8A== X-Received: by 2002:a05:600c:28d:: with SMTP id 13mr30147959wmk.52.1579070749174; Tue, 14 Jan 2020 22:45:49 -0800 (PST) Received: from localhost.localdomain.localdomain ([131.228.2.21]) by smtp.gmail.com with ESMTPSA id s128sm22446115wme.39.2020.01.14.22.45.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Jan 2020 22:45:48 -0800 (PST) From: Li Xinhai To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, Michal Hocko , Mike Kravetz Subject: [PATCH v2] mm/mempolicy,hugetlb: Checking hstate for hugetlbfs page in vma_migratable Date: Wed, 15 Jan 2020 06:43:57 +0000 Message-Id: <1579070637-26945-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 --- v1->v2: New function bool vm_hugepage_migration_supported(struct vm_area_struct *vma) is introduced to simplify the inter dependency of include/linux/mempolicy.h and include/linux/hugetlb.h, and could be useful for other caller. include/linux/hugetlb.h | 2 ++ include/linux/mempolicy.h | 6 +++--- mm/hugetlb.c | 10 ++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 31d4920..52fc034 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -834,6 +834,8 @@ static inline void set_huge_swap_pte_at(struct mm_struct *mm, unsigned long addr } #endif /* CONFIG_HUGETLB_PAGE */ +extern bool vm_hugepage_migration_supported(struct vm_area_struct *vma); + static inline spinlock_t *huge_pte_lock(struct hstate *h, struct mm_struct *mm, pte_t *pte) { diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h index 5228c62..6637166 100644 --- a/include/linux/mempolicy.h +++ b/include/linux/mempolicy.h @@ -172,6 +172,7 @@ int do_migrate_pages(struct mm_struct *mm, const nodemask_t *from, extern void mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol); +extern bool vm_hugepage_migration_supported(struct vm_area_struct *vma); /* Check if a vma is migratable */ static inline bool vma_migratable(struct vm_area_struct *vma) { @@ -185,10 +186,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..fce149c 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1316,6 +1316,16 @@ 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) +{ +#ifdef CONFIG_HUGETLB_PAGE + VM_BUG_ON(!is_vm_hugetlb_page(vma)); + if (hugepage_migration_supported(hstate_vma(vma))) + return true; +#endif + return false; +} + pgoff_t __basepage_index(struct page *page) { struct page *page_head = compound_head(page);