[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <28571549-344f-8423-a20d-aeccff0e838a@colorfullife.com>
Date: Tue, 19 Mar 2019 19:18:39 +0100
From: Manfred Spraul <manfred@...orfullife.com>
To: Waiman Long <longman@...hat.com>,
"Luis R. Rodriguez" <mcgrof@...nel.org>,
Kees Cook <keescook@...omium.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Jonathan Corbet <corbet@....net>
Cc: linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-doc@...r.kernel.org, Al Viro <viro@...iv.linux.org.uk>,
Matthew Wilcox <willy@...radead.org>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Takashi Iwai <tiwai@...e.de>, Davidlohr Bueso <dbueso@...e.de>
Subject: Re: [PATCH v12 3/3] ipc: Do cyclic id allocation with ipcmni_extend
mode
Hi Waiman,
On 3/18/19 7:46 PM, Waiman Long wrote:
> --- a/ipc/util.c
>> +++ b/ipc/util.c
>> @@ -221,9 +221,17 @@ 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 */
>> + int max_idx;
>> +
>> + max_idx = ids->in_use*3/2;
>> + if (max_idx > ipc_mni)
>> + max_idx = ipc_mni;
>> + if (max_idx < ipc_min_cycle)
>> + max_idx = ipc_min_cycle;
>
> Why don't you use the min() and max() macros which will make it easier
> to read?
>
Changed.
>>
>> /* allocate the idx, with a NULL struct kern_ipc_perm */
>> - idx = idr_alloc(&ids->ipcs_idr, NULL, 0, 0, GFP_NOWAIT);
>> + idx = idr_alloc_cyclic(&ids->ipcs_idr, NULL, 0, max_idx,
>> + GFP_NOWAIT);
>>
>> if (idx >= 0) {
>> /*
>> diff --git a/ipc/util.h b/ipc/util.h
>> index 8c834ed39012..ef4e86bb2db8 100644
>> --- a/ipc/util.h
>> +++ b/ipc/util.h
>> @@ -27,12 +27,14 @@
>> */
>> #define IPCMNI_SHIFT 15
>> #define IPCMNI_EXTEND_SHIFT 24
>> +#define IPCMNI_EXTEND_MIN_CYCLE (2 << 12)
>
> How about
>
> #define IPCMNI_EXTEND_MIN_CYCLE (RADIX_TREE_MAP_SIZE *
> RADIX_TREE_MAP_SIZE)
>
Good idea.
Actually, "2<<12" was the initial guess.
And then I noticed that this ends up as a two level radix tree during
testing :-)
Updated patch attached.
--
Manfred
View attachment "0002-ipc-Do-cyclic-id-allocation-for-the-ipc-object.patch" of type "text/x-patch" (4892 bytes)
Powered by blists - more mailing lists