Commit 171936d
mm/memory-failure: use a mutex to avoid memory_failure() races
Patch series "mm,hwpoison: fix sending SIGBUS for Action Required MCE", v5.
I wrote this patchset to materialize what I think is the current
allowable solution mentioned by the previous discussion [1]. I simply
borrowed Tony's mutex patch and Aili's return code patch, then I queued
another one to find error virtual address in the best effort manner. I
know that this is not a perfect solution, but should work for some
typical case.
[1]: https://lore.kernel.org/linux-mm/20210331192540.2141052f@alex-virtual-machine/
This patch (of 2):
There can be races when multiple CPUs consume poison from the same page.
The first into memory_failure() atomically sets the HWPoison page flag
and begins hunting for tasks that map this page. Eventually it
invalidates those mappings and may send a SIGBUS to the affected tasks.
But while all that work is going on, other CPUs see a "success" return
code from memory_failure() and so they believe the error has been
handled and continue executing.
Fix by wrapping most of the internal parts of memory_failure() in a
mutex.
[akpm@linux-foundation.org: make mf_mutex local to memory_failure()]
Link: https://lkml.kernel.org/r/20210521030156.2612074-1-nao.horiguchi@gmail.com
Link: https://lkml.kernel.org/r/20210521030156.2612074-2-nao.horiguchi@gmail.com
Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
Reviewed-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Cc: Aili Yao <yaoaili@kingsoft.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: David Hildenbrand <david@redhat.com>
Cc: Jue Wang <juew@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>1 parent fe19bd3 commit 171936d
1 file changed
Lines changed: 23 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1429 | 1429 | | |
1430 | 1430 | | |
1431 | 1431 | | |
1432 | | - | |
| 1432 | + | |
1433 | 1433 | | |
1434 | 1434 | | |
| 1435 | + | |
1435 | 1436 | | |
1436 | 1437 | | |
1437 | 1438 | | |
| |||
1449 | 1450 | | |
1450 | 1451 | | |
1451 | 1452 | | |
| 1453 | + | |
| 1454 | + | |
1452 | 1455 | | |
1453 | | - | |
1454 | | - | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
1455 | 1461 | | |
1456 | 1462 | | |
1457 | 1463 | | |
1458 | | - | |
| 1464 | + | |
1459 | 1465 | | |
1460 | 1466 | | |
1461 | 1467 | | |
| |||
1488 | 1494 | | |
1489 | 1495 | | |
1490 | 1496 | | |
1491 | | - | |
| 1497 | + | |
1492 | 1498 | | |
1493 | 1499 | | |
1494 | | - | |
| 1500 | + | |
1495 | 1501 | | |
| 1502 | + | |
1496 | 1503 | | |
1497 | 1504 | | |
1498 | 1505 | | |
1499 | 1506 | | |
1500 | 1507 | | |
1501 | | - | |
| 1508 | + | |
| 1509 | + | |
1502 | 1510 | | |
1503 | 1511 | | |
1504 | 1512 | | |
| |||
1522 | 1530 | | |
1523 | 1531 | | |
1524 | 1532 | | |
1525 | | - | |
| 1533 | + | |
1526 | 1534 | | |
1527 | 1535 | | |
1528 | 1536 | | |
| |||
1542 | 1550 | | |
1543 | 1551 | | |
1544 | 1552 | | |
1545 | | - | |
| 1553 | + | |
1546 | 1554 | | |
1547 | 1555 | | |
1548 | 1556 | | |
1549 | 1557 | | |
1550 | 1558 | | |
1551 | 1559 | | |
1552 | | - | |
| 1560 | + | |
1553 | 1561 | | |
1554 | 1562 | | |
1555 | 1563 | | |
| |||
1573 | 1581 | | |
1574 | 1582 | | |
1575 | 1583 | | |
1576 | | - | |
| 1584 | + | |
1577 | 1585 | | |
1578 | 1586 | | |
1579 | 1587 | | |
| |||
1582 | 1590 | | |
1583 | 1591 | | |
1584 | 1592 | | |
1585 | | - | |
| 1593 | + | |
1586 | 1594 | | |
1587 | 1595 | | |
1588 | 1596 | | |
1589 | 1597 | | |
1590 | | - | |
| 1598 | + | |
1591 | 1599 | | |
| 1600 | + | |
| 1601 | + | |
1592 | 1602 | | |
1593 | 1603 | | |
1594 | 1604 | | |
| |||
0 commit comments