From patchwork Wed Oct 10 07:19:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 10634131 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 260E0679F for ; Wed, 10 Oct 2018 07:28:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D61A72941E for ; Wed, 10 Oct 2018 07:28:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C523629348; Wed, 10 Oct 2018 07:28:12 +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 4478729348 for ; Wed, 10 Oct 2018 07:28:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 064846B0277; Wed, 10 Oct 2018 03:27:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9286B6B0276; Wed, 10 Oct 2018 03:27:44 -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 41FDB6B027B; Wed, 10 Oct 2018 03:27:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id 9DEF26B0278 for ; Wed, 10 Oct 2018 03:27:43 -0400 (EDT) Received: by mail-pl1-f200.google.com with SMTP id t9-v6so3174400plq.15 for ; Wed, 10 Oct 2018 00:27:43 -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=qEI4+HGjPHHxxgCWSGHSddNRiHDyEbmk3jwDJQ5xyCE=; b=WgRKDqa/pg0cFwOEdDc4ylCsvXv/zBWRBdsNitIVIzNZZ3mJHhTOs8h0b1iDEPbK1b Xc0qKKD2nGwGtaXUyTpEdOMW2yzwAG4gBm2FO8NEz66GzPSc/oZnKPA9lI56UQ2KJUgs XXNZFnaWIChnZg7PdCXRF/xKNsCBpRFa7OWBOwImbR5bDlyT2UbAQL6w/40ibgWULkMi CGNdT7qBRmJU8fYffUm+YnuBygNakr2heQ9xzWqWLRyBrsj6s8iC37Yviggtb1Lunkme eIfivCU2L5sZnxACv8SD64MK4El9YozX+D29lN+9S8BFdCw+5gbavDg9hg41iCgdKmYg hd1Q== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.31 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: ABuFfohJi2of4ZGUWZK0Ja9eWMoxEMabgtLART0pnEP4uvzBnHyrWCSR 7sk6iUZHHLMLDg4ubXAdk1Wst1kiI5HeAP3tGyzso26kuDxYGxgqhLQ5Zf2Eu0dDeZm+Cq3O+dC AOCMxwT7S9yokRyWg6lndFJDwV0oePGlcln8dGTXtVrRuc/3dVHnT4qBEO1bA+mw7oA== X-Received: by 2002:a62:75c7:: with SMTP id q190-v6mr33930432pfc.137.1539156463328; Wed, 10 Oct 2018 00:27:43 -0700 (PDT) X-Google-Smtp-Source: ACcGV62AOyTav/bSqQTYbm19nU7TI6JZzRCyYloWu7cPAzGajfNG8Rn3OsezXqm80/xManIpexFE X-Received: by 2002:a62:75c7:: with SMTP id q190-v6mr33930380pfc.137.1539156462691; Wed, 10 Oct 2018 00:27:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539156462; cv=none; d=google.com; s=arc-20160816; b=e9FoIW2Ir2QZ0M2GQAsC3ixOriloZdRXRqRsytNfXOlQoD4yGvMir/pws1VvhFvs14 eKjtEaPP6T3Yw1JhLHMAoK9fTALfwrrZb0nKVAh0NamuQRO6R8A3bw0N2HT6/oVbGtL1 TRy1YDS8E3cAF3THzPG13a14klFVqv/T8X6piNgOMFjZ6LRJIWR90hltDqJ0SaMzhwB4 q2dREy2P+5dMJpdVdtu8iw5lZ9yBqR8hEVcP1OPItXCZwHLlznz8vrOHFqDbBILKs8Jk 4VmgbenmTeuOMtHGb1k4Jpkpgq/nae2qsYg1RmzxdpmI/UrY+YGNEXrXufdtrKpTvuUK O+IA== 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=qEI4+HGjPHHxxgCWSGHSddNRiHDyEbmk3jwDJQ5xyCE=; b=pfRbi+qb153GOwC1Q9oR1g/MMtqNgSMNzNe0I9RAeQM+yCwpZXB+kYLWHhhDQV+le4 6V4JOkL9as8dJx9CZ7lvOFKCPszVu5jKoUlW6dlMqmwkchmp6ljRRO0ciAThrdQjta2D K1Wx3MVh/RNOCQnYsqMQBJZl6VrNHaB0DmnLwW3pgag20pW6pVbcNc1vq6AM8SVboFVa ZkIGaIrEK1Vu4tfzKLHuY9XlsEu/Oz1aQuIeynyeEVlRca+KZ0waeW8gptLR43jWRjGq 3hSqMKCmAu885+hGHA3X3uqzmmrr3B2CDKSQiSzq6vL62/BgiymMNBeNfm6F5jBRlnLo uWMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.31 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga06.intel.com (mga06.intel.com. [134.134.136.31]) by mx.google.com with ESMTPS id n84-v6si21364295pfg.127.2018.10.10.00.27.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 00:27:42 -0700 (PDT) Received-SPF: pass (google.com: domain of ying.huang@intel.com designates 134.134.136.31 as permitted sender) client-ip=134.134.136.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.31 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 orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Oct 2018 00:27:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,363,1534834800"; d="scan'208";a="93870238" Received: from yhuang-mobile.sh.intel.com ([10.239.198.87]) by fmsmga002.fm.intel.com with ESMTP; 10 Oct 2018 00:19:42 -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 -V6 17/21] swap: Support PMD swap mapping for MADV_WILLNEED Date: Wed, 10 Oct 2018 15:19:20 +0800 Message-Id: <20181010071924.18767-18-ying.huang@intel.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20181010071924.18767-1-ying.huang@intel.com> References: <20181010071924.18767-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 20101ff125d0..0413659ff6ba 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);