From patchwork Tue Nov 20 08:54:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 10690015 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E2D5313BB for ; Tue, 20 Nov 2018 08:55:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3B6E2991D for ; Tue, 20 Nov 2018 08:55:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C7F7629A1B; Tue, 20 Nov 2018 08:55:59 +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 4EF302991D for ; Tue, 20 Nov 2018 08:55:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C8F76B1F52; Tue, 20 Nov 2018 03:55:48 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 550926B1F54; Tue, 20 Nov 2018 03:55:48 -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 3CCB56B1F55; Tue, 20 Nov 2018 03:55:48 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id EAFD36B1F52 for ; Tue, 20 Nov 2018 03:55:47 -0500 (EST) Received: by mail-pf1-f199.google.com with SMTP id s14so1063449pfk.16 for ; Tue, 20 Nov 2018 00:55:47 -0800 (PST) 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=eHCfojupe637JnGFz/yRaskx3CwIUMdVvylmAhyeWmM=; b=KjQj/cxQ4ydvFO9AMJIFOnnuDoIsCe9R+cESlHVLJiEblrEYp22vAAfO8+7d/wSkmw f42vPy+yxBu0Ouukjrn8Pw3RB8zX7el+50J45MAhHxh3oAX1dWAGhlBoyRauubkwYfNG fjZFzSQPiabxbT0RsIOdOLuOzLxhH26V34qb+g0uh0HqTU1Gf8JTtmc3KbCZtHsr3iGy yYH5OgDFTdXjk2jo4bqZNjcljLU+II9i79YtxDC+zy0yb/s1fmdYx7cMkgDRfX58MqNa 78fM5d/ZiORElt4X1Yd8WGrIBR1ZxpbZ/ih5o1KX5syNc0Kt04KsoFXTWNQzjxQFjPVq DHyg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 192.55.52.88 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: AGRZ1gK4RHzCuuRiVvicyhjfoVuqISD4uGEYgQr4S4AvJ9KcMti5Wd9L K3QQUZuFSuGytXX+A4H5bvFGoF0pamNAqsCeeFT6lF4JwQbr/kKpJmbNhWx5Iz5CNpQw0LoP8bP vPkhotKQQ85VYfWAPeGI5rvmJcRtEa6t3e/eAUELGWQdVGYY1yd3gy2Wdzs6ueWMFjQ== X-Received: by 2002:a62:a117:: with SMTP id b23-v6mr1246063pff.163.1542704147637; Tue, 20 Nov 2018 00:55:47 -0800 (PST) X-Google-Smtp-Source: AJdET5ezTN0/0psdd+tmc3jgugHKXcZqlzx0g6fpqKkSVPpR3awsX8liahl8VjijanHJosLabo9n X-Received: by 2002:a62:a117:: with SMTP id b23-v6mr1246025pff.163.1542704146612; Tue, 20 Nov 2018 00:55:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542704146; cv=none; d=google.com; s=arc-20160816; b=I8Fa68zC9RyQWIdSHSE7uGm7mf5fL/b4upERXjzRTB/RlTn305rtiXBwKDUazco3oz QiItkgdgQNFADNXmZiaHi6jBSNFYnQC5c2O039iQfzoKomqQYLx+htpVkebMYYvl2Gd7 pfuRTfSrEdNQYJqxy+q5Edbx7gsdKKo9biwCh3cxPJ9hzs/2wFfm7oTU/XdCxZv6Qbg2 sgzNHS/EQaZquQPHWxIGIXBewdv7ppxMSBw6DLJ4Oy/kkMGLyPks6573CKnsBpqa3Nrb J78YgdB3h4bT/x09BSS1xwvQCPdjc3QbegeZpDbXOy0u7x31Y4FhWP6ZKFC3FTVY7v+E UbDw== 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; bh=eHCfojupe637JnGFz/yRaskx3CwIUMdVvylmAhyeWmM=; b=pAHdyQMy24p6H3XCUaqIw9BHPEYVqgWQqItEelDxBRE/sg72TZEnNStCdwyivuhpfM SlpDl2XeqezgVPyWHFGnGlQxtHKw54MmXizaWzjwQh5mPWQWJ82Wri0+UYK4UHbXllYz PZoemUp2x5biqtWBRVc/zrx0jdaBVSNSZ3Ux+H1RUL0e+XfnpsoFbUMgBJOSj3MLUB8o Ucb5uMXu0DSGpSWg4a4FUaRuMAVEZNv53kBJ2jA+tKjpW26ZGrAs5u0D0pyWp+C8+Qjd 0jPlWRucGopAq7kzzEa7cH6Go46qh6g3vuL8ZaLUvlnttp0IC94FcqEyYOXg3TyBITrU erlw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga01.intel.com (mga01.intel.com. [192.55.52.88]) by mx.google.com with ESMTPS id r25si673627pfk.28.2018.11.20.00.55.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Nov 2018 00:55:46 -0800 (PST) Received-SPF: pass (google.com: domain of ying.huang@intel.com designates 192.55.52.88 as permitted sender) client-ip=192.55.52.88; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 192.55.52.88 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 fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2018 00:55:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,256,1539673200"; d="scan'208";a="106105916" Received: from yhuang-mobile.sh.intel.com ([10.239.197.245]) by fmsmga002.fm.intel.com with ESMTP; 20 Nov 2018 00:55:41 -0800 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 -V7 RESEND 17/21] swap: Support PMD swap mapping for MADV_WILLNEED Date: Tue, 20 Nov 2018 16:54:45 +0800 Message-Id: <20181120085449.5542-18-ying.huang@intel.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20181120085449.5542-1-ying.huang@intel.com> References: <20181120085449.5542-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 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 0c1f96c605f8..52d27e04a204 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 (IS_ENABLED(CONFIG_THP_SWAP) && 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, 0)) + split_huge_swap_pmd(vma, pmd, start, pmdval); + } else { + page = read_swap_cache_async(entry, + GFP_HIGHUSER_MOVABLE, + vma, start, false); + if (page) { + /* The swap cluster has been split under us */ + 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);