From owner-svn-src-head@freebsd.org Tue Jun 5 22:56:49 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EBE23FD0D11; Tue, 5 Jun 2018 22:56:48 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-qt0-x22b.google.com (mail-qt0-x22b.google.com [IPv6:2607:f8b0:400d:c0d::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8228E7958D; Tue, 5 Jun 2018 22:56:48 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-qt0-x22b.google.com with SMTP id q6-v6so4397063qtn.7; Tue, 05 Jun 2018 15:56:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=BPJvmrArs93W1dTWS7Xi/gMAA+14YlZmxgDsBklMReA=; b=Ehp1D5pcJzUtD/7L9dTsNfpFBbp+TejlW0LlKeReROCOz1rD9d5sStPWS4qbs67kRZ 4MhAgNVQ2/gZjO/omcYMMJ7ymKuqLmmjrt40nqrWcSaNQz5I5PAkiEjZ5utPTH0w8f1b azvIvUAmgljvrkwMt9MMGckrFavMPL68/ivbYF+4r/BbQmK77RPzgyEz76oaylKWDhZy qowCA57xV4aE86PNAP0r8u5lzEtDQNX8Q15rqF6tD2rQa1A+4rR+PNr+AwfU6HLXzbsT m4KgOweMjAz/GpCCpggrHLHCwIum/UeczhMoNEZdRdNp6nl0HBo1dPM6TXYgaIYKnmv2 VHyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=BPJvmrArs93W1dTWS7Xi/gMAA+14YlZmxgDsBklMReA=; b=h+SCI0aYpoRVZzqwwqQGVStCOT7hTh5t3pbkDn22IZOQy71msY7pQhlgI3qBb1iOE5 91OQ556XKwANbrXaYY+DV6vo13Y9vLV4PmNqeWocWZljT1WW9dENS2vbqUAfdRH09KwB +6PxKQC1tjcWSBbMcP1ELRz/vTRBfHSvA3EDBekcxuPh+uHrbBo1/nszW93UwC22l92m 5nNxMMDO8dK0Y0G5g+q+fkIXoTvxKKvdLY6QyS+3GcYFZjfjfbd0g/TI4MAjoXEtWkql UcI9Wqq7q6h9qaE5d8Z1/8nWoXE39qvp2hc1a+sP1nvVF0hpfum8yN02DAhh+BpwKYAz OKHQ== X-Gm-Message-State: APt69E2Nd979uRKK4yM/IqilZrixtWSyCF3WL6BR+qwZAOwMWpGaDm9J 3cIuTyGNBDm5yyncEB1uL0b2p3AfX4XKSspwyRk= X-Google-Smtp-Source: ADUXVKKzJImQtcHBIKi0XGMPIlE1y0xBqfRLXQDU/5bPNg6eRsXBF/ej4YAxYY1MiTx+raqlu6aCzzRB+46z1ppGHf0= X-Received: by 2002:a0c:94fa:: with SMTP id k55-v6mr613030qvk.20.1528239407860; Tue, 05 Jun 2018 15:56:47 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ac8:1c4e:0:0:0:0:0 with HTTP; Tue, 5 Jun 2018 15:56:47 -0700 (PDT) In-Reply-To: <20180605225215.GC1005@FreeBSD.org> References: <201806022220.w52MK9TT026244@repo.freebsd.org> <1b77e282-e24b-d14c-9811-4cf214d58280@vangyzen.net> <20180605225215.GC1005@FreeBSD.org> From: Mateusz Guzik Date: Wed, 6 Jun 2018 00:56:47 +0200 Message-ID: Subject: Re: svn commit: r334545 - in head/sys: contrib/zstd/lib/freebsd kern netinet/libalias sys To: Gleb Smirnoff Cc: Eric van Gyzen , Mateusz Guzik , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.26 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jun 2018 22:56:49 -0000 On Wed, Jun 6, 2018 at 12:52 AM, Gleb Smirnoff wrote: > On Tue, Jun 05, 2018 at 06:35:37PM +0200, Mateusz Guzik wrote: > M> > On 06/02/2018 17:20, Mateusz Guzik wrote: > M> > > +#ifdef _KERNEL > M> > > +#define malloc(size, type, flags) ({ > \ > M> > > + void *_malloc_item; > \ > M> > > + size_t _size = (size); > \ > M> > > + if (__builtin_constant_p(size) && __builtin_constant_p(flags) > &&\ > M> > > + ((flags) & M_ZERO)) { > \ > M> > > + _malloc_item = malloc(_size, type, (flags) &~ > M_ZERO); \ > M> > > + if (((flags) & M_WAITOK) || _malloc_item != NULL) > \ > M> > > + bzero(_malloc_item, _size); > \ > M> > > + } else { > \ > M> > > + _malloc_item = malloc(_size, type, flags); > \ > M> > > + } > \ > M> > > + _malloc_item; > \ > M> > > +}) > M> > > +#endif > M> > > M> > Mateusz, > M> > > M> > Thank you for this and for all of your performance work. It is all > very > M> > interesting stuff. > M> > > M> > > M> Thank you for the kind words. It is positive feedback like this which > M> keeps me going! > > Btw, what was the point of checking flags || result? Most places in kernel > ignore flags and just test result regerdless of M_WAITOK/M_NOWAIT. > > The result is already in a register, why do you think checking for absense > of M_WAITOK is faster that checking for !NULL _malloc_item? > This part is only reachable if flags are known at compilation time. If they contain M_WAITOK, the flag check will get elided along (we know for a fact it passes) and subsequently the NULL check will be short circuited, iow for known M_WAITOK|M_ZERO flags this is: _malloc_item = malloc(_size, type, flags & ~ M_ZERO); bzero(_malloc_item, _size); -- Mateusz Guzik