From: David Hildenbrand <david@redhat.com>
To: Hugh Dickins <hughd@google.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Usama Arif <usamaarif642@gmail.com>,
Yang Shi <shy828301@gmail.com>,
Wei Yang <richard.weiyang@gmail.com>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Matthew Wilcox <willy@infradead.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Barry Song <baohua@kernel.org>,
Kefeng Wang <wangkefeng.wang@huawei.com>,
Ryan Roberts <ryan.roberts@arm.com>,
Nhat Pham <nphamcs@gmail.com>, Zi Yan <ziy@nvidia.com>,
Chris Li <chrisl@kernel.org>,
Shakeel Butt <shakeel.butt@linux.dev>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH hotfix v2 2/2] mm/thp: fix deferred split unqueue naming and locking
Date: Mon, 28 Oct 2024 11:43:32 +0100 [thread overview]
Message-ID: <154430c4-7b17-443f-8628-ef3bb7738ae9@redhat.com> (raw)
In-Reply-To: <8dc111ae-f6db-2da7-b25c-7a20b1effe3b@google.com>
Hi Hugh,
mostly looks good to me, one comment:
> +++ b/mm/memcontrol-v1.c
> @@ -848,6 +848,8 @@ static int mem_cgroup_move_account(struct folio *folio,
> css_get(&to->css);
> css_put(&from->css);
>
> + /* Warning should never happen, so don't worry about refcount non-0 */
> + WARN_ON_ONCE(folio_unqueue_deferred_split(folio));
> folio->memcg_data = (unsigned long)to;
>
> __folio_memcg_unlock(from);
> @@ -1217,7 +1219,9 @@ static int mem_cgroup_move_charge_pte_range(pmd_t *pmd,
> enum mc_target_type target_type;
> union mc_target target;
> struct folio *folio;
> + bool tried_split_before = false;
>
> +retry_pmd:
> ptl = pmd_trans_huge_lock(pmd, vma);
> if (ptl) {
> if (mc.precharge < HPAGE_PMD_NR) {
> @@ -1227,6 +1231,27 @@ static int mem_cgroup_move_charge_pte_range(pmd_t *pmd,
> target_type = get_mctgt_type_thp(vma, addr, *pmd, &target);
> if (target_type == MC_TARGET_PAGE) {
> folio = target.folio;
> + /*
> + * Deferred split queue locking depends on memcg,
> + * and unqueue is unsafe unless folio refcount is 0:
> + * split or skip if on the queue? first try to split.
> + */
> + if (!list_empty(&folio->_deferred_list)) {
> + spin_unlock(ptl);
> + if (!tried_split_before)
> + split_folio(folio);
> + folio_unlock(folio);
> + folio_put(folio);
> + if (tried_split_before)
> + return 0;
> + tried_split_before = true;
> + goto retry_pmd;
> + }
> + /*
> + * So long as that pmd lock is held, the folio cannot
> + * be racily added to the _deferred_list, because
> + * __folio_remove_rmap() will find !partially_mapped.
> + */
Fortunately that code is getting ripped out.
https://lkml.kernel.org/r/20241025012304.2473312-3-shakeel.butt@linux.dev
So I wonder ... as a quick fix should we simply handle it like the code
further down where we refuse PTE-mapped large folios completely?
"ignore such a partial THP and keep it in original memcg"
...
and simply skip this folio similarly? I mean, it's a corner case either way.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2024-10-28 10:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-27 19:59 [PATCH hotfix v2 1/2] mm/thp: fix deferred split queue not partially_mapped Hugh Dickins
2024-10-27 20:02 ` [PATCH hotfix v2 2/2] mm/thp: fix deferred split unqueue naming and locking Hugh Dickins
2024-10-28 10:43 ` David Hildenbrand [this message]
2024-10-28 17:19 ` Hugh Dickins
2024-10-28 17:26 ` David Hildenbrand
2024-10-28 18:39 ` Yang Shi
2024-10-27 20:06 ` [PATCH hotfix v2 1/2] mm/thp: fix deferred split queue not partially_mapped Zi Yan
2024-11-10 21:08 ` Hugh Dickins
2024-11-10 21:11 ` [PATCH hotfix] mm/thp: fix deferred split queue not partially_mapped: fix Hugh Dickins
2024-11-10 21:22 ` Usama Arif
2024-11-11 3:10 ` Zi Yan
2024-11-12 1:36 ` Baolin Wang
2024-11-13 22:57 ` Chris Li
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=154430c4-7b17-443f-8628-ef3bb7738ae9@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=chrisl@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nphamcs@gmail.com \
--cc=richard.weiyang@gmail.com \
--cc=ryan.roberts@arm.com \
--cc=shakeel.butt@linux.dev \
--cc=shy828301@gmail.com \
--cc=usamaarif642@gmail.com \
--cc=wangkefeng.wang@huawei.com \
--cc=willy@infradead.org \
--cc=ziy@nvidia.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