From patchwork Mon Sep 3 07:22:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 10585569 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 19C3A14BD for ; Mon, 3 Sep 2018 07:23:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02F2128785 for ; Mon, 3 Sep 2018 07:23:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EABC4287C6; Mon, 3 Sep 2018 07:23:05 +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 5416428785 for ; Mon, 3 Sep 2018 07:23:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C8A9E6B66B3; Mon, 3 Sep 2018 03:22:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C64E76B66B5; Mon, 3 Sep 2018 03:22: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 B06306B66B6; Mon, 3 Sep 2018 03:22:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by kanga.kvack.org (Postfix) with ESMTP id 6DE706B66B3 for ; Mon, 3 Sep 2018 03:22:44 -0400 (EDT) Received: by mail-pl1-f199.google.com with SMTP id bh1-v6so10363083plb.15 for ; Mon, 03 Sep 2018 00:22:44 -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=yp3Hua6i3ewWDTLXKOFGHH1UnEyyr+u9bkGm90RF6cs=; b=YXiaqot7VN5xR+mlH07x3woEedlOpqdwPOFD/SLTEgcwrlkj4f4Y8DWoNcMIaEaUjx MAIppbVfE5DsiED3eD6Ze6PUk+BWoyTE4xZmqugiu2CWpbN6yswlBdRWyK+EO1rbJbpT xwKR9rMYIL/w1P3S8pfDQzhU+JXK4YnLIhjiBE393I7LsoQBgicQNQvVW1AvMI2Ramop DN9WJHYq+FIBDe1m8Kz8jxiz8EZCiL9sC6LUMIYGQtbi5Ew5jUEfBSxOJyhhDvuKHzNK +8bRp2JaiVCJYEjMN0gmqySkNf/XkC61Bfm3L52UHalFFvtdfLtSofjN572WbvFkYpus r45g== 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: APzg51CnLIlP+di5TGvhDyhVc+gKrpyOeXM9Mi+GHxY4IqBB357VpH7/ poLuSt0qa/E7g4c1gagFXdevsPgF2ZIlLNW2dXxpsKo/gkSn0ES0HqBOyTEokHkW1eX8SG8atLF TaPrQsqXnl45OxsQoqcJpnfEfD3gEDtY4J0fTYzK/5BNcPA9h2vtgCeFXeofmVxMOMw== X-Received: by 2002:a63:3105:: with SMTP id x5-v6mr4747444pgx.323.1535959364130; Mon, 03 Sep 2018 00:22:44 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZjaont1uMsiQnLQzFCdl0FMKkN9230bp6qCDHwmYc1kVMdc1agBgbLzg3VG4uND+iRwKbg X-Received: by 2002:a63:3105:: with SMTP id x5-v6mr4747405pgx.323.1535959363404; Mon, 03 Sep 2018 00:22:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535959363; cv=none; d=google.com; s=arc-20160816; b=x/8lf8z314gOWHqOMBrMbm9Ttrq4oaVTrOqTj4lS35cILl4HVOXhunHPI2ADxEcth7 ckxjewu28jKJy6PjYW0vqQSYTXuvzWiTSJy/0L+0PlcL11rt/jXpDrFEnnK6pJcboW/6 rZ42WYpXtXK5BhIexF3iCqS6h8voHXPhqjpBpfO7RhgUyeV1WSnxhbUoUywLTslkxgjR qQbypnUkfA3wwY3aHqAOC07YhfW/h5k6aXVUC0xxWv9Numsb8HcPw5RJ/DH/gv035P5F n8styiGNxTcDXpsSDogEHDUfA1MkiYjs8JMauNct7FGhkqNkdhSKiqPsAP6lZa+FAYhd 0+Yw== 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=yp3Hua6i3ewWDTLXKOFGHH1UnEyyr+u9bkGm90RF6cs=; b=KwkZaaQbBiSBmQMZnu3t1GhrveHBUOyF13bIGhPOR7dy6FrRdJ5rf73XcfEmvpvvEG 7f3Q7yn82Nejglmlro7cJgAOklZ3wpo56wvAwRYRK+ygteYEiN+FiNPReUMOrrIxFNst 6EWYanF+6ZLtmd5yQmXiMy/f+N1JMiRob5OByTyYiiEAcZcvw3IUdxMvZd3ys/cR0MxU cMgSHxg9QSV9Tdt3F55jUefC6fcgIIHWHriDTmZtLogEoCGv3DLsIBFmLPVnRcOBpJFn LBlgp3levizK+CDvFf7lB1ZhFM3I5TGmOkg9aMZHZglCIXj/uJPCcHXCrp/z+jVWRjv5 qsSw== 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 az1-v6si9327648plb.513.2018.09.03.00.22.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Sep 2018 00:22:43 -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 orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Sep 2018 00:22:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,324,1531810800"; d="scan'208";a="70146905" Received: from yhuang-mobile.sh.intel.com ([10.239.196.86]) by orsmga008.jf.intel.com with ESMTP; 03 Sep 2018 00:22:40 -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 10/21] swap: Support to count THP swapin and its fallback Date: Mon, 3 Sep 2018 15:22:03 +0800 Message-Id: <20180903072214.24602-11-ying.huang@intel.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180903072214.24602-1-ying.huang@intel.com> References: <20180903072214.24602-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 2 new /proc/vmstat fields are added, "thp_swapin" and "thp_swapin_fallback" to count swapin a THP from swap device in one piece and fallback to normal page swapin. 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 --- Documentation/admin-guide/mm/transhuge.rst | 8 ++++++++ include/linux/vm_event_item.h | 2 ++ mm/huge_memory.c | 4 +++- mm/page_io.c | 15 ++++++++++++--- mm/vmstat.c | 2 ++ 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/mm/transhuge.rst b/Documentation/admin-guide/mm/transhuge.rst index 7ab93a8404b9..85e33f785fd7 100644 --- a/Documentation/admin-guide/mm/transhuge.rst +++ b/Documentation/admin-guide/mm/transhuge.rst @@ -364,6 +364,14 @@ thp_swpout_fallback Usually because failed to allocate some continuous swap space for the huge page. +thp_swpin + is incremented every time a huge page is swapin in one piece + without splitting. + +thp_swpin_fallback + is incremented if a huge page has to be split during swapin. + Usually because failed to allocate a huge page. + As the system ages, allocating huge pages may be expensive as the system uses memory compaction to copy data around memory to free a huge page for use. There are some counters in ``/proc/vmstat`` to help diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h index 5c7f010676a7..7b438548a78e 100644 --- a/include/linux/vm_event_item.h +++ b/include/linux/vm_event_item.h @@ -88,6 +88,8 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, THP_ZERO_PAGE_ALLOC_FAILED, THP_SWPOUT, THP_SWPOUT_FALLBACK, + THP_SWPIN, + THP_SWPIN_FALLBACK, #endif #ifdef CONFIG_MEMORY_BALLOON BALLOON_INFLATE, diff --git a/mm/huge_memory.c b/mm/huge_memory.c index cfbc9f15e020..0c02d54edc4e 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1668,8 +1668,10 @@ int do_huge_pmd_swap_page(struct vm_fault *vmf, pmd_t orig_pmd) /* swapoff occurs under us */ } else if (ret == -EINVAL) ret = 0; - else + else { + count_vm_event(THP_SWPIN_FALLBACK); goto fallback; + } } delayacct_clear_flag(DELAYACCT_PF_SWAPIN); goto out; diff --git a/mm/page_io.c b/mm/page_io.c index aafd19ec1db4..362254b99955 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -348,6 +348,15 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc, return ret; } +static inline void count_swpin_vm_event(struct page *page) +{ +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + if (unlikely(PageTransHuge(page))) + count_vm_event(THP_SWPIN); +#endif + count_vm_events(PSWPIN, hpage_nr_pages(page)); +} + int swap_readpage(struct page *page, bool synchronous) { struct bio *bio; @@ -371,7 +380,7 @@ int swap_readpage(struct page *page, bool synchronous) ret = mapping->a_ops->readpage(swap_file, page); if (!ret) - count_vm_event(PSWPIN); + count_swpin_vm_event(page); return ret; } @@ -382,7 +391,7 @@ int swap_readpage(struct page *page, bool synchronous) unlock_page(page); } - count_vm_event(PSWPIN); + count_swpin_vm_event(page); return 0; } @@ -401,7 +410,7 @@ int swap_readpage(struct page *page, bool synchronous) get_task_struct(current); bio->bi_private = current; bio_set_op_attrs(bio, REQ_OP_READ, 0); - count_vm_event(PSWPIN); + count_swpin_vm_event(page); bio_get(bio); qc = submit_bio(bio); while (synchronous) { diff --git a/mm/vmstat.c b/mm/vmstat.c index 8ba0870ecddd..ac04801bb0cb 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1263,6 +1263,8 @@ const char * const vmstat_text[] = { "thp_zero_page_alloc_failed", "thp_swpout", "thp_swpout_fallback", + "thp_swpin", + "thp_swpin_fallback", #endif #ifdef CONFIG_MEMORY_BALLOON "balloon_inflate",