Build F17 with Memory Compression

This page has not been liked. Updated 4/12/13 6:45 AM by jhopperTags:

Follow these instructions to build Fedora 17 with memory compression.

 


Create the build environment

1. Log in as root.

2. Install the RPM development tools:

$ yum install rpmdevtools yum-utils

3. Kernel RPMs don't need to be built as root (in fact, they probably shouldn't be for security) so create a user for building the RPM (as root):

$ useradd -d /home/build -s /bin/bash -m build
$ passwd build

4. Log out and log back in as '''build.'''



5. Create the rpmbuild directory tree:

$ rpmdev-setuptree

6. Download the kernel source RPM.

$ yumdownloader --source kernel

7. Download the build dependencies for the kernel RPM (as root):

$ yum-builddep kernel-3.6.11-1.fc17.src.rpm

8. Install the kernel source RPM:

$ rpm -Uvh kernel-3.6.11-1.fc17.src.rpm

 


Generate patches from linux-next

1. If you don't already have a linux git repository, git one (see what I did there?):

git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

2. Add the stable tree as a remote:

$ cd linux
$ git remote add stable git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
$ git fetch stable

3. Also add linux-next as a remote:

$ git remote add next git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ git fetch next

4. Create/checkout a new branch based on the Fedora kernel version.

$ git checkout -b f17ame v3.6.11

5. Cherry pick each of the commits in the '''Commit List''' below from next-linux in order like this (for each commit):

$ git cherry-pick <commit ID>

Commit list:

c9e0c8ce434076dda4a682f3c13e76b056afba53 crypto: drivers - remove cra_list initialization

c46807041283d762de8ed8b1f331c4711159e4f0 powerpc/crypto: rework Kconfig

5b0d62f4dfee86831a6f0f74d04bac5e439a597d powerpc/crypto: add compression support to arch vec

f56f43e376ba41ce419e21fbc09361bc4e309f5b powerpc/crypto: add 842 hardware compression driver

1d49fe7c064bf06c24f19b42589721925ce49b6c powerpc/crypto: add 842 crypto driver

508dc3a17c2bfd479a21df9cdda88c3a5a83ccbb crypto: nx - Remove virt_to_abs() usage in nx-842.c

bc9c8d30e4c11705126154c6dfc1a4c34a17f0af powerpc/crypto: Remove users of virt_to_abs() and phys_to_abs()

19c69252eff46c6ffbe0b86579954401ebdc395a crypto: 842 - remove .cra_list initialization

b6b3de367d4663237216bf7bc9808f8b8c8ca1bf lib/lzo: Rename lzo1x_decompress.c to lzo1x_decompress_safe.c

8e886ac9acf55a450da8506c0d8d820879794c22 lib/lzo: Update LZO compression to current upstream version

dd2a34407bd2516bb0945482919c582f3e2f69f2 lib/lzo: Optimize code for CPUs with inefficient unaligned acces

4c5d3c9ca0c39b9c655ef1fdf75ad1eecbfcd1fc crypto: testmgr - update LZO compression test vectors

ea180bf5716c7539cb1c9027b58267528ec4865f lib/decompress_unlzo.c: fix a trivial compilation error

284a308943a9d8b7155a7601ebed4ae85d6aeb33 staging: zsmalloc: s/firstpage/page in new copy map funcs

5661030e07348c9fdfe835b5b34cd552a294a38e staging: zsmalloc: prevent mappping in interrupt context

0baab3f2fd9ae94bf50e39b9f390c904e4b037b2 staging: zsmalloc: add page table mapping method

1f3b2277d717ed6e30ae738a27679bdd0571f17f zsmalloc: collapse internal .h into .c

6. Download the zswap patchset and apply them to the branch:

zswap v2 patchset links:

https://patchwork.kernel.org/patch/1942471/mbox

https://patchwork.kernel.org/patch/1942481/mbox

https://patchwork.kernel.org/patch/1942541/mbox

https://patchwork.kernel.org/patch/1942511/mbox

https://patchwork.kernel.org/patch/1942531/mbox

https://patchwork.kernel.org/patch/1942551/mbox

https://patchwork.kernel.org/patch/1942491/mbox

https://patchwork.kernel.org/patch/1942521/mbox

https://patchwork.kernel.org/patch/1942501/mbox

$ git am PATCHv2-*

7. Generate the patchset:

$ git format-patch v3.6.11..

8. You should now have numbered patch files. Copy these files to your rpmbuild directory under ~/rpmbuild/SOURCES.

 


Create the kernel.spec file

1. Generate the kernel.spec file

$ cd ~/rpmbuild/SPECS
$ rpmbuild -bp --target=$(uname -m) kernel.spec

2. Open ''kernel.spec'' and do the following:

  • Replace
#% define buildid .local

with

%define buildid .ame
  • Add "Patch#" and "ApplyPatch" lines for each patch to kernel.spec at the end of the appropriate section. For example:



Patch#

Patch25001: 0001-crypto-drivers-remove-cra_list-initialization.patch
Patch25002: 0002-powerpc-crypto-rework-Kconfig.patch
Patch25003: 0003-powerpc-crypto-add-compression-support-to-arch-vec.patch
Patch25004: 0004-powerpc-crypto-add-842-hardware-compression-driver.patch
Patch25005: 0005-powerpc-crypto-add-842-crypto-driver.patch
Patch25006: 0006-crypto-nx-Remove-virt_to_abs-usage-in-nx-842.c.patch
Patch25007: 0007-powerpc-crypto-Remove-users-of-virt_to_abs-and-phys_.patch
Patch25008: 0008-crypto-842-remove-.cra_list-initialization.patch
Patch25009: 0009-lib-lzo-Rename-lzo1x_decompress.c-to-lzo1x_decompres.patch
Patch25010: 0010-lib-lzo-Update-LZO-compression-to-current-upstream-v.patch
Patch25011: 0011-lib-lzo-Optimize-code-for-CPUs-with-inefficient-unal.patch
Patch25012: 0012-crypto-testmgr-update-LZO-compression-test-vectors.patch
Patch25013: 0013-lib-decompress_unlzo.c-fix-a-trivial-compilation-err.patch
Patch25014: 0014-staging-zsmalloc-s-firstpage-page-in-new-copy-map-fu.patch
Patch25015: 0015-staging-zsmalloc-prevent-mappping-in-interrupt-conte.patch
Patch25016: 0016-staging-zsmalloc-add-page-table-mapping-method.patch
Patch25017: 0017-zsmalloc-collapse-internal-.h-into-.c.patch
Patch25018: 0018-staging-zsmalloc-add-gfp-flags-to-zs_create_pool.patch
Patch25019: 0019-staging-zsmalloc-remove-unsed-pool-name.patch
Patch25020: 0020-staging-zsmalloc-add-page-alloc-free-callbacks.patch
Patch25021: 0021-staging-zsmalloc-make-CLASS_DELTA-relative-to-PAGE_S.patch
Patch25022: 0022-zsmalloc-promote-to-lib.patch
Patch25023: 0023-debugfs-add-get-set-for-atomic-types.patch
Patch25024: 0024-mm-break-up-swap_writepage-for-frontswap-backends.patch
Patch25025: 0025-zswap-add-to-mm.patch
Patch25026: 0026-zswap-add-documentation.patch

ApplyPatch

ApplyPatch 0001-crypto-drivers-remove-cra_list-initialization.patch
ApplyPatch 0002-powerpc-crypto-rework-Kconfig.patch
ApplyPatch 0003-powerpc-crypto-add-compression-support-to-arch-vec.patch
ApplyPatch 0004-powerpc-crypto-add-842-hardware-compression-driver.patch
ApplyPatch 0005-powerpc-crypto-add-842-crypto-driver.patch
ApplyPatch 0006-crypto-nx-Remove-virt_to_abs-usage-in-nx-842.c.patch
ApplyPatch 0007-powerpc-crypto-Remove-users-of-virt_to_abs-and-phys_.patch
ApplyPatch 0008-crypto-842-remove-.cra_list-initialization.patch
ApplyPatch 0009-lib-lzo-Rename-lzo1x_decompress.c-to-lzo1x_decompres.patch
ApplyPatch 0010-lib-lzo-Update-LZO-compression-to-current-upstream-v.patch
ApplyPatch 0011-lib-lzo-Optimize-code-for-CPUs-with-inefficient-unal.patch
ApplyPatch 0012-crypto-testmgr-update-LZO-compression-test-vectors.patch
ApplyPatch 0013-lib-decompress_unlzo.c-fix-a-trivial-compilation-err.patch
ApplyPatch 0014-staging-zsmalloc-s-firstpage-page-in-new-copy-map-fu.patch
ApplyPatch 0015-staging-zsmalloc-prevent-mappping-in-interrupt-conte.patch
ApplyPatch 0016-staging-zsmalloc-add-page-table-mapping-method.patch
ApplyPatch 0017-zsmalloc-collapse-internal-.h-into-.c.patch
ApplyPatch 0018-staging-zsmalloc-add-gfp-flags-to-zs_create_pool.patch
ApplyPatch 0019-staging-zsmalloc-remove-unsed-pool-name.patch
ApplyPatch 0020-staging-zsmalloc-add-page-alloc-free-callbacks.patch
ApplyPatch 0021-staging-zsmalloc-make-CLASS_DELTA-relative-to-PAGE_S.patch
ApplyPatch 0022-zsmalloc-promote-to-lib.patch
ApplyPatch 0023-debugfs-add-get-set-for-atomic-types.patch
ApplyPatch 0024-mm-break-up-swap_writepage-for-frontswap-backends.patch
ApplyPatch 0025-zswap-add-to-mm.patch
ApplyPatch 0026-zswap-add-documentation.patch

 


Modify config-local

1. Open ''~/rpmbuild/SOURCES/config-local'' and add the follow config options:

CONFIG_ZSMALLOC=y
CONFIG_ZSWAP=y
CONFIG_CRYPTO_842=y
CONFIG_CRYPTO_HW=y
CONFIG_CRYPTO_DEV_NX=y
CONFIG_CRYPTO_DEV_NX_ENCRYPT=y
CONFIG_CRYPTO_DEV_NX_COMPRESS=y

 


Build

$ cd ~/rpmbuild/SPECS
$ rpmbuild -bb --with baseonly --without debuginfo --target=`uname -m` kernel.spec

 


Install

$ cd ~/rpmbuild/RPMS/ppc64
$ rpm -ivh kernel-3.6.11-1.ame.fc17.ppc64.rpm

 


Modify GRUB2

1. Open ''/boot/grub2/grub.cfg''

2. Add '''zswap.enabled=1 zswap.compressor=842''' to the boot parameter list for the new AME kernel stanza.



NOTE: This is a temporary change and will be overwritten if grub-mkconfig is ever run again (i.e. during kernel updates/installs).

 


Reboot

$ reboot