Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp377733imm; Thu, 21 Jun 2018 20:59:31 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK14zPhXUak6b4C3/Vjvo/B3hQ23cgg/xE9Bpb9fKQ5//M7fPyfH009IqitlwbPZewfOclu X-Received: by 2002:a63:8848:: with SMTP id l69-v6mr750188pgd.377.1529639971409; Thu, 21 Jun 2018 20:59:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529639971; cv=none; d=google.com; s=arc-20160816; b=crRL360IWGSff69wcdM8jifR1z85eBVt/XhCGYMpnt7N90ePYJF2iqXpZGY0BW5ayO qBILfsIYTI1t2fHCiCLf50EMGjmE1yrDmvLuGfMpi1u3/Zs0WGBXiQKGYXhfFcnZV926 qqW1n3Vo/HYYtt6fu1AQoLgcDchnXSZi6KaCUb9T6RZO0EEtscIZ3nnJ4t2fIAbyHSa/ qh9uMB8eCMdhb42mhTqWro+tKzW2bmZGD2irbQtbuHNE15g4aLN5xEWSYwy381OIKKN7 vZSsKJzGQRU5vBCOB3gO7xLjiEl26pDdmC13zJuKGoRMaoHCkMBYxNR87g6ccBSeigR4 xSHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=uq3Lw/a02JGhviLe79dyAhffkx+jvLqM9PmL3NO/PbU=; b=P6PdKzdY30QrzfxU/CUeRaHFiVQNNEJNpStcy1v6B8mu3Skl6zrnHFQCkjjeTNPJOw LA8YBmn4MDs5Xf/Ulk5UgUGKTUpcCsDbe1WeNb2/4X8PiEp5JFc1U9dQxji6u790kcpW WUNVUoZq/qC+psAshP1F3GoYU6zbF2okidxvpqt/xMjtRYDZVnK0Jdgzkony6kg7qC2k H/ff0bECtOqZKoos545n4A6VRzRqo1XmQFWjpwJBMOFN/3D8uukbjPpsoJrIWAshGBtM XIF+UlaHwZdTk7yeddV/zQN9MpPMoDMbEWsF2zSSwuAfrfSxBOa3eFZPlX7xnM9OUGqy VGTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u65-v6si5414515pgc.590.2018.06.21.20.59.16; Thu, 21 Jun 2018 20:59:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934591AbeFVDz7 (ORCPT + 99 others); Thu, 21 Jun 2018 23:55:59 -0400 Received: from mga01.intel.com ([192.55.52.88]:30400 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934385AbeFVDz4 (ORCPT ); Thu, 21 Jun 2018 23:55:56 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Jun 2018 20:55:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,255,1526367600"; d="scan'208";a="65335188" Received: from wanpingl-mobl.ccr.corp.intel.com (HELO yhuang6-ux31a.ccr.corp.intel.com) ([10.254.212.200]) by fmsmga004.fm.intel.com with ESMTP; 21 Jun 2018 20:55:52 -0700 From: "Huang, Ying" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , "Kirill A. Shutemov" , Andrea Arcangeli , Michal Hocko , Johannes Weiner , Shaohua Li , Hugh Dickins , Minchan Kim , Rik van Riel , Dave Hansen , Naoya Horiguchi , Zi Yan , Daniel Jordan Subject: [PATCH -mm -v4 17/21] mm, THP, swap: Support PMD swap mapping for MADV_WILLNEED Date: Fri, 22 Jun 2018 11:51:47 +0800 Message-Id: <20180622035151.6676-18-ying.huang@intel.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180622035151.6676-1-ying.huang@intel.com> References: <20180622035151.6676-1-ying.huang@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Huang Ying During MADV_WILLNEED, for a PMD swap mapping, if THP swapin is enabled for the VMA, the whole swap cluster will be swapin. Otherwise, the huge swap cluster and the PMD swap mapping will be split and fallback to PTE swap mapping. Signed-off-by: "Huang, Ying" Cc: "Kirill A. Shutemov" Cc: Andrea Arcangeli Cc: Michal Hocko Cc: Johannes Weiner Cc: Shaohua Li Cc: Hugh Dickins Cc: Minchan Kim Cc: Rik van Riel Cc: Dave Hansen Cc: Naoya Horiguchi Cc: Zi Yan Cc: Daniel Jordan --- mm/madvise.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/mm/madvise.c b/mm/madvise.c index fc423d96d4d6..6c7a96357626 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -196,14 +196,36 @@ static int swapin_walk_pmd_entry(pmd_t *pmd, unsigned long start, pte_t *orig_pte; struct vm_area_struct *vma = walk->private; unsigned long index; + swp_entry_t entry; + struct page *page; + pmd_t pmdval; + + pmdval = *pmd; + if (thp_swap_supported() && is_swap_pmd(pmdval) && + !is_pmd_migration_entry(pmdval)) { + entry = pmd_to_swp_entry(pmdval); + if (!transparent_hugepage_swapin_enabled(vma)) { + if (!split_swap_cluster(entry, false)) + split_huge_swap_pmd(vma, pmd, start, pmdval); + } else { + page = read_swap_cache_async(entry, + GFP_HIGHUSER_MOVABLE, + vma, start, false); + /* The swap cluster has been split under us */ + if (page) { + if (!PageTransHuge(page)) + split_huge_swap_pmd(vma, pmd, start, + pmdval); + put_page(page); + } + } + } if (pmd_none_or_trans_huge_or_clear_bad(pmd)) return 0; for (index = start; index != end; index += PAGE_SIZE) { pte_t pte; - swp_entry_t entry; - struct page *page; spinlock_t *ptl; orig_pte = pte_offset_map_lock(vma->vm_mm, pmd, start, &ptl); -- 2.16.4