From: Tejun Heo <tj@kernel.org>
To: Matthew Wilcox <willy@infradead.org>
Cc: Eric Biggers <ebiggers@kernel.org>,
"Theodore Y . Ts'o" <tytso@mit.edu>,
Jaegeuk Kim <jaegeuk@kernel.org>,
linux-fscrypt@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-ext4@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net, stable@vger.kernel.org,
cgroups@vger.kernel.org
Subject: Re: [PATCH] fscrypt: Copy the memcg information to the ciphertext page
Date: Tue, 31 Jan 2023 11:27:44 -1000 [thread overview]
Message-ID: <Y9mH0PCcZoGPryXw@slm.duckdns.org> (raw)
In-Reply-To: <Y9bkoasmAmtQ2nSV@casper.infradead.org>
Hello,
On Sun, Jan 29, 2023 at 09:26:57PM +0000, Matthew Wilcox wrote:
> > > diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c
> > > index e78be66bbf01..a4e76f96f291 100644
> > > --- a/fs/crypto/crypto.c
> > > +++ b/fs/crypto/crypto.c
> > > @@ -205,6 +205,9 @@ struct page *fscrypt_encrypt_pagecache_blocks(struct page *page,
> > > }
> > > SetPagePrivate(ciphertext_page);
> > > set_page_private(ciphertext_page, (unsigned long)page);
> > > +#ifdef CONFIG_MEMCG
> > > + ciphertext_page->memcg_data = page->memcg_data;
> > > +#endif
> > > return ciphertext_page;
> > > }
> >
> > Nothing outside mm/ and include/linux/memcontrol.h does anything with memcg_data
> > directly. Are you sure this is the right thing to do here?
>
> Nope ;-) Happy to hear from people who know more about cgroups than I
> do. Adding some more ccs.
>
> > Also, this patch causes the following:
>
> Oops. Clearly memcg_data needs to be set to NULL before we free it.
These can usually be handled by explicitly associating the bio's to the
desired cgroups using one of bio_associate_blkg*() or
bio_clone_blkg_association(). It is possible to go through memcg ownership
too using set_active_memcg() so that the page is owned by the target cgroup;
however, the page ownership doesn't directly map to IO ownership as the
relationship depends on the type of the page (e.g. IO ownership for
pagecache writeback is determined per-inode, not per-page). If the in-flight
pages are limited, it probably is better to set bio association directly.
Thanks.
--
tejun
next prev parent reply other threads:[~2023-01-31 21:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-29 12:18 [PATCH] fscrypt: Copy the memcg information to the ciphertext page Matthew Wilcox (Oracle)
2023-01-29 18:10 ` Eric Biggers
2023-01-29 21:26 ` Matthew Wilcox
2023-01-31 21:27 ` Tejun Heo [this message]
2023-02-01 6:31 ` Eric Biggers
2023-02-02 21:30 ` Tejun Heo
2023-02-03 1:07 ` Eric Biggers
2023-02-03 6:29 ` kernel test robot
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=Y9mH0PCcZoGPryXw@slm.duckdns.org \
--to=tj@kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=ebiggers@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=willy@infradead.org \
/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).