Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp788103pxa; Wed, 5 Aug 2020 12:47:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmzZpV76HA/NsEUbKcbN8HSJZRkKrgpozW/s6QztcfRQvJHpodI2DZToE0sDEwimRHccT1 X-Received: by 2002:a17:907:405f:: with SMTP id ns23mr821431ejb.511.1596656840193; Wed, 05 Aug 2020 12:47:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596656840; cv=none; d=google.com; s=arc-20160816; b=uUuAofdq/FSbntavI4EQIZG+Jzi6FdCo+86fBAovei6WZO/kGDzbJ63WNlwNcDCq8d Us4hUOtKYrVyiH5F4k4rBtnilOJnWMzfrwsQhJdgZpPGOTNB6UPS65dCO68SPpCv5lrg 79EF493LJ6VhQ0eG8c67rJUfFkq1PJ/D/2GdcyEdpVtDYOPZDmDY3IiqHloq1QwwD9XL h9u3iv5XK5DYzjODMnb0G2/N2BuCgl/XR03z1vcygHA2bn8pnd5W/8odzVTDm4E9dD45 8hcRXzcABj0XrOcmG2gWM+Vk/1PCElVqTo2nb6gac5hZx7Rd9uf0nss6iw2ekmB8Z1Gc VRyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=BjUxyEqkYiqtsdR/KvRwz6ZbXTHnw0kNXap/n+8pwLc=; b=C/12Qb1fyCfMUixEz1ktHHuNW9efCKPe105OYWtR/pkwpSSWknPBJI6qkVgkjUJKNW oxR357PFnxoAckWcOQu88/UkikWRI3jlxDFdZRGplb1G0dZqXtkX+ieLoL/iqmQj7Nme zvhQ4D7jHLNGTqrrGvQsJq8qXL+6NDJ9OfwBb4gLpKFWobJ5u6OYTvlChfsQAjQ9L0A9 BCpjeJFCIIdhDy5uJHCKDkYmCiivXtxqT4fuP36EDNcjCm8uhV/MfOu1NYujDR++keU1 q0KaOX4GRRfxr/Tb3ixuvXBmx3+xWWWGYD5aG9GbjiyrIrZl47B/wj/vpCl/rQ4bbJbb NC9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=d99BKyoG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i7si2210871ejo.667.2020.08.05.12.46.56; Wed, 05 Aug 2020 12:47:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=d99BKyoG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729415AbgHETqv (ORCPT + 99 others); Wed, 5 Aug 2020 15:46:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729079AbgHETdZ (ORCPT ); Wed, 5 Aug 2020 15:33:25 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09B86C061575; Wed, 5 Aug 2020 12:33:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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; bh=BjUxyEqkYiqtsdR/KvRwz6ZbXTHnw0kNXap/n+8pwLc=; b=d99BKyoGx9hy4YcJdLSUMJqThT 5nqIKVLtODQNoljLBcp8S5Qe51texKqOh2lHfYRF6oE9Eennni9qvKXvoNCBo1BmBItdODcTP8rr0 d9fwQtJqhR7ZefvrgjrymVDmQgC18lF3oe0V6z2N2edcUvDcRkE+9XOUCafaUKs24HosE1ZjfNpyP orzIgTlu+kNLZ8DcTbs9SzVLlHxhTCkbT8b6BA/62VFAu20gPM6e4dugjgbyb55pQ8ZyZvQxTDPzk tMeIVEAdm2vkbkv0U8ueOK/GHFSZ2Sv4iPAT4k3TV9OgjyznmX+JjL+tR/NszZzvUQ9KYpokZ96xB mE2m1QXA==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1k3P9r-0005s8-TN; Wed, 05 Aug 2020 19:33:03 +0000 Date: Wed, 5 Aug 2020 20:33:03 +0100 From: Matthew Wilcox To: David Howells Cc: Miklos Szeredi , Al Viro , Linus Torvalds , Ian Kent , Miklos Szeredi , Christian Brauner , Jann Horn , "Darrick J. Wong" , Karel Zak , Jeff Layton , Linux API , linux-fsdevel@vger.kernel.org, LSM , linux-kernel@vger.kernel.org Subject: Re: [PATCH 06/18] fsinfo: Add a uniquifier ID to struct mount [ver #21] Message-ID: <20200805193303.GM23808@casper.infradead.org> References: <159646178122.1784947.11705396571718464082.stgit@warthog.procyon.org.uk> <159646183662.1784947.5709738540440380373.stgit@warthog.procyon.org.uk> <20200804104108.GC32719@miu.piliscsaba.redhat.com> <2306029.1596636828@warthog.procyon.org.uk> <2315925.1596641410@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2315925.1596641410@warthog.procyon.org.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 05, 2020 at 04:30:10PM +0100, David Howells wrote: > Miklos Szeredi wrote: > > > idr_alloc_cyclic() seems to be a good template for doing the lower > > 32bit allocation, and we can add code to increment the high 32bit on > > wraparound. > > > > Lots of code uses idr_alloc_cyclic() so I guess it shouldn't be too > > bad in terms of memory use or performance. > > It's optimised for shortness of path and trades memory for performance. It's > currently implemented using an xarray, so memory usage is dependent on the > sparseness of the tree. Each node in the tree is 576 bytes and in the worst > case, each one node will contain one mount - and then you have to backfill the > ancestry, though for lower memory costs. > > Systemd makes life more interesting since it sets up a whole load of > propagations. Each mount you make may cause several others to be created, but > that would likely make the tree more efficient. I would recommend using xa_alloc and ignoring the ID assigned from xa_alloc. Looking up by unique ID is then a matter of iterating every mount (xa_for_each()) looking for a matching unique ID in the mount struct. That's O(n) search, but it's faster than a linked list, and we don't have that many mounts in a system. The maple tree will handle this case more effectively, but I can't recommend waiting for that to be ready.