Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2286916ybb; Sun, 12 Apr 2020 02:14:20 -0700 (PDT) X-Google-Smtp-Source: APiQypLXzK6HmMW2kJA2f2lexJqLaX3KKU9Yn2LkerW0wTgNPpkcc7ObUW1FvdAFU1f8/FgZ2ZX9 X-Received: by 2002:ac8:5384:: with SMTP id x4mr6521210qtp.135.1586682860057; Sun, 12 Apr 2020 02:14:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586682860; cv=none; d=google.com; s=arc-20160816; b=D8JsVK5DnZsZv3YP1VHbyTUy7+26ldx7vjfz3q78O4Et6tLqr8QtOibQTYhcR2To42 bPwk2DJ4YF7Josq54DkVrw4iZ0/OoQrLYCKUGzO++nAGYwZYAvq954mvPWmG266a7gNk 3WNgx5kngf10HwjVfkt99TVe43xJPn+9+psJozWDqao1bg20M25g0I0sVsv9AL/jMvzY I34LJSsK2F3ltoLjkK0OkG6KVnHoLGZpUJz3FBrwTjMOlI2Siqm7ZFPs6ZxCw3JxD0vn esTWpObI3KsvNQcKwUTpKVtL+PQHtK/oFpjkzSH+yadkojs8/Hc4mQaluq/dIhG7+cr5 zNzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:mail-followup-to:message-id:subject:to:date:from :dkim-signature; bh=LfvvcUpq2FDP8LIShcAOisvw6VyejprD1pNSIk/3HfM=; b=ZU87eow0OnRtI6JW8SbqwPSMIxhG+/bGymimVXBsvPPUi1J+cxaUCt6fvcNX6jNPjq zSjlXL/gt9hmvRTwPgkXIc52ZWsbsnCTQCN8qZCsUkVK5BBZsSfq0BquFHONkkT4a5d6 RoxcToE8kEXTZW0Z+wOIvi6CWMjvhYVNk0p1/JibTyV6h6031zsolsCxbVYnqn/uEe+E HWuXZLp5LessMP/9TgEMGYbLIZVL3j9jdqAUzTCv+F25ERs1l4OV5KtCiU3mYS9vu1NN chH07inTU27OE7Lmx1MNHWDa1OBXvGf0irfoiEmEqF3vPnvu1pIrJZ+xdATXROuKWmBn bE1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OZIaB3Hp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 6si3737731qth.171.2020.04.12.02.14.05; Sun, 12 Apr 2020 02:14:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OZIaB3Hp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726658AbgDLJNB (ORCPT + 99 others); Sun, 12 Apr 2020 05:13:01 -0400 Received: from mail-pj1-f66.google.com ([209.85.216.66]:36193 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725873AbgDLJNB (ORCPT ); Sun, 12 Apr 2020 05:13:01 -0400 Received: by mail-pj1-f66.google.com with SMTP id nu11so2634150pjb.1 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=Z/ikp0qZGX2gFKc2KXe9rQhR5OeBGaNNhHJGxLljWzicS3vVzyLA6FRJU2SYYOMhhy r+mo3xQLV+74zj8vK99XVYOTeN73F1vrhm5sjSVFXFuR7yI3VSUr6E5d26h/acuRPX2x +SuBZrwkK6v/eKIB4bfSt+Ldaax0+5gYAV951Syu1A73toRSJiyRDfGKDnXiBlhzpOQA OhA+V5p0N3bKvuEOknNqMLvGNKr7QzSmYDv9yLyriGOD2Qu40KbmiwVWwt9RKC6Vzmf1 yBczegfJPY53wLeXR5PVJ35XV24AjDnhbv4NSZAAZou/nYhFDkCgVT/56O7H6HVkEntk g7oA== X-Gm-Message-State: AGi0PuZp5lsh8pa6N1xb3fNIkTGhL9jiPIercOXmOeqxNFMntGluMq1s eoOQrXZk1Zu9Q6D0fJHBrsM= 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-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- 2.14.1