From patchwork Sun Apr 12 09:07:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liang Li X-Patchwork-Id: 11484483 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 39F5281 for ; Sun, 12 Apr 2020 09:13:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E3DBA2072D for ; Sun, 12 Apr 2020 09:13:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OZIaB3Hp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E3DBA2072D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E6C8A8E00C7; Sun, 12 Apr 2020 05:13:01 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DF4EB8E0007; Sun, 12 Apr 2020 05:13:01 -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 CBC5C8E00C7; Sun, 12 Apr 2020 05:13:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0205.hostedemail.com [216.40.44.205]) by kanga.kvack.org (Postfix) with ESMTP id B0C158E0007 for ; Sun, 12 Apr 2020 05:13:01 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 65AE62839 for ; Sun, 12 Apr 2020 09:13:01 +0000 (UTC) X-FDA: 76698638562.22.land32_71a5306ac0a41 X-Spam-Summary: 2,0,0,35750efbc0b1323a,d41d8cd98f00b204,liliang.opensource@gmail.com,,RULES_HIT:41:355:379:800:960:966:973:981:988:989:1260:1277:1312:1313:1314:1345:1381:1431:1437:1516:1518:1519:1535:1543:1593:1594:1595:1596:1711:1730:1747:1777:1792:1801:2196:2199:2393:2559:2562:3138:3139:3140:3141:3142:3354:3865:3866:3867:3868:3870:3871:3872:4117:4250:4385:4605:5007:6119:6120:6261:6653:6737:7903:8603:9121:9413:10004:10394:10400:11658:11914:12043:12048:12291:12296:12297:12517:12519:12555:12679:12683:12895:13160:13161:13229:13439:13895:14040:14096:14097:14181:14687:14721:21080:21220:21444:21451:21554:21627:21666:21740:21789:21795:21939:30051:30054:30064:30070,0,RBL:209.85.216.65:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: land32_71a5306ac0a41 X-Filterd-Recvd-Size: 6703 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Sun, 12 Apr 2020 09:13:00 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id ay6so1236019pjb.0 for ; Sun, 12 Apr 2020 02:13:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:subject:message-id:mail-followup-to:mime-version :content-disposition:user-agent; bh=LfvvcUpq2FDP8LIShcAOisvw6VyejprD1pNSIk/3HfM=; b=OZIaB3Hp9mGYcRd9yIsPoQlX+8fyZAjTy4eW4wEY5bNHdn57ZS2Ls8C5H3GCr70Unt EtByddlnJRhDXHXrgMayn/azIoDAAAA+MbcyZ47VWClI9fbDFjcOP8OiKDAjzWRhpFmY 7Pfy5gDiQKSYA3kWKzy/ErBOs73NrKDFBnkr6bsh3qBTGCMZyPoG5VHmamsr5ypQlw/2 LdcG8EuUyX3McHTUHRuZfwbAMqAOAt0xsFjXVBHj/QvuUsek/0RqcNRVzZnDPLSpcr8c Ef3uEKLORRIRHyTTLlv+Ir5djdHK5ciOKEZqphPpJsu3pFghDREYaac68f9WiUl/0roN OqiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:subject:message-id:mail-followup-to :mime-version:content-disposition:user-agent; bh=LfvvcUpq2FDP8LIShcAOisvw6VyejprD1pNSIk/3HfM=; b=VZcXTC6PQnPiKrdcD515O/JHmr6RPUU01NIOfY1pFSQeG0BRW66lIudhIawghLT+LQ V6X14+UdIJToonpqbgNwAJ225S5SfThjwZ7vU+3g9EZGjqyxDRnjYFxZLjCdFXxAqaBr Tp6RCm18LmAXogxbO2riXa1ux+CXFheawyG7zRqeHEj5+9parXzc1ydjloTvrcMB+UCA DMJgnRD0mYC/pS7ORbmnsH9u6S3XpEB0dvZyageuyfNUXjqNcOq+l6CrJUW9DGi5AwG+ CQ0rjE+iKyX9TZT6fVbfTxdLH8wd/AzJtNTktaB/9svfCOHbnLtl3ByTtL9b4tVNrU+C XJ2w== X-Gm-Message-State: AGi0PuYUU4VeQAvC010BhDLcDPE2hjWZC1cMF5CB98XYQdPQO8cw/6Wm sbk/zsESnvmuUB6PdMMQsAQ= X-Google-Smtp-Source: APiQypK2+SbPWYDwAaMikOSsmCED4pKg8K/I5TQ0zYj+iHsrwsi33Mv5xyj5Pqz9/a991qhcHGv0Cg== X-Received: by 2002:a17:902:6b01:: with SMTP id o1mr12665327plk.100.1586682779821; Sun, 12 Apr 2020 02:12:59 -0700 (PDT) Received: from open-light-1.localdomain ([66.98.113.28]) by smtp.gmail.com with ESMTPSA id w192sm4621946pfc.126.2020.04.12.02.12.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Apr 2020 02:12:58 -0700 (PDT) From: liliangleo X-Google-Original-From: liliangleo Date: Sun, 12 Apr 2020 05:07:32 -0400 To: Alexander Duyck , Mel Gorman , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrea Arcangeli , Dan Williams , Dave Hansen , David Hildenbrand , Michal Hocko , Andrew Morton , Alex Williamson Subject: [RFC PATCH 0/4] mm: Add PG_zero support Message-ID: <20200412090728.GA19572@open-light-1.localdomain> Mail-Followup-To: Alexander Duyck , Mel Gorman , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrea Arcangeli , Dan Williams , Dave Hansen , David Hildenbrand , Michal Hocko , Andrew Morton , Alex Williamson MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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: Zero out the page content usually happens when allocating pages, this is a time consuming operation, it makes pin and mlock operation very slowly, especially for a large batch of memory. This patch introduce a new feature for zero out pages before page allocation, it can help to speed up page allocation. The idea is very simple, zero out free pages when the system is not busy and mark the page with PG_zero, when allocating a page, if the page need to be filled with zero, check the flag in the struct page, if it's marked as PG_zero, zero out can be skipped, it can save cpu time and speed up page allocation. This serial is based on the feature 'free page reporting' which introduced by Alexander Duyck We can benefit from this feature in the flowing case: 1. User space mlock a large chunk of memory 2. VFIO pin pages for DMA 3. Allocating transparent huge page 4. Speed up page fault process My original intention for adding this feature is to shorten VM creation time when VFIO device is attached, it works good and the VM creation time is reduced obviously. Creating a VM [64G RAM, 32 CPUs] with GPU passthrough ===================================================== QEMU use 4K pages, THP is off round1 round2 round3 w/o this patch: 23.5s 24.7s 24.6s w/ this patch: 10.2s 10.3s 11.2s QEMU use 4K pages, THP is on round1 round2 round3 w/o this patch: 17.9s 14.8s 14.9s w/ this patch: 1.9s 1.8s 1.9s ===================================================== Look forward to your feedbacks. Cc: Alexander Duyck Cc: Mel Gorman Cc: Andrea Arcangeli Cc: Dan Williams Cc: Dave Hansen Cc: David Hildenbrand Cc: Michal Hocko Cc: Andrew Morton Cc: Alex Williamson Signed-off-by: liliangleo liliangleo (4): mm: reduce the impaction of page reporing worker mm: Add batch size for free page reporting mm: add sys fs configuration for page reporting mm: Add PG_zero support include/linux/highmem.h | 31 ++++++- include/linux/page-flags.h | 18 +++- include/trace/events/mmflags.h | 7 ++ mm/Kconfig | 10 +++ mm/Makefile | 1 + mm/huge_memory.c | 3 +- mm/page_alloc.c | 2 + mm/page_reporting.c | 181 +++++++++++++++++++++++++++++++++++++++-- mm/page_reporting.h | 16 +++- mm/zero_page.c | 151 ++++++++++++++++++++++++++++++++++ mm/zero_page.h | 13 +++ 11 files changed, 416 insertions(+), 17 deletions(-) create mode 100644 mm/zero_page.c create mode 100644 mm/zero_page.h