From patchwork Tue Sep 25 07:13:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 10613533 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 51B8E161F for ; Tue, 25 Sep 2018 07:14:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4010F29B12 for ; Tue, 25 Sep 2018 07:14:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 331F729B17; Tue, 25 Sep 2018 07:14:42 +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 A260B29B12 for ; Tue, 25 Sep 2018 07:14:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6BBC98E007A; Tue, 25 Sep 2018 03:14:26 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5CDBF8E0072; Tue, 25 Sep 2018 03:14:26 -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 497428E007A; Tue, 25 Sep 2018 03:14:26 -0400 (EDT) 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 03BB08E0072 for ; Tue, 25 Sep 2018 03:14:26 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id f89-v6so745753pff.7 for ; Tue, 25 Sep 2018 00:14:25 -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=b7M8l068DUkpjDOr5g3Cef5HXa4IqKizLLwhMmuEeMg=; b=Xl6JCZF+JqTNPfiNryeKOFs+RlBP3HBZh0DdANKl04K0xqhJcaKhr258KahpRblmEM DbbiZW8YEXZPHHgbRACZeVIXGW2603C8BPiGxfQbBQsyipP08ysnMD+pDBJ9VTNKTzzG f4G4M9CDSE+rtb+qMwzmTv7+0Y0zUWVcOKJ11yWN4wSB8aMj2AO1gcnmOswPvuXRwJid /bXyNsdFAsfZDjawDX/zNN6l225vrc72tTqrtYHdJ6AiHwXoGI/pvlu8+VSye8urZdCH ZWILZi3Q+MESEV3Q0bXDtNG5fDp8LjhwkBQOMLdkjnFZP3lr5O3MoCdG9AZiVgp6fykn komw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 192.55.52.115 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: ABuFfohHNUBsduzxyyiUkVaSa1QbGlBHtJ23xJsOJFm5/fHJ1zM14FKK /TbtMOpbUs7cMpSRovlTdxxBh7JAoujQwhy8l4v2mOQsGnXKCFhKSLyZcFKqW9a6MUekHOcE+uf naVEwQwXfA8ZHEhNghXeY+92xBgMLExYM37EYqnm4Rqc6d9yBZI61JaQGMUSXw/ZpBw== X-Received: by 2002:a17:902:82c5:: with SMTP id u5-v6mr2180221plz.83.1537859665708; Tue, 25 Sep 2018 00:14:25 -0700 (PDT) X-Google-Smtp-Source: ACcGV60l94EQHoAXvHOlaiS0SX+uNo+Zx9njRXgez+woQFD48aGk6xBgeNr/HeBnAGEG5+6YSyBy X-Received: by 2002:a17:902:82c5:: with SMTP id u5-v6mr2180165plz.83.1537859665046; Tue, 25 Sep 2018 00:14:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537859665; cv=none; d=google.com; s=arc-20160816; b=QdiHyqUgpSWkr0I/zRm4IFKW9zKVK4p2H686/Q/dZa5TRPVFhdfKWIq+Hp4QT9qsQF yU/AdB/G5pnsq2+GeZYwFqneor9iGrm9BDjnKuf4hXujRH1ZT15/ql6kOJ3lJ8gL2ScX KdgpfHz6hMJOk6HvGd5iC9Ywoe59PSre/xW8a/lyIrStaMdkcF0l5xxcPItUUc+iiUfK O/sS/zlPoEbCCQXAZYVsOkTQ8ZYhSUqreGXLZp1CrvRmJeesJOlhYIrQKBASWH6oMPEK Yf/W9HfWPI1oeiOZgaHvyOoNWJNyu5GcnKr0z8Ijey4Z5YWz1K19SO4TQ2dkqWXmpnEL CGRw== 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=b7M8l068DUkpjDOr5g3Cef5HXa4IqKizLLwhMmuEeMg=; b=PnvTw8H96GVaug+EvkIrE3WOk/TsO0YgHSDBGj7tvoTDEpKSbbiwBZxUJ1943sXfio Ng9g0QSkdE08/R1qr3aBeuGwHFxrVFD4PSjHu0axiCWU9lTRTZDtjgKoQrfQ4wjXK7Kp d7Emof5+qhY6mvJ6Yk5Yb6+lWg5SZc2Bx4XqNPh9wtgMmvADJHcIs0QxaTD+wtCFyO+J 8a8zXmCJUx9Pt8AO19VyIjhOm8d8hYy3b3CzDNKsFiy5rLeBPy7Hq6t4MJwdyjVK1m+4 GCfSoBNfWj14U72zOa8eE4mKFAuzXcivj/4w6k9dXn2021VonPjalqqYYofNcG2E2P81 51Zw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga14.intel.com (mga14.intel.com. [192.55.52.115]) by mx.google.com with ESMTPS id a1-v6si1378544pgw.9.2018.09.25.00.14.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Sep 2018 00:14:25 -0700 (PDT) Received-SPF: pass (google.com: domain of ying.huang@intel.com designates 192.55.52.115 as permitted sender) client-ip=192.55.52.115; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 192.55.52.115 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 fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Sep 2018 00:14:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,301,1534834800"; d="scan'208";a="89093666" Received: from yhuang-mobile.sh.intel.com ([10.239.198.87]) by fmsmga002.fm.intel.com with ESMTP; 25 Sep 2018 00:14:21 -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 -V5 RESEND 17/21] swap: Support PMD swap mapping for MADV_WILLNEED Date: Tue, 25 Sep 2018 15:13:44 +0800 Message-Id: <20180925071348.31458-18-ying.huang@intel.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180925071348.31458-1-ying.huang@intel.com> References: <20180925071348.31458-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 07ef599d4255..608c5ae201c6 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);