From owner-freebsd-current@FreeBSD.ORG Fri Jun 5 08:11:53 2015 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2E0FFFA3; Fri, 5 Jun 2015 08:11:53 +0000 (UTC) (envelope-from jenkins-admin@freebsd.org) Received: from jenkins-9.freebsd.org (jenkins-9.freebsd.org [8.8.178.209]) by mx1.freebsd.org (Postfix) with ESMTP id 1D1AA1441; Fri, 5 Jun 2015 08:11:53 +0000 (UTC) (envelope-from jenkins-admin@freebsd.org) Received: from jenkins-9.freebsd.org (localhost [127.0.0.1]) by jenkins-9.freebsd.org (Postfix) with ESMTP id 34BA61529; Fri, 5 Jun 2015 08:11:50 +0000 (UTC) Date: Fri, 5 Jun 2015 08:11:48 +0000 (GMT) From: jenkins-admin@freebsd.org To: jenkins-admin@FreeBSD.org, freebsd-current@freebsd.org Message-ID: <1160690749.52.1433491908728.JavaMail.jenkins@jenkins-9.freebsd.org> In-Reply-To: <2030674114.50.1433460982630.JavaMail.jenkins@jenkins-9.freebsd.org> References: <2030674114.50.1433460982630.JavaMail.jenkins@jenkins-9.freebsd.org> Subject: FreeBSD_HEAD-tests - Build #1083 - Fixed MIME-Version: 1.0 X-Jenkins-Job: FreeBSD_HEAD-tests X-Jenkins-Result: SUCCESS Precedence: bulk Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.20 List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jun 2015 08:11:53 -0000 FreeBSD_HEAD-tests - Build #1083 - Fixed: Check console output at https://jenkins.freebsd.org/job/FreeBSD_HEAD-tests/1083/ to view the results. From owner-freebsd-current@FreeBSD.ORG Fri Jun 5 11:38:22 2015 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 48D05A76 for ; Fri, 5 Jun 2015 11:38:22 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CEE11133A for ; Fri, 5 Jun 2015 11:38:21 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id t55BcGSO064884 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Fri, 5 Jun 2015 14:38:16 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua t55BcGSO064884 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id t55BcGe5064883; Fri, 5 Jun 2015 14:38:16 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 5 Jun 2015 14:38:16 +0300 From: Konstantin Belousov To: Hans Petter Selasky Cc: FreeBSD Current Subject: Re: [CFR] Replacing while loops with proper division and multiplication Message-ID: <20150605113816.GB2499@kib.kiev.ua> References: <55714B26.6060802@selasky.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55714B26.6060802@selasky.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jun 2015 11:38:22 -0000 On Fri, Jun 05, 2015 at 09:09:26AM +0200, Hans Petter Selasky wrote: > Hi, > > I was going through some timer code and found some unnecessary while > loops in kern/kern_clocksource.c . > > I added some prints and found that during boot, "runs" can exceed 2000, > while during regular usage runs is typically 1. Do you think it is worth > to convert these loops into division and multiplications? It might make > the CPU pipeline a tiny bit faster, having to skip some conditionals? > And also possibly improve readability? For typical loop count of one, I think that setup time for the division is much greater than single substraction and non-taken conditional jump, which is also should be consistently predicted as not taken. You could try to run a microbenchmark to see if the patch makes any sense.