From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Subject: Re: /proc/pid/fd/ shows strange mode when executed via sudo. Date: Fri, 18 May 2012 22:23:02 +0100 Message-ID: <20120518212302.GW22082@ZenIV.linux.org.uk> References: <201205181139.IAI65153.OQOtFVJFHLSMOF@I-love.SAKURA.ne.jp> <201205181827.BAF57803.OLQMFVtFFOHSJO@I-love.SAKURA.ne.jp> <20120518180812.GR22082@ZenIV.linux.org.uk> <20120518184526.GS22082@ZenIV.linux.org.uk> <20120518191023.GU22082@ZenIV.linux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Tetsuo Handa , ebiederm@xmission.com, linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org To: Linus Torvalds Return-path: Received: from zeniv.linux.org.uk ([195.92.253.2]:49215 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967861Ab2ERVXK (ORCPT ); Fri, 18 May 2012 17:23:10 -0400 Content-Disposition: inline In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Fri, May 18, 2012 at 01:49:18PM -0700, Linus Torvalds wrote: > I think you're optimizing the wrong case, and adding code to do so. > > The ENOENT case never happens in practice - there's no sane situation > where you'd look up a non-existend /proc/xyz/fd/X file. I would agree if we only called that on lookup. We also do that on readdir(), for every descriptor in range 0..files->max_fds-1. So if you have sufficiently sparse set of descriptors, it will be called a _lot_. Moreover, that's the usual path for calling it, exactly because we do getdents before trying to open/lstat/anything else.