diff for duplicates of <20130909082255.GD22390@lge.com> diff --git a/a/1.txt b/N1/1.txt index ef2599e..5a8eb69 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -27,3 +27,101 @@ One fix is needed, so here are v4. What I fix is mentioned in commit message. ----------------->8-------------------- +>From 8ca7e41090a16fbb12dd33e8f15ee8c41c70a448 Mon Sep 17 00:00:00 2001 +From: Joonsoo Kim <iamjoonsoo.kim@lge.com> +Date: Tue, 6 Aug 2013 17:06:36 +0900 +Subject: [PATCH v4 06/20] mm, hugetlb: return a reserved page to a reserved pool + if failed + +If we fail with a reserved page, just calling put_page() is not sufficient, +because put_page() invoke free_huge_page() at last step and it doesn't +know whether a page comes from a reserved pool or not. So it doesn't do +anything related to reserved count. This makes reserve count lower +than how we need, because reserve count already decrease in +dequeue_huge_page_vma(). This patch fix this situation. + +In this patch, PagePrivate() is used for tracking reservation. +When resereved pages are dequeued from reserved pool, Private flag is +assigned to the hugepage until properly mapped. On page returning process, +if there is a hugepage with Private flag, it is considered as the one +returned in certain error path, so that we should restore one +reserve count back in order to preserve certain user's reserved hugepage. + +Using Private flag is safe for the hugepage, because it doesn't use the +LRU mechanism so that there is no other user of this page except us. +Therefore we can use this flag safely. + +v4: +- ClearPagePrivate() is added in free_huge_page(). + +v3: +- commit message is added + +Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com> + +diff --git a/mm/hugetlb.c b/mm/hugetlb.c +index 6c8eec2..2b03666 100644 +--- a/mm/hugetlb.c ++++ b/mm/hugetlb.c +@@ -572,6 +572,7 @@ retry_cpuset: + if (!vma_has_reserves(vma, chg)) + break; + ++ SetPagePrivate(page); + h->resv_huge_pages--; + break; + } +@@ -626,15 +627,22 @@ static void free_huge_page(struct page *page) + int nid = page_to_nid(page); + struct hugepage_subpool *spool = + (struct hugepage_subpool *)page_private(page); ++ bool restore_reserve; + + set_page_private(page, 0); + page->mapping = NULL; + BUG_ON(page_count(page)); + BUG_ON(page_mapcount(page)); ++ restore_reserve = PagePrivate(page); ++ if (restore_reserve) ++ ClearPagePrivate(page); + + spin_lock(&hugetlb_lock); + hugetlb_cgroup_uncharge_page(hstate_index(h), + pages_per_huge_page(h), page); ++ if (restore_reserve) ++ h->resv_huge_pages++; ++ + if (h->surplus_huge_pages_node[nid] && huge_page_order(h) < MAX_ORDER) { + /* remove the page from active list */ + list_del(&page->lru); +@@ -2616,6 +2624,8 @@ retry_avoidcopy: + spin_lock(&mm->page_table_lock); + ptep = huge_pte_offset(mm, address & huge_page_mask(h)); + if (likely(pte_same(huge_ptep_get(ptep), pte))) { ++ ClearPagePrivate(new_page); ++ + /* Break COW */ + huge_ptep_clear_flush(vma, address, ptep); + set_huge_pte_at(mm, address, ptep, +@@ -2727,6 +2737,7 @@ retry: + goto retry; + goto out; + } ++ ClearPagePrivate(page); + + spin_lock(&inode->i_lock); + inode->i_blocks += blocks_per_huge_page(h); +@@ -2773,8 +2784,10 @@ retry: + if (!huge_pte_none(huge_ptep_get(ptep))) + goto backout; + +- if (anon_rmap) ++ if (anon_rmap) { ++ ClearPagePrivate(page); + hugepage_add_new_anon_rmap(page, vma, address); ++ } + else + page_dup_rmap(page); + new_pte = make_huge_pte(vma, page, ((vma->vm_flags & VM_WRITE) +-- +1.7.9.5 diff --git a/a/content_digest b/N1/content_digest index 1fdc746..e7c4a21 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -47,6 +47,104 @@ "One fix is needed, so here are v4.\n" "What I fix is mentioned in commit message.\n" "\n" - ----------------->8-------------------- + "----------------->8--------------------\n" + ">From 8ca7e41090a16fbb12dd33e8f15ee8c41c70a448 Mon Sep 17 00:00:00 2001\n" + "From: Joonsoo Kim <iamjoonsoo.kim@lge.com>\n" + "Date: Tue, 6 Aug 2013 17:06:36 +0900\n" + "Subject: [PATCH v4 06/20] mm, hugetlb: return a reserved page to a reserved pool\n" + " if failed\n" + "\n" + "If we fail with a reserved page, just calling put_page() is not sufficient,\n" + "because put_page() invoke free_huge_page() at last step and it doesn't\n" + "know whether a page comes from a reserved pool or not. So it doesn't do\n" + "anything related to reserved count. This makes reserve count lower\n" + "than how we need, because reserve count already decrease in\n" + "dequeue_huge_page_vma(). This patch fix this situation.\n" + "\n" + "In this patch, PagePrivate() is used for tracking reservation.\n" + "When resereved pages are dequeued from reserved pool, Private flag is\n" + "assigned to the hugepage until properly mapped. On page returning process,\n" + "if there is a hugepage with Private flag, it is considered as the one\n" + "returned in certain error path, so that we should restore one\n" + "reserve count back in order to preserve certain user's reserved hugepage.\n" + "\n" + "Using Private flag is safe for the hugepage, because it doesn't use the\n" + "LRU mechanism so that there is no other user of this page except us.\n" + "Therefore we can use this flag safely.\n" + "\n" + "v4:\n" + "- ClearPagePrivate() is added in free_huge_page().\n" + "\n" + "v3:\n" + "- commit message is added\n" + "\n" + "Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>\n" + "\n" + "diff --git a/mm/hugetlb.c b/mm/hugetlb.c\n" + "index 6c8eec2..2b03666 100644\n" + "--- a/mm/hugetlb.c\n" + "+++ b/mm/hugetlb.c\n" + "@@ -572,6 +572,7 @@ retry_cpuset:\n" + " \t\t\t\tif (!vma_has_reserves(vma, chg))\n" + " \t\t\t\t\tbreak;\n" + " \n" + "+\t\t\t\tSetPagePrivate(page);\n" + " \t\t\t\th->resv_huge_pages--;\n" + " \t\t\t\tbreak;\n" + " \t\t\t}\n" + "@@ -626,15 +627,22 @@ static void free_huge_page(struct page *page)\n" + " \tint nid = page_to_nid(page);\n" + " \tstruct hugepage_subpool *spool =\n" + " \t\t(struct hugepage_subpool *)page_private(page);\n" + "+\tbool restore_reserve;\n" + " \n" + " \tset_page_private(page, 0);\n" + " \tpage->mapping = NULL;\n" + " \tBUG_ON(page_count(page));\n" + " \tBUG_ON(page_mapcount(page));\n" + "+\trestore_reserve = PagePrivate(page);\n" + "+\tif (restore_reserve)\n" + "+\t\tClearPagePrivate(page);\n" + " \n" + " \tspin_lock(&hugetlb_lock);\n" + " \thugetlb_cgroup_uncharge_page(hstate_index(h),\n" + " \t\t\t\t pages_per_huge_page(h), page);\n" + "+\tif (restore_reserve)\n" + "+\t\th->resv_huge_pages++;\n" + "+\n" + " \tif (h->surplus_huge_pages_node[nid] && huge_page_order(h) < MAX_ORDER) {\n" + " \t\t/* remove the page from active list */\n" + " \t\tlist_del(&page->lru);\n" + "@@ -2616,6 +2624,8 @@ retry_avoidcopy:\n" + " \tspin_lock(&mm->page_table_lock);\n" + " \tptep = huge_pte_offset(mm, address & huge_page_mask(h));\n" + " \tif (likely(pte_same(huge_ptep_get(ptep), pte))) {\n" + "+\t\tClearPagePrivate(new_page);\n" + "+\n" + " \t\t/* Break COW */\n" + " \t\thuge_ptep_clear_flush(vma, address, ptep);\n" + " \t\tset_huge_pte_at(mm, address, ptep,\n" + "@@ -2727,6 +2737,7 @@ retry:\n" + " \t\t\t\t\tgoto retry;\n" + " \t\t\t\tgoto out;\n" + " \t\t\t}\n" + "+\t\t\tClearPagePrivate(page);\n" + " \n" + " \t\t\tspin_lock(&inode->i_lock);\n" + " \t\t\tinode->i_blocks += blocks_per_huge_page(h);\n" + "@@ -2773,8 +2784,10 @@ retry:\n" + " \tif (!huge_pte_none(huge_ptep_get(ptep)))\n" + " \t\tgoto backout;\n" + " \n" + "-\tif (anon_rmap)\n" + "+\tif (anon_rmap) {\n" + "+\t\tClearPagePrivate(page);\n" + " \t\thugepage_add_new_anon_rmap(page, vma, address);\n" + "+\t}\n" + " \telse\n" + " \t\tpage_dup_rmap(page);\n" + " \tnew_pte = make_huge_pte(vma, page, ((vma->vm_flags & VM_WRITE)\n" + "-- \n" + 1.7.9.5 -c93b903f2c111d53dc855a6978f9f0d13b428df993a6355fdd1370af69c7a648 +cd0ea506b2a78795ca3fb51ddfedd344575cd86e0844cc417a0db4f8c283335f
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.