On Mon, Nov 4, 2019 at 8:52 AM Krzysztof Kanas <kka...@marvell.com> wrote:
>
> On 19-10-30 10:06, David Marchand wrote:
> > External Email
> >
> > ----------------------------------------------------------------------
> > On Mon, Sep 2, 2019 at 11:50 AM <kka...@marvell.com> wrote:
> > >
> > > From: Krzysztof Kanas <kka...@marvell.com>
> > >
> > > process_dup was intending to close it's own fd's but failed to do so
> >
> > A bit hard to digest, what is the problem that you want to fix?
> >
> > Thanks.
>
> I don't recall the exact test name but I think it was test_eal_flags
> that is included in the meson test suite for fast tests.
> This test was timing out on ARM64.
>
> Using strace (-f -c IIRC) showed that the process is spending most of
> the time in access syscall trying to close not existing fd's.
>
> -               for (fd = getdtablesize(); fd > 2; fd-- ) {
> -                       snprintf(path, sizeof(path), "/proc/" exe "/fd/%d", 
> fd);
> -                       if (access(path, F_OK) == 0)
> -                               close(fd);
>
> So the simplest way to do so is to close only the opened fd's not
> blindly try every possible one.
>
> Also I think the code was wrong in another way as it tried to iterate
> over /proc/ *exe* /fd/%d/ when it should iterate over /proc/ *self*
> /fd/, so either the comment bove the for loop was wrong or the code was
> incorrect.

Thanks.
I agree that this loop is terrible.
I have some comments on the patch.


-- 
David Marchand

Reply via email to