Received: by 10.213.65.68 with SMTP id h4csp1387332imn; Thu, 29 Mar 2018 03:57:43 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+Lsqef5qltGnAT2hOAYRx6Q3RfSLhjtKr0Y+xj8FnTT4dWGWcu3Wa6OEswjbzmNmI3Y5da X-Received: by 2002:a17:902:6ac1:: with SMTP id i1-v6mr7698880plt.152.1522321063739; Thu, 29 Mar 2018 03:57:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522321063; cv=none; d=google.com; s=arc-20160816; b=mkzxWk3t6EX2V0T5K+B3PWUasjq9TQ9pOM4HNGpvlWZpA0COnqnvYWOe3kEIGzsH3W NkL+Hp3wMY2SH916ptY8eCernyfCzU60tvS0QiQTV7/8T5EV2dxgFwefYClSqn3sbHqO CErtrU94bbiRcKqGIR0v/Rm6PEpUPiASzhinSqSZ4Ptq5YrG4mBQM8C/W8ycIiNn+YRG UfjKV8eFB0LimsB0lkhoWj48JYA4UIA6v7A188ZE8ufJxnQIysJ53pbpNN1lmQGPYILg yRjztyVoO0jD9lbixGVFVZcfxYoPzP3F6UuUkXHCz4uWfMC/qDkvSn6I3X6f68HdzJBa f4EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=me+qbONuELQVNdoy1IRpfUs+Z/tE65YWgCmwUaB7/fk=; b=TT5ZngC9i+J2Dev/oxPUKI1xNVNjU/rRTZJ0+goRCoQ6FwDVznc2M1jHXuGzm1xThg yawfml7Q4Aydnzpj+i0ryAYqYI0uTjfNP12nOJyni2hWaAXaw13xGb3//kCqDlZn7cij NTxQQyFeb7H+POzB3tHXgKNO0NM6VNQXZybdab5Jn8Iqi5nBTza8PelAGA4emy+xZDS4 wzxGVC+inY8aCrVLqdUNqK1ZvXyYV1zTLzn4GjFmwLZ1SzB7WsB+UU3LV9+m8Fg1b02h +/QBtwS/oX2xLPIhvITmZz2y0PMAidr3iC29Ex0CXXWK/2BVEce77OGj5ktGIWnO1qKu Qd7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=YSYtw4Yt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c22si3715835pfe.29.2018.03.29.03.57.29; Thu, 29 Mar 2018 03:57:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=YSYtw4Yt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752495AbeC2K4G (ORCPT + 99 others); Thu, 29 Mar 2018 06:56:06 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:59268 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752446AbeC2K4E (ORCPT ); Thu, 29 Mar 2018 06:56:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=me+qbONuELQVNdoy1IRpfUs+Z/tE65YWgCmwUaB7/fk=; b=YSYtw4YtbuUBfQ++3W+kVNNJT yRSdDhABpxzlqnaN7ZvkYiDaGrdpXt+lUkAYkWSAaRgdNUMJMnslnzOgJ7wapypKMcw+6mUOXJXc6 pO44Ta77JDZTl+PQ3edettO2znXPUCqnn2vxRCJBTQdw2cmtGk6buzjVbDo3l3zlz6CqH2LOW63Ge mh7E0JT25MXpgPzBs6pk8TRZzzmrSN9BRQvd6bpo3TGNgVWNcf3850HLUdDP7MG1quk2hp3H7nEba fKg2Gkz5RWmGl0HpM/v6XJ+7P/2ayhhh2levDAc8AhKalOSfg2V8RmzIP/rhSjmeN4w1yGrukWctJ 2F1SYa/Aw==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1f1VDt-0007JO-92; Thu, 29 Mar 2018 10:56:01 +0000 Date: Thu, 29 Mar 2018 03:56:01 -0700 From: Matthew Wilcox To: Manfred Spraul Cc: Davidlohr Bueso , Waiman Long , Michael Kerrisk , "Eric W. Biederman" , "Luis R. Rodriguez" , Kees Cook , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Andrew Morton , Al Viro , Stanislav Kinsbursky , Linux Containers , linux-api@vger.kernel.org Subject: Re: [RFC][PATCH] ipc: Remove IPCMNI Message-ID: <20180329105601.GA597@bombadil.infradead.org> References: <87woyfyh57.fsf@xmission.com> <5d4a858a-3136-5ef4-76fe-a61e7f2aed56@redhat.com> <87o9jru3bf.fsf@xmission.com> <935a7c50-50cc-2dc0-33bb-92c000d039bc@redhat.com> <87woyego2u.fsf_-_@xmission.com> <047c6ed6-6581-b543-ba3d-cadc543d3d25@redhat.com> <87h8ph6u67.fsf@xmission.com> <7d3a1f93-f8e5-5325-f9a7-0079f7777b6f@redhat.com> <20180329021409.gcjjrmviw2lckbfk@linux-n805> <3e201de2-bed2-6f7d-0783-700d095142e0@colorfullife.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3e201de2-bed2-6f7d-0783-700d095142e0@colorfullife.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 29, 2018 at 10:47:45AM +0200, Manfred Spraul wrote: > > > > > > This can be implemented trivially with the current code > > > > > > using idr_alloc_cyclic. > > Is there a performance impact? > Right now, the idr tree is only large if there are lots of objects. > What happens if we have only 1 object, with id=INT_MAX-1? The radix tree uses a branching factor of 64 entries (6 bits) per level. The maximum ID is 31 bits (positive signed 32-bit integer). So the worst case for a single object is 6 pointer dereferences to find the object anywhere in the range (INT_MAX/2 - INT_MAX]. That will read 12 cachelines. If we were to constrain ourselves to a maximum of INT_MAX/2 (30 bits), we'd reduce that to 5 pointer dereferences and 10 cachelines. I have plans to make the representation more efficient and bring the specific case of one element with a high ID down to one pointer dereference and 2 cachelines, but I have not yet had time to implement those plans. From a memory consumption point of view, 6 layers of tree will consume 6/7 of a page on a 64-bit x86 kernel. I'm aiming to bring that down to 1/7 of a page. We get 7 radix_tree_nodes per 4kB page. (The old IDR tree had 256 entries per level which would have taken only four layers to get us to 31 bits, but the cost was getting only 3 layers per 8kB order-1 page, so we'd've taken 2 + 2/3 page to accomplish the same goal).