linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: naoya.horiguchi@nec.com
Cc: linux-mm@kvack.org
Subject: [bug report] mm/hwpoison: fix race between hugetlb free/demotion and memory_failure_hugetlb()
Date: Wed, 6 Apr 2022 09:38:09 +0300	[thread overview]
Message-ID: <20220406063809.GA27775@kili> (raw)

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.

    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


             reply	other threads:[~2022-04-06  6:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-06  6:38 Dan Carpenter [this message]
2022-04-06 10:48 ` Naoya Horiguchi

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=20220406063809.GA27775@kili \
    --to=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