From: Waiman Long <longman@redhat.com>
To: Manfred Spraul <manfred@colorfullife.com>,
"Luis R. Rodriguez" <mcgrof@kernel.org>,
Kees Cook <keescook@chromium.org>,
Andrew Morton <akpm@linux-foundation.org>,
Jonathan Corbet <corbet@lwn.net>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-doc@vger.kernel.org, Al Viro <viro@zeniv.linux.org.uk>,
Matthew Wilcox <willy@infradead.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Takashi Iwai <tiwai@suse.de>, Davidlohr Bueso <dbueso@suse.de>
Subject: Re: [PATCH v12 3/3] ipc: Do cyclic id allocation with ipcmni_extend mode
Date: Mon, 18 Mar 2019 14:37:39 -0400 [thread overview]
Message-ID: <eaee3fad-937b-9776-5ff4-874475acc162@redhat.com> (raw)
In-Reply-To: <e780cb59-ef1b-5f56-1e92-394dff5d4e32@colorfullife.com>
On 03/17/2019 02:27 PM, Manfred Spraul wrote:
> Hi Waiman,
>
> On 2/28/19 7:47 PM, Waiman Long wrote:
>> For ipcmni_extend mode, the sequence number space is only 7 bits. So
>> the chance of id reuse is relatively high compared with the non-extended
>> mode.
>>
>> To alleviate this id reuse problem, the id allocation will be done
>> cyclically to cycle through all the 24-bit id space before wrapping
>> around when in ipcmni_extend mode. This may cause the use of more memory
>> in term of the number of xa_nodes allocated as well as potentially more
>> cachelines used as the xa_nodes may be spread more sparsely in this
>> case.
>>
>> There is probably a slight memory and performance cost in doing cyclic
>> id allocation. For applications that really need more than 32k unique
>> IPC
>> identifiers, this is a small price to pay to avoid the id reuse problem.
>
> Have you measured it?
>
> I have observed -3% for semop() for a 4 level radix tree compared to a
> 1-level radix tree, and I'm a bit reluctant to accept that.
> Especially as the percentage will increase if the syscall overhead
> goes down again (-> less spectre impact).
>
It is both Spectre (retpoline) and Meltdown (PTI). PTI is not needed in
AMD CPU and so you may see a bit higher slowdown.
> [...]
>
>> --- a/ipc/util.c
>> +++ b/ipc/util.c
>> @@ -221,7 +221,12 @@ static inline int ipc_idr_alloc(struct ipc_ids
>> *ids, struct kern_ipc_perm *new)
>> */
>> if (next_id < 0) { /* !CHECKPOINT_RESTORE or next_id is unset */
>> - idx = idr_alloc(&ids->ipcs_idr, new, 0, 0, GFP_NOWAIT);
>> + if (ipc_mni_extended)
>> + idx = idr_alloc_cyclic(&ids->ipcs_idr, new, 0, ipc_mni,
>> + GFP_NOWAIT);
>> + else
>> + idx = idr_alloc(&ids->ipcs_idr, new, 0, 0, GFP_NOWAIT);
>> +
>> if ((idx <= ids->last_idx) && (++ids->seq > IPCID_SEQ_MAX))
>> ids->seq = 0;
>
> I don't like it that there are two different codepaths.
>
> Attached is a different proposal:
>
> Always use cyclic allocation, with some logic to minimize the
> additional radix tree levels.
>
> What do you think?
Your proposed patch look good. I saw that you use the max_idx to limit
radix tree nesting level which mitigate my concern of using more memory
and slower performance. I do have some minor comments about the patch in
a later email.
-Longman
next prev parent reply other threads:[~2019-03-18 18:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-28 18:47 [PATCH v12 0/3] ipc: Increase IPCMNI limit Waiman Long
2019-02-28 18:47 ` [PATCH v12 1/3] ipc: Allow boot time extension of IPCMNI from 32k to 16M Waiman Long
2019-02-28 18:47 ` [PATCH v12 2/3] ipc: Conserve sequence numbers in ipcmni_extend mode Waiman Long
2019-03-16 18:52 ` Manfred Spraul
2019-03-18 18:57 ` Waiman Long
2019-03-18 19:00 ` Waiman Long
2019-02-28 18:47 ` [PATCH v12 3/3] ipc: Do cyclic id allocation with " Waiman Long
2019-03-17 18:27 ` Manfred Spraul
2019-03-18 18:37 ` Waiman Long [this message]
2019-03-18 18:53 ` Waiman Long
[not found] ` <728b5e85-3129-9707-3802-306f66093c78@redhat.com>
2019-03-19 18:18 ` Manfred Spraul
2019-03-19 18:46 ` Waiman Long
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=eaee3fad-937b-9776-5ff4-874475acc162@redhat.com \
--to=longman@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=dbueso@suse.de \
--cc=ebiederm@xmission.com \
--cc=keescook@chromium.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=manfred@colorfullife.com \
--cc=mcgrof@kernel.org \
--cc=tiwai@suse.de \
--cc=viro@zeniv.linux.org.uk \
--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).