From patchwork Tue Dec 22 07:49:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liang Li X-Patchwork-Id: 11986079 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.0 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D580C433E9 for ; Tue, 22 Dec 2020 07:50:39 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 18A512312E for ; Tue, 22 Dec 2020 07:50:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 18A512312E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:47260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1krcRK-0000A1-6T for qemu-devel@archiver.kernel.org; Tue, 22 Dec 2020 02:50:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34024) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krcQ3-0007yq-3M for qemu-devel@nongnu.org; Tue, 22 Dec 2020 02:49:19 -0500 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:45425) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1krcQ1-0005kq-F0 for qemu-devel@nongnu.org; Tue, 22 Dec 2020 02:49:18 -0500 Received: by mail-pf1-x430.google.com with SMTP id q22so7961052pfk.12 for ; Mon, 21 Dec 2020 23:49:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:mail-followup-to:mime-version :content-disposition:user-agent; bh=EteXygXMCMIuOH65MtjowE2DhA9SwUq1uE5SG/8bUGA=; b=LGvosuLiYLgn1b5YwdnJwfvCqo3XbN555xW2S/pLyAc8CuUqtZAGHNlX5OhLPeQRO4 C9wIUC7lj+M+iU2FFT1wsEhktcwBwq76j874fWliVKllFErvCXfAAxAKVekLKJ0fPuX4 w9BPNrCcyE8RLp4U32xhMH4/yOciZ7ZmUVQsi7kvByf34AwsJf2PEPp8adJg0WcVurN9 y91b1qv/triV2c+4b/y4HigHiL/Sk+sYpuqdkd4PTNVp0q5YaDIas0IN7YMD2gFHzTrx eV/AGLh5tP8pePBFiPGWjo4RlSKftL1n+xJaqNVLxg/eXbhAbpkDrS1x2L8CHRsIt1/n D+sA== 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:cc:subject:message-id :mail-followup-to:mime-version:content-disposition:user-agent; bh=EteXygXMCMIuOH65MtjowE2DhA9SwUq1uE5SG/8bUGA=; b=SZ0XaM7zNi2TkEY/PTOJCqmtjCwBrKfNyf1i73g3zHmqg/VWMWvlM5hZDZgwS+y0pW a5hLQyU3YoYw+WvpLj4Ls7g4be/9l7ZfppoQH6e6F9UQOmqxRbpPbsenfUP5S53NTXT5 ucyK3GGOOi8D5v5FJh7PwbHt/4IXZwlPhPB3Wi2oGY/ni2WqCCrEkP5bsjUZGt3IFAjC tFEGi9yVM5bhucQHA4+mFg6wGUmjPGSTgyP5GNQ8DneQJTloElOzquhOdTuPX5FWamxw tjvuzR7Wdcw40fVGhRcEvIcA5XEVmBjikvL/VN+dbKzPWasTcUoNGn0iJO1bremIj7jy BnCA== X-Gm-Message-State: AOAM532ofkWc4kgZaym5NELwVSBrhXQUL94sBlwFFf0Z21KUrkHMiaLe iUlhVlsrua1wAR9ExI5R36c= X-Google-Smtp-Source: ABdhPJzBJLHkMIuEbtGr1+LpiBstQirZrxRohNTninbGDYKqZqqMHLh/V9kjyaXQ/gbGgwJskKjqfQ== X-Received: by 2002:a63:445a:: with SMTP id t26mr18659351pgk.402.1608623356116; Mon, 21 Dec 2020 23:49:16 -0800 (PST) Received: from open-light-1.localdomain (66.98.113.28.16clouds.com. [66.98.113.28]) by smtp.gmail.com with ESMTPSA id b189sm19198904pfb.194.2020.12.21.23.49.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Dec 2020 23:49:15 -0800 (PST) From: Liang Li X-Google-Original-From: Liang Li Date: Tue, 22 Dec 2020 02:49:13 -0500 To: Alexander Duyck , Mel Gorman , Andrew Morton , Andrea Arcangeli , Dan Williams , "Michael S. Tsirkin" , David Hildenbrand , Jason Wang , Dave Hansen , Michal Hocko , Liang Li , Mike Kravetz , Liang Li Subject: [RFC PATCH 3/3] mm: support free hugepage pre zero out Message-ID: <20201222074910.GA30051@open-light-1.localdomain> Mail-Followup-To: Alexander Duyck , Mel Gorman , Andrew Morton , Andrea Arcangeli , Dan Williams , "Michael S. Tsirkin" , David Hildenbrand , Jason Wang , Dave Hansen , Michal Hocko , Liang Li , Mike Kravetz , Liang Li , linux-mm@kvack.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, qemu-devel@nongnu.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=liliang.opensource@gmail.com; helo=mail-pf1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This patch add support of pre zero out free hugepage, we can use this feature to speed up page population and page fault handing. 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 Cc: Michael S. Tsirkin Cc: Jason Wang Cc: Mike Kravetz Cc: Liang Li Signed-off-by: Liang Li --- mm/page_prezero.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/mm/page_prezero.c b/mm/page_prezero.c index c8ce720bfc54..dff4e0adf402 100644 --- a/mm/page_prezero.c +++ b/mm/page_prezero.c @@ -26,6 +26,7 @@ static unsigned long delay_millisecs = 1000; static unsigned long zeropage_enable __read_mostly; static DEFINE_MUTEX(kzeropaged_mutex); static struct page_reporting_dev_info zero_page_dev_info; +static struct page_reporting_dev_info zero_hugepage_dev_info; inline void clear_zero_page_flag(struct page *page, int order) { @@ -69,9 +70,17 @@ static int start_kzeropaged(void) zero_page_dev_info.delay_jiffies = msecs_to_jiffies(delay_millisecs); err = page_reporting_register(&zero_page_dev_info); + + zero_hugepage_dev_info.report = zero_free_pages; + zero_hugepage_dev_info.mini_order = mini_page_order; + zero_hugepage_dev_info.batch_size = batch_size; + zero_hugepage_dev_info.delay_jiffies = msecs_to_jiffies(delay_millisecs); + + err |= hugepage_reporting_register(&zero_hugepage_dev_info); pr_info("Zero page enabled\n"); } else { page_reporting_unregister(&zero_page_dev_info); + hugepage_reporting_unregister(&zero_hugepage_dev_info); pr_info("Zero page disabled\n"); } @@ -90,7 +99,15 @@ static int restart_kzeropaged(void) zero_page_dev_info.batch_size = batch_size; zero_page_dev_info.delay_jiffies = msecs_to_jiffies(delay_millisecs); + hugepage_reporting_unregister(&zero_hugepage_dev_info); + + zero_hugepage_dev_info.report = zero_free_pages; + zero_hugepage_dev_info.mini_order = mini_page_order; + zero_hugepage_dev_info.batch_size = batch_size; + zero_hugepage_dev_info.delay_jiffies = msecs_to_jiffies(delay_millisecs); + err = page_reporting_register(&zero_page_dev_info); + err |= hugepage_reporting_register(&zero_hugepage_dev_info); pr_info("Zero page enabled\n"); }