From: Naoya Horiguchi <naoya.horiguchi@linux.dev>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: naoya.horiguchi@nec.com, linux-mm@kvack.org
Subject: Re: [bug report] mm/hwpoison: fix race between hugetlb free/demotion and memory_failure_hugetlb()
Date: Wed, 6 Apr 2022 19:48:45 +0900 [thread overview]
Message-ID: <20220406104845.GA1150878@u2004> (raw)
In-Reply-To: <20220406063809.GA27775@kili>
On Wed, Apr 06, 2022 at 09:38:09AM +0300, Dan Carpenter wrote:
> Hello Naoya Horiguchi,
>
> The patch 3b325af8e5fe: "mm/hwpoison: fix race between hugetlb
> free/demotion and memory_failure_hugetlb()" from Apr 5, 2022, leads
> to the following Smatch static checker warning:
>
> mm/memory-failure.c:1537 __get_huge_page_for_hwpoison()
> warn: sleeping in atomic context
>
> mm/memory-failure.c
> 1515 int __get_huge_page_for_hwpoison(unsigned long pfn, int flags)
> 1516 {
> 1517 struct page *page = pfn_to_page(pfn);
> 1518 struct page *head = compound_head(page);
> 1519 int ret = 2; /* fallback to normal page handling */
> 1520 bool count_increased = false;
> 1521
> 1522 if (!PageHeadHuge(head))
> 1523 goto out;
> 1524
> 1525 if (flags & MF_COUNT_INCREASED) {
> 1526 ret = 1;
> 1527 count_increased = true;
> 1528 } else if (HPageFreed(head) || HPageMigratable(head)) {
> 1529 ret = get_page_unless_zero(head);
> 1530 if (ret)
> 1531 count_increased = true;
> 1532 } else {
> 1533 ret = -EBUSY;
> 1534 goto out;
> 1535 }
> 1536
> --> 1537 lock_page(head);
> ^^^^^^^^^^^^^^^
> Sleeps. But this is called from get_huge_page_for_hwpoison() with
> a spinlock held.
Thank you for checking/reporting, I'll move this lock_page() outside hugetlb_lock.
- Naoya Horiguchi
>
> 1538
> 1539 if (hwpoison_filter(page)) {
> 1540 ret = -EOPNOTSUPP;
> 1541 goto unlock;
> 1542 }
> 1543
> 1544 if (TestSetPageHWPoison(head)) {
> 1545 ret = -EHWPOISON;
> 1546 goto unlock;
> 1547 }
> 1548
> 1549 /* keep locking page. */
> 1550 return ret;
> 1551 unlock:
> 1552 unlock_page(head);
> 1553 if (count_increased)
> 1554 put_page(head);
> 1555 out:
> 1556 return ret;
> 1557 }
>
> regards,
> dan carpenter
>
prev parent reply other threads:[~2022-04-06 10:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-06 6:38 [bug report] mm/hwpoison: fix race between hugetlb free/demotion and memory_failure_hugetlb() Dan Carpenter
2022-04-06 10:48 ` Naoya Horiguchi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220406104845.GA1150878@u2004 \
--to=naoya.horiguchi@linux.dev \
--cc=dan.carpenter@oracle.com \
--cc=linux-mm@kvack.org \
--cc=naoya.horiguchi@nec.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).