Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp978980pxb; Wed, 3 Mar 2021 23:18:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJy975pfvOLvm3PpyvXS7FCgQ2jeUkvlXOW2F778i8iTzGYq962SjfQ/6dEBnkwXVsgHTUZ1 X-Received: by 2002:a05:6402:1013:: with SMTP id c19mr2919529edu.86.1614842288069; Wed, 03 Mar 2021 23:18:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614842288; cv=none; d=google.com; s=arc-20160816; b=AvGLnLl4EfNkFkkqATLdeVqKUaYRnPR602QzzU9elqgsulbSmJ/0DwWwrAqSF/UjyF T2Z6k4M9qJgtD+wWJ42PG0fi/i8ZT/x+SvYaPCQ4KLebH43GobJExy8JAX7i1fu3RJGs N/kgAw5qx4tOBQMDwmKkqgY/HYuXtntTjQQ1nF8e38TaLPZgTjlapRIfIkhzLw8FaWUP RKpi5lEfRMMSGdPAzoMzkRKUxof0fPK+sLVJs48/BYVKLImm/11yYwo0VKXyqDz34zBT ZrMHuycT81l4fetPni5Hi+35RKzQ20KDxBVi6lR76fqH3C13oewHaDyghUJuYvdvrUoW sU/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=VQfXllwKN5G8JGXptjBrQYjr7HBI6bLZ8JEcl84qd2Q=; b=seN5yPyA8mjcEbZGX6Xv1akj2lFu1lS/fByJFSLH5M+aLMpuHW27UJOYpUcqAqE9Al ZNc8VeCq7O3wPk9EMJNvW3QkpbflcgJCFk7HxVislMNWG2WMjySbjcuf9ZVOIwI0jcvf lRW9XLl0dZFC6hhYBeFeTujEfURRfv+6SXY2hqQdaxVkBnLRkWvvdlJHR2sJj71WP9Lw VM383eBrXGl/SYE7Je0aRrPpwnLIIIrRHam+P3Zr5jGNvuwxSbomWxnN+vmq2Y0WjGC1 ASemmVRT9ocx2aDYusICX9j7bs5np24582ES9isrFLSSHQxV/zmGiN7t/pMOCS+I1kpG 1NWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=fCQLxGXe; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j26si1749450ejs.484.2021.03.03.23.17.44; Wed, 03 Mar 2021 23:18:08 -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=@google.com header.s=20161025 header.b=fCQLxGXe; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2360351AbhCBWTf (ORCPT + 99 others); Tue, 2 Mar 2021 17:19:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381439AbhCBU4k (ORCPT ); Tue, 2 Mar 2021 15:56:40 -0500 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C81FC061356 for ; Tue, 2 Mar 2021 12:55:19 -0800 (PST) Received: by mail-qv1-xf2b.google.com with SMTP id s17so6059385qvr.12 for ; Tue, 02 Mar 2021 12:55:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VQfXllwKN5G8JGXptjBrQYjr7HBI6bLZ8JEcl84qd2Q=; b=fCQLxGXewrDDQXo/cYSGKTR+uA+HfeC9xfDoFNHv0vnbdbprQea443sCI6U0NKpTv3 p4iADjmCJWrOGiFFZOxAA3C5mU7wNkcWRaThgI0p92BxKTo8ZY/uuBq2gf22DCACVoa2 YdeU+qrchMMKT06xG46FkN+PelpWnENCBf9wMXal7me9nSyoiqROsdxf8Tr+7VbCyZ4+ JTxsLYX7Ek5sVOUHWkTBIaOZVr6yarV15jPdfXsgeIf3LLrkMUnCzsvzdhtHr38o4xHx kaljloJBXwugJNFdA6nEZojSGR82YDmCT4MRtYsTQarndl5sCNtSiPNG8zsMvi40t73y TqIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VQfXllwKN5G8JGXptjBrQYjr7HBI6bLZ8JEcl84qd2Q=; b=D3IJJt+XmLgLKlpN8gniOYEFxVMRlq8cNc6ysxT5PQ6NBqmaXfBvq+tg6r+CaJ5dWj 73ZKDYBegBQ/JZ+k3PCv0nT67MlOx2Lq18hlf3nA9pmX7JJSjZRnU1xCkT8K+ajhOR72 muii/qAzo6WfObe/vzsXA+a1ixXdWBeY1LAMMj704g/HMLRDmXlxo33G9JxF0jYMmz8j uXACkCD7mJJ6aj5JMzuR7PNus/etUwPmitioLFiszhF9VGWWUayDgkKrjvOnbCa0wUOd YtDPkKtMLDbS7k2Fttr0RC1d+00wfE5nzAX+l9mHbWghdheB8azld2JtAUJP62JEjjdV G4/w== X-Gm-Message-State: AOAM531AZ1fdlVsdpelGhsODhxi4xG9xmuJ4qdmqHpkknjItbxxx+f9F EmpuOJtWyW6Vujzc3XSEwVeiQNTNjKKETZPTiw9Zpg== X-Received: by 2002:a0c:b912:: with SMTP id u18mr21543184qvf.2.1614718518335; Tue, 02 Mar 2021 12:55:18 -0800 (PST) MIME-Version: 1.0 References: <20210226195239.3905966-1-joshdon@google.com> In-Reply-To: From: Josh Don Date: Tue, 2 Mar 2021 12:55:07 -0800 Message-ID: Subject: Re: [PATCH] sched: Optimize __calc_delta. To: Peter Zijlstra 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.