From: Shivank Garg <shivankg@amd.com>
To: <akpm@linux-foundation.org>, <linux-kernel@vger.kernel.org>,
<linux-mm@kvack.org>
Cc: <bharata@amd.com>, <raghavendra.kodsarathimmappa@amd.com>,
<Michael.Day@amd.com>, <dmaengine@vger.kernel.org>,
<vkoul@kernel.org>, <shivankg@amd.com>
Subject: [RFC PATCH 2/5] mm: add folios_copy() for copying pages in batch during migration
Date: Sat, 15 Jun 2024 03:45:22 +0530 [thread overview]
Message-ID: <20240614221525.19170-3-shivankg@amd.com> (raw)
In-Reply-To: <20240614221525.19170-1-shivankg@amd.com>
This patch introduces the folios_copy() function to copy the folio content
from the list of src folios to the list of dst folios. This is preparatory
patch for batch page migration offloading.
Signed-off-by: Shivank Garg <shivankg@amd.com>
---
include/linux/mm.h | 1 +
mm/util.c | 22 ++++++++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index f5a97dec5169..cd5f37ec72f0 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1300,6 +1300,7 @@ void put_pages_list(struct list_head *pages);
void split_page(struct page *page, unsigned int order);
void folio_copy(struct folio *dst, struct folio *src);
+void folios_copy(struct list_head *dst_list, struct list_head *src_list);
unsigned long nr_free_buffer_pages(void);
diff --git a/mm/util.c b/mm/util.c
index 5a6a9802583b..3a278db28429 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -811,6 +811,28 @@ void folio_copy(struct folio *dst, struct folio *src)
}
EXPORT_SYMBOL(folio_copy);
+/**
+ * folios_copy - Copy the contents of list of folios.
+ * @dst_list: Folios to copy to.
+ * @src_list: Folios to copy from.
+ *
+ * The folio contents are copied from @src_list to @dst_list.
+ * Assume the caller has validated that lists are not empty and both lists
+ * have equal number of folios. This may sleep.
+ */
+void folios_copy(struct list_head *dst_list,
+ struct list_head *src_list)
+{
+ struct folio *src, *dst;
+
+ dst = list_first_entry(dst_list, struct folio, lru);
+ list_for_each_entry(src, src_list, lru) {
+ cond_resched();
+ folio_copy(dst, src);
+ dst = list_next_entry(dst, lru);
+ }
+}
+
int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS;
int sysctl_overcommit_ratio __read_mostly = 50;
unsigned long sysctl_overcommit_kbytes __read_mostly;
--
2.34.1
next prev parent reply other threads:[~2024-06-14 22:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-14 22:15 [RFC PATCH 0/5] Enhancements to Page Migration with Batch Offloading via DMA Shivank Garg
2024-06-14 22:15 ` [RFC PATCH 1/5] mm: separate move/undo doing on folio list from migrate_pages_batch() Shivank Garg
2024-06-14 22:15 ` Shivank Garg [this message]
2024-06-14 22:15 ` [RFC PATCH 3/5] mm: add migrate_folios_batch_move to batch the folio move operations Shivank Garg
2024-06-14 22:15 ` [RFC PATCH 4/5] mm: add support for DMA folio Migration Shivank Garg
2024-06-14 22:15 ` [RFC PATCH 5/5] dcbm: add dma core batch migrator for batch page offloading Shivank Garg
2024-06-15 4:02 ` [RFC PATCH 0/5] Enhancements to Page Migration with Batch Offloading via DMA Matthew Wilcox
2024-06-17 11:40 ` Garg, Shivank
2024-06-25 8:57 ` Garg, Shivank
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240614221525.19170-3-shivankg@amd.com \
--to=shivankg@amd.com \
--cc=Michael.Day@amd.com \
--cc=akpm@linux-foundation.org \
--cc=bharata@amd.com \
--cc=dmaengine@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=raghavendra.kodsarathimmappa@amd.com \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox