From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22879 invoked by alias); 9 Oct 2014 14:51:32 -0000 Mailing-List: contact cygwin-developers-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner@cygwin.com Mail-Followup-To: cygwin-developers@cygwin.com Received: (qmail 22860 invoked by uid 89); 9 Oct 2014 14:51:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.9 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: calimero.vinschen.de Received: from aquarius.hirmke.de (HELO calimero.vinschen.de) (217.91.18.234) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 09 Oct 2014 14:51:31 +0000 Received: by calimero.vinschen.de (Postfix, from userid 500) id 88BE38E0A26; Thu, 9 Oct 2014 16:51:28 +0200 (CEST) Date: Thu, 09 Oct 2014 14:51:00 -0000 From: Corinna Vinschen To: cygwin-developers@cygwin.com Subject: Re: src/winsup/cygwin ChangeLog fhandler_proc.cc f ... Message-ID: <20141009145128.GA25442@calimero.vinschen.de> Reply-To: cygwin-developers@cygwin.com Mail-Followup-To: cygwin-developers@cygwin.com References: <20141009132437.7650.qmail@sourceware.org> <54369C4E.2030708@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="fUYQa+Pmc3FrFX/N" Content-Disposition: inline In-Reply-To: <54369C4E.2030708@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2014-10/txt/msg00001.txt.bz2 --fUYQa+Pmc3FrFX/N Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 2279 On Oct 9 08:31, Eric Blake wrote: > On 10/09/2014 07:24 AM, corinna@cygwin.com wrote: >=20 > > Log message: > > * fhandler_proc.cc (fhandler_proc::readdir): Set dirent d_type. > > * fhandler_process.cc (fhandler_process::readdir): Ditto. > > * fhandler_procnet.cc (fhandler_procnet::readdir): Ditto. > > * fhandler_procsys.cc (fhandler_procsys::readdir): Ditto. > > * fhandler_procsysvipc.cc (fhandler_procsysvipc::readdir): Ditto. > > * fhandler_virtual.h (virt_ftype_to_dtype): Define new inline function > > to generate dirent d_type from virtual_ftype_t. >=20 > Most of these look okay; but I have a problem with fhandler_procsys.cc: >=20 > > @@ -357,10 +358,17 @@ > > res =3D ENMFILE; > > else > > { > > + struct stat st; > > + char *file =3D tp.c_get (); > > + > > sys_wcstombs (de->d_name, NAME_MAX + 1, f.dbi.ObjectName.Buffer, > > f.dbi.ObjectName.Length / sizeof (WCHAR)); > > de->d_ino =3D hash_path_name (get_ino (), de->d_name); > > - de->d_type =3D 0; > > + stpcpy (stpcpy (stpcpy (file, get_name ()), "/"), de->d_name); > > + if (!lstat64 (file, &st)) > > + de->d_type =3D IFTODT (st.st_mode); > > + else > > + de->d_type =3D DT_UNKNOWN; >=20 > The whole point of d_type is for optimization, to tell a process when it > can avoid the overhead of an lstat() because the system was able to > obtain the information in a cheaper manner. But if you have to resort > to an lstat() to get the information, then you are wasting cycles on the > case of a user that doesn't care about d_type. I'd rather we always > return DT_UNKNOWN if the only way we'd get a better type is by calling > lstat(). I see. The idea here was to try and, at least on my machine, it was still *very* fast, likely because the whole thing occurs only in globally allocated memory and there's no disk access or paging involved. The question is, what exactly do we lose? /proc/sys isn't often accessed at all (I guess) and what could be gained? Yaakov asked for setting d_type under /proc, so he might enlighten us which tools make heavy use of the stuff, so the net gain is > 0... Corinna --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --fUYQa+Pmc3FrFX/N Content-Type: application/pgp-signature Content-length: 819 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJUNqDwAAoJEPU2Bp2uRE+gV5AQAIAIm6xwlGT62Zk0FHjoNTtT BM7utDTeKDBG2K45tEtbjJF1fVx0vT0eWb2iUXlIUv6SVfTUI8sb7hl2lxtZBFv8 nfSNgc8q4LgyEBxViawbYYiIOIh+mAIBHf9oG6TUfmB4gbghTEX4n+ux++7E3K5/ ekaMpFfqH6XH0OrcRb2Qm05TUdNGEB70giGDlezfsBqZRXNnl/Wbw3Xftc58CrYi 8dM0v0TmOn13zIedQ1BRHAN4rxQoEQtZzVfo1h7X6XcWL36JrG6wUiwBmgiq5AZw XeqKren8MyZ7dRYxtP+tbHfI7SW//JDK6LcfDs6U56l0AW3xKsouKBeFoiFvivoa 5POq+b8pL8wpgPEidCp1XSukU4HCSWk1ORI069O9kSBCQc7gOPHZT7DeEFBeSvDg WYDbTcu4IaxGQ0W6hNl6Wgiv+TRGIyGZAaQbbo8vGm0ZqPWBVRFaUlkpfiQhtut7 Gbq7lZ8VKfUIo59nXKxPud5jLVoaCwgTURIvnAfPiOpnqyvFzRFEPls5//HnnMNh nYduLYqaBUWS5h+jUKihxXdBTgXRrDrBlHcEM4AOfDP0E/8BiVi4obfPY94cE8d2 hhX0ioQ+FqiAwjnT6FtaY/RNtEeYvFM5Tkq5VdPeAz9AT6I/OUYCHNj/Co4cq+EC bkWNQPWusR5ILRA/FtxU =HU2P -----END PGP SIGNATURE----- --fUYQa+Pmc3FrFX/N--