1. 03 Apr, 2015 20 commits
    • Kirill Smelkov's avatar
      bigfile/file.h: C interface for defining BigFile backends · 9065e2b9
      Kirill Smelkov authored
      Users can inherit from BigFile and provide custom ->loadblk() and
      ->storeblk() to load/store file blocks from a database or some other
      storage. The system then could use such files to memory map them into
      user address space (see next patch).
      9065e2b9
    • Kirill Smelkov's avatar
      Script to run compiled linux kernel with root fs mounted from host · 76d8f76d
      Kirill Smelkov authored
      Useful to debug (via either printk or gdb) the kernel - one can boot it,
      and tweak compile test program on host and be ready to test it inside
      qemu on tested kernel. Another use case is to add tracing printk to
      kernel and to boot it on each iteration. Booting via qemu means the
      workflow is not disrupted as would with rebooting the hardware.
      
      With this tool it was straightforward to find out why mmap-alias through
      mremap does not work for huge pages:
      
      static struct vm_area_struct *vma_to_resize(unsigned long addr,
              unsigned long old_len, unsigned long new_len, unsigned long *p)
      {
              struct mm_struct *mm = current->mm;
              struct vm_area_struct *vma = find_vma(mm, addr);
      
              if (!vma || vma->vm_start > addr)
                      goto Efault;
      
              if (is_vm_hugetlb_page(vma))            <--
                      goto Einval;
      
      mremap_to(...)
      {
              /* lots of checks, then */
              vma_to_resize(...)
      76d8f76d
    • Kirill Smelkov's avatar
      bigfile: RAM subsystem · 8c935a5f
      Kirill Smelkov authored
      This thing allows to get aliasable RAM from OS kernel and to manage it.
      Currently we get memory from a tmpfs mount, and hugetlbfs should also
      work, but is TODO because hugetlbfs in the kernel needs to be improved.
      
      We need aliasing because we'll need to be able to memory map the same
      page into several places in address space, e.g. for taking two slices
      overlapping slice of the same array at different times.
      
      Comes with test programs that show we aliasing does not work for
      anonymous memory.
      8c935a5f
    • Kirill Smelkov's avatar
      bigfile: Stub for virtmem · 77d61533
      Kirill Smelkov authored
      This will be the core of virtual memory subsystem. For now we just
      define a structure to describe pages of memory and add utility to
      allocate address space from OS.
      77d61533
    • Kirill Smelkov's avatar
    • Kirill Smelkov's avatar
      Low-level pagefault handler · 6f7d4d64
      Kirill Smelkov authored
      We hook into SIGSEGV and handle read/write pagefaults this way.
      
      In this patch there goes stub code that only detects faults and
      determines (in arch specific way) whether fault was for read or write
      and there is a TODO to pass that information to higher level.
      
      It also comes with tests to detect we still crash if we access something
      incorrectly, so people could have coredumps and investigate them.
      6f7d4d64
    • Kirill Smelkov's avatar
      bigfile/pagemap: specialized {} uint64 -> void * mapping · 45af76e6
      Kirill Smelkov authored
      For BigFiles we'll needs to maintain `{} offset-in-file -> void *` mapping. A
      hash or a binary tree could be used there, but since we know files are
      most of the time accessed sequentially and locally in pages-batches, we
      can also organize the mapping in batches of keys.
      
      Specifically offset bits are so divided into parts, that every part
      addresses 1 entry in a table of hardware-page in size. To get to the actual
      value, the system lookups first table by first part of offset, then from
      first table and next part from address - second table, etc.
      
      To clients this looks like a dictionary with get/set/del & clear methods,
      but lookups are O(1) time always, and in contrast to hashes values are
      stored with locality (= adjacent lookups almost always access the same tables).
      45af76e6
    • Kirill Smelkov's avatar
      bigfile/types.h: Type's we'll use · 8114ad6c
      Kirill Smelkov authored
      8114ad6c
    • Kirill Smelkov's avatar
      Prepare to unit-test C stuff · cd5646af
      Kirill Smelkov authored
      We'll be testing C code in a similiar-to-python way - keep test_*.c
      files nearby and compile/executing them as needed.
      
      Tests are run several times in several ways - as plainly compiled and
      also with additional error checkers:
      
       - AddressSanitizer
       - ThreadSanitizer
       - and similiar checkers from Valgrind
      cd5646af
    • Kirill Smelkov's avatar
      lib/mem: Python utilities to zero, set & copy memory · 699b1375
      Kirill Smelkov authored
      Like C bzero / memset & memcopy - but work on python buffers. We
      leverage NumPy for doing actual work, and this way NumPy becomes a
      depenency.
      
      Having NumPy as a dependency is ok - we'll for sure need it later as we
      are trying to build out-of-core ndarrays.
      699b1375
    • Kirill Smelkov's avatar
      lib/utils: Small C utilities we'll use · 3e5e78cd
      Kirill Smelkov authored
      Like taking an exact integer log2, upcasting pointers for C-style
      inheritance done in a Plan9 way, and wrappers to functions which should
      never fail.
      3e5e78cd
    • Kirill Smelkov's avatar
      lib/bug: Small utilities to say there is a warning, or a todo, or a bug on condition · db28e53f
      Kirill Smelkov authored
      Modelled by ones used in Linux kernel.
      db28e53f
    • Kirill Smelkov's avatar
      Basic setup.py / Makefile to build/install/sdist stuff + bigfile.so skeleton · 5755a6b3
      Kirill Smelkov authored
      It is an early project decision to use gnu99 & Plan9 C extensions, to
      simplify C code.
      
      So far we only build stub wendelin/bigfile/_bigfile.so .
      
      Makefile is introduced because there will be targets which are easier to
      handle at make level. For end users no make knowledge is required -
      usual `python setup.py build|install|...` work, redirecting to make
      where necessary.
      
      As was promised (e870781d "Top-level in-tree import redirector")
      setup.py contains install-time hooks to handle in-tree wendelin.py and
      install it as a module namespace.
      
      For sdist, we just use `git ls-files` info if we are in a checkout.
      5755a6b3
    • Kirill Smelkov's avatar
      Basic .gitignore · 0b7b5f6a
      Kirill Smelkov authored
      Prepare for building stuff and add commonly produced files to our
      .gitignore .
      0b7b5f6a
    • Kirill Smelkov's avatar
      Start wendelin.bigfile module · 1e92c921
      Kirill Smelkov authored
      This will be a module to allow users to program custom file-like
      backends and latter memory-map content of files from the backend.
      
      For now just start the module structure.
      1e92c921
    • Kirill Smelkov's avatar
      Hook in list.h from Linux · a0f940ad
      Kirill Smelkov authored
      Unfortunately in CCAN they made separation of list_head into list_head &
      list_node (for better type safety I suppose), but that leads e.g. to
      inablility to insert element in the middle of the list.
      
      We take the code from util-linux.git (v2.25-165-g9138d6f)[1] which claims
      LGPL license for it, with which we are fine.
      
      [1] https://git.kernel.org/cgit/utils/util-linux/util-linux.git/tree/include/list.h?id=v2.25-165-g9138d6f
      a0f940ad
    • Kirill Smelkov's avatar
      Hook in CCAN · ea890863
      Kirill Smelkov authored
      CCAN[1] is a "Comprehensive C Archive Network" - a collection of useful
      C libraries to use.
      
      Wendelin.core will be a C project in big part, so having CCAN at hand is
      useful.
      
      We hook CCAN as git submodule, without copying it into git repo. Later
      on making source tarball distribution, the code will be injected into
      generated tarball, so there will be no additional dependencies to
      download something from network for end users.
      
      [1] http://ccodearchive.net/
      ea890863
    • Kirill Smelkov's avatar
      Top-level in-tree import redirector · e870781d
      Kirill Smelkov authored
      For working copy checkout we would like to work on the source
      right-away, without putting it under additional wendelin/ (and possibly
      /core/) subdirectories.
      
      Add in-tree modules redirector which tweaks plain-python and
      pkg_resources-based imports so that e.g.
      
          import wendelin.bigarray
      
      while in-tree resolves to
      
          bigarray/__init__.py
      
      In installed state, there will be no such redirector, and code will be
      installed with conventional structure.
      e870781d
    • Kirill Smelkov's avatar
      Licensing · 66c976ed
      Kirill Smelkov authored
      As a first step we want to make sure the code can be used by open-source
      projects without a problem.
      
      So GPLv3+ with wide exception for all open-source licenses.
      66c976ed
    • Kirill Smelkov's avatar
      Start of wendelin.core.git · f155a6d6
      Kirill Smelkov authored
      The project to implement Out-of-core NumPy arrays in backward-compatible
      way.
      f155a6d6