From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04484E77350 for ; Sat, 30 Sep 2023 01:16:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233909AbjI3BQc (ORCPT ); Fri, 29 Sep 2023 21:16:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229489AbjI3BQa (ORCPT ); Fri, 29 Sep 2023 21:16:30 -0400 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0831F3; Fri, 29 Sep 2023 18:16:27 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 763C13200916; Fri, 29 Sep 2023 21:16:22 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 29 Sep 2023 21:16:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=themaw.net; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm1; t= 1696036581; x=1696122981; bh=fFeBd2wnRQFZEpz+r8VxUNSi+h4AN2LcJPK 4S1aXKis=; b=AsuR5BNr/3Zccy/Xb5uNgfZgXpVBovOZBwhYBQ0E4yfaaq7CpZh /ZQv/TbE0C6nViX/Qp/767ob3XI3jDp5fgYGH8kTpkTagAAjs9gVTpjdmtsKfsbM iop9rnxJsmUcFDBehPEvfSOO+7nAbOboC8ZPdwHIkrd07YZiVY7zuOkvbfYKAocI P3N0+NCCIBBgaNwcm4UQX7FyJxoo4ML+dmI3bXOkXI2ML+sqZ9tTjQEjJVPnXfTx AMoN59No0cz303+JEs9rjyOp4oTRmYj//EGMTHdBK4fAUSQ/M8U2NGQ1HCysUoV4 BbPMZhG7Qn9NYI5QOJhA1zKppl7F4uluoQA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1696036581; x=1696122981; bh=fFeBd2wnRQFZEpz+r8VxUNSi+h4AN2LcJPK 4S1aXKis=; b=MCPogdCTKEpWqzyxwXUoXwfpyQJygkdIURvYLbVFhBo218HKEjf 46mRPT8AH0p/CC32x0nIVVSbFNni23E0H3vQ+Ot6kSkWANtJr6jEtQAuUqYgtLcV zF3DGMUXDxFBYmbc6NCkFD0m44M+lQmqeyC4OONy01owuyCm88YMvx/v3k+5wWgm lJ3SFBfiF2ZfG9iZizW5/P7d9wqytHEIkCiiytYTvmV5BJdhLvv3TkevTZysgoHo EjzWUhlDBT6GZf6yqku6erzlBru/OPCNrsf6LZDnEV2TrEhcEZcFOQ+Yq18HhVxI bxZiGfCErYvgxcYUuHWbBQYU0j9qyNYf5sA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrtdehgddugecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfevfhfhjggtgfesthejredttdefjeenucfhrhhomhepkfgrnhcu mfgvnhhtuceorhgrvhgvnhesthhhvghmrgifrdhnvghtqeenucggtffrrghtthgvrhhnpe euhfeuieeijeeuveekgfeitdethefguddtleffhfelfeelhfduuedvfefhgefhheenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrrghvvghnse hthhgvmhgrfidrnhgvth X-ME-Proxy: Feedback-ID: i31e841b0:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 29 Sep 2023 21:16:14 -0400 (EDT) Message-ID: <348596f8-e88b-2e8b-96e2-20caaf5c9d7b@themaw.net> Date: Sat, 30 Sep 2023 09:16:11 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v3 3/4] add statmount(2) syscall To: Miklos Szeredi Cc: Miklos Szeredi , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-man@vger.kernel.org, linux-security-module@vger.kernel.org, Karel Zak , David Howells , Linus Torvalds , Al Viro , Christian Brauner , Amir Goldstein , Matthew House , Florian Weimer , Arnd Bergmann References: <20230928130147.564503-1-mszeredi@redhat.com> <20230928130147.564503-4-mszeredi@redhat.com> <5787bac5-b368-485a-f906-44e7049d4b8f@themaw.net> Content-Language: en-US From: Ian Kent In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29/9/23 17:10, Miklos Szeredi wrote: > On Fri, 29 Sept 2023 at 02:42, Ian Kent wrote: >> On 28/9/23 21:01, Miklos Szeredi wrote: >>> +static struct vfsmount *lookup_mnt_in_ns(u64 id, struct mnt_namespace *ns) >>> +{ >>> + struct mount *mnt; >>> + struct vfsmount *res = NULL; >>> + >>> + lock_ns_list(ns); >>> + list_for_each_entry(mnt, &ns->list, mnt_list) { >>> + if (!mnt_is_cursor(mnt) && id == mnt->mnt_id_unique) { >>> + res = &mnt->mnt; >>> + break; >>> + } >>> + } >>> + unlock_ns_list(ns); >>> + return res; >>> +} >> Seems like we might need to consider making (struct mnt_namespace)->list >> >> a hashed list. > Yes, linear search needs to go. A hash table is probably the easiest solution. > > But I'd also consider replacing ns->list with an rbtree. Not as > trivial as adding a system hash table and probably also slightly > slower, but it would have some advantages: > > - most space efficient (no overhead of hash buckets) > > - cursor can go away (f_pos can just contain last ID) I guess that would be ok. Avoiding the cursor is a big plus. An rbtree is used in kernfs and its readdir function is rather painful so I wonder what the implications might be for other enumeration needs. Ian