From patchwork Tue Jan 24 01:22:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13113247 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 8DAC5C05027 for ; Tue, 24 Jan 2023 01:22:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 611576B007D; Mon, 23 Jan 2023 20:22:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C0F26B007E; Mon, 23 Jan 2023 20:22:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3509B6B0080; Mon, 23 Jan 2023 20:22:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 141BA6B007D for ; Mon, 23 Jan 2023 20:22:23 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E0FF7160999 for ; Tue, 24 Jan 2023 01:22:22 +0000 (UTC) X-FDA: 80387942124.20.75D0A58 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by imf03.hostedemail.com (Postfix) with ESMTP id 233192000D for ; Tue, 24 Jan 2023 01:22:20 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="C/U/++SQ"; spf=pass (imf03.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.180 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=1674523341; 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=aN57XfC0N2Z9PnMQ9nUjXYfVmJE2FGzydu2ZVvrzX3Q=; b=Y5y7ARii5ZZcFD8f7naajmSB6jYYWFV79HpZd90mg3IJEm6Y1g2m0fX3wNYpKT5/yqPoUc IpGcUqo2yw993eus1sRrtXg1eo3QptpH/FgzWfTt4eNBhsS0qPMlxXwh2U/NiBPnlLaL/Q 79JQB+3Y0SGTzO8bPmyFgEgp89WzOJs= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="C/U/++SQ"; spf=pass (imf03.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.180 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=1674523341; a=rsa-sha256; cv=none; b=x3gfT03sM2cfLCMCaejF+6/gfRiCP/e5BBH/KJ4sknYmiZXFRVKQPDETHQMs66LqZ8Ao7s atqp4ZmSes1E3O2HcuuEp6NxEPwK7WnqwO8ZYCh4bJSlwQmnEanXUo0yzCPVF2nVJhs3rs Bx5fopqCvFl//XuePvCavW7IEs64i+g= Received: by mail-pg1-f180.google.com with SMTP id v3so10351537pgh.4 for ; Mon, 23 Jan 2023 17:22:20 -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=aN57XfC0N2Z9PnMQ9nUjXYfVmJE2FGzydu2ZVvrzX3Q=; b=C/U/++SQ2raDEJiXZtLwp/aQPJIL2snP32r34/JamWV0YT5a5TsRoxvkNwbqlG+WDL Ps9wGzMk2fiKNQXMr2OEKdhMvvQfUMMtwtVHTbBPYYhV8nQcLx8qaQELNcPzo8v7Ttmf VmKiBt4Qr55YGjL0lwWS3LlD/Buk97PMiEpFshtmKPPbhX+1xEZd87JnVl7KpInH2k5c R2I/J6j7A0NCijafjBjis/f0LP6dYdH2w6/hgAka5LvRlZ5Tg5e//B6nTlGW6Z+W2fGt UmVFycoXRWSqB05rk6sYjNnEASAC57l7Sc6+Gmba8spUW3oIL05EE51CkXLabKhrLqo4 V3iA== 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=aN57XfC0N2Z9PnMQ9nUjXYfVmJE2FGzydu2ZVvrzX3Q=; b=qGKtMBk1cS6zNJbmQlcDgmbSrbSAYmcJtsvn6R0YzpZdA1uSFj3nZ9QN2N+AE/33lY O9fuEOPIiAbnhMsJiD2CwZkrmN3yn6jwnLguBlBDiUsBECKq2W/dKjVJggpUzWGOSFbM 5NAlxb1TMb3lgBpS4i7JE+UjqY089yFJVjyZzrV3OgUwCV3dZrGM3TZrHjdvRQSgciSG 5pY6/GEETwog/wUDaVhf5pja+6iDpaR31zrjg0UA8E6LDj2Ks/BLnQvSfbF0TDE3nkgU du9DkjhPo2TWltMA/hZGMBOpUI3I+Ww7y+KX6AaQsDIf8Th5cSGQNSa0iigKCgW7xU7p hvYA== X-Gm-Message-State: AFqh2kpDsrJSNgYjN4qdS3wqzHdtKwLWhLDRFEnA5WmycfSHAJ4TD4p3 nf2i/CJHeSaMmsyNFcnJ7FJTkvZOjCk= X-Google-Smtp-Source: AMrXdXsUcKBht35TPhoeIdubPl8bcQOBoTQINC0wEB8tAeEYBIKQ/4JjGSme0DY/zIDwqcq5kn6xZw== X-Received: by 2002:a05:6a00:2986:b0:58c:8bdd:2e3c with SMTP id cj6-20020a056a00298600b0058c8bdd2e3cmr28301423pfb.20.1674523339887; Mon, 23 Jan 2023 17:22:19 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::4e4b]) by smtp.googlemail.com with ESMTPSA id 68-20020a620547000000b005825b8e0540sm213335pff.204.2023.01.23.17.22.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 17:22:19 -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 v2 6/6] mm/mempolicy: Convert migrate_page_add() to migrate_folio_add() Date: Mon, 23 Jan 2023 17:22:10 -0800 Message-Id: <20230124012210.13963-7-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230124012210.13963-1-vishal.moola@gmail.com> References: <20230124012210.13963-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Stat-Signature: du4k7eg5cukbra7zf6pptam4c38ojape X-Rspam-User: X-Rspamd-Queue-Id: 233192000D X-Rspamd-Server: rspam06 X-HE-Tag: 1674523340-126497 X-HE-Meta: U2FsdGVkX18m7lpmhpToTWBt+VJIgjvZJf8BSOV/NK0vfXyAxpPEF6sXM0kogOIkDk5KhZ+m1dv6aD0cseaz3yUGuvQmfF6Xljpk8YcYfmBh4c31BMVC9V5SjmGoso7rGYX4NCLuliOXfQqQbmu+bMFS1tvoOOJiPtxRv2sV7o88WuFcMrHH9Ayy7DQNj+eHOQu0lEpJ0yXQzBz1H1ayDjVSL2UAB0b2EgRmEcGNJS22LD/chcGrFTbXA0BIfW8ml5rWkatK7+w935rFtvnz0j6oRMwfBFf6my6lZFuv26W5pvdpb72bvpNjW+fU2/QkOkSE7XVEpe3OQ2G3x6rVDTVBt1C+jN4s4GvV19HLxcJL+FXE8pOSSheAGJHm7X6b/pSGGZ7an1HCaB/GvLHpPz9UwGzdPk63OEQpMEZE/4Qd1/lDZ0V7y3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zn0fpRSYa10pKSCzy85/uvfx25xsIDyYmzUgodzdtGmhE+/UOUl5NNGbv49+WtQRkVfLGUxxz+ykX+mKQhwhw== 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) --- mm/mempolicy.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index da87644430e3..9bb4600c4294 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; @@ -1029,27 +1029,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_mapcount(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. */ @@ -1241,7 +1242,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;