From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10515 Path: news.gmane.org!.POSTED!not-for-mail From: Denys Vlasenko Newsgroups: gmane.linux.lib.musl.general Subject: Re: Re: [PATCH] make fflush_unlocked(NULL) work Date: Sun, 25 Sep 2016 01:49:38 +0200 Message-ID: References: <20160918194455.21981-1-vda.linux@googlemail.com> <20160918203608.GB15995@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1474761024 24537 195.159.176.226 (24 Sep 2016 23:50:24 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 24 Sep 2016 23:50:24 +0000 (UTC) To: musl Original-X-From: musl-return-10528-gllmg-musl=m.gmane.org@lists.openwall.com Sun Sep 25 01:50:20 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1bnwhx-0005DT-W6 for gllmg-musl@m.gmane.org; Sun, 25 Sep 2016 01:50:14 +0200 Original-Received: (qmail 27824 invoked by uid 550); 24 Sep 2016 23:50:12 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 27803 invoked from network); 24 Sep 2016 23:50:11 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=m1LNW1uLeFsl8ppsD+s6OEqn9lF4CeNb9m4+z1RUJvo=; b=XtrbXw6Cq0v5VvIKSOnwv0mcqjcrHAg4q/YOlAL0Jk8a6KO4Gsw1Cw7rFDf94QGCJi 0Oyw1WvQsTi/UlCHnckYNpEyQVMbb02IYLK5afTRrR3uR4g8p2HSSYQz2innq/RGQSyO z6KZANfrbdfkKNLJWQ6WDbSWtRomNv9OghY1fkx+nnZ7qwU+isb0/1fSM2/0O/wHfMYY aOwoOXe/DTZYqVcRDJeAaLhnYXuYPGvq7tl7UrUT0vfUHhgsRwrw1uF9vEIQgsWFPsZD Rd90WX23PHsTQ6OawRAULfTmA4Fmliqgwq1w0DU/Stq3rI66A8pKz0WODbkDftcQRowb lltg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=m1LNW1uLeFsl8ppsD+s6OEqn9lF4CeNb9m4+z1RUJvo=; b=Eezp7PunAyzNUx24O+OoHVZqqmkU0ATZCUmAs9XUP2QRXSGBuSx/m8Yde1Bx17K9T9 /0Q9toccQbPlQGY3aUCiXSik4AAW+8h8YpUCf4psjrTGHWb+zKc4/mteB+QoBzXib7HY jPc/4Fd11/7AopYhCpz7qTKitM8rmgsUQIt2awjDM2gpliHKQsb2pHzC2qAD4EmDnUrv DaduwIx49jVgfW/sFkgVT/wv2wMhlJneoGdkHyDjBsghBOy1Nwq/dFfWMX/sIp9OgSMF XcgrKaYLdI36ir0dsNm3X55ttKrTB0z7Muf2vfZI3nO3HIqq1OCbigmXLNdXjFcIBftb M/Aw== X-Gm-Message-State: AA6/9RlRT6XwB5LR2/UzlU7hZb55dK51U4tD7tgdvMNZDxoCN3cniUYrhi+IzHY1q+O2WmL8U0yQaetzTuT8OA== X-Received: by 10.55.69.79 with SMTP id s76mr14800994qka.13.1474760999204; Sat, 24 Sep 2016 16:49:59 -0700 (PDT) In-Reply-To: <20160918203608.GB15995@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:10515 Archived-At: On Sun, Sep 18, 2016 at 10:36 PM, Rich Felker wrote: > This patch introduces significant code duplication and complexity for > the sake of saving something like 10 cycles in an operation that makes > syscalls (i.e. takes thousands if not tens of thousands of cycles). fflush(NULL) does not _always_ perform syscalls. It may well find that none of the streams need any work. In fact, in some applications it may end it not doing any writes most of the times it is called: for example, I call it before (v)fork() (unless I know that I for sure do not have any buffered writes). Sometimes I call it before vfork out of sheer paranoia, even if it "looks like it's not needed": having stdio buffering in vfork-shared mm is huge PITA and a source of nasty bugs. Been there. > As > mentioned on the bb list, the right fix is just making fflush_unlocked > an alias for fflush. Then __fflush_unlocked can be eliminated > completely and the file simplified rather than increased in > complexity. Your call.