From patchwork Sun Apr 12 09:08:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liang Li X-Patchwork-Id: 11484485 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1469E112C for ; Sun, 12 Apr 2020 09:13:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CADF420709 for ; Sun, 12 Apr 2020 09:13:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="H6V+wkIR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CADF420709 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 14CC38E00C8; Sun, 12 Apr 2020 05:13:30 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0FDF38E0007; Sun, 12 Apr 2020 05:13:30 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F06878E00C8; Sun, 12 Apr 2020 05:13:29 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0226.hostedemail.com [216.40.44.226]) by kanga.kvack.org (Postfix) with ESMTP id D55AC8E0007 for ; Sun, 12 Apr 2020 05:13:29 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 95DC95DDC for ; Sun, 12 Apr 2020 09:13:29 +0000 (UTC) X-FDA: 76698639738.01.vest78_75c101c0ad940 X-Spam-Summary: 2,0,0,e1176cb0cec1a681,d41d8cd98f00b204,liliang.opensource@gmail.com,,RULES_HIT:41:355:379:800:960:966:973:988:989:1260:1277:1312:1313:1314:1345:1381:1437:1516:1518:1519:1535:1542:1593:1594:1595:1596:1711:1730:1747:1777:1792:2194:2196:2198:2199:2200:2201:2393:2553:2559:2562:2693:2731:2895:2898:3138:3139:3140:3141:3142:3353:3865:3867:3870:3871:4117:4321:4385:5007:6120:6261:6653:6737:7903:8957:9010:9413:9707:10004:10400:11026:11473:11658:11914:12043:12048:12291:12296:12297:12438:12517:12519:12555:12683:12895:13439:13895:14093:14097:14181:14687:14721:21080:21444:21451:21554:21627:21666:21987:21990:30054:30070:30090,0,RBL:209.85.214.193:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: vest78_75c101c0ad940 X-Filterd-Recvd-Size: 6613 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Sun, 12 Apr 2020 09:13:29 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id h11so2334193plr.11 for ; Sun, 12 Apr 2020 02:13:28 -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=RuB1CaDpM0woLJXutDrQTOUUotmzhwc0OsCFpbFNptA=; b=H6V+wkIRDejLir6iRbxVY7CX2fia/E09n9eexfrXPrbXSwPB7iYZSqJIMSDwa+w9Z7 3j1u23NQvBvNsKsq/r+qCdUim8VsGxkUpXC80iNFjD28ASiuzwT0ViCnPsUuDzKO/9au WlSD8vkDoFIajB9XtSwyIvuyu70EsfMh7xgLvcH2gEQXf+4MdOBXiwraC0/qxwLU84T3 4FApS/7RK58A0rgXMcgAaA/oVkTY58KwDEbg7VQJdmxbhQdLVrx2xDQWU8gKlK0IU1gG gAZsGlJ0OWf/2QeRUC4h3ol6hBF6CK4VdUAw7bOti56H/siMGzMOk+euNtiujucc96W3 cjcA== 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=RuB1CaDpM0woLJXutDrQTOUUotmzhwc0OsCFpbFNptA=; b=oxeFORQJspu4B+0/TSUeboTQmTMMk+PPcNVQ6Sk975qgJKd2U+Nd8AbQHPVG5MBKCf lOJghMWX4nLu2EORZcYTdJ2go7z96XIXA3FUZiAl9653GE2Gf52MCJ8nlidE9gN31Ef/ +yC2o+L7aqlA4OkmPp0/9KrDiDuFIKh2jtgoyqgRPxzkZ7A3EcpUu+xz15FLeUl3b04e g5Try1fYQLpAdbvnDpCHXcHX5wy2dL/shEzAg2ouEpFez1hAHPewQzyp5jn6IQGOfD3H Y1rqQ9RvcTJmaXF/2N9GaM8bS6z7p78TzH/FrelVyFkdlCPMcbu2B2eZHQA7uq1F7cuK 142A== X-Gm-Message-State: AGi0PuZ/rVF/o8mcs+yeHYYR8dn0QUcDM0jTV1cZ9xMFSSsj37rxPlAc IoFEqug3fCrqiTQOqSh5dEVc2Id4 X-Google-Smtp-Source: APiQypJuLi6FpbQOASVt3bnvLG7scASlrJ5x7KwCWifh3zbzoiuzuJkj8eG+Sx+zIbBUBby62zO42g== X-Received: by 2002:a17:902:8a8f:: with SMTP id p15mr12549686plo.45.1586682808174; Sun, 12 Apr 2020 02:13:28 -0700 (PDT) Received: from open-light-1.localdomain ([66.98.113.28]) by smtp.gmail.com with ESMTPSA id p12sm6057594pfq.153.2020.04.12.02.13.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Apr 2020 02:13:27 -0700 (PDT) From: liliangleo X-Google-Original-From: liliangleo Date: Sun, 12 Apr 2020 05:08:00 -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 1/4] mm: reduce the impaction of page reporing worker Message-ID: <20200412090756.GA19574@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-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: When scaning the free list, 'page_reporting_cycle' may hold the zone->lock for a long time when there are no reported page in the free list. Setting PAGE_REPORTING_MIN_ORDER to a lower oder will make this issue worse. Two ways were used to reduce the impact: 1. Release zone lock periodicly 2. Yield cpu voluntarily if needed. Signed-off-by: liliangleo --- 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 3bbd471cfc81..3a7084e508e1 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;