From: Matthew Wilcox <willy@infradead.org>
To: Michal Hocko <mhocko@suse.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
Vladimir Davydov <vdavydov.dev@gmail.com>,
cgroups@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [RFC] memcg: Convert mc_target.page to mc_target.folio
Date: Fri, 18 Mar 2022 03:49:27 +0000 [thread overview]
Message-ID: <YjQBRx1+Rq7CYC4M@casper.infradead.org> (raw)
In-Reply-To: <YjMidqgZbieEyBuF@dhcp22.suse.cz>
On Thu, Mar 17, 2022 at 12:58:46PM +0100, Michal Hocko wrote:
> On Wed 16-03-22 20:31:30, Matthew Wilcox wrote:
> > This is a fairly mechanical change to convert mc_target.page to
> > mc_target.folio. This is a prerequisite for converting
> > find_get_incore_page() to find_get_incore_folio(). But I'm not
> > convinced it's right, and I'm not convinced the existing code is
> > quite right either.
> >
> > In particular, the code in hunk @@ -6036,28 +6041,26 @@ needs
> > careful review. There are also assumptions in here that a memory
> > allocation is never larger than a PMD, which is true today, but I've
> > been asked about larger allocations.
>
> Could you be more specific about those usecases? Are they really
> interested in supporting larger pages for the memcg migration which is
> v1 only feature? Or you are interested merely to have the code more
> generic?
Ah! I didn't realise memcg migration was a v1-only feature. I think
that makes all of the questions much less interesting. I've done some
more reading, and it seems like all of this is "best effort", so it
doesn't really matter if some folios get skipped.
I'm not entirely sure what the usecases are for >PMD sized folios.
I think the people who are asking for them probably overestimate how
useful / practical they'll turn out to be. I sense it's a case of "our
hardware supports a range of sizes, and we'd like to be able to support
them all", rather than any sensible evaluation of the pros and cons.
> [...]
> > @@ -6036,28 +6041,26 @@ static int mem_cgroup_move_charge_pte_range(pmd_t *pmd,
> > case MC_TARGET_DEVICE:
> > device = true;
> > fallthrough;
> > - case MC_TARGET_PAGE:
> > - page = target.page;
> > + case MC_TARGET_FOLIO:
> > + folio = target.folio;
> > /*
> > - * We can have a part of the split pmd here. Moving it
> > - * can be done but it would be too convoluted so simply
> > - * ignore such a partial THP and keep it in original
> > - * memcg. There should be somebody mapping the head.
> > + * Is bailing out here with a large folio still the
> > + * right thing to do? Unclear.
> > */
> > - if (PageTransCompound(page))
> > + if (folio_test_large(folio))
> > goto put;
> > - if (!device && isolate_lru_page(page))
> > + if (!device && folio_isolate_lru(folio))
> > goto put;
> > - if (!mem_cgroup_move_account(page, false,
> > + if (!mem_cgroup_move_account(folio, false,
> > mc.from, mc.to)) {
> > mc.precharge--;
> > /* we uncharge from mc.from later. */
> > mc.moved_charge++;
> > }
> > if (!device)
> > - putback_lru_page(page);
> > -put: /* get_mctgt_type() gets the page */
> > - put_page(page);
> > + folio_putback_lru(folio);
> > +put: /* get_mctgt_type() gets the folio */
> > + folio_put(folio);
> > break;
> > case MC_TARGET_SWAP:
> > ent = target.ent;
>
> It's been some time since I've looked at this particular code but my
> recollection and current understanding is that we are skipping over pte
> mapped huge pages for simplicity so that we do not have to recharge
> all other ptes from the same huge page. What kind of concern do you see
> there?
That makes sense. I think the case that's currently mishandled is a
THP in tmpfs which is misaligned when mapped to userspace. It's
skipped, even if the entire THP is mapped. But maybe that simply
doesn't matter.
I suppose the question is: Do we care if mappings of files are not
migrated to the new memcg? I'm getting a sense that the answer is "no",
and if we actually ended up skipping all file mappings, it wouldn't
matter.
Thanks for taking a look!
next prev parent reply other threads:[~2022-03-18 3:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-16 20:31 Matthew Wilcox
2022-03-17 11:58 ` Michal Hocko
2022-03-18 3:49 ` Matthew Wilcox [this message]
2022-03-18 9:12 ` Michal Hocko
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=YjQBRx1+Rq7CYC4M@casper.infradead.org \
--to=willy@infradead.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=vdavydov.dev@gmail.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