mm, madvise_inject_error: Let memory_failure() optionally take a page reference
The madvise_inject_error() routine uses get_user_pages() to lookup the pfn and other information for injected error, but it does not release that pin. The assumption is that failed pages should be taken out of circulation. However, for dax mappings it is not possible to take pages out of circulation since they are 1:1 physically mapped as filesystem blocks, or device-dax capacity. They also typically represent persistent memory which has an error clearing capability. In preparation for adding a special handler for dax mappings, shift the responsibility of taking the page reference to memory_failure(). I.e. drop the page reference and do not specify MF_COUNT_INCREASED to memory_failure(). Cc: Michal Hocko <mhocko@suse.com> Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Acked-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
This commit is contained in:
Родитель
2fa147bdbf
Коммит
23e7b5c2e2
18
mm/madvise.c
18
mm/madvise.c
|
@ -631,11 +631,13 @@ static int madvise_inject_error(int behavior,
|
||||||
|
|
||||||
|
|
||||||
for (; start < end; start += PAGE_SIZE << order) {
|
for (; start < end; start += PAGE_SIZE << order) {
|
||||||
|
unsigned long pfn;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = get_user_pages_fast(start, 1, 0, &page);
|
ret = get_user_pages_fast(start, 1, 0, &page);
|
||||||
if (ret != 1)
|
if (ret != 1)
|
||||||
return ret;
|
return ret;
|
||||||
|
pfn = page_to_pfn(page);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When soft offlining hugepages, after migrating the page
|
* When soft offlining hugepages, after migrating the page
|
||||||
|
@ -651,17 +653,25 @@ static int madvise_inject_error(int behavior,
|
||||||
|
|
||||||
if (behavior == MADV_SOFT_OFFLINE) {
|
if (behavior == MADV_SOFT_OFFLINE) {
|
||||||
pr_info("Soft offlining pfn %#lx at process virtual address %#lx\n",
|
pr_info("Soft offlining pfn %#lx at process virtual address %#lx\n",
|
||||||
page_to_pfn(page), start);
|
pfn, start);
|
||||||
|
|
||||||
ret = soft_offline_page(page, MF_COUNT_INCREASED);
|
ret = soft_offline_page(page, MF_COUNT_INCREASED);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n",
|
|
||||||
page_to_pfn(page), start);
|
|
||||||
|
|
||||||
ret = memory_failure(page_to_pfn(page), MF_COUNT_INCREASED);
|
pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n",
|
||||||
|
pfn, start);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Drop the page reference taken by get_user_pages_fast(). In
|
||||||
|
* the absence of MF_COUNT_INCREASED the memory_failure()
|
||||||
|
* routine is responsible for pinning the page to prevent it
|
||||||
|
* from being released back to the page allocator.
|
||||||
|
*/
|
||||||
|
put_page(page);
|
||||||
|
ret = memory_failure(pfn, 0);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче