From patchwork Wed May 23 08:26:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 10420621 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AD16360224 for ; Wed, 23 May 2018 08:27:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E50E28E3F for ; Wed, 23 May 2018 08:27:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9316128E54; Wed, 23 May 2018 08:27:31 +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=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE 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 E24BB28E3F for ; Wed, 23 May 2018 08:27:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8A1926B0274; Wed, 23 May 2018 04:27:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8539E6B0275; Wed, 23 May 2018 04:27:24 -0400 (EDT) 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 7446F6B0276; Wed, 23 May 2018 04:27:24 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id 335276B0274 for ; Wed, 23 May 2018 04:27:24 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id b64-v6so12816045pfl.13 for ; Wed, 23 May 2018 01:27:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=3ZzLloSB2+bT79w24CysRz2CYqCB4fAK5OfwVM4vocE=; b=Jv0BOHrJON2aPpND1s6E1+YYWPfiC3lm6ubdW6RbbNe2fX4oB6Wnrb4/i0WmlbXHRm FHYiP3RSVW4qpQfFU0mJdujZ6MS1sd3I1rX4TuCeWuNWamnsMPkHTP5Smgsquinvl/1O PhQ4JFzyF/wDRKimuZKSToeVTSpNfoosVSBjOBUdH2Xh5AFNiqopOfL/ZDWyruNMLzMV gr2vFO/OPG3sYm94N7mDgDsWGnbjjd1/GY+9iBbUQziyYyZ5ehwtBA8tjsWV7aFRJhPY guHYf5SfSmIgDlnz3+KjfoIBORIEHgwS54wqp5vq7h48FU8EvMjN8JTA2cMp/CrkVxvn qDUQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: ALKqPwfAIim5hHDDENhNZE5Uv283qH+rOgJ6YcP1ASC5QfkrKXtxOfjY nGY1gkowI8ipEXuWxDmfv0V8lB/9+oZH5LEbZavSbsO6/RCkGYqBecZgG0ZppwkFPz+q3eAcZvR 47boTai8sBOSdOgbhvrvwG1GABqYuhoGB42go3T5PfgpH37tmsfC2aeboF8kE4bVixA== X-Received: by 2002:a62:7002:: with SMTP id l2-v6mr1963210pfc.40.1527064043897; Wed, 23 May 2018 01:27:23 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrzruinVYKccK4m6Z7nfGapimNUHUBAa3B9IU19TPRvWAavt2QiafTA8UUgljEnITvXa2cD X-Received: by 2002:a62:7002:: with SMTP id l2-v6mr1963182pfc.40.1527064043103; Wed, 23 May 2018 01:27:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527064043; cv=none; d=google.com; s=arc-20160816; b=uik5atQJFNi2jgUdnuHHxEk9SN5sW39c3LXtuswziSeTNDXN8oSfdbtxg4fONwgTdy rQDl44izydX6ZItqpVCLM/gcqMP02tJ7g87bg5GG4uo12xKDotUd5cz5b4dpQKXEJOLt WJH9cbGKv9m05Ex0xh2ZrJX6vY0ziCbOyOE/XFNV0j8oX/3PRHL/FdSzzItlScfynope v7r/eGncLZMB6+eIHiUHn4HfVBf6RUNa3p01NCdJBfwZRxEEKexv/+XWdCTCDQi/PQdz zstxIDFr1wrlo2jiwTrsnk80HXVALqHuBqhbeHYudNcfvOt+T49+2u/1XqPzwhdVOQXE IIug== 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 :arc-authentication-results; bh=3ZzLloSB2+bT79w24CysRz2CYqCB4fAK5OfwVM4vocE=; b=FK6uNf2cT8vwLo6c0a3s9k8AT1T67Ar5fM9qTY6vQpJL3qdxzHeCkAuN7vE7W4skpw ogQy5FbhMVB5ewfjsSS0fKRJqKf+H3VWtxShJj6PRRbiJElwP8D0QKwMv2QO3ICY58Jm SLCVyt8xDIltGIJw75cxDJpnF/weL8t1OFqud6cnW0DNCtA31MkC8GXE6jG83t3LxMBg kQ1MXW2o2BTdz4MWyiRq2X+jDaTL0SboUUnXB5zBgqLT5yzUFBTlnye3fvu5ToImSYYU YpJutKabytjraNkBfgTBiaXKjLJX3K/El88il+QPW1tkLam2KtAgMOfOwS3LeeLYxOIO 1D9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga12.intel.com (mga12.intel.com. [192.55.52.136]) by mx.google.com with ESMTPS id e9-v6si18192372pln.72.2018.05.23.01.27.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 May 2018 01:27:23 -0700 (PDT) Received-SPF: pass (google.com: domain of ying.huang@intel.com designates 192.55.52.136 as permitted sender) client-ip=192.55.52.136; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 May 2018 01:27:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,432,1520924400"; d="scan'208";a="57726260" Received: from yhuang6-ux31a.sh.intel.com ([10.239.197.97]) by fmsmga001.fm.intel.com with ESMTP; 23 May 2018 01:27:17 -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 Subject: [PATCH -mm -V3 17/21] mm, THP, swap: Support PMD swap mapping for MADV_WILLNEED Date: Wed, 23 May 2018 16:26:21 +0800 Message-Id: <20180523082625.6897-18-ying.huang@intel.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180523082625.6897-1-ying.huang@intel.com> References: <20180523082625.6897-1-ying.huang@intel.com> 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 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 --- mm/madvise.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/mm/madvise.c b/mm/madvise.c index e03e85a20fb4..44a0a62f4848 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);