From patchwork Mon Dec 21 16:28:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liang Li X-Patchwork-Id: 11984877 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 51816C433DB for ; Mon, 21 Dec 2020 16:28:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E9DCA22C9C for ; Mon, 21 Dec 2020 16:28:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E9DCA22C9C 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 46E466B0036; Mon, 21 Dec 2020 11:28:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4440A6B005C; Mon, 21 Dec 2020 11:28:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 30BCE6B005D; Mon, 21 Dec 2020 11:28:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0212.hostedemail.com [216.40.44.212]) by kanga.kvack.org (Postfix) with ESMTP id 184956B0036 for ; Mon, 21 Dec 2020 11:28:13 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id CE0748249980 for ; Mon, 21 Dec 2020 16:28:12 +0000 (UTC) X-FDA: 77617821624.19.nest35_3e0523e27458 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id A0AF11AD1B1 for ; Mon, 21 Dec 2020 16:28:12 +0000 (UTC) X-HE-Tag: nest35_3e0523e27458 X-Filterd-Recvd-Size: 7642 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Mon, 21 Dec 2020 16:28:12 +0000 (UTC) Received: by mail-pj1-f54.google.com with SMTP id m5so6721830pjv.5 for ; Mon, 21 Dec 2020 08:28:11 -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=yCqvw49/Rmb78qrcQ/V5V54EYYCj1w98X72tRqbM6ug=; b=ISuBRRAJ/22G4sfeIRuMpcpnOaxALlpU4jqnRl3kvDrtgKm3mszXPYIzziMVzphXMH ruF9mJTxXebBWTXxVxxVJrR/0KtJrLr3gAWy3I1zDEMplJnMFY/QdWYLfr0dJk33FAlc TpvLGlUWCSWVVP6nYbFhNPkJPaD5yq3x+EkbVN0Hor468AyTqFaqKEG94wph/WDMy+ds BZc9tnM5gXI8EZD8GsVCQla/qU2TKGqLzvfJCKGNMK1+3sVcppgRivwQv0tpG8qxOhB5 xTW6KaPMZOnqtTNFvw+9cwtQ9P9aLpxFu3FYKA8vj0D8s2NEb7i6MZ9AgTB2dwlt6T60 p26g== 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=yCqvw49/Rmb78qrcQ/V5V54EYYCj1w98X72tRqbM6ug=; b=pvbrlKnxGtKiS9YmQVsgkxDTAMZMRHswxxPlBBC5RDVYcN95mqmy2Gjugeqvs4UWDX FhqqbP0Da6BuCzBReVUp5OdUW/cm25B9bGdz8joQK53OFj7ihVEj9UzXOHp9qFIPzm0G I4AgewBOcIUVH6jVu/t6YbCltvmrpteQmfwqVB7TpRWACiyzlEmyrjbgRvUYVUYQwUiQ t/3KK3Cl7Jp+IRywsJqXcyk5+4HQAagr/BuGHnZ9mjUbaKAvzD2o8pA8Pz0sjqhRdrpG Slyi9lvc0w4yNH3SofhOt9zHp4quGMIWMJNOHSrz4bvjTAD+D/XTRRkH0hjyTP+/98ta CN0g== X-Gm-Message-State: AOAM531iLGFdPN3IZk0fhhQ+tQAFpfSnJaF4gjUr5GPpAvrAvW0d09MI bMs1mKJGnqozjQ23uXD5QSg= X-Google-Smtp-Source: ABdhPJz3AIrbe7WmvCFNyoUxmGYHG4WGKx8LarPfV1FGev4qvJ72uy0P4T4bxfBZHf2YyXIp2rSmQw== X-Received: by 2002:a17:902:aa8b:b029:da:ef22:8675 with SMTP id d11-20020a170902aa8bb02900daef228675mr16841289plr.15.1608568091235; Mon, 21 Dec 2020 08:28:11 -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 ev23sm16794186pjb.24.2020.12.21.08.28.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Dec 2020 08:28:11 -0800 (PST) From: Liang Li X-Google-Original-From: Liang Li Date: Mon, 21 Dec 2020 11:28:08 -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 1/4] mm: make page reporing worker works better for low order page Message-ID: <20201221162806.GA22524@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: 'page_reporting_cycle' may take the zone lock for too long when scan a low order free page list, because the low order page free list may have a lot iterms and very few pages without the PG_report flag. Current implementation limits the mini reported order to pageblock_order, it's ok for most case. If we want to report low order pages, we should prevent zone lock from being taken too long by the reporting worker, or it may affect system performance, this patch try to make 'page_reporting_cycle' work better for low order pages, the zone lock was released periodicly and cup was yielded voluntarily if needed. 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 | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/mm/page_reporting.c b/mm/page_reporting.c index cd8e13d41df4..0b22db94ce2a 100644 --- a/mm/page_reporting.c +++ b/mm/page_reporting.c @@ -6,11 +6,14 @@ #include #include #include +#include #include "page_reporting.h" #include "internal.h" #define PAGE_REPORTING_DELAY (2 * HZ) +#define MAX_SCAN_NUM 1024 + static struct page_reporting_dev_info __rcu *pr_dev_info __read_mostly; enum { @@ -115,7 +118,7 @@ page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone, unsigned int page_len = PAGE_SIZE << order; struct page *page, *next; long budget; - int err = 0; + int err = 0, scan_cnt = 0; /* * Perform early check, if free area is empty there is @@ -145,8 +148,14 @@ page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone, /* loop through free list adding unreported pages to sg list */ list_for_each_entry_safe(page, next, list, lru) { /* We are going to skip over the reported pages. */ - if (PageReported(page)) + if (PageReported(page)) { + if (++scan_cnt >= MAX_SCAN_NUM) { + err = scan_cnt; + break; + } continue; + } + /* * If we fully consumed our budget then update our @@ -219,6 +228,26 @@ page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone, return err; } +static int +reporting_order_type(struct page_reporting_dev_info *prdev, struct zone *zone, + unsigned int order, unsigned int mt, + struct scatterlist *sgl, unsigned int *offset) +{ + int ret = 0; + unsigned long total = 0; + + might_sleep(); + do { + cond_resched(); + ret = page_reporting_cycle(prdev, zone, order, mt, + sgl, offset); + if (ret > 0) + total += ret; + } while (ret > 0 && total < zone->free_area[order].nr_free); + + return ret; +} + static int page_reporting_process_zone(struct page_reporting_dev_info *prdev, struct scatterlist *sgl, struct zone *zone) @@ -245,7 +274,7 @@ page_reporting_process_zone(struct page_reporting_dev_info *prdev, if (is_migrate_isolate(mt)) continue; - err = page_reporting_cycle(prdev, zone, order, mt, + err = reporting_order_type(prdev, zone, order, mt, sgl, &offset); if (err) return err;