Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\memory-failure.c Create Date:2022-07-28 16:19:29
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:memory_failure - Handle memory failure of a page.*@pfn: Page Number of the corrupted page*@flags: fine tune action taken* This function is called by the low level machine check code* of an architecture when it detects hardware memory corruption* of a page

Proto:int memory_failure(unsigned long pfn, int flags)

Type:int

Parameter:

TypeParameterName
unsigned longpfn
intflags
1243  If Not sysctl_memory_failure_recovery Then panic - halt the system*@fmt: The text string to print* Display a message, then perform cleanups.* This function never returns.
1246  p = Return page for the valid pfn only if the page is online. All pfn* walkers which rely on the fully initialized page->flags and others* should use this rather than pfn_valid && pfn_to_page(pfn)
1247  If Not p Then
1248  If pfn_valid(pfn) Then
1249  pgmap = get_dev_pagemap(pfn, NULL)
1250  If pgmap Then Return memory_failure_dev_pagemap(pfn, flags, pgmap)
1254  pr_err("Memory failure: %#lx: memory outside kernel control\n", pfn)
1256  Return -ENXIO
1259  If PageHuge() only returns true for hugetlbfs pages, but not for normal or* transparent huge pages. See the PageTransHuge() documentation for more* details. Then Return memory_failure_hugetlb(pfn, flags)
1261  If TestSetPageHWPoison(p) Then
1262  pr_err("Memory failure: %#lx: already hardware poisoned\n", pfn)
1264  Return 0
1267  orig_head = hpage = compound_head(p)
1268  num_poisoned_pages_inc()
1281  If Not (flags & MF_COUNT_INCREASED) && Not get_hwpoison_page() - Get refcount for memory error handling:*@page: raw error page (hit by memory error)* Return: return 0 if failed to grab the refcount, otherwise true (some* non-zero value.) Then
1282  If is_free_buddy_page(p) Then
1284  Return 0
1285  Else
1287  Return -EBUSY
1291  If PageHuge() only returns true for hugetlbfs pages, but not for* normal or transparent huge pages.* PageTransHuge() returns true for both transparent huge and* hugetlbfs pages, but not normal pages. PageTransHuge() can only be Then
1292  lock_page may only be called if we have the page's inode pinned.
1295  If Not PageAnon(p) Then pr_err("Memory failure: %#lx: non anonymous thp\n", pfn)
1298  Else pr_err("Memory failure: %#lx: thp split failed\n", pfn)
1304  Return -EBUSY
1306  lock_page - unlock a locked page*@page: the page* Unlocks the page and wakes up sleepers in ___wait_on_page_locked().* Also wakes sleepers in wait_on_page_writeback() because the wakeup* mechanism between PageLocked pages and PageWriteback pages is shared.
1307  VM_BUG_ON_PAGE(!page_count(p), p)
1308  hpage = compound_head(p)
1319  When a unknown page type is encountered drain as many buffers as possible* in the hope to turn the page into a LRU or free page, which we can handle.
1321  If Not PageLRU(p) && is_free_buddy_page(p) Then
1322  If flags & MF_COUNT_INCREASED Then "Dirty/Clean" indication is not 100% accurate due to the possibility of* setting PG_dirty outside page lock. See also comment above set_page_dirty().
1324  Else "Dirty/Clean" indication is not 100% accurate due to the possibility of* setting PG_dirty outside page lock. See also comment above set_page_dirty().
1326  Return 0
1329  lock_page may only be called if we have the page's inode pinned.
1335  If PageCompound(p) && compound_head(p) != orig_head Then
1336  "Dirty/Clean" indication is not 100% accurate due to the possibility of* setting PG_dirty outside page lock. See also comment above set_page_dirty().
1337  res = -EBUSY
1338  Go to out
1348  If PageHuge() only returns true for hugetlbfs pages, but not for normal or* transparent huge pages. See the PageTransHuge() documentation for more* details. Then page_flags = Atomic flags, some possibly * updated asynchronously
1350  Else page_flags = Atomic flags, some possibly * updated asynchronously
1356  If Not PageHWPoison(p) Then
1357  pr_err("Memory failure: %#lx: just unpoisoned\n", pfn)
1358  num_poisoned_pages_dec()
1359  lock_page - unlock a locked page*@page: the page* Unlocks the page and wakes up sleepers in ___wait_on_page_locked().* Also wakes sleepers in wait_on_page_writeback() because the wakeup* mechanism between PageLocked pages and PageWriteback pages is shared.
1360  put_hwpoison_page(p)
1361  Return 0
1363  If hwpoison_filter(p) Then
1364  If TestClearPageHWPoison(p) Then num_poisoned_pages_dec()
1366  lock_page - unlock a locked page*@page: the page* Unlocks the page and wakes up sleepers in ___wait_on_page_locked().* Also wakes sleepers in wait_on_page_writeback() because the wakeup* mechanism between PageLocked pages and PageWriteback pages is shared.
1367  put_hwpoison_page(p)
1368  Return 0
1371  If Not PageTransTail returns true for both transparent huge pages* and hugetlbfs pages, so it should only be called when it's known* that hugetlbfs pages aren't involved. && Not PageLRU(p) Then Go to identify_page_state
1378  Wait for a page to complete writeback
1387  If Not Do all that is necessary to remove user space mappings. Unmap* the pages and send SIGBUS to the processes if the data was dirty. Then
1388  "Dirty/Clean" indication is not 100% accurate due to the possibility of* setting PG_dirty outside page lock. See also comment above set_page_dirty().
1389  res = -EBUSY
1390  Go to out
1396  If (PageLRU(p) && !PageSwapCache(p) && See page-flags.h for PAGE_MAPPING_FLAGS == NULL) Then
1397  "Dirty/Clean" indication is not 100% accurate due to the possibility of* setting PG_dirty outside page lock. See also comment above set_page_dirty().
1398  res = -EBUSY
1399  Go to out
1402  identify_page_state :
1403  res = identify_page_state(pfn, p, page_flags)
1404  out :
1405  lock_page - unlock a locked page*@page: the page* Unlocks the page and wakes up sleepers in ___wait_on_page_locked().* Also wakes sleepers in wait_on_page_writeback() because the wakeup* mechanism between PageLocked pages and PageWriteback pages is shared.
1406  Return res
Caller
NameDescribe
do_memory_failure
memory_failure_work_func
hwpoison_inject
madvise_inject_errorError injection support for memory error handling.