From: Mina Almasry <almasrymina@google.com>
Cc: Mina Almasry <almasrymina@google.com>,
linux-mm@kvack.org, Mike Kravetz <mike.kravetz@oracle.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH] mm, hugetlb: fix allocation error check and copy func name
Date: Fri, 4 Jun 2021 18:06:26 -0700 [thread overview]
Message-ID: <20210605010626.1459873-1-almasrymina@google.com> (raw)
In-Reply-To: <1fd32aad-c99d-e89a-cdb1-05843f568f0c@oracle.com>
The alloc_huge_page_vma() doesn't return error pointers, it returns
NULL.
There is an existing migrate_page_copy() which not only copies the page
contents, but also page state/metadata. People could get confused that
'migrate_page_copy' and 'migrate_copy_huge_page' do not have the same
functionality. Rename to 'copy_huge_page()' to make it less likely
folks get confused.
Fixes: 6a0badc266df ("mm, hugetlb: fix racy resv_huge_pages underflow on
UFFDIO_COPY")
Signed-off-by: Mina Almasry <almasrymina@google.com>
Cc: linux-mm@kvack.org
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
---
include/linux/migrate.h | 4 ++--
mm/hugetlb.c | 4 ++--
mm/migrate.c | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/linux/migrate.h b/include/linux/migrate.h
index e0b98876a52e..9b7b7cd3bae9 100644
--- a/include/linux/migrate.h
+++ b/include/linux/migrate.h
@@ -51,7 +51,7 @@ extern int migrate_huge_page_move_mapping(struct address_space *mapping,
struct page *newpage, struct page *page);
extern int migrate_page_move_mapping(struct address_space *mapping,
struct page *newpage, struct page *page, int extra_count);
-extern void migrate_copy_huge_page(struct page *dst, struct page *src);
+extern void copy_huge_page(struct page *dst, struct page *src);
#else
static inline void putback_movable_pages(struct list_head *l) {}
@@ -78,7 +78,7 @@ static inline int migrate_huge_page_move_mapping(struct address_space *mapping,
return -ENOSYS;
}
-static inline void migrate_copy_huge_page(struct page *dst, struct page *src)
+static inline void copy_huge_page(struct page *dst, struct page *src)
{
}
#endif /* CONFIG_MIGRATION */
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 64a460ff2d5b..637395907908 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -5130,7 +5130,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm,
* contents.
*/
page = alloc_huge_page_vma(h, dst_vma, dst_addr);
- if (IS_ERR(page)) {
+ if (!page) {
ret = -ENOMEM;
goto out;
}
@@ -5156,7 +5156,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm,
*pagep = NULL;
goto out;
}
- migrate_copy_huge_page(page, *pagep);
+ copy_huge_page(page, *pagep);
put_page(*pagep);
*pagep = NULL;
}
diff --git a/mm/migrate.c b/mm/migrate.c
index 2515210a9747..51f355757490 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -557,7 +557,7 @@ static void __copy_gigantic_page(struct page *dst, struct page *src,
}
}
-void migrate_copy_huge_page(struct page *dst, struct page *src)
+void copy_huge_page(struct page *dst, struct page *src)
{
int i;
int nr_pages;
@@ -662,7 +662,7 @@ EXPORT_SYMBOL(migrate_page_states);
void migrate_page_copy(struct page *newpage, struct page *page)
{
if (PageHuge(page) || PageTransHuge(page))
- migrate_copy_huge_page(newpage, page);
+ copy_huge_page(newpage, page);
else
copy_highpage(newpage, page);
--
2.32.0.rc1.229.g3e70b5a671-goog
next prev parent reply other threads:[~2021-06-05 3:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-28 0:50 [PATCH v4] mm, hugetlb: fix racy resv_huge_pages underflow on UFFDIO_COPY Mina Almasry
2021-05-31 23:25 ` Andrew Morton
2021-06-01 0:11 ` Mina Almasry
2021-06-01 0:36 ` Andrew Morton
2021-06-01 2:48 ` Mina Almasry
2021-06-01 17:09 ` Mike Kravetz
2021-06-01 18:04 ` Mina Almasry
2021-06-01 18:05 ` Mina Almasry
2021-06-04 21:41 ` Mike Kravetz
2021-06-05 1:06 ` Mina Almasry [this message]
2021-06-05 12:49 ` [External] [PATCH] mm, hugetlb: fix allocation error check and copy func name Muchun Song
2021-06-07 20:32 ` Mike Kravetz
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=20210605010626.1459873-1-almasrymina@google.com \
--to=almasrymina@google.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
/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;
as well as URLs for NNTP newsgroup(s).