From patchwork Wed Jan 6 03:48:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liang Li X-Patchwork-Id: 12000915 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=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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=ham 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 5F812C433E0 for ; Wed, 6 Jan 2021 03:48:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D920A22CB1 for ; Wed, 6 Jan 2021 03:48:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D920A22CB1 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 420E48D00E1; Tue, 5 Jan 2021 22:48:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A91C8D00D1; Tue, 5 Jan 2021 22:48:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2221C8D00E1; Tue, 5 Jan 2021 22:48:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0168.hostedemail.com [216.40.44.168]) by kanga.kvack.org (Postfix) with ESMTP id 05BFE8D00D1 for ; Tue, 5 Jan 2021 22:48:15 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C236B21E4 for ; Wed, 6 Jan 2021 03:48:14 +0000 (UTC) X-FDA: 77673967308.27.robin95_5815056274de Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id A86453D663 for ; Wed, 6 Jan 2021 03:48:14 +0000 (UTC) X-HE-Tag: robin95_5815056274de X-Filterd-Recvd-Size: 9791 Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Wed, 6 Jan 2021 03:48:13 +0000 (UTC) Received: by mail-pg1-f177.google.com with SMTP id i7so1306228pgc.8 for ; Tue, 05 Jan 2021 19:48:13 -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=B3WV/j0Yc3UxPycY24YbbsJo25sgb+PzV0Vt6RMFIJ4=; b=p3QzQqTq1x0ViyPmHXZ0vVH7lPNwPDUFAlch1JuuQBXeGQHUbPBD7OrSBcWrzru7kX JPto5iqfwVBAVg8jfDcNFrfFcMzYeWZRDoTkMplia/JRwuGYC9BulZF7mrDMhvNJ2Gnl mt2RFpygGcezHGnLG06Fk7EoTjVa/oK5CGZZRDnTAjoULTWU1PSLj+c/xZ4jpoURjV9G uA7yyAYH4by5fB+WwZBA/+N62r9yuIP/55klMvSJZvhz2XBpvlt9sh8SGtkJtiNmLB1v NLf2/wPpv1lS3w8i+wu58tKw/9Y+nRf6B4gWunkCsqpJhIW2no6TO5+vlSi24zKvQ9f6 gqaA== 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=B3WV/j0Yc3UxPycY24YbbsJo25sgb+PzV0Vt6RMFIJ4=; b=UYOXnCzGcyZGTcV+dt+RtAU9l/XANIvkBuji4TtD4+orXkqsMAFsNXiChNpVF8eqWh 4pkByj9dq1bOYknxKn63kb0BBmEH4zOZlcg2BBmuaf111aCDJI1b1QOrcmM6Hl5P4D2D b5a3pGNnTx1yj2ArAaZayr6YuOHH5P1rGr/carphsWmR0YDVZIHOGRgoEsHQoZM+ovpm XKyFP1HLS4N3dEyMaG3oEkIvJe71pJzpbxVykbECzIMmxeZ5EUsWf15knBTA4JeA1yjj 03RghfQpzk21g4WzrpBryV5vrhU4sNp6Db/W4pMJjGbdLnXz7wMZKb/wVYoZCbV2hpmr UPjQ== X-Gm-Message-State: AOAM530ixN9jgSD/m044wkcIfteP3i2u2/jLOwUgLU8DPY8YkjMB1WIP 1r6M7AoI11B9TuNblEVgsHQ= X-Google-Smtp-Source: ABdhPJz9vssAAYkLAHpWNywNUSwHPNC9skdPEiGDqhNAxr+rje3pVUyq972g8FX64yvm6siaLRbxXA== X-Received: by 2002:aa7:8641:0:b029:1a1:e2f5:23de with SMTP id a1-20020aa786410000b02901a1e2f523demr2131021pfo.35.1609904892473; Tue, 05 Jan 2021 19:48:12 -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 t15sm736076pfc.12.2021.01.05.19.48.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 19:48:11 -0800 (PST) From: Liang Li X-Google-Original-From: Liang Li Date: Tue, 5 Jan 2021 22:48:09 -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 , Liang Li , Mike Kravetz Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: [PATCH 2/6] mm: let user decide page reporting option Message-ID: <20210106034806.GA1146@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 , linux-mm@kvack.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org 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: Some key parameters for page reporting are now hard coded, different users of the framework may have their special requirements, make these parameter configrable and let the user decide them. 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: Liang Li Signed-off-by: Liang Li --- drivers/virtio/virtio_balloon.c | 3 +++ include/linux/page_reporting.h | 3 +++ mm/page_reporting.c | 13 +++++++++---- mm/page_reporting.h | 6 +++--- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 8985fc2cea86..684bcc39ef5a 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -993,6 +993,9 @@ static int virtballoon_probe(struct virtio_device *vdev) goto out_unregister_oom; } + vb->pr_dev_info.mini_order = pageblock_order; + vb->pr_dev_info.batch_size = 16 * 1024 * 1024; /* 16M */ + vb->pr_dev_info.delay_jiffies = 2 * HZ; /* 2 seconds */ err = page_reporting_register(&vb->pr_dev_info); if (err) goto out_unregister_oom; diff --git a/include/linux/page_reporting.h b/include/linux/page_reporting.h index 3b99e0ec24f2..63e1e9fbcaa2 100644 --- a/include/linux/page_reporting.h +++ b/include/linux/page_reporting.h @@ -13,6 +13,9 @@ struct page_reporting_dev_info { int (*report)(struct page_reporting_dev_info *prdev, struct scatterlist *sg, unsigned int nents); + unsigned long batch_size; + unsigned long delay_jiffies; + int mini_order; /* work struct for processing reports */ struct delayed_work work; diff --git a/mm/page_reporting.c b/mm/page_reporting.c index 694df981ddd2..39bc6a9d7b73 100644 --- a/mm/page_reporting.c +++ b/mm/page_reporting.c @@ -13,6 +13,7 @@ #define PAGE_REPORTING_DELAY (2 * HZ) static struct page_reporting_dev_info __rcu *pr_dev_info __read_mostly; unsigned long page_report_batch_size __read_mostly = 16 * 1024 * 1024UL; +int page_report_mini_order = pageblock_order; enum { PAGE_REPORTING_IDLE = 0, @@ -44,7 +45,7 @@ __page_reporting_request(struct page_reporting_dev_info *prdev) * now we are limiting this to running no more than once every * couple of seconds. */ - schedule_delayed_work(&prdev->work, PAGE_REPORTING_DELAY); + schedule_delayed_work(&prdev->work, prdev->delay_jiffies); } /* notify prdev of free page reporting request */ @@ -230,7 +231,7 @@ page_reporting_process_zone(struct page_reporting_dev_info *prdev, /* Generate minimum watermark to be able to guarantee progress */ watermark = low_wmark_pages(zone) + - (PAGE_REPORTING_CAPACITY << PAGE_REPORTING_MIN_ORDER); + (PAGE_REPORTING_CAPACITY << prdev->mini_order); /* * Cancel request if insufficient free memory or if we failed @@ -240,7 +241,7 @@ page_reporting_process_zone(struct page_reporting_dev_info *prdev, return err; /* Process each free list starting from lowest order/mt */ - for (order = PAGE_REPORTING_MIN_ORDER; order < MAX_ORDER; order++) { + for (order = prdev->mini_order; order < MAX_ORDER; order++) { for (mt = 0; mt < MIGRATE_TYPES; mt++) { /* We do not pull pages from the isolate free list */ if (is_migrate_isolate(mt)) @@ -307,7 +308,7 @@ static void page_reporting_process(struct work_struct *work) */ state = atomic_cmpxchg(&prdev->state, state, PAGE_REPORTING_IDLE); if (state == PAGE_REPORTING_REQUESTED) - schedule_delayed_work(&prdev->work, PAGE_REPORTING_DELAY); + schedule_delayed_work(&prdev->work, prdev->delay_jiffies); } static DEFINE_MUTEX(page_reporting_mutex); @@ -335,6 +336,8 @@ int page_reporting_register(struct page_reporting_dev_info *prdev) /* Assign device to allow notifications */ rcu_assign_pointer(pr_dev_info, prdev); + page_report_mini_order = prdev->mini_order; + page_report_batch_size = prdev->batch_size; /* enable page reporting notification */ if (!static_key_enabled(&page_reporting_enabled)) { static_branch_enable(&page_reporting_enabled); @@ -352,6 +355,8 @@ void page_reporting_unregister(struct page_reporting_dev_info *prdev) mutex_lock(&page_reporting_mutex); if (rcu_access_pointer(pr_dev_info) == prdev) { + if (static_key_enabled(&page_reporting_enabled)) + static_branch_disable(&page_reporting_enabled); /* Disable page reporting notification */ RCU_INIT_POINTER(pr_dev_info, NULL); synchronize_rcu(); diff --git a/mm/page_reporting.h b/mm/page_reporting.h index b8fb3bbb345f..86ac6ffad970 100644 --- a/mm/page_reporting.h +++ b/mm/page_reporting.h @@ -9,9 +9,9 @@ #include #include #include +#include -#define PAGE_REPORTING_MIN_ORDER pageblock_order - +extern int page_report_mini_order; extern unsigned long page_report_batch_size; #ifdef CONFIG_PAGE_REPORTING @@ -42,7 +42,7 @@ static inline void page_reporting_notify_free(unsigned int order) return; /* Determine if we have crossed reporting threshold */ - if (order < PAGE_REPORTING_MIN_ORDER) + if (order < page_report_mini_order) return; batch_size += (1 << order) << PAGE_SHIFT;