From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Florian Weimer Newsgroups: gmane.comp.lib.glibc.alpha Subject: Re: [PATCH 3/3] Refactor atfork handlers Date: Tue, 20 Feb 2018 14:05:48 +0100 Message-ID: <9d8251a8-7604-9846-ebde-409786e2ebf4@redhat.com> 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> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1519131835 5966 195.159.176.226 (20 Feb 2018 13:03:55 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 20 Feb 2018 13:03:55 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 Cc: libc-alpha@sourceware.org To: Adhemerval Zanella Original-X-From: libc-alpha-return-90398-glibc-alpha=m.gmane.org@sourceware.org Tue Feb 20 14:03:51 2018 Return-path: Envelope-to: glibc-alpha@blaine.gmane.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:cc:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=a9hAfZ8TVRCpwHLK GxXHNQd6uG5VS4p13SCx7KB8gzzjMkyd3WzBYAaie1PLrIyJ10oCtpUbCedrQKvU JsgnkD2Cy4zEMUdNiPoMCjQLlWGLRsfCFmACyKIuj2i/u0TA7RQAuxsMLoiLk0PC aUjZ6x80zLhLsF7tTLB1+xaCr3w= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:cc:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=1nt8XNWK6VkcH1Bl0nlDT0 y2B5w=; b=tqnC0Btw2IWsReYWeKn96116V8kvlcODSuNlgGS98yLbbkgSCcv+9R WhR8ssK0xdNZ6bKUV7qiDXzsTj+TBfJL08ozHRD39ytTskVwHjK/s51f+OO9Rwja ljRX1MSrWrSEaq8oGdGmbNmW5Q28lGiVWkEmMxqRJL1Kaz+XgPlCc= Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Original-Sender: libc-alpha-owner@sourceware.org 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 In-Reply-To: <4aad8145-b06f-4d95-315a-73d5f2253971@linaro.org> Xref: news.gmane.org gmane.comp.lib.glibc.alpha:82730 Archived-At: Received: from server1.sourceware.org ([209.132.180.131] helo=sourceware.org) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eo7aI-0001EZ-Ty for glibc-alpha@blaine.gmane.org; Tue, 20 Feb 2018 14:03:51 +0100 Received: (qmail 52469 invoked by alias); 20 Feb 2018 13:05:53 -0000 Received: (qmail 52458 invoked by uid 89); 20 Feb 2018 13:05:53 -0000 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