From: Andy Lutomirski <luto@amacapital.net>
To: Daniel Mack <daniel@zonque.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Tom Gundersen <teg@jklm.no>,
"Kalle A. Sandstrom" <ksandstr@iki.fi>,
Borislav Petkov <bp@alien8.de>,
One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>,
Havoc Pennington <havoc.pennington@gmail.com>,
Djalal Harouni <tixxdz@opendz.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
cee1 <fykcee1@gmail.com>, David Herrmann <dh.herrmann@gmail.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: kdbus: to merge or not to merge?
Date: Sun, 9 Aug 2015 19:10:20 -0700 [thread overview]
Message-ID: <CALCETrUA6o04QYhvSZjtVUs9p1A+ASndEv0C8X6D+Fg5uudo9A@mail.gmail.com> (raw)
In-Reply-To: <55C7D02A.9060905@zonque.org>
On Sun, Aug 9, 2015 at 3:11 PM, Daniel Mack <daniel@zonque.org> wrote:
>
> Internally, the connection pool is simply a shmem backed file. From the
> context of the HELLO ioctl, we are calling into shmem_file_setup(), so
> the file is eventually owned by the task which created the bus task
> connecting to the bus. One reason why we do the shmem file allocation in
> the kernel and on behalf of a the userspace task is that we clear the
> VM_MAYWRITE bit to prevent the task from writing to the pool through its
> mapped buffer. We also do not set VM_NORESERVE, so the entire buffer is
> pre-accounted for the task that created the connection.
I don't have access to the system I've been using for testing right
now, but I wonder how the kdbus pool stack up against the entire rest
of memory allocations for the average desktop process.
>
> The pool implementation uses an r/b tree to organize the buffer into
> slices. Those slices can be kept by userspace as long as the parsing
> implementation needs to have access to them. When finished, the slices
> are freed. A simple ring buffer cannot cope with the gaps that emerge by
> that.
>
> When a connection buffer is written to, it is done from the context of
> another task which calls into the kdbus code through one of the ioctls.
> The memcg implementation should hence charge the task that acts as
> writer, which is maybe not ideal but can be changed easily with some
> addition to the internal APIs. We omitted it for the current version,
> which is non-intrusive with regards to other kernel subsystems.
>
This has at least the following weakness. I can very easily get
systemd to write to my shmem-backed pool: simply subscribe to one of
its broadcasts. If I cause such a write to be very slow
(intentionally or otherwise), then PID 1 blocks.
If you change the memcg code to charge me instead of PID 1 (as it
should IMO), then the problem gets worse.
> The kdbus implementation is actually comparable to two tasks X and Y
> which both have their own buffer file open and mmap()ed, and they both
> pass their FD to the other side. If X now writes to Y's file, and that
> is causing a page fault, X is accounted for it, correct?
If PID 1 accepted a memfd from me (even a properly sealed one) and
wrote to it, I would wonder whether it were actually a good idea.
Does this scheme have any actual measurable advantage over the
traditional model of a small non-paged buffer in the kernel (i.e. the
way sockets work) with explicit userspace memfd use as appropriate?
--Andy
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2015-08-10 2:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CANq1E4SnYq_pZMWYcafB9GmB_O77tbVLPT0=0d6LGQVpvThTrw@mail.gmail.com>
[not found] ` <CALCETrWE-oYRq+AzRxxcz03AK0pAzgKJtmxAuNwQu+p5S0msBw@mail.gmail.com>
[not found] ` <CANq1E4Rek3HXCDU_13OGfRShS7Z0g+fxcTp5C1V3oKC4HgkD_A@mail.gmail.com>
[not found] ` <CALCETrUaSgdaq4_mr3GG-ekLwGXkQR5MoRLSj9Wu2dTXDYUp1g@mail.gmail.com>
[not found] ` <CANq1E4SkUWWXuksJnWzXd5KStZx-T6q6+WWTHdrQz_WiMry4Cw@mail.gmail.com>
[not found] ` <CALCETrXcqOFedk8r-jHK-deRwfum29JHspALE6JUi2gzbo-dhg@mail.gmail.com>
[not found] ` <55C3A403.8020202@zonque.org>
[not found] ` <CALCETrVr04ZdXHLZXLp_Y+m68Db5Mmh_Wnu6prNCfCqgWm0QzA@mail.gmail.com>
[not found] ` <55C4C35A.4070306@zonque.org>
[not found] ` <CA+55aFxDLt-5+=xXeYG4nJKMb8L_iD9FmwTZ2VuughBku-mW3g@mail.gmail.com>
[not found] ` <20150809190027.GA24185@kroah.com>
2015-08-09 22:11 ` Daniel Mack
2015-08-10 2:10 ` Andy Lutomirski [this message]
2015-08-10 17:04 ` Linus Torvalds
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=CALCETrUA6o04QYhvSZjtVUs9p1A+ASndEv0C8X6D+Fg5uudo9A@mail.gmail.com \
--to=luto@amacapital.net \
--cc=bp@alien8.de \
--cc=daniel@zonque.org \
--cc=dh.herrmann@gmail.com \
--cc=ebiederm@xmission.com \
--cc=fykcee1@gmail.com \
--cc=gnomes@lxorguk.ukuu.org.uk \
--cc=gregkh@linuxfoundation.org \
--cc=havoc.pennington@gmail.com \
--cc=ksandstr@iki.fi \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=teg@jklm.no \
--cc=tixxdz@opendz.org \
--cc=torvalds@linux-foundation.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