Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2254292rdh; Tue, 26 Sep 2023 18:31:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFex9U+TQEUvYdB9TQWlnWPHQeIW86YdlmmWBMusM4b0K3BNkyH4e2Kv0Y5a3R9w59ejaYU X-Received: by 2002:a05:6a00:c91:b0:68a:53e6:1fed with SMTP id a17-20020a056a000c9100b0068a53e61fedmr922167pfv.23.1695778305015; Tue, 26 Sep 2023 18:31:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695778305; cv=none; d=google.com; s=arc-20160816; b=WgBG22tjMrS1puGmN7ugeD+Ugre3cIKc8rSUITkq8aejNMR5NKREckWF9NSJwDAhL4 ndYbWDMj0k4R5lZNYXA6gS312FTeJBAyNQLCKtQ1kbvP4o2bqcTNv3nhUppD6kotuclH aet0lM8YmMIE4ST1KP4x7I72ejE+LkHBEqOxPzLo+MM00h0vM4IabBvotjaRpGA+IJdV KW+nTNzTSmMhTNviFckgX18/d1XqgrR0UGbQiBpGGqmxwY2s4Eu6mlOHqO5qsnJUGqem hQfNqyO6nQkfH0IXHlK2WbOpLECtbDr3CDtm4yq2mBZ77cS4tZG0FzIlz91wgNomUcvG GGtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=CLfoTuiOlkq71LtQIM368ZbzJBNnHFUnsO5iHo6yhEM=; fh=GIEBknSoYkKw8qkoUJqS/tSoQT824HIc6B13M+w0+0M=; b=AlI2096XRi022yOsb9v26Ai2kNvj5M1iVyUM2f11hk9cH9OLY46QVk90RLBE1hIAUY n80D3y13Sa3cRXhZN4FGkDQ8QoUBYiRRG5dr0qIt2kvb0eBWX1/UYWKXGwNe3ktzgBKR ZrMVAtAqSQg0SciNPxE/j6u9C4L27ZpqPyKbM4eudmbc2+nrUezZ+9qxpc4y5A/nOx1d NQMtMAh0sHAGSUsCBdOGSyyOjrOuBLbgygBSSMOFzCqN4Ldjmo+3BuxIkUDKq1vYnib3 UvW8rMPjqY/IEQOPnRiXEK3GpeehQU0os2urjtOl1fq6yp+C6q08VcWtlYSINkVn0ZDh 5vsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eVn23K6v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id cl4-20020a056a0032c400b00693366c707fsi468547pfb.299.2023.09.26.18.31.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 18:31:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eVn23K6v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 93F3A8051B34; Tue, 26 Sep 2023 07:20:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232626AbjIZOUt (ORCPT + 99 others); Tue, 26 Sep 2023 10:20:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232954AbjIZOUs (ORCPT ); Tue, 26 Sep 2023 10:20:48 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6524211D for ; Tue, 26 Sep 2023 07:19:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695737995; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=CLfoTuiOlkq71LtQIM368ZbzJBNnHFUnsO5iHo6yhEM=; b=eVn23K6vPxGTA9xe79fRwdiwwYhjxgu5HBzPw9wNKZz4opStTbXp7pvSUo2prWAZ5+eKYX PEax4QaYssEgCw6YPOn/NWIpKHrSSXNiTmUae6gIeZninqcvm0IzZ0eoddSjhYnl1yOT6M CgfI5HjeW/Qbsznj9lg6vB2j3SOEJMc= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-96-Za_WVKlVMr-fkse-WyoN-g-1; Tue, 26 Sep 2023 10:19:50 -0400 X-MC-Unique: Za_WVKlVMr-fkse-WyoN-g-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 906C03C1ACE4; Tue, 26 Sep 2023 14:19:49 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.53]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A1F78492C37; Tue, 26 Sep 2023 14:19:47 +0000 (UTC) From: Florian Weimer To: Miklos Szeredi Cc: Miklos Szeredi , Christian Brauner , Linus Torvalds , 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 , Ian Kent , David Howells , Al Viro , Christian Brauner , Amir Goldstein Subject: Re: [RFC PATCH 2/3] add statmnt(2) syscall References: <20230913152238.905247-1-mszeredi@redhat.com> <20230913152238.905247-3-mszeredi@redhat.com> <20230914-salzig-manifest-f6c3adb1b7b4@brauner> <20230914-lockmittel-verknallen-d1a18d76ba44@brauner> <20230918-grafik-zutreffen-995b321017ae@brauner> <871qeloxj0.fsf@oldenburg.str.redhat.com> Date: Tue, 26 Sep 2023 16:19:46 +0200 In-Reply-To: (Miklos Szeredi's message of "Tue, 26 Sep 2023 16:06:05 +0200") Message-ID: <87wmwdnhj1.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 26 Sep 2023 07:20:48 -0700 (PDT) * Miklos Szeredi: >> Try-and-resize interfaces can be quite bad for data obtained from the >> network. > > In this particular case it's all local information. That's good. >> If the first call provides the minimum buffer size (like >> getgroups, but unlike readlink or the glibc *_r interfaces for NSS), >> this could at least allow us to avoid allocating too much. In >> userspace, we cannot reduce the size of the heap allocation without >> knowing where the pointers are and what they mean. > > Does it matter if the heap allocation is say 32k instead of 589bytes? > The returned strings are not limited in size, but are quite unlikely > to be over PATH_MAX. It matters if the application needs to keep a copy. > E.g. getdents apparently uses 32k buffers, which is really a tiny > amount of heap these days, but more than enough for the purpose. Not > sure if this is hard coded into libc or if it's the result of some > heuristic based on available memory, but I don't see why similar > treatment couldn't be applied to the statmount(2) syscall. getdents gets away with this buffer size because applications can copy out all the data from struct dirent if they need long-term storage. They have to do that because the usual readdir interface overwrites the buffer, potentially at the next readdir call. This means the buffer size does not introduce an amount of memory fragmention that is dependent on the directory size. With an opaque, pointer-carrying struct, copying out the data is not possible in a generic fashion. Only the parts that the application knows about can be copied out. So I think it's desirable to have a fairly exact allocation. >> I also don't quite understand the dislike of variable-sized records. >> Don't getdents, inotify, Netlink all use them? And I think at least for >> Netlink, more stuff is added all the time? > > What do you mean by variable sized records? Iterating through d_reclen-sized subojects (for getdents). Thanks, Florian