diff mbox series

[v4,2/6] mm: add folio_mc_copy()

Message ID 20240603092439.3360652-3-wangkefeng.wang@huawei.com (mailing list archive)
State New
Headers show
Series mm: migrate: support poison recover from migrate folio | expand

Commit Message

Kefeng Wang June 3, 2024, 9:24 a.m. UTC
Add a #MC variant of folio_copy() which uses copy_mc_highpage() to
support #MC handled during folio copy, it will be used in folio
migration soon.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 include/linux/mm.h |  1 +
 mm/util.c          | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)

Comments

Jane Chu June 4, 2024, 7:41 p.m. UTC | #1
On 6/3/2024 2:24 AM, Kefeng Wang wrote:

> Add a #MC variant of folio_copy() which uses copy_mc_highpage() to
> support #MC handled during folio copy, it will be used in folio
> migration soon.
>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>   include/linux/mm.h |  1 +
>   mm/util.c          | 17 +++++++++++++++++
>   2 files changed, 18 insertions(+)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index c499d5adb748..cc21b2f0cdf8 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -1321,6 +1321,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);
> +int folio_mc_copy(struct folio *dst, struct folio *src);
>   
>   unsigned long nr_free_buffer_pages(void);
>   
> diff --git a/mm/util.c b/mm/util.c
> index c9e519e6811f..90ea0c0f10d3 100644
> --- a/mm/util.c
> +++ b/mm/util.c
> @@ -828,6 +828,23 @@ void folio_copy(struct folio *dst, struct folio *src)
>   }
>   EXPORT_SYMBOL(folio_copy);
>   
> +int folio_mc_copy(struct folio *dst, struct folio *src)
> +{
> +	long nr = folio_nr_pages(src);
> +	long i = 0;
> +
> +	for (;;) {
> +		if (copy_mc_highpage(folio_page(dst, i), folio_page(src, i)))
> +			return -EHWPOISON;
> +		if (++i == nr)
> +			break;
> +		cond_resched();
> +	}
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(folio_mc_copy);
> +
>   int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS;
>   int sysctl_overcommit_ratio __read_mostly = 50;
>   unsigned long sysctl_overcommit_kbytes __read_mostly;

Reviewed-by: Jane Chu <jane.chu@oracle.com>

thanks,

-jane
Andrew Morton June 5, 2024, 3:31 a.m. UTC | #2
On Tue, 4 Jun 2024 12:41:20 -0700 Jane Chu <jane.chu@oracle.com> wrote:

> >   int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS;
> >   int sysctl_overcommit_ratio __read_mostly = 50;
> >   unsigned long sysctl_overcommit_kbytes __read_mostly;
> 
> Reviewed-by: Jane Chu <jane.chu@oracle.com>

Thanks.  I'll merge the series for testing, but I'd prefer to see more
review activity before proceeding further.  Please.
Kefeng Wang June 5, 2024, 7:15 a.m. UTC | #3
On 2024/6/5 11:31, Andrew Morton wrote:
> On Tue, 4 Jun 2024 12:41:20 -0700 Jane Chu <jane.chu@oracle.com> wrote:
> 
>>>    int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS;
>>>    int sysctl_overcommit_ratio __read_mostly = 50;
>>>    unsigned long sysctl_overcommit_kbytes __read_mostly;
>>
>> Reviewed-by: Jane Chu <jane.chu@oracle.com>
> 
> Thanks.  I'll merge the series for testing, but I'd prefer to see more
> review activity before proceeding further.  Please.

Thank Andrew and thank for all the review, more review is appreciated.
>
Miaohe Lin June 6, 2024, 2:36 a.m. UTC | #4
On 2024/6/3 17:24, Kefeng Wang wrote:
> Add a #MC variant of folio_copy() which uses copy_mc_highpage() to
> support #MC handled during folio copy, it will be used in folio
> migration soon.
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>
Thanks.
.
diff mbox series

Patch

diff --git a/include/linux/mm.h b/include/linux/mm.h
index c499d5adb748..cc21b2f0cdf8 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1321,6 +1321,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);
+int folio_mc_copy(struct folio *dst, struct folio *src);
 
 unsigned long nr_free_buffer_pages(void);
 
diff --git a/mm/util.c b/mm/util.c
index c9e519e6811f..90ea0c0f10d3 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -828,6 +828,23 @@  void folio_copy(struct folio *dst, struct folio *src)
 }
 EXPORT_SYMBOL(folio_copy);
 
+int folio_mc_copy(struct folio *dst, struct folio *src)
+{
+	long nr = folio_nr_pages(src);
+	long i = 0;
+
+	for (;;) {
+		if (copy_mc_highpage(folio_page(dst, i), folio_page(src, i)))
+			return -EHWPOISON;
+		if (++i == nr)
+			break;
+		cond_resched();
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(folio_mc_copy);
+
 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS;
 int sysctl_overcommit_ratio __read_mostly = 50;
 unsigned long sysctl_overcommit_kbytes __read_mostly;