From patchwork Thu Jun 21 21:40:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 10480767 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 E7D8260365 for ; Thu, 21 Jun 2018 21:41:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA24228FDC for ; Thu, 21 Jun 2018 21:41:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE4CF28FFF; Thu, 21 Jun 2018 21:41:24 +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, UNPARSEABLE_RELAY autolearn=unavailable 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 8049428FDC for ; Thu, 21 Jun 2018 21:41:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8EED96B0006; Thu, 21 Jun 2018 17:41:23 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 89E7F6B0008; Thu, 21 Jun 2018 17:41:23 -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 766566B000A; Thu, 21 Jun 2018 17:41:23 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f200.google.com (mail-pf0-f200.google.com [209.85.192.200]) by kanga.kvack.org (Postfix) with ESMTP id 35C696B0006 for ; Thu, 21 Jun 2018 17:41:23 -0400 (EDT) Received: by mail-pf0-f200.google.com with SMTP id g20-v6so2122155pfi.2 for ; Thu, 21 Jun 2018 14:41:23 -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; bh=F6eXKZNvAqKCQNYwyZaHeUBi9/Fkg7IxTiUwBw+7WQM=; b=YIYIAVVnFSHP2m6jSZOoSbg/RH2P5aXCiE8oQttD3AqtcqRRyfgjviEKckgHlLHl11 xXNszR8OkNyoyDO4f84/LAxYO9eGuVnhTGsadkJzs6myrxeWaldWXb9y1olVkEcFRGSw rqJX32W9XURPI+bO0t0UGa6u//lX1QRtw5UuDyA+gcCP0ZOK7Y3YvZZbH+DMD4DM+Wwp 0saV3wGIQruMloMfRVFhPucUr+KmZoM65oWx0CAPHgBdnrZeZg1noWB5eu5RQfJFygFf 27KkAQYn8slh1WxQ/n0CpC/JgoZcJygvnYN7pTu2d3RnUCQkxUmLEYoIWBD5r2hDiTvg CF3Q== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.37 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Gm-Message-State: APt69E3IcCqnHfdLIpSuGZ/ysJo3tyNFFfgyMpmK7KeFyTjbPFvyvxF9 eO669Znh4M+tszzE1eH7kqGDsicqJdqI8plEgsMQw1a/dOXCoBIlanYh2zBLrRObolpIx77lINA nh6NrehMRzT/T6aatzNxp4aKza2dJrf+tPckIGjpDURy6VKw1jYS9bJI5kBnkubvmbA== X-Received: by 2002:a62:8a0a:: with SMTP id y10-v6mr29228676pfd.237.1529617282910; Thu, 21 Jun 2018 14:41:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI+W7RMZYFdDIqNfhjFJcFGWrEuURG4Ew8vpEVwgF8+7YZe9MtkO7t3geTwwlpTWQny3dhK X-Received: by 2002:a62:8a0a:: with SMTP id y10-v6mr29228644pfd.237.1529617282163; Thu, 21 Jun 2018 14:41:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529617282; cv=none; d=google.com; s=arc-20160816; b=n3bhFiZAkVm7O+uZX9CVD8r54Hk/wkG4IJgvFz21Ihb2ZPCHODf3kTV+eiIrzNfHvM W5AwJQ0BpecREjNrEr3vhEFFaZiPvq9tBzO+nZGOLjKrS4aV7LRdfYxRxktlcGXesGtW Zv0Q2j83/FpCcytypB5NRjzK4GwWHSuEvI5yZRMaX+p9Yx3p5XWVGbx/wyku+W9YyUWq Z/bWh8NNaj89rSIkvOkiL5fWMLY8qxPkDPX58fSypUe4cpppqwoeKUtTBzic6uwTfYDj ceoF5Q1EBuoq0SxeO9fOqt/5BuFMH1VnckgHdKYRblbLYtPADPFVgwuIRyKl+G4fzzxr B6lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=F6eXKZNvAqKCQNYwyZaHeUBi9/Fkg7IxTiUwBw+7WQM=; b=D1/77jrLKGHK/tEdA8pVcDu7fMB50cjfr/w6gAJUycOXM7XJM1e68YdAcML6dDWAv7 WITFnjL1xOnxizbwpjW4qv5W4i9Ff7/VRr5e7he6FU54Vv4KGq7y2N9/6wtLS7+CnkhU GRePyGwo9U4jXJhQlaTTosS2ryhBSElw8Mm9dcxi7Jw0OVEO4z4C3btb03NdBNziVz91 SPGr8FpOP6k1GOvzeiPM5nFfJQfkK0PFHRduizg5Oa9mwg4c0c14dhUdjMS5vk0aCL5y 1ovKwvboql01G3LbMfwmZWTx18+8zqUGw4ALNS9WrTMGgKB3aFOMivZuijuEyCoQCUlE uAEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.37 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out4437.biz.mail.alibaba.com (out4437.biz.mail.alibaba.com. [47.88.44.37]) by mx.google.com with ESMTPS id i5-v6si5233845pfe.27.2018.06.21.14.41.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jun 2018 14:41:22 -0700 (PDT) Received-SPF: pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.37 as permitted sender) client-ip=47.88.44.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.37 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R131e4; CH=green; FP=0|-1|-1|-1|0|-1|-1|-1; HT=e01e04400; MF=yang.shi@linux.alibaba.com; NM=1; PH=DS; RN=7; SR=0; TI=SMTPD_---0T37i56h_1529617247; Received: from e19h19392.et15sqa.tbsite.net(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0T37i56h_1529617247) by smtp.aliyun-inc.com(127.0.0.1); Fri, 22 Jun 2018 05:40:56 +0800 From: Yang Shi To: hughd@google.com, kirill.shutemov@linux.intel.com, vbabka@suse.cz, akpm@linux-foundation.org Cc: yang.shi@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: thp: register mm for khugepaged when merging vma for shmem Date: Fri, 22 Jun 2018 05:40:47 +0800 Message-Id: <1529617247-126312-1-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 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 When merging anonymous page vma, if the size of vam can fit in at least one hugepage, the mm will be registered for khugepaged for collapsing THP in the future. But, it skips shmem vma. Doing so for shmem too when merging vma in order to increase the odd to collapse hugepage by khugepaged. Also increase the count of shmem THP collapse. It looks missed before. Signed-off-by: Yang Shi Cc: Hugh Dickins Cc: Kirill A. Shutemov Cc: Vlastimil Babka --- mm/khugepaged.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index d7b2a4b..27f5ce2 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -440,8 +440,12 @@ int khugepaged_enter_vma_merge(struct vm_area_struct *vma, * page fault if needed. */ return 0; - if (vma->vm_ops || (vm_flags & VM_NO_KHUGEPAGED)) - /* khugepaged not yet working on file or special mappings */ + if ((vma->vm_ops && !shmem_file(vma->vm_file)) || + (vm_flags & VM_NO_KHUGEPAGED)) + /* + * khugepaged not yet working on non-shmem file or special + * mappings + */ return 0; hstart = (vma->vm_start + ~HPAGE_PMD_MASK) & HPAGE_PMD_MASK; hend = vma->vm_end & HPAGE_PMD_MASK; @@ -1517,6 +1521,8 @@ static void collapse_shmem(struct mm_struct *mm, unlock_page(new_page); *hpage = NULL; + + khugepaged_pages_collapsed++; } else { /* Something went wrong: rollback changes to the radix-tree */ shmem_uncharge(mapping->host, nr_none);