Commit 9d08ec4
mm: allow set/clear page_type again
Some page flags (page->flags) were converted to page types
(page->page_types). A recent example is PG_hugetlb.
From the exclusive writer's perspective, e.g., a thread doing
__folio_set_hugetlb(), there is a difference between the page flag and
type APIs: the former allows the same non-atomic operation to be repeated
whereas the latter does not. For example, calling __folio_set_hugetlb()
twice triggers VM_BUG_ON_FOLIO(), since the second call expects the type
(PG_hugetlb) not to be set previously.
Using add_hugetlb_folio() as an example, it calls __folio_set_hugetlb() in
the following error-handling path. And when that happens, it triggers the
aforementioned VM_BUG_ON_FOLIO().
if (folio_test_hugetlb(folio)) {
rc = hugetlb_vmemmap_restore_folio(h, folio);
if (rc) {
spin_lock_irq(&hugetlb_lock);
add_hugetlb_folio(h, folio, false);
...
It is possible to make hugeTLB comply with the new requirements from the
page type API. However, a straightforward fix would be to just allow the
same page type to be set or cleared again inside the API, to avoid any
changes to its callers.
Link: https://lkml.kernel.org/r/[email protected]
Fixes: d99e314 ("mm: turn folio_test_hugetlb into a PageType")
Signed-off-by: Yu Zhao <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Muchun Song <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>1 parent b3a033e commit 9d08ec4
1 file changed
+8
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
975 | 975 | | |
976 | 976 | | |
977 | 977 | | |
| 978 | + | |
| 979 | + | |
978 | 980 | | |
979 | 981 | | |
980 | 982 | | |
981 | 983 | | |
982 | 984 | | |
983 | 985 | | |
| 986 | + | |
| 987 | + | |
984 | 988 | | |
985 | 989 | | |
986 | 990 | | |
| |||
993 | 997 | | |
994 | 998 | | |
995 | 999 | | |
| 1000 | + | |
| 1001 | + | |
996 | 1002 | | |
997 | 1003 | | |
998 | 1004 | | |
999 | 1005 | | |
1000 | 1006 | | |
| 1007 | + | |
| 1008 | + | |
1001 | 1009 | | |
1002 | 1010 | | |
1003 | 1011 | | |
| |||
0 commit comments