From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 52469 invoked by alias); 20 Feb 2018 13:05:53 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 52458 invoked by uid 89); 20 Feb 2018 13:05:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=held, our X-HELO: mx1.redhat.com Subject: Re: [PATCH 3/3] Refactor atfork handlers To: Adhemerval Zanella Cc: libc-alpha@sourceware.org References: <1518008967-8310-1-git-send-email-adhemerval.zanella@linaro.org> <1518008967-8310-3-git-send-email-adhemerval.zanella@linaro.org> <88a58530-092d-4daa-1096-97a1bf8e08ff@redhat.com> <7b71dd04-afd0-9ff0-79c3-3d47cbd77ee2@redhat.com> <4aad8145-b06f-4d95-315a-73d5f2253971@linaro.org> From: Florian Weimer Message-ID: <9d8251a8-7604-9846-ebde-409786e2ebf4@redhat.com> Date: Tue, 20 Feb 2018 13:27:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <4aad8145-b06f-4d95-315a-73d5f2253971@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2018-02/txt/msg00544.txt.bz2 On 02/20/2018 02:00 PM, Adhemerval Zanella wrote: > The temporary copy is problematic because we either need to allocate on the stack using > vla/alloca (current practice and prone of stack overflow) or by malloc (which requires > locking anyway). Also, to temporary copy we will need pretty much the same lock-free > algorithm which adds code complexity. I think the lock in malloc is fine, at least for the time being, with our non-async-safe fork. The point is not avoiding the lock, but callbacks when the lock is held. This can easily result in deadlocks. > My understanding is current algorithm tries hard to remove any locking on fork generation > mainly because back then posix_spawn was no specified and suboptimal. Now that we have > a faster way to spawn process in multithread environment I think there is no much gain > in trying to optimizing locking in atfork handlers. I think it's also needed to avoid deadlocks . > Regarding the handler running in child process the proposed implementation does implement > it. I don't see how? I meant that only those handlers run that ran in the parent. I think there's a window where more fork handlers can be added. Thanks, Florian