Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2145816ybb; Sun, 29 Mar 2020 23:57:45 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvzJZoLIHjHlFK1q+Tq0B6/BOi29y+tu3+CSmV7kNQGptxm0YHgt5z+qs7Ehexu3Z//rDzQ X-Received: by 2002:a9d:480b:: with SMTP id c11mr7774107otf.109.1585551465546; Sun, 29 Mar 2020 23:57:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585551465; cv=none; d=google.com; s=arc-20160816; b=eUSj66Bwe63pbaSkXYGMPKNeqL+hkspkK1spxXN/ewmyB94a/pxM72HlzdoIw4X1fA H6dJStBgQ2NRPfRWIR6XENSRHgJ742ch0N0iCfSLaO47tpR0iCz8OHC0GAvuwrHTqWX1 3pBsHt+iZLRkeaOkLs8srkJlenwEk5i1uKGXc3HqxgUUQn1cwZCvn8GWAMFIifavTNnc o/wpzbI0rkFODTq3gYsVo8nI61cGCUtiGIKPHW1lRXPcfNYY5eajl53MSXx7WSVwHnog oSIlwxzFxXynzd4GvBtUofXxwpuR7Vc4c4zu99qDwyUTCvzkIhG8PZXeGcxcyS/JXA3X z2gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=NfiWfQV+8na3yhEOIJEsG+duOj68C5elRHVUzQb9o6w=; b=SXkMH8qaYsLWS+TwcH33cDc5suoH5zaIyRVMDdspRW94dHoVcZw1NaDdzLEgSUdOGV wS9TAO8Lu2HMrsadEIBCK5XGYCZY3lYiEA+8GFiaEnfqdhS+5w3xDrV7TOEJsTRrmZH8 7acsHUL9bQfZBKRcYBV/ZVArLlZFet648RUN3nQTtU7dQIHWBn7HlM2qYVfVxTYlsD6l bd6TnxGvqXkNxlI6HT/J2hGTDGS9SCrmss1FShmaPlZVVmvc28DAOAKURuFJ0qt9GKxj 2J2+T/f7M9WBy8U6BoipYz57vz2mgC7Pl41slfUTG6zm6o2hXSfhDonRO63bHnGaKbTT Y5FQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m7si4645387oim.179.2020.03.29.23.57.32; Sun, 29 Mar 2020 23:57:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729342AbgC3G4j (ORCPT + 99 others); Mon, 30 Mar 2020 02:56:39 -0400 Received: from mx.sdf.org ([205.166.94.20]:65413 "EHLO mx.sdf.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729099AbgC3G4j (ORCPT ); Mon, 30 Mar 2020 02:56:39 -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 02U6p8D4025450 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO); Mon, 30 Mar 2020 06:51:08 GMT Received: (from lkml@localhost) by sdf.org (8.15.2/8.12.8/Submit) id 02U6p5rX014028; Mon, 30 Mar 2020 06:51:05 GMT Date: Mon, 30 Mar 2020 06:51:05 +0000 From: George Spelvin To: Takashi Iwai Cc: James Bottomley , 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: <20200330065105.GB9333@SDF.ORG> References: <202003281643.02SGhBrh000992@sdf.org> <20200329121129.GC11951@SDF.ORG> <20200329175032.GE4675@SDF.ORG> <1585505807.4510.1.camel@HansenPartnership.com> 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 Mon, Mar 30, 2020 at 08:27:01AM +0200, Takashi Iwai wrote: > On Sun, 29 Mar 2020 20:16:47 +0200, James Bottomley wrote: >> We all assume that msecs_to_jiffies is properly optimized so there >> should be no need to open code it like you're proposing. > > Yes, it'd be best if the compiler can handle it properly. I've tried, and can't figure out how to get the compiler to detect this special case and not invoke the general code. In particular, for a variable x, __builtin_constant_p(x * 1000 % 1000) is false. Even if x is signed and ANSI lets the compiler assume that overflow doesn't happen. If you can do it, I'm most curious how! > But also I meant to keep using the macro for consistency reason. > IIRC, we wanted to eliminate the explicit use of HZ in the past, and > it's how many lines have been converted with *_to_jiffies() calls. > I don't know whether the eliminate of HZ is still wished, but > reverting to the open code is a step backward for that. Well, you could always add a secs_to_jiffies(x) wrapper. But given that it expands to basically x * HZ, some people might wonder why you're bothering. I assumed that open-coding x * HZ was the preferred style, so that's what I did.