From owner-svn-src-all@FreeBSD.ORG Fri Mar 20 22:43:14 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E601427C; Fri, 20 Mar 2015 22:43:14 +0000 (UTC) Received: from mail110.syd.optusnet.com.au (mail110.syd.optusnet.com.au [211.29.132.97]) by mx1.freebsd.org (Postfix) with ESMTP id A6E6D896; Fri, 20 Mar 2015 22:43:14 +0000 (UTC) Received: from c211-30-166-197.carlnfd1.nsw.optusnet.com.au (c211-30-166-197.carlnfd1.nsw.optusnet.com.au [211.30.166.197]) by mail110.syd.optusnet.com.au (Postfix) with ESMTPS id BEB32784085; Sat, 21 Mar 2015 09:42:51 +1100 (AEDT) Date: Sat, 21 Mar 2015 09:42:51 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Konstantin Belousov Subject: Re: svn commit: r280279 - head/sys/sys In-Reply-To: <20150320130216.GS2379@kib.kiev.ua> Message-ID: <20150321085923.U1046@besplex.bde.org> References: <201503201027.t2KAR6Ze053047@svn.freebsd.org> <20150320130216.GS2379@kib.kiev.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=Za4kaKlA c=1 sm=1 tr=0 a=KA6XNC2GZCFrdESI5ZmdjQ==:117 a=PO7r1zJSAAAA:8 a=kj9zAlcOel0A:10 a=JzwRw_2MAAAA:8 a=6I5d2MoRAAAA:8 a=ORg6-SmGG5svwvipwukA:9 a=CjuIK1q_8ugA:10 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, John Baldwin X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Mar 2015 22:43:15 -0000 On Fri, 20 Mar 2015, Konstantin Belousov wrote: > On Fri, Mar 20, 2015 at 10:27:06AM +0000, John Baldwin wrote: >> Author: jhb >> Date: Fri Mar 20 10:27:06 2015 >> New Revision: 280279 >> URL: https://svnweb.freebsd.org/changeset/base/280279 >> >> Log: >> Expand the bitcount* API to support 64-bit integers, plain ints and longs >> and create a "hidden" API that can be used in other system headers without >> adding namespace pollution. >> - If the POPCNT instruction is enabled at compile time, use >> __builtin_popcount*() to implement __bitcount*(), otherwise fall back >> to software implementations. > Are you aware of the Haswell errata HSD146 ? I see the described behaviour I wasn't. > on machines back to SandyBridge, but not on Nehalems. > HSD146. POPCNT Instruction May Take Longer to Execute Than Expected > Problem: POPCNT instruction execution with a 32 or 64 bit operand may be > delayed until previous non-dependent instructions have executed. If it only affects performance, then it is up to the compiler to fix it. > Jilles noted that gcc head and 4.9.2 already provides a workaround by > xoring the dst register. I have some patch for amd64 pmap, see the end > of the message. IIRC, then patch never never uses asm, but intentionally uses the popcount builtin to avoid complications. >> - Use the existing bitcount16() and bitcount32() from to >> implement the non-POPCNT __bitcount16() and __bitcount32() in >> . > Why is it in sys/types.h ? To make it easier to use, while minimizing namespace pollution and inefficiencies. Like the functions used to implement ntohl(), except the implementation is MI so it doesn't need to be in . (The functions used to implement ntohl() are in machine/endian.h. sys/types.h always includes that, so it makes little difference to pollution and inefficiency that the implementation is not more directly in machine/_types.h.) bitcount is simpler and not burdened by compatibility, so it doesn't need a separate header.) Bruce