From patchwork Fri Aug 25 13:59:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13365806 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0ACE4C71133 for ; Fri, 25 Aug 2023 13:59:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 45A672800C2; Fri, 25 Aug 2023 09:59:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CB0958E0018; Fri, 25 Aug 2023 09:59:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E6742800C4; Fri, 25 Aug 2023 09:59:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B917F2800CA for ; Fri, 25 Aug 2023 09:59:27 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8D10B806F7 for ; Fri, 25 Aug 2023 13:59:27 +0000 (UTC) X-FDA: 81162784374.29.E0C5E11 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf22.hostedemail.com (Postfix) with ESMTP id D9FA9C0009 for ; Fri, 25 Aug 2023 13:59:25 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=IeYsemVD; spf=none (imf22.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692971966; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Xv0w05Np1RQXNMNntL3Ow/R7WXDn51tGEj4wuerPY4E=; b=V3XkdduQMYMtTjXVgURWKuq2ZaiiIwyJ9mgFuiKhvor/9/GcT0C3XWxMw3OYhJo5o1VbSD +EdyFKai2pa6zRs70or+6ZbQhChBZWvaI6dsgcetla6GkO+n9bTH//3IZk+eo8qHkP6YMf UGjSNePMZmCTUiuRMhTj897B2mXVkWw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692971966; a=rsa-sha256; cv=none; b=5gRB430xBSSw1ItU8heUBWRw6Mjb6RPpVaHM8nIGaaFAes3QdvicxQmZN30ykb8DNKE6Vr FKhzeqxdIonsMfdMrw6663LH9B9KxtwR2415qsp3gd50O5rjq8gxbnVUynTPoH5fk4qMg5 PYo2YKJ9XeqMK9ytDK3BulgV5gc4vls= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=IeYsemVD; spf=none (imf22.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=Xv0w05Np1RQXNMNntL3Ow/R7WXDn51tGEj4wuerPY4E=; b=IeYsemVDHdHrQVgR+egV4xparP MZ94nwvfPyHwekhRRuh2X08ija5wUaTPGc80nPeFOjSqDoi4fY4wfxd/j3Kb8158CyV5WyOJnat6/ 4EyjjNB3hOuToYOjc26X0aNTVi3IUhiljJYl4BBFyoLqQgBHDeSJs3xWGpBMRLKUS4WLkwgiUtOf7 Xfen5Ylccpt/fkJ4d7Szgxtrl8begsNI0SJF2DIOTOvBz+VrSU1zNyHttmgM2jWmXXuiLpRpC3m4D bI0hIl3rkZSwI5X8AT549IeEbNaOpHQ5p/HQ7hGFWPGxFIHgD+EHJyJzmylPnRxz++Fiqc5iPG5WZ WGtyN/tg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qZXLO-00HTRI-6q; Fri, 25 Aug 2023 13:59:22 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Mel Gorman Subject: [RFC PATCH 11/14] mm: Free folios in a batch in shrink_folio_list() Date: Fri, 25 Aug 2023 14:59:15 +0100 Message-Id: <20230825135918.4164671-12-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230825135918.4164671-1-willy@infradead.org> References: <20230825135918.4164671-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: D9FA9C0009 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 7kmkkmzf6zkau5mznyy8s3s4o4w1df5w X-HE-Tag: 1692971965-626795 X-HE-Meta: U2FsdGVkX19LAFBPBTCuKdHEBCVKpo9if3MdbL/NWSzs5M2/Ut8TM1M+9SQyEIvJ7SWMfYkOpqm8jhFUw4J+5Byus+hOSGhOfoCUHuEKwqYJb5+z/cAOcxU1mo+cr6BivA5wPCi+6lylTI2zdZA3ndzE/SEFdO4boUbHU9rvO4oBpCPJWC+kymVfd2UT2YpSwUnMw0VbiusqjLAixI0RrRAMi0TlGB/QvNs3SkWwPHK5XGLjKoO5SajQfssQhboKuldctWRXkfFtUzmYM3QOCOz6aNqO0aRChrCi17tlXl5TZX6/RiFDlDws97pAtSY/tpCShcGSu8RJumAdlFs3SdvSKjwfTgYFx9x0gr0jNsz3yFx1BRUJQCjaqMW/ghfM8+ZJFnsoMqPQy/rUktv0EYIjaJwOSkR7nh096Vu/2rW6ZvlKt0aLlGhrPsZYgaUvN3G2boC5LNUYLxw3ZyRPM+uiZRdWcxN9YOMRNIoK/SXkSmvelwSerdkUM4M1Wvp+CabaI34iQz3bRzurqWGtYFQhAZxne4IpNz+oh4KHftEACKGV1u1ix43ki3yL5EHEZmLdgSdqsn4goPmToO/We5Gtw35ZuMuKPWDOruTqkGrBCgVscsFsJ2/a8l/vUve5tiPFT9VQQF8tupUUhnPa4gROWE3vCyh+XWBAuBTudvGu1WKJ80+cFR/TYOqeHYOhjgSpPZEnBXeV4YPZB8UtPH2fe8Du9IFYKLRidDRgEnvxnICR8N7drP+676O5lsBPS/B2iR9+cqJNb8+QuwCRse89+u58iTrYS3o2qcighB40xtrbasublMvrKCl2vo9FnNhvVjfFC4piLrJrhlFBJO3EnnzpguI1UcM3yp5oECKdPX7u/9qO0nnCgoFw677L7vpAJSwR5mL2SPKIqr5DKtY8uB7rlA6kseJ3icOMllMPNKgkxO/JHcKyqJglF9I+BnNbXd1I9MxTjdtaTcT Gtz2C2vN aRCjwvnsSE24u19VmUqn90x0Hb+oztwl5V8SlGBnDP4CgCmxJHAqgOMMhbT1vbxU+xy4W1JRH0l04vLrPbVwhCuoOpSobw53kfRWSlzSm7NtxwcflN56tz19efGkPDGtybh6xl+S/Vyj3X0TEs3lvRxisFCdoMdXl9jQ2kieH2bu5WHJ46HwTeAKnz+5b+qEYbYhek5dIai2GvdJUp+aZ0ihGfeskVdRPCxqi 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 free_unref_page_batch() to free the folios. This may increase the numer of IPIs from calling try_to_unmap_flush() more often, but that's going to be very workload-dependent. Signed-off-by: Matthew Wilcox (Oracle) Cc: Mel Gorman --- mm/vmscan.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 6f13394b112e..965c429847fd 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1706,14 +1706,15 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, struct pglist_data *pgdat, struct scan_control *sc, struct reclaim_stat *stat, bool ignore_references) { + struct folio_batch free_folios; LIST_HEAD(ret_folios); - LIST_HEAD(free_folios); LIST_HEAD(demote_folios); unsigned int nr_reclaimed = 0; unsigned int pgactivate = 0; bool do_demote_pass; struct swap_iocb *plug = NULL; + folio_batch_init(&free_folios); memset(stat, 0, sizeof(*stat)); cond_resched(); do_demote_pass = can_demote(pgdat->node_id, sc); @@ -2111,14 +2112,11 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, */ nr_reclaimed += nr_pages; - /* - * Is there need to periodically free_folio_list? It would - * appear not as the counts should be low - */ - if (unlikely(folio_test_large(folio))) - destroy_large_folio(folio); - else - list_add(&folio->lru, &free_folios); + if (folio_batch_add(&free_folios, folio) == 0) { + mem_cgroup_uncharge_folios(&free_folios); + try_to_unmap_flush(); + free_unref_folios(&free_folios); + } continue; activate_locked_split: @@ -2182,9 +2180,9 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, pgactivate = stat->nr_activate[0] + stat->nr_activate[1]; - mem_cgroup_uncharge_list(&free_folios); + mem_cgroup_uncharge_folios(&free_folios); try_to_unmap_flush(); - free_unref_page_list(&free_folios); + free_unref_folios(&free_folios); list_splice(&ret_folios, folio_list); count_vm_events(PGACTIVATE, pgactivate);