Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751381AbbDLIgn (ORCPT ); Sun, 12 Apr 2015 04:36:43 -0400 Received: from hofr.at ([212.69.189.236]:40126 "EHLO mail.hofr.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751037AbbDLIgg (ORCPT ); Sun, 12 Apr 2015 04:36:36 -0400 Date: Sun, 12 Apr 2015 10:36:34 +0200 From: Nicholas Mc Guire To: Joe Perches Cc: Nicholas Mc Guire , Michal Marek , Masahiro Yamada , Sam Ravnborg , Thomas Gleixner , "H. Peter Alvin" , John Stultz , Andrew Hunter , Paul Turner , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] time: allow gcc to fold constants when using msecs_to_jiffies Message-ID: <20150412083634.GA19486@opentech.at> References: <1428218636-3780-1-git-send-email-hofrat@osadl.org> <1428218636-3780-3-git-send-email-hofrat@osadl.org> <1428278627.2775.75.camel@perches.com> <20150406010025.GA5956@opentech.at> <1428286502.2775.92.camel@perches.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1428286502.2775.92.camel@perches.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3892 Lines: 116 > Your inline version has not worked with any of > x86-64 gcc 4.4, 4.6, 4.7, or 4.9 > > I suggest you add some lines to > lib/test_module.c/test_module_init like: > > unsigned int m; > > for (m = 10; m < 200; m += 10) > pr_info("msecs_to_jiffies(%u) is %lu\n", > m, msecs_to_jiffies(m)); > > pr_info("msecs_to_jiffies(%u) is %lu\n", > 10, msecs_to_jiffies(10)); > pr_info("msecs_to_jiffies(%u) is %lu\n", > 100, msecs_to_jiffies(100)); > pr_info("msecs_to_jiffies(%u) is %lu\n", > 1000, msecs_to_jiffies(1000)); > > Then it's pretty easy to look at the assembly/.lst file > > Your inline function doesn't allow gcc to precompute > the msecs_to_jiffies value. The macro one does for all > those gcc versions. > > Try it and look at the generated .lst files with and > without the patch I sent. > I have checked it with the testcase you proposed - and I quite sure it is working, find the .s file snippets from the test_module.c modified as you suggested below. HZ is set to 300 so that it is easy to differenciate the parameter to msecs_to_jiffies and the printed const. there is no call and no calculation for the constant cases - just load as it should be. with the patch applied: test_module_init: pushq %rbp # movq %rsp, %rbp #, pushq %rbx # movl $10, %ebx #, m pushq %rcx # .L4: movl %ebx, %edi # m, call __msecs_to_jiffies # movl %ebx, %esi # m, movq %rax, %rdx # D.14515, movq $.LC1, %rdi #, xorl %eax, %eax # addl $10, %ebx #, m call printk # cmpl $200, %ebx #, m jne .L4 #, <---end of for loop movl $3, %edx #, <---msecs_to_jiffies(10) movl $10, %esi #, movq $.LC1, %rdi #, xorl %eax, %eax # call printk # movl $30, %edx #, <---msecs_to_jiffies(100) movl $100, %esi #, movq $.LC1, %rdi #, xorl %eax, %eax # call printk # movl $300, %edx #, <---msecs_to_jiffies(1000) movl $1000, %esi #, movq $.LC1, %rdi #, xorl %eax, %eax # call printk # without the patch applied: pushq %rbp # movq %rsp, %rbp #, pushq %rbx # movl $10, %ebx #, m pushq %rcx # .L2: movl %ebx, %edi # m, call msecs_to_jiffies # movl %ebx, %esi # m, movq %rax, %rdx # D.14503, movq $.LC0, %rdi #, xorl %eax, %eax # addl $10, %ebx #, m call printk # cmpl $200, %ebx #, m jne .L2 #, movl $10, %edi #, call msecs_to_jiffies # movl $10, %esi #, movq %rax, %rdx # D.14504, movq $.LC0, %rdi #, xorl %eax, %eax # call printk # movl $100, %edi #, call msecs_to_jiffies # movl $100, %esi #, movq %rax, %rdx # D.14505, movq $.LC0, %rdi #, xorl %eax, %eax # call printk # movl $1000, %edi #, could you check the .s file for you test module ? I'm a bit lost on why you are not seeing this - also checked with cross-build (multi_v7_defconfig) and it looks like thats working as well. thx! hofrat -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/