From patchwork Mon Jan 30 20:18:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13121760 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 4505BC54EAA for ; Mon, 30 Jan 2023 20:18:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8AB836B007D; Mon, 30 Jan 2023 15:18:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 85D646B007E; Mon, 30 Jan 2023 15:18:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 74BF96B0080; Mon, 30 Jan 2023 15:18:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 5511A6B007E for ; Mon, 30 Jan 2023 15:18:50 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 30DD2C03C9 for ; Mon, 30 Jan 2023 20:18:50 +0000 (UTC) X-FDA: 80412578820.09.705E017 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by imf10.hostedemail.com (Postfix) with ESMTP id 605AAC001D for ; Mon, 30 Jan 2023 20:18:48 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Tj3i6e31; spf=pass (imf10.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.173 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675109928; a=rsa-sha256; cv=none; b=ghK4jEl+qTMGisBABG41nRDsH+5bkTkRwdsuhUmB/a6Vk31pyQn4tcui38HsNTMkJ754Fo Jh04kqWbTNdJX8smHfH3pew/jy4gYj9cDYkl+t3DYMEyPVECOiOsCJyikjw7qU59NLHPoZ y5wIrr35GWc8m24ZDy0TtEs+wWdo87U= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Tj3i6e31; spf=pass (imf10.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.173 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675109928; 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=Rj/qU+zS2SpVSC06qhYsv6OtjuVRmpJHRc9Sl9s1IRQ=; b=3EI6iC2zllhC00+833/EU8HGwEMFxG/Al1FBXsL/w253TrE+G8PaWDam/5J8vz2iuWk1b3 vN2CliU4/py0hSPM/O3tGnp/iOPvjK5kPhcDNWG6TbIOOcsYeZAaP2V5eDuI1WAvwFT5zq yfrDytllBfL78EE+lNToen5hLl9tA8o= Received: by mail-pf1-f173.google.com with SMTP id ay1so8599358pfb.7 for ; Mon, 30 Jan 2023 12:18:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Rj/qU+zS2SpVSC06qhYsv6OtjuVRmpJHRc9Sl9s1IRQ=; b=Tj3i6e31rScg++PudsTthpoxV+1jPlpPlY3/2b5Bf0/UDddmvfwoSeZ+wYXRcuVc2s wRlQRVqhaPdfYKY1/JcUFWGAyeH43ttEzDrtWbqT+7iJn/MB4dHk+JXlS32nb7igoFty J9/9643gbLQ/ImSRTqG97EHjD5VvPpCXcog14K0EjqXA51AkRgjmIbWqnOfPPXFe65Ri MDyBz/g7XdxdVnoMxbYe2N6WuWw1NeC62o4FfTo4S/s3M+4uRlhzGZ/c6TYRKZXNODpk TDOT5lG0BDlRIhjVRNv7IIUn6wH7Sx+sBaVWNVUw/fpiys5R733Q1SifNCc1biGkBk2W r0CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Rj/qU+zS2SpVSC06qhYsv6OtjuVRmpJHRc9Sl9s1IRQ=; b=faH7VMgQ5jNAosSv3klU0HeAaHdBWiW+qZItp9oXJt/3OAfzBWmoj0eGnkobWjnPJm GEVUTmcvDIe1Fo6eWfZr+Ii0L0gbArmUI1fSZMY5sfWbRlvbjcb/MrL9EPCDOMwEqrYL Zp0rfkhCVDVyL7arLQwv/uc8LOhlM2Yu2Kz4UNrfhx3xz4snN12OLujb99fu9UBXlaE0 57gPKucg3HwgRgXQISHuszqt4h0sS8wzBDyXGNc+oHApboM3W+4r2Q3LB+ydQGZWY452 SdBpatPi70x81qQrF8uYvzl2q6zCbWZ+hywEdq8z4KAYQvLjBPoKqlLOu3KP1KXvnrTC aENw== X-Gm-Message-State: AO0yUKVRArF1/QnGzJSUJJuqk3Exi0fLccrcX/H9KA8Uvb0tq9rM2tfJ QMZqTsw/SWpHRDJ2jvtV8o23xlGLEKg= X-Google-Smtp-Source: AK7set8JYge76j6ldf/cIJq9uWBWkQOUiCPeaBC+LTVdk7HzGHP97Ti5ETwPgNXR/shIaFwgkw06Cw== X-Received: by 2002:a62:3044:0:b0:590:64f1:8873 with SMTP id w65-20020a623044000000b0059064f18873mr7945965pfw.5.1675109927113; Mon, 30 Jan 2023 12:18:47 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:937f:7f20::a8cd]) by smtp.googlemail.com with ESMTPSA id g9-20020a056a000b8900b0058d9730ede0sm113262pfj.210.2023.01.30.12.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 12:18:46 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, "Vishal Moola (Oracle)" Subject: [PATCH mm-unstable v4 6/6] mm/mempolicy: convert migrate_page_add() to migrate_folio_add() Date: Mon, 30 Jan 2023 12:18:33 -0800 Message-Id: <20230130201833.27042-7-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230130201833.27042-1-vishal.moola@gmail.com> References: <20230130201833.27042-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 605AAC001D X-Rspamd-Server: rspam01 X-Stat-Signature: 16aoj6zrqd9884sgjzwf48m3gb5hwpce X-HE-Tag: 1675109928-809665 X-HE-Meta: U2FsdGVkX1+oC/+5dXs3pUcudyRda/5BB4wzX4ayOw3lMnjNtREdkJ8QakPF74+Tr3PfHupMSHn012I3ExcQ7GZ2dnzga6Oh7Hnm4VlgMrKNc4XxHEKD6t/kYRZ9l2OIBUVSBx81V8+a/QfmZO4thNKA+YqbDwhQLWY3Mn4EfQLc/FEa0WkHrrHjzQkkNTphdbel4YmgasKAR1aSAOHMYIJgca6IDZEPqLlO+B7y+t9sGBvGfEf2UCvGvY4NFa3N3Qn1ygxlVwLWAKMXsgI0Xcy0+NeK+ToXczG7x3RaeGOOfZ3JH3bLhRpKeTRKaddhndFOLKQY23Fu7ZlpoKtNPHT//8SRymbVyM9wQt4/z7maELq1XO+Nwa0qG+2tCt1z7ZzGYz+yOygvFRE4AIGyenLXS+paRbkvQ8y0EIXUaAP1OlN//EGvhRWznbvo7ogJPog3Qi7To7hC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BEJsTEkFOFTYB11/l+tS/se8SVyVIj0QsH7St7tl8g53ZX69g9eFrkrh/HDsUT7ycfpeMK6TviUvqoTrLEWrAHSMFqnPVXnh6kMvUl5MjRdHo= 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: Replace migrate_page_add() with migrate_folio_add(). migrate_folio_add() does the same a migrate_page_add() but takes in a folio instead of a page. This removes a couple of calls to compound_head(). Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Yin Fengwei --- mm/mempolicy.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 6a68dbce3b70..0919c7a719d4 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -414,7 +414,7 @@ static const struct mempolicy_operations mpol_ops[MPOL_MAX] = { }, }; -static int migrate_page_add(struct page *page, struct list_head *pagelist, +static int migrate_folio_add(struct folio *folio, struct list_head *foliolist, unsigned long flags); struct queue_pages { @@ -476,7 +476,7 @@ static int queue_folios_pmd(pmd_t *pmd, spinlock_t *ptl, unsigned long addr, /* go to folio migration */ if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) { if (!vma_migratable(walk->vma) || - migrate_page_add(&folio->page, qp->pagelist, flags)) { + migrate_folio_add(folio, qp->pagelist, flags)) { ret = 1; goto unlock; } @@ -544,7 +544,7 @@ static int queue_folios_pte_range(pmd_t *pmd, unsigned long addr, * temporary off LRU pages in the range. Still * need migrate other LRU pages. */ - if (migrate_page_add(&folio->page, qp->pagelist, flags)) + if (migrate_folio_add(folio, qp->pagelist, flags)) has_unmovable = true; } else break; @@ -1021,27 +1021,28 @@ static long do_get_mempolicy(int *policy, nodemask_t *nmask, } #ifdef CONFIG_MIGRATION -/* - * page migration, thp tail pages can be passed. - */ -static int migrate_page_add(struct page *page, struct list_head *pagelist, +static int migrate_folio_add(struct folio *folio, struct list_head *foliolist, unsigned long flags) { - struct page *head = compound_head(page); /* - * Avoid migrating a page that is shared with others. + * We try to migrate only unshared folios. If it is shared it + * is likely not worth migrating. + * + * To check if the folio is shared, ideally we want to make sure + * every page is mapped to the same process. Doing that is very + * expensive, so check the estimated mapcount of the folio instead. */ - if ((flags & MPOL_MF_MOVE_ALL) || page_mapcount(head) == 1) { - if (!isolate_lru_page(head)) { - list_add_tail(&head->lru, pagelist); - mod_node_page_state(page_pgdat(head), - NR_ISOLATED_ANON + page_is_file_lru(head), - thp_nr_pages(head)); + if ((flags & MPOL_MF_MOVE_ALL) || folio_estimated_sharers(folio) == 1) { + if (!folio_isolate_lru(folio)) { + list_add_tail(&folio->lru, foliolist); + node_stat_mod_folio(folio, + NR_ISOLATED_ANON + folio_is_file_lru(folio), + folio_nr_pages(folio)); } else if (flags & MPOL_MF_STRICT) { /* - * Non-movable page may reach here. And, there may be - * temporary off LRU pages or non-LRU movable pages. - * Treat them as unmovable pages since they can't be + * Non-movable folio may reach here. And, there may be + * temporary off LRU folios or non-LRU movable folios. + * Treat them as unmovable folios since they can't be * isolated, so they can't be moved at the moment. It * should return -EIO for this case too. */ @@ -1235,7 +1236,7 @@ static struct page *new_page(struct page *page, unsigned long start) } #else -static int migrate_page_add(struct page *page, struct list_head *pagelist, +static int migrate_folio_add(struct folio *folio, struct list_head *foliolist, unsigned long flags) { return -EIO;