From patchwork Mon Feb 26 14:05:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggyu Kim X-Patchwork-Id: 206686 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2115764dyb; Mon, 26 Feb 2024 06:34:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXohoUdknWrGZfA9NtVlXpQ30YcSNiRmc0oKtKKZsEuPtyjz7M5PhiGzGfLeBPbc1AyAgLPDtswLWX+bGa5+rs0xqIoYQ== X-Google-Smtp-Source: AGHT+IGk8AlaxpoMuoKKzxNqfoKW8T445KcYtOERrKXp26t5VXngeCLDOqq9KSILHZmtXsE/cM7F X-Received: by 2002:a05:6a20:c78d:b0:1a0:fde5:6bd9 with SMTP id hk13-20020a056a20c78d00b001a0fde56bd9mr4455776pzb.44.1708958083028; Mon, 26 Feb 2024 06:34:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708958083; cv=pass; d=google.com; s=arc-20160816; b=TeFtD0u0vDaqoAUx3WP2QUJFcW7F+4a7jb211URHTGSm2B1IaCpk/eMRf/ydF2UuDy o+vlDiawx0m7LpRrAIVCaye3VrvtuCNoxDNQtzX0sTDWhip3smPLoxj6/M768fZZegOx ziKRseU21P16WdvvP4oxR13YPOjIUkN6abDSp8B4Muk2GY34uT4ce7BMQDdWZORDu7sK gPBCrEX4F3sgsqXAlQf4JYvstCQ7dZ45CBXwRjKn3/263Zzlczc1z3xnQZa3KQs8u3Zy P06jXsH8ygBEnAp3xpBkUvvTugkO5Kgkh3zkk0ZdHJALw0xSHPA4SbblL6GqIztQEMmr 6yqg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=/O1IDxVh05t8M0nebcpVtrx+/Qgao8Jaq6x7QW3BvpY=; fh=egwJU2bb679B4Zi0WdxyKykgfACRkSkUGxyHY52POxM=; b=ZAj7JgTYw7BS988p77W72FPkmu9O9FtCDKvgBETTIrfaZhohGCqL0zYNKv0/L3AQFt NanEMrkdRzQcW2xRQIKtTp4gIZWBBM0NgMxrZIhNzTczvKyLRpTWyS816T3tB9+m1sJa qZP7pkYq+GwNWQQ8CkaWXT8xiU5EXT2j6UU2dQdB5nzXZfhKzfBEy60MVRYffzYX12S0 Fx6gQNRTmewSMok+ovfsBpli/8ZikS2Bp0qHPS73UCMNhhPN1Yge8tWSOqxrsHbfJOpa +GNf+jWg68DNDT8xgxAxmXwcAOHaHvUOy6cDbo2vUy+fAa+UkoTC4ApatwkskBjhbuHz KDXg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=sk.com); spf=pass (google.com: domain of linux-kernel+bounces-81582-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81582-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 27-20020a630f5b000000b005d8e12c85d9si3817352pgp.738.2024.02.26.06.34.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 06:34:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81582-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=sk.com); spf=pass (google.com: domain of linux-kernel+bounces-81582-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81582-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 93FB0B271CA for ; Mon, 26 Feb 2024 14:10:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6FD7212D75C; Mon, 26 Feb 2024 14:06:25 +0000 (UTC) Received: from invmail4.hynix.com (exvmail4.skhynix.com [166.125.252.92]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D3D4412BF3C; Mon, 26 Feb 2024 14:06:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=166.125.252.92 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708956383; cv=none; b=HHXiI0j3QpZImVnrrAvN1e9OBNOgJsPWW8hz6N1WzbEPg5zwa1y6INO9yLb1iYxVznwzr2nCxKeWeq/2YQ23NYfhrlTMZRVdvRbWUTV41Ds8MRXIU52b7UlaHUF3LHGQJQ/s0sBE9nvTh4RP3DdK72nh7FkxyjPAMj8ZakAOhaM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708956383; c=relaxed/simple; bh=C468lHYjYAI9vBRck8tz19UeLn3N7jq8un3nPfdUOcw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X9b+rOJlfvJtfKp0RIYUtmgyeS0HHWwiOcvltFCtIDlEdle9wcbHTXOm4TX8txbgL5/hFMiwhL7O6122PA5YetrC0TRAYN3+xnqWrsacwTNBPuU8jsaCD6xRVPbbWhgns4wo84/cyJMjW4LGYrqMibCq69JHazaYDcqmwOP/jh4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sk.com; spf=pass smtp.mailfrom=sk.com; arc=none smtp.client-ip=166.125.252.92 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sk.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sk.com X-AuditID: a67dfc5b-d6dff70000001748-65-65dc9ad7da0c From: Honggyu Kim To: sj@kernel.org, damon@lists.linux.dev, linux-mm@kvack.org Cc: akpm@linux-foundation.org, apopple@nvidia.com, baolin.wang@linux.alibaba.com, dave.jiang@intel.com, honggyu.kim@sk.com, hyeongtak.ji@sk.com, kernel_team@skhynix.com, linmiaohe@huawei.com, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, lizhijian@cn.fujitsu.com, mathieu.desnoyers@efficios.com, mhiramat@kernel.org, rakie.kim@sk.com, rostedt@goodmis.org, surenb@google.com, yangx.jy@fujitsu.com, ying.huang@intel.com, ziy@nvidia.com, 42.hyeyoo@gmail.com Subject: [PATCH v2 2/7] mm: make alloc_demote_folio externally invokable for migration Date: Mon, 26 Feb 2024 23:05:48 +0900 Message-ID: <20240226140555.1615-3-honggyu.kim@sk.com> X-Mailer: git-send-email 2.43.0.windows.1 In-Reply-To: <20240226140555.1615-1-honggyu.kim@sk.com> References: <20240226140555.1615-1-honggyu.kim@sk.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRmVeSWpSXmKPExsXC9ZZnoe71WXdSDU4sELaY2GNgMWf9GjaL XTdCLP7vPcZo8eT/b1aLEzcb2Sw6vy9lsbi8aw6bxb01/1ktjqw/y2Kx7haQtfnsGWaLxcvV LPZ1PGCyOPz1DZPF5EsL2CxeTDnDaHFy1mQWi9lH77E7CHv8PziJ2WPp6TdsHhuagMTOWXfZ PVr23WL3WLCp1KPlyFtWj8V7XjJ5bFrVyeax6dMkdo8TM36zeOx8aOnxYvNMRo/e5ndsHp83 yQXwR3HZpKTmZJalFunbJXBl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QlHi8/Sc7iM0pYC7x/3A7G8hMIaCa o7eZIcoFJU7OfALWyiwgL9G8dTbzBEaeWUhSs5CkFjAyrWIUycwry03MzDHVK87OqMzLrNBL zs/dxAiMtGW1fybuYPxy2f0QowAHoxIPr0PtnVQh1sSy4srcQ4wSHMxKIrzhMjdThXhTEiur Uovy44tKc1KLDzFKc7AoifN6hacmCAmkJ5akZqemFqQWwWSZODilGhjZNkyuCLp5K9RnIVvv BK/jzJd2fv5YuFJ0kqB47etlR0SNBHy9s7PU5Z+dnLlbueDFzfiM1A/Mc9tWv88t3V9o0+/j FhMptMBwh0blCYtZ65uz/z2Kaj2276LO18eTpxTeaWu8y78lz9Tn4b8TDNJ/9yxo+HR+S7zC pudtX1USPNaWlTpyTvuuxFKckWioxVxUnAgAPK1J3bACAAA= X-CFilter-Loop: Reflected X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791972430887255178 X-GMAIL-MSGID: 1791972430887255178 The alloc_demote_folio can be used out of vmscan.c so it'd be better to remove static keyword from it. This function can also be used for both demotion and promotion so it'd be better to rename it from alloc_demote_folio to alloc_migrate_folio. Signed-off-by: Honggyu Kim --- mm/internal.h | 1 + mm/vmscan.c | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index b61034bd50f5..61af6641235d 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -866,6 +866,7 @@ extern unsigned long __must_check vm_mmap_pgoff(struct file *, unsigned long, unsigned long, unsigned long); extern void set_pageblock_order(void); +struct folio *alloc_migrate_folio(struct folio *src, unsigned long private); unsigned long reclaim_pages(struct list_head *folio_list); unsigned int reclaim_clean_pages_from_list(struct zone *zone, struct list_head *folio_list); diff --git a/mm/vmscan.c b/mm/vmscan.c index bba207f41b14..b8a1a1599e3c 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -910,8 +910,7 @@ static void folio_check_dirty_writeback(struct folio *folio, mapping->a_ops->is_dirty_writeback(folio, dirty, writeback); } -static struct folio *alloc_demote_folio(struct folio *src, - unsigned long private) +struct folio *alloc_migrate_folio(struct folio *src, unsigned long private) { struct folio *dst; nodemask_t *allowed_mask; @@ -935,6 +934,11 @@ static struct folio *alloc_demote_folio(struct folio *src, if (dst) return dst; + /* + * Allocation failed from the target node so try to allocate from + * fallback nodes based on allowed_mask. + * See fallback_alloc() at mm/slab.c. + */ mtc->gfp_mask &= ~__GFP_THISNODE; mtc->nmask = allowed_mask; @@ -973,7 +977,7 @@ static unsigned int demote_folio_list(struct list_head *demote_folios, node_get_allowed_targets(pgdat, &allowed_mask); /* Demotion ignores all cpuset and mempolicy settings */ - migrate_pages(demote_folios, alloc_demote_folio, NULL, + migrate_pages(demote_folios, alloc_migrate_folio, NULL, (unsigned long)&mtc, MIGRATE_ASYNC, MR_DEMOTION, &nr_succeeded);