From: Florian Weimer <fweimer@redhat.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH 3/3] Refactor atfork handlers
Date: Tue, 20 Feb 2018 12:57:00 -0000 [thread overview]
Message-ID: <7b71dd04-afd0-9ff0-79c3-3d47cbd77ee2@redhat.com> (raw)
In-Reply-To: <a2c3a2e6-d983-d5aa-9291-76399736ddba@linaro.org>
On 02/08/2018 01:50 PM, Adhemerval Zanella wrote:
> +static struct fork_handler *
> +fork_handler_list_find_if (struct fork_handler_list *fork_handlers,
> + void *dso_handle)
Should be called _find, not find_if (no callback is involved).
> + struct fork_handler *first = fork_handler_list_find_if (&fork_handlers,
> + dso_handle);
> + /* Removing is done by shifting the elements in the way the elements
> + that are not to be removed appear in the beginning in dynarray.
> + This avoid the quadradic run-time if a naive strategy to remove and
> + shift one element at time. */
> + if (first != NULL)
> + {
> + struct fork_handler *result = first;
result should probably be called new_end or something like that.
> + first++;
> + for (; first != fork_handler_list_end (&fork_handlers); ++first)
> + {
> + if (first->dso_handle != dso_handle)
> + {
> + memcpy (result, first, sizeof (struct fork_handler));
Wouldn't a simple struct assignment work here?
I think this patch is a step in the right direction, so it should go in
with these changes.
However, I think we should make a few improvements in follow-up fixes:
Reduce RSS usage for the common case that no atfork handlers are ever
registered. This will be the case once we remove the bogus
__reclaim_stacks function.
Make a temporary copy of the handler array during fork. This has two
benefits: We can run the handlers without acquiring the handler lock (to
avoid application deadlocks). We also make sure that a handler does not
run in a child process which did not run in the parent process. I think
the old implementation had both properties.
Thanks,
Florian
next prev parent reply other threads:[~2018-02-20 11:29 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-07 14:10 [PATCH 1/3] Refactor Linux ARCH_FORK implementation Adhemerval Zanella
2018-02-07 13:09 ` [PATCH 3/3] Refactor atfork handlers Adhemerval Zanella
2018-02-07 15:13 ` Florian Weimer
2018-02-07 17:38 ` Adhemerval Zanella
2018-02-08 11:26 ` Florian Weimer
2018-02-08 13:49 ` Adhemerval Zanella
2018-02-20 12:57 ` Florian Weimer [this message]
2018-02-20 13:26 ` Adhemerval Zanella
2018-02-20 13:27 ` Florian Weimer
2018-02-20 13:30 ` Adhemerval Zanella
2018-02-20 13:48 ` Florian Weimer
2018-02-20 13:58 ` Adhemerval Zanella
2018-02-20 13:59 ` Florian Weimer
2018-02-20 17:22 ` Adhemerval Zanella
2018-02-23 12:17 ` Florian Weimer
2018-02-23 17:42 ` Adhemerval Zanella
2018-02-27 12:03 ` Florian Weimer
2018-02-07 13:35 ` [PATCH 2/3] dynarray: Implement remove function Adhemerval Zanella
2018-02-07 15:07 ` Alexander Monakov
2018-02-07 17:16 ` Adhemerval Zanella
2018-03-07 16:51 ` [PATCH 1/3] Refactor Linux ARCH_FORK implementation Adhemerval Zanella
2018-03-08 12:05 ` Florian Weimer
2018-03-08 12:58 ` Adhemerval Zanella
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7b71dd04-afd0-9ff0-79c3-3d47cbd77ee2@redhat.com \
--to=fweimer@redhat.com \
--cc=adhemerval.zanella@linaro.org \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).