From patchwork Wed May 9 08:38:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 10388663 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 7027960170 for ; Wed, 9 May 2018 08:39:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61F3028E13 for ; Wed, 9 May 2018 08:39:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54C3E28E26; Wed, 9 May 2018 08:39: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 B67E228E13 for ; Wed, 9 May 2018 08:39:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9B0BE6B049F; Wed, 9 May 2018 04:39:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9617B6B04A1; Wed, 9 May 2018 04:39:37 -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 8528C6B04A2; Wed, 9 May 2018 04:39:37 -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 4376B6B049F for ; Wed, 9 May 2018 04:39:37 -0400 (EDT) Received: by mail-pl0-f71.google.com with SMTP id a14-v6so3375728plt.7 for ; Wed, 09 May 2018 01:39:37 -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=okrcnQZG2VZn7RLHyeCg5RQx8QwAuqjRMwyo142As8A=; b=LRx0Ay3OI6c6xRORDNhByubs5ia1QtmZ13ThZ/jjhtGGGkIcCAvnNbfqobLOCzV40N kM1DY9bIA6mPJtlKR9vncJVH1ND0CIXcHaU7AfhOAgYPH98ZoCSJw3WNYFW8LryUDG3L 176x5sbOzZJh4yA+0e2Ws0LFjzVAt4/p7pSMmlHh9sSgStc1A8Ze30E9ElSnlAbWV/Fp qhw830WETp9L1MYLwi+C00+yBFb2+V1cTqNRqGrUdwpxBYSa0FtfoNj/bLLwd0/YXCtt 7t8EVQ2EVZLzod6oWLIvyFTkU8CDs2a2zxjlV+dJOiqQfDdsZpUdGQgGnIacakyJ2IlF ep/Q== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=ying.huang@intel.com X-Gm-Message-State: ALQs6tDIqHB4jRL50uZemtyyR9Hs0ElCXovYTzMhVQMurNPzJsAEtppJ rkdjcDVmegPaiBZp94nbTAghs0O1TTgaelXPDIwdLx4V6Qf9HKvWS/rAj9dr2VR8kOtlV32sU8p I1r7zWMY4GlWRynZeXggeQjelmbuRiXVNK7zBqYfvwto3NFpNHX2OmLUaVA0kopl1Jw== X-Received: by 2002:a17:902:b908:: with SMTP id bf8-v6mr44098993plb.358.1525855176965; Wed, 09 May 2018 01:39:36 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrN2SD7HvTERur7MGzZaDmNXnEcW5tEiK0o1MdJbYyEGM6XSMaY1U0pnzHXzlVzs/fHr8me X-Received: by 2002:a17:902:b908:: with SMTP id bf8-v6mr44098961plb.358.1525855176175; Wed, 09 May 2018 01:39:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525855176; cv=none; d=google.com; s=arc-20160816; b=aKG4cTiVvjXTHhY2/Q+QxjSnqrHlFGfSck/tp+R1vNLExt9fMF1uLPhaoVFv7c4MYi pW6J5/kXJsUvqhulHDDefk8m6TvHPP+0V+vz8CcEn64oic0nLSe8OSdxXnAcMF2PNF/t AhzfPtb9nBx5WPTBQFe6eoU/vvIYxHAwjS0EGTZ1WPyH+pmL+RsZrZwT7u613xV3Ll5t SS/mwHWPVVXITfU+UavG3yWXGATACXd9JWVNjVWL7bVrrrMdrQTq787WJf4VWplIclgF bXz9OU+TIJwH+xuH2qdcY9FgLcm87rW7qsTji6SFr8yBewi5fLyJJFCsG2lMvdoLi1hO vEWQ== 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=okrcnQZG2VZn7RLHyeCg5RQx8QwAuqjRMwyo142As8A=; b=g1Z+wi1LFPUM3nKLqJPT6q6DUvm/2e9Il9VLN1Y5qPmkDpeDcTyrDP56hhD/ckOxk7 N8iLIHk6vx7yVeKHZwrAWpJHRwlxgIQeoK9PzVSmHbw2D3fgz3MAHJMHl9png46A5OrW g1bWasa1UoOlGae/nvT199WPJkrhh2DZVF9RVTGE2IT7Mf9haW4ZOGtizrrTABXuegOg 9ZbZx6aAGztn2L0d8TH25wHTOgt+XNhMw/TJziCtvp0WENPPPv4SL8mIiutdN8B/AiZs HAS4q4S/CYhmq5I81NMs35vXPEA1MYHfeqYbFZZukUL0smItBJZwj76pbLEBq1IZ4PIF YY9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=ying.huang@intel.com Received: from mga18.intel.com (mga18.intel.com. [134.134.136.126]) by mx.google.com with ESMTPS id y11-v6si18624861pgv.473.2018.05.09.01.39.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 May 2018 01:39:36 -0700 (PDT) Received-SPF: pass (google.com: domain of ying.huang@intel.com designates 134.134.136.126 as permitted sender) client-ip=134.134.136.126; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=ying.huang@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 orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 May 2018 01:39:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,381,1520924400"; d="scan'208";a="52769648" Received: from yhuang-gentoo.sh.intel.com ([10.239.193.148]) by fmsmga004.fm.intel.com with ESMTP; 09 May 2018 01:39:32 -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 Subject: [PATCH -mm -V2 10/21] mm, THP, swap: Support to count THP swapin and its fallback Date: Wed, 9 May 2018 16:38:35 +0800 Message-Id: <20180509083846.14823-11-ying.huang@intel.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180509083846.14823-1-ying.huang@intel.com> References: <20180509083846.14823-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 2 new /proc/vmstat fields are added, "thp_swapin" and "thp_swapin_fallback" to count swapin a THP from swap device as a whole 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 --- Documentation/vm/transhuge.rst | 10 +++++++++- include/linux/vm_event_item.h | 2 ++ mm/huge_memory.c | 4 +++- mm/page_io.c | 15 ++++++++++++--- mm/vmstat.c | 2 ++ 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/Documentation/vm/transhuge.rst b/Documentation/vm/transhuge.rst index 2c6867fca6ff..a87b1d880cd4 100644 --- a/Documentation/vm/transhuge.rst +++ b/Documentation/vm/transhuge.rst @@ -360,10 +360,18 @@ thp_swpout piece without splitting. thp_swpout_fallback - is incremented if a huge page has to be split before swapout. + is incremented if a huge page is split before swapout. 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 is 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 de6a32226121..7f4442e064b5 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1667,8 +1667,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 b41cf9644585..96277058681e 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -347,6 +347,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; @@ -370,7 +379,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; } @@ -381,7 +390,7 @@ int swap_readpage(struct page *page, bool synchronous) unlock_page(page); } - count_vm_event(PSWPIN); + count_swpin_vm_event(page); return 0; } @@ -400,7 +409,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 a2b9518980ce..dfe83d74f713 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",