From owner-svn-src-head@freebsd.org Thu Jul 16 20:52:30 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9D9D036D4F1; Thu, 16 Jul 2020 20:52:30 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4B75zf1rlcz45Zv; Thu, 16 Jul 2020 20:52:29 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wm1-x344.google.com with SMTP id w3so12981653wmi.4; Thu, 16 Jul 2020 13:52:29 -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=SSPtdXq2R6yyMWgwMKGaQDJH5WZ/wkf2oh5s0z7Ta7M=; b=UTgvgzB5LhBpIb0OSMukCHWQuH6V11ImRUBbTIxtOvYuq8nkPhQ3Wp60UmeKgZQkTo e/0C7aAeFXTCAXOoZ45byK9ov9+TTl3PV4pp5x7G0aeD62ZFlVMegv/Vop/GJQVElJFq 6YXWNL7NqmLr+z2/nqUW/BiZ2KqMdvBqHxR+Zjw6sIXh+S/3U+OjnRVmm7Ua/n/OKcxH vz7mcb9yFyJtIruK5r5Gf77Buqiu45I9xly15qeEDy81AAMjD5+Dd3xiH8iNgGmD5bFx 5+Skw52rj/ZPM0yYhQpP1UnNcLEkRhUFR3brNBRBdsKKPwk4YzLKBO4dLlIvClYD2qKA RXmQ== 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=SSPtdXq2R6yyMWgwMKGaQDJH5WZ/wkf2oh5s0z7Ta7M=; b=Yoi2ZkfwAkLDxKIw5xDtk8W4XG1TJTnqAVSHbE79Xs1tofe2Ib8Q+Z9P0gWf+Q/MlW T6rDWiqNu5UiOupcmeWOTFQBgIx7D5VNtttheEmVUeKipOexaLVH3J4mwIjqKKTIJF4d B9SLb7pYOJ8VomNz2kkUypHTpHhXXMWeyetzOBh5Yop0+yB/ftGwEy+sGRgBdJkjOjhg +YSdD1J2gqnKnt9yM5GoKQvWITgr0XzBpX3pbYs6x/YMzdcvuFpoKWtLoVG/DwVA9nlg no883TMq31PMq/IOoi/QwJ/q6HUotgc9Wjp654Yo7VMrmRf5baOevZwVIvkXyYIyf5Kx O2Mg== X-Gm-Message-State: AOAM5324xhaiRXy7GeQLVYiXJngvw8bDjR8mBxiI4zx9YZ76aXvMxCNk peCXxqqmsvyLFfICZjkxl5eXe/bSmqWpiyXHX9Xe/w== X-Google-Smtp-Source: ABdhPJy1//BCVgPl6EQjECT00rDLLWmYqhEYrSlRWmjVFLKo9Hi69xfao/9oRkHcR69SiZ+zrmFWzXBdK+b84JULz4I= X-Received: by 2002:a05:600c:20d3:: with SMTP id y19mr6241369wmm.10.1594932748040; Thu, 16 Jul 2020 13:52:28 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:adf:9d84:0:0:0:0:0 with HTTP; Thu, 16 Jul 2020 13:52:27 -0700 (PDT) In-Reply-To: References: <202007161128.06GBSPSB045345@repo.freebsd.org> From: Mateusz Guzik Date: Thu, 16 Jul 2020 22:52:27 +0200 Message-ID: Subject: Re: svn commit: r363242 - head/sys/amd64/include To: Mitchell Horne Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4B75zf1rlcz45Zv X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; REPLY(-4.00)[] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 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: Thu, 16 Jul 2020 20:52:30 -0000 Sounds good, albeit true to my commit message, I'm strongly recommending you run both at the same time. I had ORIG_ and NEW_, with ffs calling both and comparing the result. But perhaps more importantly this may be a good time to create a MI-header for this stuff and do a pass with other archs. We are long past a point where hand-rolled primitives make sense in the common case. On 7/16/20, Mitchell Horne wrote: > On Thu, Jul 16, 2020 at 8:28 AM Mateusz Guzik wrote: >> >> Author: mjg >> Date: Thu Jul 16 11:28:24 2020 >> New Revision: 363242 >> URL: https://svnweb.freebsd.org/changeset/base/363242 >> >> Log: >> amd64: patch ffsl to use the compiler builtin >> >> This shortens fdalloc by over 60 bytes. Correctness verified by running >> both >> variants at the same time and comparing the result of each call. >> >> Note someone(tm) should make a pass at converting everything else >> feasible. >> > > I have a local version of such a change. I'll see about getting it up > for review in the next little while. > > Mitchell > >> Modified: >> head/sys/amd64/include/cpufunc.h >> >> Modified: head/sys/amd64/include/cpufunc.h >> ============================================================================== >> --- head/sys/amd64/include/cpufunc.h Thu Jul 16 10:20:35 2020 >> (r363241) >> +++ head/sys/amd64/include/cpufunc.h Thu Jul 16 11:28:24 2020 >> (r363242) >> @@ -167,7 +167,8 @@ enable_intr(void) >> static __inline __pure2 int >> ffsl(long mask) >> { >> - return (mask == 0 ? mask : (int)bsfq((u_long)mask) + 1); >> + >> + return (__builtin_ffsl(mask)); >> } >> >> #define HAVE_INLINE_FFSLL > -- Mateusz Guzik