From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?Am=C3=A9rico_Wang?= Subject: Re: [PATCH] vfs: does call expand_files when needed Date: Wed, 18 Nov 2009 16:35:13 +0800 Message-ID: <2375c9f90911180035v45b3f732gfe898092583a667a@mail.gmail.com> References: <2375c9f90911172317x781e22a9y56ecb8e682e8e061@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Alexander Viro , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org To: Liu Aleaxander Return-path: Received: from mail-qy0-f174.google.com ([209.85.221.174]:40768 "EHLO mail-qy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753421AbZKRIfI convert rfc822-to-8bit (ORCPT ); Wed, 18 Nov 2009 03:35:08 -0500 In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Wed, Nov 18, 2009 at 3:41 PM, Liu Aleaxander = wrote: > On Wed, Nov 18, 2009 at 3:17 PM, Am=C3=A9rico Wang wrote: >> >> On Wed, Nov 18, 2009 at 1:54 PM, Liu Aleaxander wrote: >> > From: Liu Aleaxander >> > Date: Wed, 18 Nov 2009 10:59:09 +0800 >> > Subject: [PATCH] vfs: does call expand_files when needed >> > >> > I don't think we should call expand_files every time we open a >> > file for a new unused fd, so does the expand when necessary. >> > >> > Signed-off-by: Liu Aleaxander >> > --- >> > =C2=A0fs/file.c | =C2=A0 27 ++++++++++++++------------- >> > =C2=A01 files changed, 14 insertions(+), 13 deletions(-) >> > >> > diff --git a/fs/file.c b/fs/file.c >> > index 87e1290..3f3d0fc 100644 >> > --- a/fs/file.c >> > +++ b/fs/file.c >> > @@ -452,22 +452,22 @@ repeat: >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0if (fd < files->next_fd) >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fd =3D file= s->next_fd; >> > >> > - =C2=A0 =C2=A0 =C2=A0 if (fd < fdt->max_fds) >> > + =C2=A0 =C2=A0 =C2=A0 if (likely(fd < fdt->max_fds)) { >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fd =3D find= _next_zero_bit(fdt->open_fds->fds_bits, >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 fdt->max_fds, fd); >> > - >> > - =C2=A0 =C2=A0 =C2=A0 error =3D expand_files(files, fd); >> > - =C2=A0 =C2=A0 =C2=A0 if (error < 0) >> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 goto out; >> > - >> > - =C2=A0 =C2=A0 =C2=A0 /* >> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0* If we needed to expand the fs array= we >> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0* might have blocked - try again. >> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0*/ >> > - =C2=A0 =C2=A0 =C2=A0 if (error) >> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 goto repeat; >> > - >> > + =C2=A0 =C2=A0 =C2=A0 } else { >> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 error =3D expan= d_files(files, fd); >> >> >> In expand_files(), it has the check for >> ' < fdt->max_fds', so this change is not necessary. > > Yeah, indeed. But why we should go into an another function to do a > _double_ check especially we mostly don't need to do that? You only optimized one call path, it's trivial, not so much an improvement, IMO. -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html