GithubHelp home page GithubHelp logo

unbrice / ksm_preload Goto Github PK

View Code? Open in Web Editor NEW
53.0 53.0 14.0 53 KB

Enables legacy applications to leverage Linux's memory deduplication.

Home Page: http://vleu.net/ksm_preload/

License: GNU General Public License v3.0

Shell 9.30% C 87.79% CMake 2.91%

ksm_preload's People

Contributors

heisspiter avatar kensharp avatar unbrice avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ksm_preload's Issues

Tweaks needed to shell script wrapper on Ubuntu 16.04

Didn't work out-of-the-box on Ubuntu 16.04: [[ test not supported in vanilla /bin/sh, and the .so is not executable so the file test failed.

Fixed by making these edits:

--- soft/ksm_preload/ksm-wrapper        2016-12-21 12:42:43.590732436 +0000
+++ /usr/local/bin/ksm-wrapper  2016-12-21 12:59:28.366223605 +0000
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # Runs the provided executable with ksm-preload.so , which enables KSM
 # on heap-allocated memory.
 
@@ -22,12 +22,13 @@
 readonly KSM_SO_GIT="${KSM_PATH}/libksm_preload.so"
 readonly KSM_SO_CMAKE="${KSM_PATH}/../share/ksm_preload/libksm_preload.so"
 
-if  [[ -x "${KSM_SO_GIT}" ]]; then
+if  [[ -s "${KSM_SO_GIT}" ]]; then
     readonly KSM_SO="${KSM_SO_GIT}"
-elif [[ -x "${KSM_SO_CMAKE}" ]]; then
+elif [[ -s "${KSM_SO_CMAKE}" ]]; then
     readonly KSM_SO="${KSM_SO_CMAKE}"
 else
-    echo $KSM_SO_CMAKE
+    echo "KSM_SO_CMAKE is " $KSM_SO_CMAKE
+    echo "KSM_SO is " $KSM_SO
     echo "Could not find libksm_preload.so. Have you compiled it with 'make' ?"
     exit 1
 fi

running ksm_preload with container

so I'm doing an experiment to check whether KSM can also be applying on the container technology
here's the step:

  1. launching some docker container instances
  2. $ sudo ./ksm-wrapper to let it call madvise for me
  3. check the result in /sys/kernel/mm/ksm

and there's nothing happened.
just wondering whether I missed some steps on using ksm_preload or KSM just don't work on container.

/ksm-preload.so: undefined symbol: dlsym in minimal openvz templates

I highly suspect I'm having an issue with depends, but since none are listed on this project it's somewhat tough to figure out what I'm missing. It might be nice to list the basic depends for building ksm-preload.so with make. (I've installed build-essential, kernel sources, and a few other packages)

On minimal OpenVZ templates (A probable use case for this technology) such as 14.04 Ubuntu Minimal typing make does build a ksm-preload.so but we get a symbol lookup error: /path/unbrice-ksm_preload/ksm-preload.so: undefined symbol: dlsym

If I can get this working on a minimal ubuntu 14.04 openvz template I'll document my findings so nobody else gets stuck where I am.

running ksm_preload in alpine docker images

Would be nice to be able to use this in alpine docker images. If I try to compile inside alpine I get:

/tmp/ksm_preload-0.11 $ make
[ 50%] Building C object CMakeFiles/ksm_preload.dir/libksm_preload.c.o
/tmp/ksm_preload-0.11/libksm_preload.c:32:19: fatal error: error.h: No such file or directory
#include <error.h>

If I try to run in alpine image I get symbol errors, even in alpine images where I have glibc and running other glibc based binaries.

Build script

Hi,

I had a hard time to compile it, so here is my solution:

libtoolize --force
aclocal
autoheader
automake --force-missing --add-missing
autoconf
./configure

malloc/dlsym loop in debian stretch

# ksm-wrapper tail
Segmentatiocn fault (core dumped)
# gdb tail
GNU gdb (Debian 7.12-6) 7.12.0.20161007-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from tail...(no debugging symbols found)...done.
(gdb) set env LD_PRELOAD=/usr/local/share/ksm_preload/libksm_preload.so
(gdb) r
Starting program: /usr/bin/tail 

Program received signal SIGSEGV, Segmentation fault.
0xb6fd8b8c in _dl_lookup_symbol_x (undef_name=undef_name@entry=0xb6fbc494 "calloc", undef_map=undef_map@entry=0xb6ffbad0, ref=ref@entry=0xbe8000cc, symbol_scope=0xb6fffb28, version=version@entry=0x0, type_class=0, flags=0, 
    skip_map=skip_map@entry=0xb6ffbad0) at dl-lookup.c:833
833	dl-lookup.c: No such file or directory.
(gdb) bt full
#0  0xb6fd8b8c in _dl_lookup_symbol_x (undef_name=undef_name@entry=0xb6fbc494 "calloc", undef_map=undef_map@entry=0xb6ffbad0, ref=ref@entry=0xbe8000cc, symbol_scope=0xb6fffb28, version=version@entry=0x0, type_class=0, 
    flags=0, skip_map=skip_map@entry=0xb6ffbad0) at dl-lookup.c:833
        res = <optimized out>
        start = 1
        new_hash = 4125497075
        old_hash = 4294967295
        current_value = {s = 0x0, m = 0x0}
        scope = 0xb6fffb28
        __PRETTY_FUNCTION__ = "_dl_lookup_symbol_x"
        i = 1
        protected = <optimized out>
#1  0xb6f82b98 in do_sym (handle=<optimized out>, name=0xb6fbc494 "calloc", who=0xb6fbaadc <xdlsym+32>, vers=vers@entry=0x0, flags=flags@entry=2) at dl-sym.c:161
        l = <optimized out>
        ref = 0x0
        result = <optimized out>
        caller = 3069946588
        l = <optimized out>
        match = 0xb6ffbad0
#2  0xb6f82fe8 in _dl_sym (handle=<optimized out>, name=<optimized out>, who=<optimized out>) at dl-sym.c:273
No locals.
#3  0xb6e5dce0 in dlsym_doit (a=0xbe800310) at dlsym.c:50
        args = 0xbe800310
#4  0xb6fdee08 in _dl_catch_error (objname=0xb6fff884 <data>, objname@entry=0xb6e6f09c <last_result+12>, errstring=0xbe800960, errstring@entry=0xb6e6f0a0 <last_result+16>, mallocedp=0xb6e6f09c <last_result+12>, 
    mallocedp@entry=0xb6e6f098 <last_result+8>, operate=0xb6e6f0a0 <last_result+16>, operate@entry=0xb6e5dcd0 <dlsym_doit>, args=args@entry=0xbe800310) at dl-error.c:187
        errcode = 0
        c = {objname = 0xb6e6f09c <last_result+12>, errstring = 0xb6e6f0a0 <last_result+16>, malloced = 0xb6e6f098 <last_result+8>, errcode = 0xbe80014c, env = {{__jmpbuf = {-1090294466, -1216445954, -1226379120, 
                -1224872564, -1098906864, -1226449712, -1226379124, 47, -1225014084, -1098906796, 0 <repeats 54 times>}, __mask_was_saved = 0, __saved_mask = {__val = {0 <repeats 32 times>}}}}}
        catchp = 0xb6fff884 <data>
        old = <optimized out>
#5  0xb6e5e310 in _dlerror_run (operate=0xb6e5dcd0 <dlsym_doit>, args=args@entry=0xbe800310) at dlerror.c:163
        result = 0xb6e6f090 <last_result>
#6  0xb6e5dd44 in __dlsym (handle=<optimized out>, name=<optimized out>) at dlsym.c:70
        args = {handle = 0xffffffff, name = 0xb6fbc494 "calloc", who = 0xb6fbaadc <xdlsym+32>, sym = 0x0}
        result = <optimized out>
#7  0xb6fbaadc in xdlsym () from /usr/local/share/ksm_preload/libksm_preload.so
No symbol table info available.
#8  0xb6fbab68 in setup () from /usr/local/share/ksm_preload/libksm_preload.so
No symbol table info available.
#9  0xb6fbad70 in lazily_setup () from /usr/local/share/ksm_preload/libksm_preload.so
No symbol table info available.
#10 0xb6fbafd8 in malloc () from /usr/local/share/ksm_preload/libksm_preload.so
No symbol table info available.
#11 0xb6fdeb18 in _dl_signal_error (errcode=0, errcode@entry=24, objname=0xb6ffbaa0 "/usr/local/share/ksm_preload/libksm_preload.so", 
    objname@entry=0xbe800960 "\234\360涠\360涘\360\346\266\\\t\200\276Ne\003\277\376\201~\267\220\360涌\355\375\266 \v\200\276\320\334嶌\360\346\266/", occation=occation@entry=0xb6fec75c "symbol lookup error", 
    errstring=0xbe800800 "undefined symbol: mmap2", errstring@entry=0xb6ffbaa0 "/usr/local/share/ksm_preload/libksm_preload.so") at dl-error.c:90
        len_objname = 47
        len_errstring = 24
        errstring_copy = <optimized out>
        lcatch = 0xbe800960
#12 0xb6fded74 in _dl_signal_cerror (errcode=24, objname=0xbe800960 "\234\360涠\360涘\360\346\266\\\t\200\276Ne\003\277\376\201~\267\220\360涌\355\375\266 \v\200\276\320\334嶌\360\346\266/", 
    occation=0xb6fec75c "symbol lookup error", errstring=0xb6ffbaa0 "/usr/local/share/ksm_preload/libksm_preload.so") at dl-error.c:155
No locals.
#13 0xb6fd8e88 in _dl_lookup_symbol_x (undef_name=undef_name@entry=0xb6fbc4bc "mmap2", undef_map=undef_map@entry=0xb6ffbad0, ref=0x2f, ref@entry=0xbe8008dc, symbol_scope=0xb6fffb28, version=version@entry=0x0, type_class=0, 
    flags=0, skip_map=skip_map@entry=0xb6ffbad0) at dl-lookup.c:874
        reference_name = <optimized out>
        versionstr = <optimized out>
        versionname = <optimized out>
        new_hash = <optimized out>
        old_hash = 4294967295
        current_value = {s = 0x0, m = 0x0}
        scope = <optimized out>
        __PRETTY_FUNCTION__ = "_dl_lookup_symbol_x"
        i = <optimized out>
        protected = <optimized out>
#14 0xb6f82b98 in do_sym (handle=<optimized out>, name=0xb6fbc4bc "mmap2", who=0xb6fbabf4 <setup+172>, vers=vers@entry=0x0, flags=flags@entry=2) at dl-sym.c:161
        l = <optimized out>
        ref = 0x0
        result = <optimized out>
        caller = 3069946868
        l = <optimized out>
        match = 0xb6ffbad0
#15 0xb6f82fe8 in _dl_sym (handle=<optimized out>, name=<optimized out>, who=<optimized out>) at dl-sym.c:273
No locals.
#16 0xb6e5dce0 in dlsym_doit (a=0xbe800b20) at dlsym.c:50
        args = 0xbe800b20
#17 0xb6fdee08 in _dl_catch_error (objname=0xb6fff884 <data>, objname@entry=0xb6e6f09c <last_result+12>, errstring=0xbe801148, errstring@entry=0xb6e6f0a0 <last_result+16>, mallocedp=0xb6e6f09c <last_result+12>, 
    mallocedp@entry=0xb6e6f098 <last_result+8>, operate=0xb6e6f0a0 <last_result+16>, operate@entry=0xb6e5dcd0 <dlsym_doit>, args=args@entry=0xbe800b20) at dl-error.c:187
        errcode = -1226449712
        c = {objname = 0xb6e6f09c <last_result+12>, errstring = 0xb6e6f0a0 <last_result+16>, malloced = 0xb6e6f098 <last_result+8>, errcode = 0xbe80095c, env = {{__jmpbuf = {-1090296498, -1216445954, -1226379120, 
                -1224872564, -1098904800, -1226449712, -1226379124, 47, -1225014084, -1098904732, 0 <repeats 54 times>}, __mask_was_saved = 0, __saved_mask = {__val = {0 <repeats 23 times>, 3068588176, 3068519184, 
                  3196062456, 0, 0, 3070226512, 24, 0, 3196063720}}}}}
        catchp = 0xb6fff884 <data>
        old = <optimized out>
#18 0xb6e5e310 in _dlerror_run (operate=0xb6e5dcd0 <dlsym_doit>, args=args@entry=0xbe800b20) at dlerror.c:163
        result = 0xb6e6f090 <last_result>
#19 0xb6e5dd44 in __dlsym (handle=<optimized out>, name=<optimized out>) at dlsym.c:70
        args = {handle = 0xffffffff, name = 0xb6fbc4bc "mmap2", who = 0xb6fbabf4 <setup+172>, sym = 0x0}
        result = <optimized out>
#20 0xb6fbabf4 in setup () from /usr/local/share/ksm_preload/libksm_preload.so
No symbol table info available.
#21 0xb6fbad70 in lazily_setup () from /usr/local/share/ksm_preload/libksm_preload.so
No symbol table info available.
#22 0xb6fbafd8 in malloc () from /usr/local/share/ksm_preload/libksm_preload.so
No symbol table info available.
#23 0xb6fdeb18 in _dl_signal_error (errcode=0, errcode@entry=24, objname=0xb6ffbaa0 "/usr/local/share/ksm_preload/libksm_preload.so", 
    objname@entry=0xbe801148 "\234\360涠\360涘\360\346\266D\021\200\276&}\003\277\376\201~\267\220\360涌\355\375\266\b\023\200\276\320\334嶌\360\346\266/", occation=occation@entry=0xb6fec75c "symbol lookup error", 
    errstring=0xbe800fe8 "undefined symbol: mmap2", errstring@entry=0xb6ffbaa0 "/usr/local/share/ksm_preload/libksm_preload.so") at dl-error.c:90
        len_objname = 47
        len_errstring = 24
        errstring_copy = <optimized out>
        lcatch = 0xbe801148
....

and so on...

it worked before upgrading to stretch (in jessie).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.