Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp709177rwb; Sat, 17 Sep 2022 13:18:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7raUjHfssVyuDopDpdU8LdKEzcS5OOBjMJDotasNOUw+iRFcW3I3fd2JGGGueKKSqtZNvb X-Received: by 2002:a05:6402:1909:b0:451:ace7:ccbd with SMTP id e9-20020a056402190900b00451ace7ccbdmr8935107edz.276.1663445936042; Sat, 17 Sep 2022 13:18:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663445936; cv=none; d=google.com; s=arc-20160816; b=VAk7aW6Z87GwGHx1UWNITRtBVZA7RPGIfserdnKgNzIm80yy3HdtJAjwkkj+lz8c2c 1PseNLTknrQyybohSgraBuHjTNVxeiACalFFxFph6g3OJsy34T4HalJybrabiFNjMjq9 f6IC8jjg9EbXfTPc2KFvcAX15tEzl+saN+UhmsxbbJtHQaz+gKx/qX4iPXbiYmAYNg26 QwOUqz9Qxr1zFAKNoU5O2rEuYxaJEB/hXX9vj5UuRmidG9CKc1oYBHUGmktOK5t30rBe tRtxO55d8a2KybKmfU8EmJCcZsNdU7NU4JZx+Otbvsb5iz11I/Qb0tJ3NOYLPeyM9u+T vNtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ddmg5bRCAtXyxOkY+3dyLtIUd+SwkxVDg5Z+QEuBU9w=; b=wyTA8l9JSVy/nQm+KcRkQwiq0rZMAq7a40GPz+4J0ZKMeWu5UIxmBFQGV8lHb34rYo upQhVpGI6b49hzr/GIaFYU7FGXRaY0gYh04eFXgSjTv6XiyzHZVxVNOC7LguyO5jx+l3 O56g4YznuR6nBN1/7wisYXLjhr7Lks5sTEIiyaLea6eZ2v77O1omGcDCTJwe5NmB2xw2 8FXCQuU4c/ROs8seqoqd+Hev1OWaRAE0SioTsMoHOIrk+t8raOU/AKhpFE9t2BLXAgVi ZpqtccJjGbZyyezzleZTWaR7wUgqBiWqJWkDDV0RZqORK/pixK+xex8fldLunv4lVRAk 4PEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=lcwodcX5; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cw10-20020a170906c78a00b007416895306fsi17024742ejb.645.2022.09.17.13.18.21; Sat, 17 Sep 2022 13:18:56 -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=pass header.i=@cloudflare.com header.s=google header.b=lcwodcX5; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229612AbiIQScY (ORCPT + 99 others); Sat, 17 Sep 2022 14:32:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229570AbiIQScQ (ORCPT ); Sat, 17 Sep 2022 14:32:16 -0400 Received: from mail-yw1-x1130.google.com (mail-yw1-x1130.google.com [IPv6:2607:f8b0:4864:20::1130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A52462CCB3 for ; Sat, 17 Sep 2022 11:32:15 -0700 (PDT) Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-3321c2a8d4cso296471727b3.5 for ; Sat, 17 Sep 2022 11:32:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=ddmg5bRCAtXyxOkY+3dyLtIUd+SwkxVDg5Z+QEuBU9w=; b=lcwodcX5v2bqj7Qs6vsBtAbOPk+cjgDXQ4hiyf44oGWS8dLoCDVWheuZdnNGu7eg1u nvizPsQUjW/BmgPIj7B9Jr0ScoMzbN2JnYV3ZuWsVuTwLSu4+BWKQymWM5SI4afLlbeU YphL4O1TBH8aniK9Hz/cYYXW+cBIXLPUpHpLA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=ddmg5bRCAtXyxOkY+3dyLtIUd+SwkxVDg5Z+QEuBU9w=; b=mJou69gAfp6zYRJ7aSHIU5SNJgCx3xRChz9M3m6ia0IG/4VQv5buC9HEGZYsIzSd5E ZI/ifgICcJyXG4ZBCEoD0zxJxijVLQllfniUS8bCkIygk9UkgIF/aPyzr78TdZ9AgD48 ADmg28J6B+1Zv1BruPzfDSNwLsCWW7H+f8R+xpxtkvd7/oC99be0ESh4bU9pnSLPcICX dXXI+uYF9/eGyzeO8GFBnwof8JJE83h6SmyNCkndAYri1a0frWpxtbLMg64IpSEcx9Vs wsqxzzpBsh+yt5i2+Jb/JgfzVKoEUkhTsLvZjdyT7kB6Z0ppgNhM1UsnmdylHdp05Wq9 Ra+Q== X-Gm-Message-State: ACrzQf0IqznCr2YGxe30TZsxY4pvoB5PNfPuGfEwqml0/YTb/AR/Aybm bXW4XFCqe87sx3OuLrQ4RZMGe1yy76JqfH0xgtjn9Q== X-Received: by 2002:a0d:e80b:0:b0:345:1c88:2885 with SMTP id r11-20020a0de80b000000b003451c882885mr8675871ywe.322.1663439534933; Sat, 17 Sep 2022 11:32:14 -0700 (PDT) MIME-Version: 1.0 References: <20220916230853.49056-1-ivan@cloudflare.com> In-Reply-To: From: Ivan Babrou Date: Sat, 17 Sep 2022 11:32:04 -0700 Message-ID: Subject: Re: [RFC] proc: report open files as size in stat() for /proc/pid/fd To: "Theodore Ts'o" Cc: linux-fsdevel@vger.kernel.org, linux-kernel , kernel-team , Andrew Morton , Kalesh Singh Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 Sat, Sep 17, 2022 at 8:31 AM Theodore Ts'o wrote: > > 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. From what I see, st_nlinks is used for the number of subdirectories and it doesn't include files. In /proc/fd we only have files (well, symlinks really). I'm still happy to use that instead if that's preferred.