From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Adhemerval Zanella Newsgroups: gmane.comp.lib.glibc.alpha Subject: Re: [PATCH 3/3] Refactor atfork handlers Date: Tue, 20 Feb 2018 10:27:45 -0300 Message-ID: <780cefa6-543f-1a04-4b4e-9059a30d211b@linaro.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> <9d8251a8-7604-9846-ebde-409786e2ebf4@redhat.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1519133157 20069 195.159.176.226 (20 Feb 2018 13:25:57 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 20 Feb 2018 13:25:57 +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: Florian Weimer Original-X-From: libc-alpha-return-90400-glibc-alpha=m.gmane.org@sourceware.org Tue Feb 20 14:25:53 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=Kjjq9sawahWUfQCc sS5o+b/vFR754r96wUlDDNaHyrerfV0ncFx+E5K8lO6cC9OCNbPfB5moKjLvOBAB YIKprbIwJsRClv4cGmk2G6IJgkMuaoa+DtSsDlqOS2PAM9xcok5tYP8ewIPNkhSS YL3ZquUsvf1jpBC7DjbUV78unJI= 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=njE721HVQRBKiQTIQ8smzq QW3iQ=; b=DETRtYEjEfeomiEaCTmdR+uyFLHmT896pY4gfGlQPTdidx5Prt8il0 P8D5xtExWMyZEcMfhQBrRDrVKnNXGC7UjBNPeKp2ON7aRLpE5rbUlghZL6ST03tq 2Jz9uuzv2s3Tc4SsxDrFYQnXrgW+kXSgtfjX4DgxyEJ+CtfxHflVY= 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=-3.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=held, our X-HELO: mail-qt0-f193.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=vYgcqsBgndSPd/E5BTqMx3igeiFdcUna+2AG+hxYBwI=; b=REh0bhgpTB36PahbJTAxn/pejvWLpeg6YQYbtdAh08xNXf8fRtG2QxSiawYq8ymJgO 7InjEdzUjPb30OMNvYqgXVLOvSSPHhJpGKCwyTO1sFiYTinZ/JP0mqrdJrb+tMYUnQ7r uUN6g8k+o2Oqkn0wM96qxvOGScPa1LBUXnnwFa2J8dl3RNPNrz5saqSipNRvjq8cBrBd Ob2i8dZ8qTs7Ff5/K0aU8S/ojdV/6hOaEXnHwwYGIyFxDo3PZIUFlLEMkVY8Hvcdr+U8 d3hL/7pp7Bg7Ti73hJ81oIv/KyZWVv72uXd4yEq5CbfvaQA6AgDD2tfk9qd6opp3y4Nw MAnA== X-Gm-Message-State: APf1xPA5nZLiND7eou495Ziavw9oyuWsundj+9wp1qUiL3gF9Fy4p/yM P3JUhFN6N8efIdPmIFqknVHfjBNTcqk= X-Google-Smtp-Source: AH8x225JRZt2bBsUyIvR2Y2KAXZjURxRDj9J2kaqkPXOBVSovpSZ3MULud3UtxjkvXxCRiOED5YIrw== X-Received: by 10.200.35.235 with SMTP id r40mr27754498qtr.256.1519133271040; Tue, 20 Feb 2018 05:27:51 -0800 (PST) In-Reply-To: <9d8251a8-7604-9846-ebde-409786e2ebf4@redhat.com> Xref: news.gmane.org gmane.comp.lib.glibc.alpha:82732 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 1eo7vb-0004sw-VN for glibc-alpha@blaine.gmane.org; Tue, 20 Feb 2018 14:25:52 +0100 Received: (qmail 19017 invoked by alias); 20 Feb 2018 13:27:54 -0000 Received: (qmail 17073 invoked by uid 89); 20 Feb 2018 13:27:54 -0000 On 20/02/2018 10:05, Florian Weimer wrote: > 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. I think it might occur with proposed implementation only if a callback tries to call pthread_atfork or fork itself. It these scenario you have in mind? And should we really support them if this is the case? > >> 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. >