From patchwork Mon Dec 21 16:28:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liang Li X-Patchwork-Id: 11984879 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 F2D83C433DB for ; Mon, 21 Dec 2020 16:28:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8186622B51 for ; Mon, 21 Dec 2020 16:28:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8186622B51 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 DB90D6B005C; Mon, 21 Dec 2020 11:28:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D69CE6B005D; Mon, 21 Dec 2020 11:28:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C591C6B006C; Mon, 21 Dec 2020 11:28:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0236.hostedemail.com [216.40.44.236]) by kanga.kvack.org (Postfix) with ESMTP id 9CAE96B005C for ; Mon, 21 Dec 2020 11:28:57 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 574873643 for ; Mon, 21 Dec 2020 16:28:57 +0000 (UTC) X-FDA: 77617823514.29.card18_2e0e44227458 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id 39145180868FB for ; Mon, 21 Dec 2020 16:28:57 +0000 (UTC) X-HE-Tag: card18_2e0e44227458 X-Filterd-Recvd-Size: 6865 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Mon, 21 Dec 2020 16:28:56 +0000 (UTC) Received: by mail-pf1-f178.google.com with SMTP id t22so6744454pfl.3 for ; Mon, 21 Dec 2020 08:28:56 -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=TWbytHk0kwDmGNz219zPiK2yM0SvWN9E6mBmb9Rckbw=; b=VsX+OIQPLU3ay3St7Stnyt2AOk+euEJgP8drwoX3Wj31/pbdT/Ko9TWjb0JbdVzVs3 yvCZDHYcwR3dazppXzQqvTB13XlvW3jV2/T97Tkjd0EeqZz7Z6/xpSBapsC5obYpjtOW EIET1bZ17a2dSa2aZZ/2oJdKnJZuWAp6/qycQEFnsFg5xM0Oa+uc66jA30Z98VvYyswK 9jzn5K/MSE/H4hZ3oWj4A4w5UA9Xb6YXejyFg92y7txHX3Y/slWBan9EyrjdoOWikCE5 R6i2P71yAbGNZxyFgbtJ4uDoCzTPpQEhUCRvtll4kqR1e8QKl1NF4nNpu7774LsZGUR/ naaQ== 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=TWbytHk0kwDmGNz219zPiK2yM0SvWN9E6mBmb9Rckbw=; b=DuVLn+GPvMFNHFh+YbcT3Pxi5SekQDT13qXkbk5GsyK8x5+SNk3Ocl5xXtIWsPxlBc 7VsgdV8eHK/lRjbCHZLiKnhtnLxZtCxytxbDD4mvnkbbkIwA+EqZ28SU7oB5B/zCEcrE cfJWqO57ADpeEgPzngiUT4xsO/w7u8FJ4a1iohcFHFShJ/akrBpzt80tnhXF0priR4KW C1AhMS+Hi+QI42v/RbASl2J2AbD/k3M/H4EmFBNIi4yvNCJgptF/mfbIr82l6jE9T6gT sBS552F9iA+iYZE1QEtykQT+1CbWZf4y1z5ReuCxepPmOhX8+fk2eOEp1YaGLcv9kEYu OliQ== X-Gm-Message-State: AOAM532hpWbSbVl9xhSE2+1mS7HxB2vkgGU4ZyP79VKNQDmSjRys80CK Ig6KQI+5ZTUlMApTEjmwzmo= X-Google-Smtp-Source: ABdhPJwzr5pBcakDlhPI2PXs+KSqljHYy/00sB78l96c6Dn/mbSBJJ218gj4PIzYRWs0Xx/WSc9ZGQ== X-Received: by 2002:a65:64c9:: with SMTP id t9mr16051232pgv.418.1608568135985; Mon, 21 Dec 2020 08:28:55 -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 gm18sm16118590pjb.55.2020.12.21.08.28.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Dec 2020 08:28:55 -0800 (PST) From: Liang Li X-Google-Original-From: Liang Li Date: Mon, 21 Dec 2020 11:28:53 -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 Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: [RFC v2 PATCH 2/4] mm: Add batch size for free page reporting Message-ID: <20201221162851.GA22528@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 , 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: Use the page order as the only threshold for page reporting is not flexible and has some flaws. When the system's memory becomes very fragmented, there will be a lot of low order free pages but very few high order pages, limit the mini order as pageblock_order will prevent most of free pages from being reclaimed by host for the case of page reclmain through the virtio-balllon driver. Scan a long free list is not cheap, it's better to wake up the page reporting worker when there are more pages, wake it up for a sigle page may not worth. This patch add a batch size as another threshold to control the waking up of reporting worker. 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 Signed-off-by: Liang Li --- mm/page_reporting.c | 2 ++ mm/page_reporting.h | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/mm/page_reporting.c b/mm/page_reporting.c index 0b22db94ce2a..2f8e3d032fab 100644 --- a/mm/page_reporting.c +++ b/mm/page_reporting.c @@ -14,6 +14,8 @@ #define PAGE_REPORTING_DELAY (2 * HZ) #define MAX_SCAN_NUM 1024 +unsigned long page_report_batch_size __read_mostly = 4 * 1024 * 1024UL; + static struct page_reporting_dev_info __rcu *pr_dev_info __read_mostly; enum { diff --git a/mm/page_reporting.h b/mm/page_reporting.h index 2c385dd4ddbd..b8fb3bbb345f 100644 --- a/mm/page_reporting.h +++ b/mm/page_reporting.h @@ -12,6 +12,8 @@ #define PAGE_REPORTING_MIN_ORDER pageblock_order +extern unsigned long page_report_batch_size; + #ifdef CONFIG_PAGE_REPORTING DECLARE_STATIC_KEY_FALSE(page_reporting_enabled); void __page_reporting_notify(void); @@ -33,6 +35,8 @@ static inline bool page_reported(struct page *page) */ static inline void page_reporting_notify_free(unsigned int order) { + static long batch_size; + /* Called from hot path in __free_one_page() */ if (!static_branch_unlikely(&page_reporting_enabled)) return; @@ -41,8 +45,12 @@ static inline void page_reporting_notify_free(unsigned int order) if (order < PAGE_REPORTING_MIN_ORDER) return; - /* This will add a few cycles, but should be called infrequently */ - __page_reporting_notify(); + batch_size += (1 << order) << PAGE_SHIFT; + if (batch_size >= page_report_batch_size) { + batch_size = 0; + /* This add a few cycles, but should be called infrequently */ + __page_reporting_notify(); + } } #else /* CONFIG_PAGE_REPORTING */ #define page_reported(_page) false