From patchwork Thu Jun 21 23:15:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 10480927 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 87DEB602CB for ; Thu, 21 Jun 2018 23:16:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 792AC1FFB2 for ; Thu, 21 Jun 2018 23:16:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D55328F82; Thu, 21 Jun 2018 23:16:17 +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=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 C7A881FFB2 for ; Thu, 21 Jun 2018 23:16:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C51776B0003; Thu, 21 Jun 2018 19:16:15 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C0CC06B0005; Thu, 21 Jun 2018 19:16:15 -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 ACB0F6B0006; Thu, 21 Jun 2018 19:16:15 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f70.google.com (mail-pg0-f70.google.com [74.125.83.70]) by kanga.kvack.org (Postfix) with ESMTP id 6A2E06B0003 for ; Thu, 21 Jun 2018 19:16:15 -0400 (EDT) Received: by mail-pg0-f70.google.com with SMTP id w23-v6so1821050pgv.1 for ; Thu, 21 Jun 2018 16:16:15 -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=isbLDYZ2XL9XIrTkIzygYlVctKU6SHI/DX0+oQANAmw=; b=L0ruXvuCuritbRY6h4kgQQ2FLriHIEvYSA+lkL0pRp0hPWH4VeKxKbagzhJu8NkZzV WuZhmJe9z9WAKif7sh5m1/vPQkFXXDr0d2epQy31QFUk9uXJp2xE2w+NyeTK98RFNUEi M9r/yvHBL1/zQy0b7TOUS/ApdSY+RgXiw+giHhEoV30iliDAZCdvh408NoIAd3j4MU1m wMaEHAAnDMYwbTT6uRG3CCRBB3eyJFS4+XU2Y0Pwhkd+Ool646ttSYejk1CnGIyuifbJ 2ZPk2jEq1iL0tGs1kQbCFDOPRmYjVgCw5ZKDXv23ACF4YK3hJ77kHMS2E3OKjyc7WBeK zn8Q== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.133 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: APt69E0T8GKcz+2JGPtxPXLDlmQ8rEeSiJKZ/WI0UtaI78nqifh6ST8U i7u6MStSV8y5CzP+mbEZ5n+ovH53CJCaPskordvbuOSnCBIT1pBf0JMPSvJz8PPtxZcD5+J4eWN d1dmCpTQQQaUefFQRTHnavcwEi5MfRmQ60F6Rxm3ZdgDIQ2UrUPgpkDl3tgsN6Zs9fQ== X-Received: by 2002:a62:d0c5:: with SMTP id p188-v6mr29692697pfg.101.1529622975121; Thu, 21 Jun 2018 16:16:15 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLWq0QHjDppnjUpcJ6c7I+rLA//m3QLxRODRl68u/cMuRYYe23awv1dm9lgks9pQ5V8/zpW X-Received: by 2002:a62:d0c5:: with SMTP id p188-v6mr29692634pfg.101.1529622974090; Thu, 21 Jun 2018 16:16:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529622974; cv=none; d=google.com; s=arc-20160816; b=H9F8nioa3Zf0gYJ7uBP+7WvQqS8mnQ/oo0zca2C0DeMF+m+i5szO1tT+S2iSdr6Sp/ Fz4I6l7hbX74yo8mcv1zxPPLypetNLa6CwSDypNzdfn94gwxQK3yzzllPUVxI8SsfVGo J+d5+3vPYRHRD97U9x3y6d07/LVcgrQK5MhZ6rzmOZ+94RA1e2SLBkAaD4AZNo0gVT7v +RIW7FvF5UNeIby/sCJKr7N9HZ51kEH7xe48XnkjZ636Nq3OVZHAli8Qt9DLecsRuMjQ FD1ttlMlCV4+lbe+k+cdwQJNsSlZU8rVLoMvv3N0i095fAv1mocaWIlqqdGGKOgq3M8f 7ytA== 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=isbLDYZ2XL9XIrTkIzygYlVctKU6SHI/DX0+oQANAmw=; b=RWx1GJZVZ8d9M0xWxuUH5UzGTbLBx/1v+UHVaSc6qjqXCKF7tDBUrKWBek54i4KAgz EwuPmRXmtpu3ozt/Axf6a2kLNFip7KsScdy3+RpLTTHwUz/vEvGNMzFKFverSGwwhoQk mWAXyfhmd90mxn00Fr/zK5GgiqfFlVYNLBt9QEzlZPtg75+jHDinqZnRfeB7/jvn/qiC S8Rv1gw7o8drv58km9dQujXDMsb+HTq+SlvJzz4guwXlFMjG4GnNF/zNE0/wccdR+cHi /efKhPPsQSbN5kbEC1OmMuWzkf5Iko3DHWDzcp9QFrZZ8/d7umiayqyighRO/6FRl2Yj GBEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.133 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com. [115.124.30.133]) by mx.google.com with ESMTPS id x6-v6si5710020pln.486.2018.06.21.16.16.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jun 2018 16:16:14 -0700 (PDT) Received-SPF: pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.133 as permitted sender) client-ip=115.124.30.133; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.133 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=01201311R281e4; 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_---0T389Jdj_1529622950; Received: from e19h19392.et15sqa.tbsite.net(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0T389Jdj_1529622950) by smtp.aliyun-inc.com(127.0.0.1); Fri, 22 Jun 2018 07:16:01 +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: [v2 PATCH 1/2] mm: thp: register mm for khugepaged when merging vma for shmem Date: Fri, 22 Jun 2018 07:15:48 +0800 Message-Id: <1529622949-75504-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 vma 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, but not file-private mapping, when merging vma in order to increase the odd to collapse hugepage by khugepaged. Signed-off-by: Yang Shi Cc: Hugh Dickins Cc: Kirill A. Shutemov Cc: Vlastimil Babka --- v1 --> 2: * Exclude file-private mapping per Kirill's comment mm/khugepaged.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index d7b2a4b..9b0ec30 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) || vma->anon_vma)) || + (vm_flags & VM_NO_KHUGEPAGED)) + /* + * khugepaged not yet working on non-shmem file or special + * mappings. And, file-private shmem THP is not supported. + */ return 0; hstart = (vma->vm_start + ~HPAGE_PMD_MASK) & HPAGE_PMD_MASK; hend = vma->vm_end & HPAGE_PMD_MASK;