archive mirror
 help / color / mirror / Atom feed
From: liliangleo <>
To: Alexander Duyck <>,
	Mel Gorman <>,,,
	Andrea Arcangeli <>,
	Dan Williams <>,
	Dave Hansen <>,
	David Hildenbrand <>,
	Michal Hocko <>,
	Andrew Morton <>,
	Alex Williamson <>
Subject: [RFC PATCH 0/4] mm: Add PG_zero support
Date: Sun, 12 Apr 2020 05:07:32 -0400	[thread overview]
Message-ID: <20200412090728.GA19572@open-light-1.localdomain> (raw)

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


             reply	other threads:[~2020-04-12  9:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-12  9:07 liliangleo [this message]
2020-04-13  1:43 ` [RFC PATCH 0/4] mm: Add PG_zero support Dave Hansen
2020-04-13 14:49   ` Alex Williamson
2020-04-13 15:14     ` Dave Hansen
2020-04-13 15:25       ` Raj, Ashok
2020-04-13 15:47       ` Alex Williamson
2020-04-13 16:43         ` Dave Hansen
2020-04-14 12:01 ` David Hildenbrand
2020-04-14 15:07   ` Alexander Duyck
2020-04-14 15:40     ` Daniel Jordan
2020-04-14 15:44     ` David Hildenbrand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200412090728.GA19572@open-light-1.localdomain \ \ \ \ \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).