Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752535AbdGaPqM convert rfc822-to-8bit (ORCPT ); Mon, 31 Jul 2017 11:46:12 -0400 Received: from mx2.suse.de ([195.135.220.15]:53307 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752063AbdGaPqL (ORCPT ); Mon, 31 Jul 2017 11:46:11 -0400 Date: Mon, 31 Jul 2017 08:45:58 -0700 From: Davidlohr Bueso To: Guillaume Knispel Cc: Andrew Morton , Manfred Spraul , Kees Cook , Alexey Dobriyan , "Eric W. Biederman" , "Peter Zijlstra (Intel)" , Ingo Molnar , Sebastian Andrzej Siewior , Serge Hallyn , Andrey Vagin , Marc Pardo , linux-kernel@vger.kernel.org Subject: Re: [PATCH] ipc: optimize semget/shmget/msgget for lots of keys Message-ID: <20170731154558.GB21328@linux-80c1.suse> References: <20170731084237.GA123231@ubuntu> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8BIT In-Reply-To: <20170731084237.GA123231@ubuntu> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 750 Lines: 21 On Mon, 31 Jul 2017, Guillaume Knispel wrote: >ipc_findkey() scanned all objects to look for the wanted key. This is >slow when using a high number of keys, for example on an i5 laptop the >following loop took 17 s, with last semget calls taking ~1 ms each. I would argue that this is not the common case. > > for (int i = 0, k=0x424242; i < 31900; ++i) > semget(k++, 1, IPC_CREAT | 0600); > >This change adds an rhashtable of kern_ipc_perm objects in ipc_ids, so >that one lookup cease to be O(n). The above loop now takes ~10 ms. Each >lookup-only semget() call can take between ~120 ns and a few ?s. Rarely, >some creations can take a few dozen of ?s. Could you please provide numbers for smaller amounts of keys? Thanks, Davidlohr