CMA on LCE/ELCE 2012

Michał ‘mina86’ Nazarewicz | 7 listopada 2012

LinuxCon / Embedded Linux Conference Europe 2012 is nearly over, and I had a pleasure of talking about the Contiguous Memory Allocator. The slides from the talk are embedded below, are available for download from Google Drive, and their source code can be accessed at GitHub.

Unfortunately, in contrast to other LCE/ELCE conferences, talks were not recorded, so the video of the presentation is not available.

For more links regarding CMA, I have set up a resource page at Beside the link to the final CMA patchset and to the LCE/ELCE presentation, it links to various articles and patches relating to CMA directly or indirectly.

Czytaj dalej »

LazyProxy in Python

Michał ‘mina86’ Nazarewicz | 8 lipca 2012

Paths of destiny lead mysterious ways. Not so long ago, I was a hard-core C hacker and now, I spend a lot of the time coding in Python.

In somehow related news, I have discovered that my search-foo is not good enough, when I was unable to find a decent implementations of several design patterns in Python.

What I needed was a generic proxy that would defer initialisation of an object to the moment it is first used. Here is what I came up with:

class LazyProxy(object):
    __slots__ = '__get'

    def __init__(self, cls, *args, **kw):
        object.__setattr__(self, '_LazyProxy__get',
                           lambda: self.__set(cls(*args, **kw)))

    def __set(self, obj):
        object.__setattr__(self, '_LazyProxy__get', lambda: obj)
        return obj

    def __getattr__(self, name):
        return getattr(self.__get(), name)

    def __setattr__(self, name, value):
        return setattr(self.__get(), name, value)

    def __delattr__(self, name):
        return delattr(self.__get(), name)

Czytaj dalej »

Deep Dive into Contiguous Memory Allocator

Michał ‘mina86’ Nazarewicz | 10 czerwca 2012

This is the first part of an extended version of an LWN article on CMA. It contains much more detail on how to use CMA, and a lot of boring code samples. Should you be more interested in an overview, consider reading the original instead.

Contiguous Memory Allocator (or CMA) has been developed to allow big physically contiguous memory allocations. By initialising early at boot time and with some fairly intrusive changes to Linux memory management, it is able to allocate big memory chunks without a need to grab memory for exclusive use.

Simple in principle, it grew to be a quite complicated system which requires coöperation between boot-time allocator, buddy system, DMA subsystem, and some architecture-specific code. Still, all that complexity is usually hidden away and normal users won’t be exposed to it. Depending on perspective, CMA appears slightly different and there are different things to be done and look for.

Czytaj dalej »