CentOS Icon CentOS Logo
CentOS Text
   
  
www.centos.org Forum Index
   CentOS 4 - General Support
  need to build kernel with HZ = 100

 

 Bottom   Previous Topic   Next Topic
  •  Rate Thread
      Rate this Thread
      Excellent
      Good
      Average
      Bad
      Terrible
Poster Thread Rated:  2 Votes
  •  dreamgear
      dreamgear
need to build kernel with HZ = 100
#1
Peeking in the Member Window
Joined: 2006/4/15
From
Posts: 12
I want to change the timer interrupt rate back to 100 HZ in a 2.6 kernel. This will be for use on a VMware ESX server.

As described in http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&externalId=1420 :

Quote:
In standard 2.6 kernels, the timer interrupt rate is fixed at kernel compile time and cannot be changed by command line parameters. You can, however, recompile your kernel with a lower timer interrupt rate. 100Hz is adequate for most applications in a Linux guest. See the documentation for your Linux distribution for detailed instructions on how to build and run a custom kernel. Before recompiling the guest kernel, locate the following line in /usr/src/linux-2.6/include/asm-i386/param.h:

#define HZ 1000

Change the value of HZ to 100:

#define HZ 100


But my objective is not to correct a slow clock, it is rather to reduce the cpu overhead to the VMware host at idle (at the possible expense of timing accuracy on the VMware client OS).

What's the easiest way to do this? I followed the instructions at http://wiki.centos.org/HowTos/Custom_Kernel but I suspect that once I manually change include/asm-i386/param.h, the following steps in the rebuilding process will un-do my change. I thought I might be able to change it using "make menuconfig" but I could not find any place to change the timer interrupt rate. I may have missed it, of course...
Posted on: 2007/7/5 19:08
Create PDF from Post Print
Top
  •  toracat
      toracat
Re: need to build kernel with HZ = 100
#2
Moderator
Joined: 2006/9/3
From California, US
Posts: 5070
Quote:

dreamgear wrote:
What's the easiest way to do this? I followed the instructions at http://wiki.centos.org/HowTos/Custom_Kernel but I suspect that once I manually change include/asm-i386/param.h, the following steps in the rebuilding process will un-do my change. I thought I might be able to change it using "make menuconfig" but I could not find any place to change the timer interrupt rate. I may have missed it, of course...

If you follow the instructions on that wiki page *exactly* the way they are given, you should be able to build the kernel successfully. Please note that the page was slightly amended very recently. If you attempted the rebuild process more than a couple of days ago, you might want to re-read the page and try again. More specifically, you need to run "make oldconfig" after copying the config file to the BUILD directory.

Akemi
_________________
Useful links: Search Forums; Forum FAQ; CentOS Wiki
Posted on: 2007/7/5 21:19
Create PDF from Post Print
Top
  •  toracat
      toracat
Re: need to build kernel with HZ = 100
#3
Moderator
Joined: 2006/9/3
From California, US
Posts: 5070
In addition, after making changes to the param.h file, the next rpmbuild command must be run in such a way that the %prep step is skipped. Try rmpbuild -bc --short-circuit to achieve that. Read man rpmbuild for details. If you run rpmbuild -ba, it will repeat the %prep step and therefore wipe out the change you had made.

Akemi
_________________
Useful links: Search Forums; Forum FAQ; CentOS Wiki
Posted on: 2007/7/5 21:53
Create PDF from Post Print
Top
  •  toracat
      toracat
Re: need to build kernel with HZ = 100
#4
Moderator
Joined: 2006/9/3
From California, US
Posts: 5070
There is another way to apply the change -- that is to use a patch file. I have just created it for you.

The "param.h.patch" file:
--- linux-2.6.9/include/asm-i386/param.h.orig   2007-07-05 17:25:23.000000000 -0700
+++ linux-2.6.9/include/asm-i386/param.h        2007-07-05 17:24:51.000000000 -0700
@@ -2,7 +2,7 @@
 #define _ASMi386_PARAM_H

 #ifdef __KERNEL__
-# define HZ            1000            /* Internal kernel timer frequency */
+# define HZ            100             /* Internal kernel timer frequency */
 # define USER_HZ       100             /* .. some user interfaces are in "ticks" */
 # define CLOCKS_PER_SEC                (USER_HZ)       /* like times() */
 #endif

Save this patch file and add it to the .spec file by following the instructions in the wiki page. Once this is done, there is no need to edit the source, and you can rebuild the kernel just by running rpmbuild -ba (no need to go through cp .config etc.).

Hope this works,
Akemi
_________________
Useful links: Search Forums; Forum FAQ; CentOS Wiki
Posted on: 2007/7/6 0:51
Create PDF from Post Print
Top
  •  dreamgear
      dreamgear
Re: need to build kernel with HZ = 100
#5
Peeking in the Member Window
Joined: 2006/4/15
From
Posts: 12
Thanks much!
Posted on: 2007/7/6 17:31
Create PDF from Post Print
Top
  •  brandpc
      brandpc
Re: need to build kernel with HZ = 100
#6
Newbie
Joined: 2007/7/10
From
Posts: 5
I attempted to apply the patch file above as specified in the .spec file

However, my results are the following:

+ echo 'Patch #40000 (param.h.patch):'
Patch #40000 (param.h.patch):
+ patch -p1 -s
1 out of 1 hunk FAILED -- saving rejects to file include/asm-i386/param.h.rej
error: Bad exit status from /var/tmp/rpm-tmp.82523 (%prep)


RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.82523 (%prep)
[kernel@node101 SPECS]$ \


The file it references (include/asm-i386/param.h.rej) contains the following:

[kernel@node101 /]$ vi /home/kernel/rpmbuild/BUILD/kernel-2.6.9/linux-2.6.9/include/asm-i386/param.h.rej
***************
*** 2,8 ****
  #define _ASMi386_PARAM_H

  #ifdef __KERNEL__
- # define HZ            1000            /* Internal kernel timer frequency */
  # define USER_HZ       100             /* .. some user interfaces are in "ticks" */
  # define CLOCKS_PER_SEC                (USER_HZ)       /* like times() */
  #endif
--- 2,8 ----
  #define _ASMi386_PARAM_H

  #ifdef __KERNEL__
+ # define HZ            100             /* Internal kernel timer frequency */
  # define USER_HZ       100             /* .. some user interfaces are in "ticks" */
  # define CLOCKS_PER_SEC                (USER_HZ)       /* like times() */
  #endif
~


Any ideas?
Posted on: 2007/7/10 14:21
Create PDF from Post Print
Top
  •  toracat
      toracat
Re: need to build kernel with HZ = 100
#7
Moderator
Joined: 2006/9/3
From California, US
Posts: 5070
It appears that the include/asm-i386/param.h file does not contain the line "# define HZ 1000". It is already "100" instead of "1000". Are you sure this is the file you want to modify? Or does your original param.h file say "1000" ? This is kernel 2.6.18, right?
_________________
Useful links: Search Forums; Forum FAQ; CentOS Wiki
Posted on: 2007/7/10 17:39
Create PDF from Post Print
Top
  •  brandpc
      brandpc
Re: need to build kernel with HZ = 100
#8
Newbie
Joined: 2007/7/10
From
Posts: 5
The orginal says 1000, which is making this even more confusing.

I have tried multiple times now, multiple reformats. One time it worked, I have no clue what I am doing so wrong.
Posted on: 2007/7/10 21:02
Create PDF from Post Print
Top
  •  toracat
      toracat
Re: need to build kernel with HZ = 100
#9
Moderator
Joined: 2006/9/3
From California, US
Posts: 5070
Sorry, I was a bit confused. You are talking about CentOS 4, not 5. Yes, the original file says 1000. I re-created a patch file and confirmed it works in my test box (CentOS 4.5). This one succesfully patched param.h.


--- linux-2.6.9/include/asm-i386/param.h        2007-07-10 15:48:17.000000000 -0700
+++ linux-2.6.9/include/asm-i386/param.h        2007-07-10 15:49:24.000000000 -0700
@@ -2,7 +2,7 @@
 #define _ASMi386_PARAM_H

 #ifdef __KERNEL__
-# define HZ            1000            /* Internal kernel timer frequency */
+# define HZ            100             /* Internal kernel timer frequency */
 # define USER_HZ       100             /* .. some user interfaces are in "ticks" */
 # define CLOCKS_PER_SEC                (USER_HZ)       /* like times() */
 #endif

_________________
Useful links: Search Forums; Forum FAQ; CentOS Wiki
Posted on: 2007/7/10 23:07
Create PDF from Post Print
Top
  •  brandpc
      brandpc
Re: need to build kernel with HZ = 100
#10
Newbie
Joined: 2007/7/10
From
Posts: 5
Toracat,

I was having problems with that patch file earlier --- but it appears to be working now -- only not in the enviorment where I need it.

Since I am compiling an x86_64 kernel, I keep changing the variables to match those within the x86_64 folder.

However, the operation continues to fail.

Here is how I am modifying:

[kernel@node101 SOURCES]$ vi linux-2.6.9-vmware-time-x86_64.patch
--- linux-2.6.9/include/asm-x86_64/param.h        2007-07-10 15:48:17.000000000 -0700
+++ linux-2.6.9/include/asm-x86_64/param.h        2007-07-10 15:49:24.000000000 -0700
@@ -2,7 +2,7 @@
 #define _ASMx86_64_PARAM_H

 #ifdef __KERNEL__
-# define HZ            1000            /* Internal kernel timer frequency */
+# define HZ            100             /* Internal kernel timer frequency */
 # define USER_HZ       100             /* .. some user interfaces are in "ticks" */
 #define CLOCKS_PER_SEC                (USER_HZ)       /* like times() */
 #endif


This fails however -- with a same / very similar error to before
Posted on: 2007/7/11 0:24
Create PDF from Post Print
Top
  •  brandpc
      brandpc
Re: need to build kernel with HZ = 100
#11
Newbie
Joined: 2007/7/10
From
Posts: 5
Here is the exact rej file:

[kernel@node101 include]$ cd asm-x86_64
[kernel@node101 asm-x86_64]$ vi param.h.rej
***************
*** 2,8 ****
  #define _ASMx86_64_PARAM_H

  #ifdef __KERNEL__
- # define HZ            1000            /* Internal kernel timer frequency */
  # define USER_HZ       100             /* .. some user interfaces are in "ticks" */
  #define CLOCKS_PER_SEC                (USER_HZ)       /* like times() */
  #endif
--- 2,8 ----
  #define _ASMx86_64_PARAM_H

  #ifdef __KERNEL__
+ # define HZ            100             /* Internal kernel timer frequency */
  # define USER_HZ       100             /* .. some user interfaces are in "ticks" */
  #define CLOCKS_PER_SEC                (USER_HZ)       /* like times() */
  #endif
~ 
'


Here is the attempted patch response:

Patch #30000 (linux-2.6.9-vmware-time-x86_64.patch):
+ patch -p1 -s
1 out of 1 hunk FAILED -- saving rejects to file include/asm-x86_64/param.h.rej
error: Bad exit status from /var/tmp/rpm-tmp.17679 (%prep)
Posted on: 2007/7/11 0:31
Create PDF from Post Print
Top
  •  brandpc
      brandpc
Re: need to build kernel with HZ = 100
#12
Newbie
Joined: 2007/7/10
From
Posts: 5
I have manually done a complete rewrite of the patch -- and just saw it go through.

I guess I'll see in an hour or so if I have a working compile.
Posted on: 2007/7/11 1:03
Create PDF from Post Print
Top
  •  jottschi
      jottschi
Re: need to build kernel with HZ = 100
#13
Newbie
Joined: 2007/7/23
From
Posts: 1
Hi,

you also could ask your preferred search engine for xaox vmware or
take a look at http://www.vmware.com/community/thread.jspa?messageID=699089
I use this kernels for CentOS 4.x with succsess.

Jottschi
Posted on: 2007/7/23 9:11
Create PDF from Post Print
Top
 Top   Previous Topic   Next Topic

 


 You cannot start a new topic.
 You can view topic.
 You cannot reply to posts.
 You cannot edit your posts.
 You cannot delete your posts.
 You cannot add new polls.
 You cannot vote in polls.
 You cannot attach files to posts.
 You cannot post without approval.




"Linux" is a registered trademark of Linus Torvalds. | All other trademarks are property of their respective owners. | All other content is Copyright @ 2004-2009 by the CentOS Project or "each individual contributor (forums, comments, etc.) unless otherwise assigned".| Theme based on a theme by 7dana.com