You are not logged in.

#1 2009-05-16 03:45:33

methuselah
Member
Registered: 2007-10-02
Posts: 570

Wondering if this was the correct way to patch my kernel for CFLAGS?

Hello. I use to build the zen-sources kernel but stopped many months ago. I didn't really need all of those patches but I did miss the Custom CFLAGS/MAKEFLAGS option that the zen kernel had. I also missed the 432HZ Timer frequency setting available in the zen patch.


So I researched a bit and grabbed these parts from the zen patch to add to the Arch kernel:


For the CFLAGS/MAKEFLAGS

diff --git a/Makefile b/Makefile
index 1ab3ebf..472fe73 100644
--- a/Makefile
+++ b/Makefile
@@ -328,13 +328,12 @@ CHECK        = sparse
 CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
           -Wbitwise -Wno-return-void $(CF)
 MODFLAGS    = -DMODULE
-CFLAGS_MODULE   = $(MODFLAGS)
-AFLAGS_MODULE   = $(MODFLAGS)
-LDFLAGS_MODULE  =
-CFLAGS_KERNEL    =
+CFLAGS_MODULE    = $(MODFLAGS) $(CUSTOM_CFLAGS)
+AFLAGS_MODULE    = $(MODFLAGS)
+LDFLAGS_MODULE    =
+CFLAGS_KERNEL    = $(CUSTOM_CFLAGS)
 AFLAGS_KERNEL    =
 
-
 # Use LINUXINCLUDE when you must reference the include/ directory.
 # Needed to be compatible with the O= option
 LINUXINCLUDE    := -Iinclude \
@@ -344,6 +343,9 @@ LINUXINCLUDE    := -Iinclude \
 
 KBUILD_CPPFLAGS := -D__KERNEL__
 
+# Apply custom flags
+KBUILD_CFLAGS    += $(CUSTOM_CFLAGS)
+
 KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
            -fno-strict-aliasing -fno-common \
            -Werror-implicit-function-declaration
diff --git a/init/Kconfig b/init/Kconfig
index 6a5c5fe..7b2f4b5 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -672,6 +734,32 @@ config CC_OPTIMIZE_FOR_SIZE
 
       If unsure, say Y.
 
+menu "Custom Build Flags"
+
+config CUSTOM_CFLAGS
+    string "Custom CFLAGS for kernel"
+    default ""
+    help
+        You can use this to easily set custom gcc CFLAGS to be used for the
+        entire kernel (including modules).
+
+    No warning for you, i can't fix stupidity.
+
+        If unsure, leave blank.
+
+config CUSTOM_MAKEFLAGS
+    string "Custom MAKEFLAGS for kernel"
+    default ""
+    help
+        You can use this to easily set custom MAKEFLAGS to be used for building
+        the entire kernel.
+
+    (Or just use the options when you run make?)
+
+        If unsure, leave blank.
+
+endmenu
+
 config SYSCTL
     bool

and for the Timer frequency:

diff --git a/kernel/Kconfig.hz b/kernel/Kconfig.hz
index 94fabd5..7a830d4 100644
--- a/kernel/Kconfig.hz
+++ b/kernel/Kconfig.hz
@@ -4,7 +4,7 @@
 
 choice
     prompt "Timer frequency"
-    default HZ_250
+    default HZ_1000
     help
      Allows the configuration of the timer frequency. It is customary
      to have the timer interrupt run at 1000 Hz but 100 Hz may be more
@@ -23,6 +23,30 @@ choice
       with lots of processors that may show reduced performance if
       too many timer interrupts are occurring.
 
+    config HZ_108
+        bool "108 HZ"
+    help
+          864 HZ is the best value for desktop systems. Most responsive
+          out of all the options. This is for Eight core/Processor systems only
+          as timer frequencies * NR_CPUS = actual frequency.
+          Try this if you have a Eight Core/Processor processor system and a desktop environment.
+
+    config HZ_144
+        bool "144 HZ"
+    help
+      864 HZ is the best value for desktop systems. Most responsive
+      out of all the options. This is for Six Core/Processor systems only
+      as timer frequencies * NR_CPUS = actual frequency.
+      Try this if you have a Six core/processor system and a desktop environment.
+
+    config HZ_216
+        bool "216 HZ"
+    help
+      864 HZ is the best value for desktop systems. Most responsive
+      out of all the options. This is for Quad-core/Processor systems only
+      as timer frequencies * number of processors = actual frequency.
+      Try this if you have a quad-core/dual processor system and a desktop environment.
+
     config HZ_250
         bool "250 HZ"
     help
@@ -39,6 +63,22 @@ choice
      on SMP and NUMA systems and exactly dividing by both PAL and
      NTSC frame rates for video and multimedia work.
 
+    config HZ_432
+      bool "432 HZ"
+    help
+      864 HZ is the best value for desktop systems. Most responsive
+      out of all the options. This is for Dual Core/Processor systems only
+      as timer frequencies * number of processors = actual frequency.
+      Try this if you have a dual-core/dual processor system and a desktop environment.
+
+    config HZ_864
+      bool "864 HZ"
+    help
+      864 HZ is the best value for desktop systems. Most responsive
+      out of all the options. The only reason it is not default is
+      because it may break few drivers. Give it a try if you have
+      a desktop :).
+
     config HZ_1000
         bool "1000 HZ"
     help
@@ -50,8 +90,13 @@ endchoice
 config HZ
     int
     default 100 if HZ_100
+    default 108 if HZ_108
+    default 144 if HZ_144
+    default 216 if HZ_216
     default 250 if HZ_250
     default 300 if HZ_300
+    default 432 if HZ_432
+    default 864 if HZ_864
     default 1000 if HZ_1000
 
 config SCHED_HRTICK

Well the code was added to my make menuconfig kernel settings, and is in the .config of my newly compiled kernel..... I'm just wondering if I did this correctly. (I'm pretty sure that I did a crappy job of patching since I just grabbed the pieces of the zen patch that I thought were the correct one)..... This is the message from the patch:

patching file Makefile
patching file init/Kconfig
patch unexpectedly ends in middle of line
Hunk #1 succeeded at 734 with fuzz 2.
patching file kernel/Kconfig.hz
patch unexpectedly ends in middle of line
Hunk #4 succeeded at 90 with fuzz 1.

So if someone can tell me a better way to patch the kernel26 for custom CFLAGS and 432HZ Timer frequency (for dual core) I would appreciate it. Thanks.

Offline

#2 2009-05-19 15:20:10

methuselah
Member
Registered: 2007-10-02
Posts: 570

Re: Wondering if this was the correct way to patch my kernel for CFLAGS?

I'm still trying to find out if I needed to patch any other parts of the kernel source when I added CFLAGS to the kernel modules? I also would like to know if I did the Timing part correctly (so I could use the 432HZ setting for a dual core).

..... so far this kernel has worked ok for the last 4 days. Does anybody know how I can benchmark it and compare it to other kernels that I have built with different settings?

Any info is appreciated.

Last edited by methuselah (2009-05-19 15:20:55)

Offline

Board footer

Powered by FluxBB