From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70EF2C43331 for ; Sun, 29 Mar 2020 17:56:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 403072076A for ; Sun, 29 Mar 2020 17:56:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728437AbgC2R4G (ORCPT ); Sun, 29 Mar 2020 13:56:06 -0400 Received: from mx.sdf.org ([205.166.94.20]:54745 "EHLO mx.sdf.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728358AbgC2R4F (ORCPT ); Sun, 29 Mar 2020 13:56:05 -0400 Received: from sdf.org (IDENT:lkml@sdf.lonestar.org [205.166.94.16]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id 02THoYVV027072 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO); Sun, 29 Mar 2020 17:50:34 GMT Received: (from lkml@localhost) by sdf.org (8.15.2/8.12.8/Submit) id 02THoW6w010257; Sun, 29 Mar 2020 17:50:32 GMT Date: Sun, 29 Mar 2020 17:50:32 +0000 From: George Spelvin To: Takashi Iwai Cc: linux-kernel@vger.kernel.org, Hannes Reinecke , linux-scsi@vger.kernel.org, Marek Lindner , Simon Wunderlich , Antonio Quartulli , Sven Eckelmann , b.a.t.m.a.n@diktynna.open-mesh.org, Johannes Berg , linux-wireless@vger.kernel.org, Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, lkml@sdf.org Subject: Re: [RFC PATCH v1 13/50] Avoid some useless msecs/jiffies conversions Message-ID: <20200329175032.GE4675@SDF.ORG> References: <202003281643.02SGhBrh000992@sdf.org> <20200329121129.GC11951@SDF.ORG> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 29, 2020 at 07:13:33PM +0200, Takashi Iwai wrote: > On Sun, 29 Mar 2020 14:11:29 +0200, George Spelvin wrote: >> On Sun, Mar 29, 2020 at 09:52:23AM +0200, Takashi Iwai wrote: >>> I thought the compiler already optimizes to the constant calculation >>> for the above case? >> >> It optimizes that if the entire argument, including "seconds", is >> a compile-time constant. >> >> However, given "msecs_to_jiffies(hdev->rpa_timeout * 1000);", >> the computatin is non-trivial. > > Fair enough. But it's still a question whether an open code X * HZ is > good at all... I'm sorry, I don't understand what you mean by "good at all" here. The value computed is exactly the same. msecs_to_jiffies(x) is basically (x * HZ + 999) / 1000, so msecs_to_jiffies(s * 1000) = (s * 1000 * HZ + 999) / 1000 = s * HZ + 999/1000 = s * HZ.