Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp516856rwb; Sat, 17 Sep 2022 09:15:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7jqg9P1ej/9oamh/UIj1JMyhKhggNQAt3WW3HuiR5T2v2/A7VSyemnFCbtd3YrlXD+Q+nZ X-Received: by 2002:a05:6402:228d:b0:44e:f15e:a841 with SMTP id cw13-20020a056402228d00b0044ef15ea841mr8163925edb.157.1663431313703; Sat, 17 Sep 2022 09:15:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663431313; cv=none; d=google.com; s=arc-20160816; b=ZCb3urOnXg2dSHcuzzZ2YpTi5JbqC7SUrET98S6eLzi3fN4kukiFA61X64NxfgF0RE FtfXxPA7UD4f3C9CzNGO5Mxuwa8w57+iFkoFb3i7RpEEg8iWOBDKFkqeCegVhl0+dPpS ZXGKqQGE/f64ClV0QpHJLYY34gTvi7u02YeTXL8vND9jPNgmGYnBCmA3DTorTvYBpjw/ hcA07RdSqsVpwDBk8l/U4mPR/q6WYOmCMIZ+PDUAVdJP7RQ3rp8g4SpcosQOrRaMJs74 rddNPPRz6nM1OlRGdCNPj9ifCiDAp5HrVyBq6Y+ueqykH5vvX7txCsA+t6YEYBC5E91t s/Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=P8X7BrdrxW4HqvXTvhAMJnCX+huMjVN2Vx33TFJijmA=; b=u7BryLxUxaOK10yj1fBjOJOQv96dXdl8RlwCPa9NKjUD3nBf/DiYStMYSK4lO47Rzc fygY0XkYZ2SDGuPF4swEBRNBBLor6aB3l6UmoC0uWFzMrGEPT7w8KR4Yet2hBPyrUcm2 REvOYAzEiBPm+BzHdIjWwz5hpoErzJwGn5PweIO34B98bMESn6ZuQTddOOsBocY4YnM2 puQjc872muVqBCruBtspWoX20pt1m8Sj3YTJlU1aWWtnjC9HyQCunDBPO8oDFnNPWLAj BZmyucHffIIhuGiCLqyz8tIgdbgceyWtUIv4StU5YUGtz6IhADvgAQdiri4IxcPqrnQK GSpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mit.edu header.s=outgoing header.b=dx2CCf8S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mit.edu Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c12-20020a05640227cc00b004515d9b26d3si5947315ede.406.2022.09.17.09.14.46; Sat, 17 Sep 2022 09:15:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@mit.edu header.s=outgoing header.b=dx2CCf8S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mit.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229488AbiIQPbu (ORCPT + 99 others); Sat, 17 Sep 2022 11:31:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbiIQPbr (ORCPT ); Sat, 17 Sep 2022 11:31:47 -0400 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 771EEB7D9; Sat, 17 Sep 2022 08:31:45 -0700 (PDT) Received: from letrec.thunk.org (c-73-142-117-47.hsd1.ma.comcast.net [73.142.117.47]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 28HFVZET013813 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 17 Sep 2022 11:31:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=outgoing; t=1663428698; bh=P8X7BrdrxW4HqvXTvhAMJnCX+huMjVN2Vx33TFJijmA=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=dx2CCf8SULDqFSMxx4Io4Pb2S1UjZqIRtq5xrTqs1ZLZx6xVGAz7lH1SYeUifAxWF gMHTdZzc0rK+2+nihZ9NI0p+hv9NvWHEk3lB5rkISBtmJ8pOozsyI96G2SyoprXXsx TagAFilQi7hJvNGQlCD2r8T1Xvsc7NW8dxjmnRcyLVKSe1haDmMkZthdOlL0MDkvNE 7tT4IetagYU98i/2gYgVBHtNK1gra9YfTJI+wKzzN3xQPZ8ADyzsRhBO08D3ZJRu6d 2PV5bIq3RS85iF08b6xbNhcGL67slp4S3IdSKrS8nUYjau3vRg1TgunZpt0eclJs2a 03LDc+lWe8wbA== Received: by letrec.thunk.org (Postfix, from userid 15806) id 5F8468C2C23; Sat, 17 Sep 2022 11:31:35 -0400 (EDT) Date: Sat, 17 Sep 2022 11:31:35 -0400 From: "Theodore Ts'o" To: Ivan Babrou Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@cloudflare.com, Andrew Morton , Kalesh Singh Subject: Re: [RFC] proc: report open files as size in stat() for /proc/pid/fd Message-ID: References: <20220916230853.49056-1-ivan@cloudflare.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220916230853.49056-1-ivan@cloudflare.com> X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 16, 2022 at 04:08:52PM -0700, Ivan Babrou wrote: > We considered putting the number of open files in /proc/pid/stat. > Unfortunately, counting the number of fds involves iterating the fdtable, > which means that it might slow down /proc/pid/stat for processes > with many open files. Instead we opted to put this info in /proc/pid/fd > as a size member of the stat syscall result. Previously the reported > number was zero, so there's very little risk of breaking anything, > while still providing a somewhat logical way to count the open files. Instead of using the st_size of /proc//fd, why not return that value in st_nlink? /proc//fd is a directory, so having st_nlinks return number of fd's plus 2 (for . and ..) would be much more natural. Cheers, - Ted