LJ Archive


diff -u: What's New in Kernel Development

Zack Brown

Issue #211, November 2011

As Linus Torvalds released Linux 3.0 at long last, there followed a cascade of minor breakages related solely to the change in version number. Some of these had to do with the kernel sources themselves; others had to do with user scripts out in the wild. The git tree had to be renamed to git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git, because the previous tree had “2.6” in the URL. Then the kernel.org page pointed to the wrong git tree, so that had to be sorted out.

The kernel build scripts also expected a three-numbered version number, with an optional fourth (for the stable series), while the 3.0 kernel will have only two, with an optional third. But, it turns out that there's no easy answer, because the kernel is so used to recognizing itself as a three-numbered entity, that it couldn't (for now) be made to identify as 3.0 internally.

A related problem is that some third-party software, including some that exists in binary form only, can't tolerate the version number change. As Andi Kleen reported, this means that Linux 3.0 is not fully backward-compatible with Linux 2.6, even though the only cause of that incompatibility is the version number. He posted a patch to cause the kernel to masquerade as a 2.6 kernel, with an additional string tacked onto the version number, indicating the proper 3.0 version. It's about as ugly a solution as you could imagine, but Andi said that there didn't seem to be any better workaround that would still allow the binary-only software to run under the new kernels.

The OpenRISC architecture will be included in the Linux kernel. OpenRISC is a really cool hardware project for creating an open-source CPU design. The project has gone through various vicissitudes, including being virtually dead for a while. But, now there are about 25 developers on the project, and they've had a kernel port in development since 2.6.35. Jonas Bonn recently submitted that code to Linus Torvalds for inclusion, and it was accepted readily enough, after a small moment of confusion over whether a related patch by Rusty Russell would be cleaner to accept before or after Jonas'.

Another architecture also is well on the way to being accepted into the kernel. The C64x from Texas Instruments recently got a GCC port, which means it's now possible to compile a full system for that chip. The GCC port is actually in a relatively early stage, but it's still promising enough that Mark Salter felt the time was right to post his patch introducing the C64x architecture into the kernel. He also set up a developer wiki at linux-c6x.org.

An interesting detail about the C64x processors is that they don't support cache coherency. In other words, multiple CPU cores are not guaranteed to see the same data when they check a given location in a shared data store. Without cache coherency, supporting SMP (Symmetric Multiprocessing) systems is much more difficult. For now, C64x systems may have to remain single-processor only.

Tweak Your Android Memory Management System

James Coyner

Issue #211, November 2011

In my travels, I've discovered that not only does the Linux community have a robust following, but so does the Android hacking community. My journey began two years ago with the release of the Original Droid. I had come from a Windows Mobile world and didn't know that phone hacking even existed. Now hacking around on my Droid is almost an everyday task.

Most of you own Android phones now, and many of you already are running hacked versions of Android, and many of you already heavily tweak your builds. This article is not for you. It's an introduction to the world of Android customization, intended for Android users who don't yet know how to tweak their devices.

You've probably heard of Cyanogen and CVPCS if you are at all involved in the community. They are, in fact, a couple of the most influential developers of CyanogenMod, an open-source customized version of Android—a distribution of sorts. With this distro, you get the kernel for your device as well as the latest version of Android.

Before I begin, the most important requirement is that you are rooted. You can find many guides on-line to do this. Once you obtain root, let's begin with the tweaks.

Android comes with the Linux kernel, which, if you have not already inferred, means that many of the mainline kernel tweaks can be applied to the Android version of the kernel through the use of various configuration files. For this guide, you're going to edit build.prop, which is located under /system, and the local.prop, which is under /data.

On Linux, you can edit these files with vim or nano, but Android is slightly different. On Android, you need a file browser that is able to run and edit files as the superuser or root. There are many root-level browsers on the Android market, but I have been quite successful with an application called Root Explorer, so I use that for the remainder of this guide, but any root browser with text editor support will suffice.

Now that you have rooted your device and have the version of Android installed that you want to tweak, you can begin tweaking. The first thing I normally do is optimize my TCP stack for faster 3G download speeds. To do this, open your file browser of choice (I used Root Explorer), navigate to /system/build.prop or /data/local.prop, and open it in the text editor.

Every Android device has a build.prop file, but not all will have the local.prop file. If the local.prop file exists, it's generally safer to edit this file rather than the build.prop file. So edit whichever you feel safer editing, and copy the code below into your file of choice:


I generally tend to add my tweaks of preference to the local.prop file, but after you edit it, reboot your device and enjoy the faster download and browsing speeds. This method is generally the more difficult of the two methods that are available. The easiest way to apply tweaks is to do it with a script. To run a script on Android, you can, in fact, run your script of choice exactly the same as you do on your Linux desktop, through the terminal.

Two scripts that I now use to accomplish the above are the V8/V6 Supercharge and 3G Turbocharger scripts. The V8/V6 script modifies how Android manages the available system memory as well as various kernel tweaks to provide a smoother and more fluid Android experience. A simple Web search will help you find both of these scripts. You can run these scripts in either of two ways: through the terminal application or a script manager. To run the script from the terminal, su to root, then navigate to where you downloaded it to your SD card and run it. To run it from a script manager, again navigate to the directory where it is located, and run it as root. It will ask you which scrolling speed you prefer, so select one. Next, the V8/V6 script will present you with 14 different options from which to choose. I like to multitask without my applications forcibly closing, so I choose option 7, but there also are options for gaming, aggressive memory management and balanced management.

It's that simple. Happy tweaking!

Elmer for PDEs

Joey Bernard

Issue #211, November 2011

Elmer is an open-source multiphysics simulation software that has been around since 1995. It is developed by the CSC — IT Center for Science Ltd. This group is administered by the Ministry of Education, Science and Culture in Finland. With Elmer, you can model physical systems, such as fluid dynamics, electromagnetism, heat transfer and acoustics. All of those problem areas have one thing in common—they are all described by partial differential equations (PDEs).

A PDE is a differential equation that depends on more than one variable, usually more than one space variable. For example, an equation that describes how heat gets transferred across a metal plate, where a is the thermal diffusivity of the metal plate, would look like the formula shown in Figure 1.

Figure 1. Sample Equation

Very simple PDEs have exact solutions, but anything more complex that describes more physical situations just can't be solved exactly. This is where numerical solutions come into play. There are three widely used methods: finite element, finite volume and finite difference methods. Elmer uses the finite element method. The basic idea is to break up the problem space into some kind of a mesh of smaller spaces, and then either eliminate the PDE completely, by reworking it into a steady state problem on the mesh, or approximating the PDE with a system of ordinary differential equations that then are integrated using standard methods, like Euler's method or Runge-Kutta.

Elmer is distributed under the GPL, so you always can download the source and compile your very own version. Binaries are available for all those poor users still stuck on Windows. Packages should be available for most Linux distributions. For Ubuntu-based distros, you simply can use the following to install Elmer and all the necessary libraries:

sudo apt-get install elmer

Elmer is broken into several parts. ElmerSolver is the part that actually takes the input files and does the calculations to evolve the PDE you are interested in. ElmerPost is the visualization and post-processing tool. With this tool, you actually can see the results of your calculations. ElmerGrid is the meshing tool that can create simple 1-D, 2-D and 3-D meshes that will be used to evolve your PDE. It also can be used to import meshes generated using other software packages, such as those created using the Ansys tools.

There also is a GUI interface called ElmerGUI. ElmerGUI allows you to define and generate input files for ElmerSolver, as well as import external meshes from other software (Figure 2).

Figure 2. ElmerGUI

Looking at all of this, you may be thinking, “This is perfect!” So, I also should mention some of Elmer's downsides. Elmer actually is a suite of tools, and those tools are not always at the same development level. The documentation tends to lag behind the newest features, and ElmerGUI may be missing some of the more esoteric methods and models that ElmerSolver can use. Elmer is a huge system, and like any large software package, it has a steep learning curve. The tools available (ElmerGrid) can handle generating only relatively simple meshes. This means that if you have a very complicated system, you likely will need to use some other tool to generate the mesh and then import it into Elmer. If you can work around these possible deficiencies, Elmer may be exactly the right solution for you.

ElmerGUI is likely to be what most people prefer using. You can import element mesh files in various formats, generate element partitionings for geometry input files, set up the PDE systems you want to solve, and export model data to hand in to ElmerSolver. Most conveniently, ElmerGui also provides an interface to the parallel version of the solver, ElmerSolver.mpi. There also is a built-in post-processor that allows you to view your results right there from ElmerGUI. The menus in ElmerGUI are fully programmable as well, so you can tune the interface to match your specific problem area better.

A user forum, wiki and other resources are available at www.elmerfem.org, and a very good tutorial is available from the main Elmer Web site (www.csc.fi/english/pages/elmer). Along with the tutorial documentation, sample files are available for each of the cases. Those files can be great starting points for your own calculations and help you as you are learning the system. As an example, let's look at the sample “Computation of fringe capacitance”. Once you have downloaded the sample files and unpacked them, you can load the project with File→Load Project... from the menu. Once it is loaded, all the input data also is loaded. A project is simply a directory containing all the files required to do a computation. The actual mesh is defined by the files mesh.header, mesh.nodes, mesh.elements and mesh.boundary. The current settings and state are stored in the file egproject.xml. There also is a solver input file called case.sif that is handed in to ElmerSolver when you actually are ready to do your calculations. You can edit this file via Sif→Edit... (Figure 3).

Figure 3. Solver Input File

You can edit the model details (like physical constants) via Model→Setup.... When you are ready to run your calculation, you can use Run→Start Solver. This opens a log window and shows its progress. A convergence monitor shows how quickly Elmer converges on the results (Figure 4).

Figure 4. Convergence Monitor

This creates a new file named case.ep in your project directory containing the results of your calculation. You can view it using either Run→Start Postprocessor or Run→Postprocessor (VTK)... (Figure 5).

Figure 5. Viewing the Results

As you can see, several tools are available to help you visualize the results of your calculation.

Now that you have seen a basic example of running one of the tutorials, what else can Elmer do for you? The solver can handle solving linear systems. It can do this by using direct methods, through the LAPACK library, for example. You can use a set of Krylov subspace methods to do iterative solutions. In order to get rapid convergence though, you usually need to use some form of preconditioning. A class of iterative methods called multilevel methods are used for large linear systems. Elmer provides two options: geometric multigrid and algebraic multigrid.

More complex, and hence more physically accurate, problems tend to be nonlinear. This nonlinearity may be as simple as what you see in the full equation for pendulum motion to the Navier-Stokes equations for fluid flow to the equations of General Relativity. Elmer deals with nonlinear systems by first linearizing the equations at each iteration step. How the equations are linearized depends on exactly which solver method is being used. For example, the Navier-Stokes solver can use either the Picard linearization or the Newton linearization.

There are methods for solving time-dependent systems. First-order time derivatives can be discretized using either the Crank-Nicolson method or the Backward Differences Formulae. You also can solve eigenvalue problems with Elmer. These tend to crop up in structural analysis problems, including factors like elasticity and damping.

For really large problems, you likely will want to look into running your computation in parallel. Elmer uses MPI as the parallelization technique, along with domain decomposition as the method of dividing up the work. The first step is to take the mesh and subdivide it into chunks or partitions, which, depending on the actual calculation to perform, will divide the load evenly across all the CPUs. These chunks then are sent out to individual CPUs, and the calculation is done. At the end of the run, the results are combined back into a single result. Because of the work involved in partitioning and so forth, most users likely will take advantage of ElmerGUI's parallelization tool.

The last of Elmer's selling points is its modular nature. The solver is written in FORTRAN 90. This means if you want to add your own user functions or a complete solver, it is simply a matter of writing a FORTRAN module and including it in Elmer. The main Elmer site provides good documentation covering the steps involved.

Hopefully, this introduction has given you some ideas of what you can do with Elmer. If you are studying multiphysics problems, Elmer probably is a very good tool to learn. It also might be a good tool to introduce in a numerical physics course, because you can model so much. If you do end up using it in your research or studies, I would love to hear about it.

Flow, Flow, Flow Your Code

Shawn Powers

Issue #211, November 2011

Our recent transition to a fully digital magazine has been exciting, stressful, tumultuous and, thanks to our readers, collaborative. As we were converting our traditional publishing skills into the digital arena, we tried hard to preserve the things that make magazines popular. We didn't want the magazine to become less; we wanted it to become more. Unfortunately, with all our efforts to maintain useful layouts and provide interactive reading apps, we did miss an important consumption model: the traditional e-reader.

We're so thankful for all the feedback we received, and continue to receive, regarding our digital transition. Thanks to that feedback, we now offer an epub edition of Linux Journal, complete with flowing text and functional navigation for the vast majority of E Ink devices. Yes, many devices can read PDF files, but they're just not pleasant to read on a small screen. We're excited about this issue, and we hope you are too!

Non-Linux FOSS

Shawn Powers

Issue #211, November 2011

Whether you're trying to use Google Voice and a free SIP service to get a free telephone system or trying to connect to your company's internal phone system, if you're on a Mac, you need a SIP client. A few free options exist, but none are as simple as Alexei Kuznetsov's Telephone.

Telephone even integrates with OS X's Contacts program, so you can make a SIP call directly from there. It's free, open source, and it's even available in the Apple App Store. If you need to make a VoIP call on your Macintosh, be sure to check out Telephone: www.tlphn.com.

Stop Installing Outdated Ubuntu!

Shawn Powers

Issue #211, November 2011

Have you ever installed Linux, only to be greeted immediately with the system update notification applet? If you have a fast Internet connection or, even better, a local Ubuntu mirror (see www.linuxjournal.com/video/mirror-partner-repo-canonical for some tips on creating your own local mirror), you can use the “Installation Minimal CD” and get a fully up-to-date system the first time it boots.

Another advantage to using the Installation Minimal CD is that it allows you to install any official Ubuntu variant with the same CD. Whether you want Ubuntu, Xubuntu, Kubuntu or even the more specialized *buntus for video editing and such, the Minimal CD can do it. Download a copy at https://help.ubuntu.com/community/Installation/MinimalCD. It's less than 20MB!

They Said It

An empty stomach is not a good political adviser.

—Albert Einstein

A question that sometimes drives me hazy: am I or are the others crazy?

—Albert Einstein

A man should look for what is, and not for what he thinks should be.

—Albert Einstein

Any man who can drive safely while kissing a pretty girl is simply not giving the kiss the attention it deserves.

—Albert Einstein

Common sense is the collection of prejudices acquired by age eighteen.

—Albert Einstein

Education is what remains after one has forgotten what one has learned in school.

—Albert Einstein


Katherine Druckman

Issue #211, November 2011

Since this issue is devoted to the fun and exciting world of hacking, consider this a friendly reminder to visit our security section at www.linuxjournal.com/tag/security.

While most hacking you'll read about here in Linux Journal is of the fun and harmless variety, hacking occasionally comes in forms that can become a nuisance or security risk to our dear readers. So, take some time to check out our offerings at LinuxJournal.com, because you never know what threats lurk and what awesome tips you might find for avoiding them. And, if that doesn't convince you, just please think of the children.

Give these a try to get started:

LJ Archive