From: Rob Landley <rob@landley.net>
To: Michal Marek <mmarek@suse.cz>
Cc: linux-kernel@vger.kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
linux-kbuild@vger.kernel.org
Subject: Re: [PATCH 1/3] Replace kernel/timeconst.pl with kernel/timeconst.sh
Date: Wed, 9 Dec 2009 17:40:41 -0600 [thread overview]
Message-ID: <200912091740.43147.rob@landley.net> (raw)
In-Reply-To: <4B1FC621.8060500@suse.cz>
On Wednesday 09 December 2009 09:45:37 Michal Marek wrote:
> [CC hpa who wrote the timeconst.pl script]
>
> On 8.12.2009 10:19, Rob Landley wrote:
> > From: Rob Landley <rob@landley.net>
> >
> > Replace kernel/timeconst.pl with kernel/timeconst.sh. The new shell
> > script is much simpler, about 1/4 the size, and runs on Red Hat 9 from
> > 2003.
>
> I tried the shell script with the precomputed values in timeconst.pl and
> it gave me different results than the perl version for 250 and 1000:
You're right.
They're functionally equivalent (due to the relationship between MUL32 and
SHR32), which is why this code has worked for me and other people for a year
now. The difference is the possibility of an integer overflow if you try to
convert a time period of "0xffffffff".
Trivial fix:
--- a/sources/patches/linux-2.6.25-rc1-noperl.patch Tue Dec 08 20:22:53 2009
-0600
+++ b/sources/patches/linux-2.6.25-rc1-noperl.patch Wed Dec 09 17:28:26 2009
-0600
@@ -507,7 +507,7 @@
+
+ # Keep increasing $SHIFT until we've got 32 bits.
+
-+ [ $MUL32 -gt $(( 1 << 31 )) ] && break
++ [ $MUL32 -ge $(( 1 << 31 )) ] && break
+ SHIFT=$(( $SHIFT + 1 ))
+ done
+ MUL32=$( printf %x $MUL32 )
As long as MUL32 fits in 32 bits than you can multiply it by another 32 bit
number without overflow, and that's probably all the kernel's enforcing.
> #define HZ_TO_MSEC_NUM U64_C(4)
> #define HZ_TO_MSEC_DEN U64_C(1)
> -#define MSEC_TO_HZ_MUL32 U64_C(0x80000000)
> -#define MSEC_TO_HZ_ADJ32 U64_C(0x180000000)
> -#define MSEC_TO_HZ_SHR32 33
> +#define MSEC_TO_HZ_MUL32 U64_C(0x100000000)
> +#define MSEC_TO_HZ_ADJ32 U64_C(0x300000000)
> +#define MSEC_TO_HZ_SHR32 34
> #define MSEC_TO_HZ_NUM U64_C(1)
> #define MSEC_TO_HZ_DEN U64_C(4)
> #define HZ_TO_USEC_MUL32 U64_C(0xfa000000)
The same.
> and with HZ=1000:
> --- perl
> +++ bash
> @@ -8,14 +8,14 @@
> #error "kernel/timeconst.h has the wrong HZ value!"
> #endif
>
> -#define HZ_TO_MSEC_MUL32 U64_C(0x80000000)
> +#define HZ_TO_MSEC_MUL32 U64_C(0x100000000)
> #define HZ_TO_MSEC_ADJ32 U64_C(0x0)
> -#define HZ_TO_MSEC_SHR32 31
> +#define HZ_TO_MSEC_SHR32 32
And again.
> #define HZ_TO_MSEC_NUM U64_C(1)
> #define HZ_TO_MSEC_DEN U64_C(1)
> -#define MSEC_TO_HZ_MUL32 U64_C(0x80000000)
> +#define MSEC_TO_HZ_MUL32 U64_C(0x100000000)
> #define MSEC_TO_HZ_ADJ32 U64_C(0x0)
> -#define MSEC_TO_HZ_SHR32 31
> +#define MSEC_TO_HZ_SHR32 32
Same thing.
> You're trying to avoid the build dependency on Perl. What about adding a
> timeconst.h_shipped with the precomputed values from timeconst.pl:
Been there, done that. My first patch (way back for 2.6.25) took that
approach:
http://landley.net/hg/hgwebdir.cgi/firmware/file/a791ca629d9c/sources/patches/linux-2.6.25-
rc1-noperl.patch
But it turns out various non-x86 targets (such as ARM OMAP) allow HZ to be
specified by an entry field in the config file, into which the user can type a
range of numbers. See this post from last year for details:
http://lists.impactlinux.com/pipermail/firmware-impactlinux.com/2008-
December/000022.html
This is why reducing the perl version to just the precomputed constants
wouldn't work either. (They're there so that you only need to install a
random cpan library when surprised by a build break on non-x86 machines.)
> > + echo
> > + echo "#endif /* __KERNEL_TIMECHONST_H */"
>
> ^
>
> Should be "__KERNEL_TIMECONST_H".
Yeah, Joe Perches pointed that out to me off-list. It's just a comment so I
didn't resubmit the patch for that, but I've fixed my local version already.
Rob
--
Latency is more important than throughput. It's that simple. - Linus Torvalds
next prev parent reply other threads:[~2009-12-09 23:40 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-08 9:17 [PATCH 0/3] clean out Perl from build system Rob Landley
2009-12-08 9:19 ` [PATCH 1/3] Replace kernel/timeconst.pl with kernel/timeconst.sh Rob Landley
2009-12-09 15:45 ` Michal Marek
2009-12-09 23:40 ` Rob Landley [this message]
2009-12-09 23:45 ` H. Peter Anvin
2009-12-10 1:50 ` Rob Landley
2009-12-10 1:53 ` H. Peter Anvin
2009-12-10 13:52 ` Michal Marek
2009-12-10 23:16 ` Rob Landley
2009-12-11 15:31 ` Michal Marek
2009-12-11 19:13 ` H. Peter Anvin
2009-12-12 0:49 ` Rob Landley
2009-12-08 9:21 ` [PATCH 2/3] Remove perl from make headers_install Rob Landley
2009-12-08 9:22 ` [PATCH 3/3] Convert kernel/cpu/mkcapflags.pl to kernel/cpu/mkcapflags.sh Rob Landley
2009-12-08 10:23 ` [PATCH 0/3] clean out Perl from build system Michal Marek
2009-12-08 15:08 ` Rob Landley
-- strict thread matches above, loose matches on Subject: below --
2009-09-19 1:25 [PATCH 0/3] Perl removal patches for 2.6.31 Rob Landley
2009-09-19 1:33 ` [PATCH 1/3]: Replace kernel/timeconst.pl with kernel/timeconst.sh Rob Landley
2009-01-02 8:07 PATCH [0/3]: Simplify the kernel build by removing perl Rob Landley
2009-01-02 8:13 ` [PATCH 1/3]: Replace kernel/timeconst.pl with kernel/timeconst.sh Rob Landley
2009-01-02 8:13 ` Rob Landley
2009-01-02 9:04 ` Sam Ravnborg
2009-01-02 12:00 ` Rob Landley
2009-01-02 19:33 ` H. Peter Anvin
2009-01-04 1:32 ` Rob Landley
2009-01-04 1:35 ` H. Peter Anvin
2009-01-04 12:07 ` Alan Cox
2009-01-04 18:36 ` H. Peter Anvin
2009-01-04 19:03 ` Rob Landley
2009-01-04 20:39 ` H. Peter Anvin
2009-01-05 0:59 ` Rob Landley
2009-01-03 6:28 ` Harvey Harrison
2009-01-03 12:28 ` Ingo Oeser
2009-01-04 1:36 ` Rob Landley
2009-01-04 1:36 ` Rob Landley
2009-01-04 5:07 ` Valdis.Kletnieks
2009-01-04 6:43 ` Rob Landley
2009-01-04 22:13 ` Jamie Lokier
2009-01-05 0:15 ` Bernd Petrovitsch
2009-01-05 2:23 ` Jamie Lokier
2009-01-05 10:46 ` Bernd Petrovitsch
2009-01-05 15:01 ` Jamie Lokier
2009-01-05 16:18 ` Bernd Petrovitsch
2009-01-06 0:06 ` Rob Landley
2009-01-05 21:07 ` Rob Landley
2009-01-05 4:50 ` Rob Landley
2009-01-05 12:29 ` Bernd Petrovitsch
2009-01-04 21:51 ` Alejandro Mery
2009-01-04 7:15 ` Michal Jaegermann
2009-01-04 7:15 ` Michal Jaegermann
2009-01-05 0:41 ` Ray Lee
2009-01-05 5:08 ` Rob Landley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200912091740.43147.rob@landley.net \
--to=rob@landley.net \
--cc=hpa@zytor.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mmarek@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.