Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1035582pxb; Thu, 4 Mar 2021 01:16:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJyjhDtJJ0TKeWWifolH+IiR203rwG621faWTsQhxDeXZRQT94/WOpg94hwIhAmoCa2NjADJ X-Received: by 2002:a05:6402:c11:: with SMTP id co17mr3327237edb.246.1614849416642; Thu, 04 Mar 2021 01:16:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614849416; cv=none; d=google.com; s=arc-20160816; b=VQFm9Kvh/mZYrBs08bjGv3gp95QRRQjjNWVl9bT2J0wGZYlbJO291fT5A15kXn7hzB 6qrj8d3ECQm3n+H/tilt+21heO5qK19HiDnb+oG9frCu5O7rW/28Aky3lXHWQ3rERwJE uLHln8mm9kROckkJ313+69d6ITK3UHgm2Le0dv6V8m5fKxqa3HrA2s+SQKtfB4ihIB4d T+9olz6eHeyb4LwVKx4E9gDN3TriR6mt5tP9mluG5JttkprhqdQB6Wrpfmqa56ejX9nv fmpRxbK0SmHIF4f/3EkE8qYty9nB3ZK3mkBo9x0Ivqis+F0UYEP64N98WaHjBvAmGwbU S/fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=RRqVDNmqK8qWgfS2O35qxiJ4bts6fZ0niwzW8fuS1pE=; b=OKU0PJAm3IJpPNiLXKLr39GPrWyde+5oAwUmLPEig8a4yPLBCX0jrwZ+JwVtp2Owx6 l9mq+ikBcs6vd9nbhXdBDjuHz4zrnPoWD+Ud6rLKRIGgJL/93X/Qbad+0LVwhBOYi/DY 531oszVsMqqTQsUnwrIRrtDfLExAGhNa0vB+RVkddtftWLzlGbpkJhLUpOfTh9BNzJOx RS/xI1HDG/75Bbsjprv/zNp2rbLKZcZHIWylHv7Lyw0aU1oyllzmhYOTwbfVMApOR7bA xUQq6z0QSOFdlSGkFSPfuS3NhIKas/sv411xCGDeoWsH08ogRqYl5gjhjap6S7X16407 2Zcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=RZxNeBzv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s11si16958950ejb.114.2021.03.04.01.16.34; Thu, 04 Mar 2021 01:16:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=RZxNeBzv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381254AbhCCOah (ORCPT + 99 others); Wed, 3 Mar 2021 09:30:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1842965AbhCCKXK (ORCPT ); Wed, 3 Mar 2021 05:23:10 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFD2EC08ECA4 for ; Wed, 3 Mar 2021 01:49:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=RRqVDNmqK8qWgfS2O35qxiJ4bts6fZ0niwzW8fuS1pE=; b=RZxNeBzv4lnmfhVYK840iREUeF W6lHMxTpkq+4pRUUJ3aOlWBf6ktD2mMo0UptaXOfuzkV/Z2RDN32ZJA/aMTTCsWkpM9cNEcS1sI3i /ns/0khSsg3vlB84N5dd0erf87ZjTK0rKw9AaixgMgUNKMioP7Ip7XAZHqXbm2km6XM7pE6Le3yEZ km+RvqDGMKiKRdiWjAGNuq3B6LQ0IohV2MDQeQPi0BUW9Q/jwOmgvmxqQEHFeumkhYZW06ZK6c7dN XC4YV16WVQmyIJKlaT5iIvEXcgg+5gVvYs/aatti7GwnBSbeJTyy9YvqZlCfmSaRABQLFC0XY/s1P 2Nf/5SFg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lHO8G-0023te-UB; Wed, 03 Mar 2021 09:49:29 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 26027303205; Wed, 3 Mar 2021 10:49:27 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id D520E264F0E2E; Wed, 3 Mar 2021 10:49:27 +0100 (CET) Date: Wed, 3 Mar 2021 10:49:27 +0100 From: Peter Zijlstra To: Josh Don Cc: Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , linux-kernel , Clement Courbet , Oleg Rombakh Subject: Re: [PATCH] sched: Optimize __calc_delta. Message-ID: References: <20210226195239.3905966-1-joshdon@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 02, 2021 at 12:55:07PM -0800, Josh Don wrote: > On Fri, Feb 26, 2021 at 1:03 PM Peter Zijlstra wrote: > > > > On Fri, Feb 26, 2021 at 11:52:39AM -0800, Josh Don wrote: > > > From: Clement Courbet > > > > > > A significant portion of __calc_delta time is spent in the loop > > > shifting a u64 by 32 bits. Use a __builtin_clz instead of iterating. > > > > > > This is ~7x faster on benchmarks. > > > > Have you tried on hardware without such fancy instructions? > > Was not able to find any on hand unfortunately. Clement did rework the > patch to use fls() instead, and has benchmarks for the generic and asm > variations. All of which are faster than the loop. In my next reply, > I'll include the updated patch inline. Excellent; I have some vague memories where using fls ended up slower for some ARMs, but I can't seem to remember enough to even Google it :/