[Samsung Galaxy Nexus] lioux:
Hi,

CoDel has been making its rounds around the Internet. It would be nice if we could have it on our Galaxy Nexus. In case you have no idea what I'm talking about:

Codel

Codel on BufferBloat.net

A must read, a non-technical explanation on BufferBloat, why we should care, why/how we should fight it and CoDel:

Why should we fight bufferbloat?

I apologize but I can't post URL links yet. The forum won't allow it. :)

This little "guide" teaches how to build CoDel based SCH_NET modules for Android. I'll probably should have posted on "Galaxy Nexus Android Development" but I don't have permission yet. :(

I've successfully built it for Android but I'm currently having trouble loading the modules on Android. I'm getting "exec format errors" when I insmod. I am pretty sure it's a version mismatch problem between my kernel source and my phone installed kernel. Anyone knowledgeable on generating kernel images willing to build this one? It should work if you build this against your kernel and generate a complete kernel image.

I used a kubuntu system for building the modules, yet you should be okay with any linux flavor.

You are required to know how to build a Android kernel module. It's assumed you know your way around a Linux system. This is not a step-by-step guide. It requires changes depending on your system installation.

Get the appropriate Android build toolchain and kernel sources for your Android.

I'm using the Linaro cross platform toolchain which you can download.

CoDel is obtained from the mcgrof compat module done by Luis R. Rodriguez. I only tweaked the Makefile to build it for Synology.

Download the mcgrof compat module.

Extract it somewhere. Rename the extracted directory to "mcgrof-compat" (without the quotes).

Apply the following patch for a kernel 3.0.+. I'm building for my Galaxy Nexus.

diff -ruN ../mcgrof-compat-5461c02.orig/compat/Makefile ./compat/Makefile
--- ../mcgrof-compat-5461c02.orig/compat/Makefile 2013-01-21 22:01:41.000000000 -0200
+++ ./compat/Makefile 2013-02-24 10:06:23.268068197 -0300
@@ -2,6 +2,10 @@
obj-m += compat.o
#compat-objs :=

+CONFIG_COMPAT_NET_SCH_FQ_CODEL=m
+CONFIG_COMPAT_NET_SCH_CODEL=m
+CONFIG_COMPAT_KERNEL_3_3=y
+
obj-$(CONFIG_COMPAT_FIRMWARE_CLASS) += compat_firmware_class.o
obj-$(CONFIG_COMPAT_NET_SCH_CODEL) += sch_codel.o

diff -ruN ../mcgrof-compat-5461c02.orig/Makefile ./Makefile
--- ../mcgrof-compat-5461c02.orig/Makefile 2013-01-21 22:01:41.000000000 -0200
+++ ./Makefile 2013-02-24 10:06:58.480242839 -0300
@@ -38,7 +38,7 @@
# the same.
NOSTDINC_FLAGS := -I$(M)/include/ \
-include $(M)/include/linux/compat-2.6.h \
- $(CFLAGS) \
+ $(CFLAGS) -fno-pic \
-DCOMPAT_BASE="\"$(COMPAT_BASE)\"" \
-DCOMPAT_BASE_TREE="\"$(COMPAT_BASE_TREE)\"" \
-DCOMPAT_BASE_TREE_VERSION="\"$(COMPAT_BASE_TREE_VERSION)\"" \

Set CROSS_COMPILE to your toolchain and KLIB_BUILD to your kernel sources.

# cd mcgrof-compat
# ./scripts/gen-compat-config.sh > mcgrof-compat/compat/.config
# ./scripts/gen-compat-autoconf.sh mcgrof-compat/compat/.config > ./include/linux/compat_autoconf.h
# make ARCH=arm \
CROSS_COMPILE="/v/0/ccache-bin/arm-linux-androideabi-" \
KLIB_BUILD=/v/0/android-git/linux-linaro-3.0/
# ls mcgrof-compat/compat/*ko

Now, you have the following kernel modules:

mcgrof-compat/compat/compat.ko

mcgrof-compat/compat/sch_codel.ko

mcgrof-compat/compat/sch_fq_codel.ko

Decide which CoDel flavor you need: codel or fq_codel. Copy the files to your Android.

For example, to load fq_codel which is a fair queueing implementation:

# insmod compat.ko
# insmod sch_fq_codel.ko
# tc qdisc add dev rmmnet0 root fq_codel
# tc qdisc add dev wlan0 root fq_codel

I hope this is helpful to you. You now have both codel and fq_codel modules and you can load them.

Codel is not a silver bullet: it needs at least basic configuration (updated iproute2 or source patching) and a proper QoS configuration on your network.

The QoS configuration is up to you. However, CoDel is a improvement regardless of your setup.

In case you're feeling adventurous AND you know what you're doing. You can always tweak the configuration inside the source code. Follows the configuration I'm using for my ADSL 5Mib D/ 512Kib U when on WIFI. This is what I'm using for my Synology NAS. We probably can find "optimal" configurations for our Android phones but I'd be trying that one for now.

Let me know if there is anything I can do to help.

Best regards,

--- sch_fq_codel_core.c.orig 2013-02-13 09:12:35.654488441 -0200
+++ sch_fq_codel_core.c 2013-02-13 09:14:58.884429036 -0200
@@ -351,7 +351,7 @@
q->cparams.ecn = !!nla_get_u32(tb[TCA_FQ_CODEL_ECN]);

if (tb[TCA_FQ_CODEL_QUANTUM])
- q->quantum = max(256U, nla_get_u32(tb[TCA_FQ_CODEL_QUANTUM]));
+ q->quantum = max(500U, nla_get_u32(tb[TCA_FQ_CODEL_QUANTUM]));

#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39))
while (sch->q.qlen > q->limit) {
@@ -408,7 +408,7 @@
int i;

#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39))
- q->limit = 10*1024;
+ q->limit = 600;
#else
sch->limit = 10*1024;
#endif