From owner-svn-src-head@freebsd.org Mon May 7 20:57:14 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 B2661FBCA59; Mon, 7 May 2018 20:57:14 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-qt0-x242.google.com (mail-qt0-x242.google.com [IPv6:2607:f8b0:400d:c0d::242]) (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 44D0D69C5F; Mon, 7 May 2018 20:57:14 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-qt0-x242.google.com with SMTP id e8-v6so33381694qth.0; Mon, 07 May 2018 13:57:14 -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=+Ugb7DDrhqFr0Ms9K49qMHyCVqbYLEDj+WK5h0+0/OU=; b=HcBp6zqqzG9ZBjSoWSfpP8eyzT37bAIaGk35iiVuULUSBWpYViVWtC/ARFOU3QpQuL 6s++8duSkHmO94PaxfAHZrLvkQuJQMghe16ZSV3zKIRX0bIR1gEQfmaviL7eLo4LGZl2 aLEkPpQLAJzvHtE8802mDZlONS69hdsj4Q7hyFlnHZLLXua792k3x5Tt6WMEZAhZerJZ cMXdHbbiv5u/CY1fNgLQ/V4GjqtFlpLNdAaaIQFMTD7NWyI86SaI1LZsulydBddUJKIX +RDC38LmZ+SaFjdNLe7Nn0jm6zjcjvs9gGyqaefAmVmTbPISiYtVXV6OzlwmSBeaoUsg zaYA== 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=+Ugb7DDrhqFr0Ms9K49qMHyCVqbYLEDj+WK5h0+0/OU=; b=ECiNo3XZQO7BHe5M2ljIi0HMYYs3ZDJ6TzkW+zZkDY/K1fTLB+86n6HMvF3Robj2Ld 81QGSORV4hhxelIHULu/YLnBS4XbL7bLiWtG7upi9sdNM2N3O3GWmPvVmjaQ9ZIKzeVk Hfx2TRPN2gJiZI7J/po1M6cnQ707cqH1GkP4PMIFe0MzR0Pv8Uh62/xFOliWgSpaqFYb CL2jwfLwuBNvngyw0KTRVa+joDCPmEKdOwpNKu2uaSLGL5ZSfdmjR3lzCNTuxvyuoDR6 3W81B9HL18RuF2oOajVutTw3VMc1RUO3CdQinjkKECmmmHiWid+2f7E7VZuFs2j8Da72 fUIA== X-Gm-Message-State: ALKqPweIR6lIb4PkYQucntUDfamyDHFPwh/niPln94ufMm5JJBRrKbns Je1dPgwwRQ4h2GPmbg+bccfDxMIm+9aihMOKV/7I3w== X-Google-Smtp-Source: AB8JxZoUAnC4e9BE86gqwri/L11qKoWKehUnId81vnMFFdWW8SBnwX7WNaz72RjVqn3M/8wDCYCae5y6CSUlZdjIATU= X-Received: by 2002:ac8:3508:: with SMTP id y8-v6mr13407607qtb.26.1525726633700; Mon, 07 May 2018 13:57:13 -0700 (PDT) MIME-Version: 1.0 Received: by 10.200.28.74 with HTTP; Mon, 7 May 2018 13:57:13 -0700 (PDT) In-Reply-To: References: <201805071507.w47F7SOs035073@repo.freebsd.org> From: Mateusz Guzik Date: Mon, 7 May 2018 22:57:13 +0200 Message-ID: Subject: Re: svn commit: r333324 - in head/sys: amd64/amd64 conf To: Oliver Pinter Cc: 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.25 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 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: Mon, 07 May 2018 20:57:15 -0000 On Mon, May 7, 2018 at 9:03 PM, Oliver Pinter wrote: > On 5/7/18, Mateusz Guzik wrote: > > Author: mjg > > Date: Mon May 7 15:07:28 2018 > > New Revision: 333324 > > URL: https://svnweb.freebsd.org/changeset/base/333324 > > > > Log: > > amd64: replace libkern's memset and memmove with assembly variants > > > > memmove is repurposed bcopy (arguments swapped, return value added) > > The libkern variant is a wrapper around bcopy, so this is a big > > improvement. > > > > memset is repurposed memcpy. The librkern variant is doing fishy stuff, > > including branching on 0 and calling bzero. > > > > Both functions are rather crude and subject to partial depessimization. > > > > This is a soft prerequisite to adding variants utilizing the > > 'Enhanced REP MOVSB/STOSB' bit and let the kernel patch at runtime. > > > > + > > +/* > > + * memset(dst, c, len) > > + * rdi, rsi, rdx > > + */ > > +ENTRY(memset) > > + PUSH_FRAME_POINTER > > + movq %rdi,%r9 > > + movq %rdx,%rcx > > + movq %rsi,%rax > > + shrq $3,%rcx > > + rep > > + stosq > > According to Intel SDM stosq stores the whole RAX into destination, > and then increments the destination register with 8. This > implementation is wrong, since the c is a char, and the The RAX looks > like 000000CC, so the stored patter would be 000000CC * SIZE / 8 * 8 + > CC * SIZE % 8 in destination buffer. > Ye, my bad. Forgot to expand the arg with the multiplication trick. Fixed: https://svnweb.freebsd.org/base?view=revision&revision=333332 -- Mateusz Guzik