From patchwork Fri Jun 22 03:51:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 10481173 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 A28F860383 for ; Fri, 22 Jun 2018 03:56:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 950BC28F91 for ; Fri, 22 Jun 2018 03:56:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89F7A28F98; Fri, 22 Jun 2018 03:56:14 +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=unavailable 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 2E1AB28F91 for ; Fri, 22 Jun 2018 03:56:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 62A5A6B0280; Thu, 21 Jun 2018 23:55:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5D9326B0282; Thu, 21 Jun 2018 23:55:58 -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 454226B0283; Thu, 21 Jun 2018 23:55:58 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f71.google.com (mail-pl0-f71.google.com [209.85.160.71]) by kanga.kvack.org (Postfix) with ESMTP id EE33C6B0280 for ; Thu, 21 Jun 2018 23:55:57 -0400 (EDT) Received: by mail-pl0-f71.google.com with SMTP id t17-v6so2964399ply.13 for ; Thu, 21 Jun 2018 20:55:57 -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=uq3Lw/a02JGhviLe79dyAhffkx+jvLqM9PmL3NO/PbU=; b=Cx3Qg6q2xzvve2vWjpTo36cIvIyrUqnDkBCGusJpYotwQFbVpIYV9iF8O7ec6RfeQa E9qJLq/GvYo/gxr3tE/unuiFDco+MpJ55mlczxYOYGKGtj3A3b78qVX1i3jOziG1eeNB 2IQBJYHzpcx8Dx/JEcgb3cUS86nzfGH0X6Xb9yCiePCBHfzVIGpmcM00OrZ7U1xqPIL1 BdtsoGNoAJyQC4eba0bMwbbAL7qqSlRxV0oJNNEpc+AAYbec+G223CuESh6tmK7MX+dx l+TGgnR/TbE+5E8D4j0c4jEhuEyr5oY/9KfmQR1Xm9CeCZ58kTbNy+YIXDvga6hEbHM/ LpmA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.100 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: APt69E2GqAevOhaP94Ti/krknfzj09/paCYZ16RAMikK/M5SuiqFSmSG IdA9Qh+Pzt1tuzBZ0lwLRzGoIEAPi7oHS36wuKs7ZdZDM1zFIiKF2ZunXxxPCr94cpv4hKH9phG Owuwc0tSguEOkDa1m0s63bWqo/5FFv6c62+xRYpStbX2VGIZQ9hfATtEfGSDeCkJ/6w== X-Received: by 2002:a17:902:8b86:: with SMTP id ay6-v6mr31532717plb.295.1529639757687; Thu, 21 Jun 2018 20:55:57 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI84qRjwtsAShCNt1QUJAhU/h9eL+SdRc6TwvRJMfx+knKrxy1r8bFaNM7ZSuKeOchFqeHH X-Received: by 2002:a17:902:8b86:: with SMTP id ay6-v6mr31532687plb.295.1529639756924; Thu, 21 Jun 2018 20:55:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529639756; cv=none; d=google.com; s=arc-20160816; b=vTYVZed+ScC8Malx6OojsUxWLDiD2Zhyfbiav95My8QZR0vV1kuugC5aIXm7GsV8Wf pbzbkLT0qLNaP8k5E40GFV4/hi0c1f9vmAITDJpqww/bz6B3wQQLOjT0aIY/GUIXqRL9 yxJpkVlM59J5WXe6c0jqnFeAKR5qQzEvidjbfe6PmgripWP99vbrJMgDIZCl3wttvHii zqZ26J6Dl+45/T92fFJfd1dHUE9Z4cy5161GglsSzpYK8tAbx4PhG85wwPdX2YQiML7s 6dZ3thZcC/OaFKv9rOXrSw85KS3l+aM7jn1GXKTDEt2/g6Cx6fb7qnkiOEEOdl3lcWPa Morg== 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=uq3Lw/a02JGhviLe79dyAhffkx+jvLqM9PmL3NO/PbU=; b=b5bRGkP9TL4LGZN0VhanfSX8KIHcNEJdzbmYp+Xy0aCUInKdTKztdH1aphl3wbd5+h /YejEniwlY+3uCuv5f1HH7Xt+1OfzdC76jV2oCv+KfEPDreXalREkdFBgBp3Qq302dxN SHytrqdaZSHyapHzhqXvfO48nMMcx9Ypgt1p7dau5gYdpyOa1nKf3h8T/2jsja6RW/lR PVIy30GAR5xUs4TvlmKog37ooXz0dKskkSbD4GHmPVOcmRlSzG5mzbdQUXc0CB9ZoF8B rQ2zH0MEK4NsUaxoRpg8VhorxAEjHghzOGMpL2s+rpHyKmUGmMFVMN4PSLkZjOgEqcvC e1/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga07.intel.com (mga07.intel.com. [134.134.136.100]) by mx.google.com with ESMTPS id a12-v6si7022827plt.474.2018.06.21.20.55.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jun 2018 20:55:56 -0700 (PDT) Received-SPF: pass (google.com: domain of ying.huang@intel.com designates 134.134.136.100 as permitted sender) client-ip=134.134.136.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.100 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 fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Jun 2018 20:55:56 -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> 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 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);