On Sat, 2016-08-06 at 02:42 +0200, Jan Ziak wrote: > Mesa source code prior to this patch uses both RTLD_NOW and > RTLD_LAZY. > This patch removes all RTLD_NOW in favor of RTLD_LAZY. > > In comparison to early binding, lazy binding reduces CPU instruction > count > of small GL apps (e.g: glxinfo) by 6 million instructions. > Larger apps won't notice the difference. > > Signed-off-by: Jan Ziak (http://atom-symbol.net) > <0xe2.0x9a.0...@gmail.com> > --- > src/egl/drivers/dri2/egl_dri2.c | 6 +++--- > src/gbm/backends/dri/gbm_dri.c | 6 +++--- > src/glx/apple/apple_cgl.c | 2 +- > src/glx/dri_common.c | 10 +++++----- > 4 files changed, 12 insertions(+), 12 deletions(-) > > diff --git a/src/egl/drivers/dri2/egl_dri2.c > b/src/egl/drivers/dri2/egl_dri2.c > index a5cab68..3c9f58e 100644 > --- a/src/egl/drivers/dri2/egl_dri2.c > +++ b/src/egl/drivers/dri2/egl_dri2.c > @@ -449,12 +449,12 @@ dri2_open_driver(_EGLDisplay *disp) > #if GLX_USE_TLS > snprintf(path, sizeof path, > "%.*s/tls/%s_dri.so", len, p, dri2_dpy->driver_name); > - dri2_dpy->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL); > + dri2_dpy->driver = dlopen(path, RTLD_LAZY | RTLD_GLOBAL); > #endif > if (dri2_dpy->driver == NULL) { > snprintf(path, sizeof path, > "%.*s/%s_dri.so", len, p, dri2_dpy->driver_name); > - dri2_dpy->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL); > + dri2_dpy->driver = dlopen(path, RTLD_LAZY | RTLD_GLOBAL); > if (dri2_dpy->driver == NULL) > _eglLog(_EGL_DEBUG, "failed to open %s: %s\n", path, > dlerror()); > } > @@ -464,7 +464,7 @@ dri2_open_driver(_EGLDisplay *disp) > > #ifdef ANDROID > snprintf(path, sizeof path, "%.*s/gallium_dri.so", len, p); > - dri2_dpy->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL); > + dri2_dpy->driver = dlopen(path, RTLD_LAZY | RTLD_GLOBAL); > if (dri2_dpy->driver == NULL) > _eglLog(_EGL_DEBUG, "failed to open %s: %s\n", path, > dlerror()); > else > diff --git a/src/gbm/backends/dri/gbm_dri.c > b/src/gbm/backends/dri/gbm_dri.c > index c3626e3..a1921b7 100644 > --- a/src/gbm/backends/dri/gbm_dri.c > +++ b/src/gbm/backends/dri/gbm_dri.c > @@ -332,12 +332,12 @@ dri_open_driver(struct gbm_dri_device *dri) > #if GLX_USE_TLS > snprintf(path, sizeof path, > "%.*s/tls/%s_dri.so", len, p, dri->base.driver_name); > - dri->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL); > + dri->driver = dlopen(path, RTLD_LAZY| RTLD_GLOBAL); > #endif > if (dri->driver == NULL) { > snprintf(path, sizeof path, > "%.*s/%s_dri.so", len, p, dri->base.driver_name); > - dri->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL); > + dri->driver = dlopen(path, RTLD_LAZY | RTLD_GLOBAL); > } > /* not need continue to loop all paths once the driver is > found */ > if (dri->driver != NULL) > @@ -345,7 +345,7 @@ dri_open_driver(struct gbm_dri_device *dri) > > #ifdef ANDROID > snprintf(path, sizeof path, "%.*s/gallium_dri.so", len, p); > - dri->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL); > + dri->driver = dlopen(path, RTLD_LAZY | RTLD_GLOBAL); > if (dri->driver == NULL) > sprintf("failed to open %s: %s\n", path, dlerror()); > else > diff --git a/src/glx/apple/apple_cgl.c b/src/glx/apple/apple_cgl.c > index 648ed86..a458d34 100644 > --- a/src/glx/apple/apple_cgl.c > +++ b/src/glx/apple/apple_cgl.c > @@ -75,7 +75,7 @@ apple_cgl_init(void) > } > > (void) dlerror(); /*drain dlerror */ > - h = dlopen(opengl_framework_path, RTLD_NOW); > + h = dlopen(opengl_framework_path, RTLD_LAZY); > > if (NULL == h) { > fprintf(stderr, "error: unable to dlopen %s : %s\n", > diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c > index 6728d38..c7b7562 100644 > --- a/src/glx/dri_common.c > +++ b/src/glx/dri_common.c > @@ -42,8 +42,8 @@ > #include "dri_common.h" > #include "loader.h" > > -#ifndef RTLD_NOW > -#define RTLD_NOW 0 > +#ifndef RTLD_LAZY > +#define RTLD_LAZY 0 > #endif > #ifndef RTLD_GLOBAL > #define RTLD_GLOBAL 0 > @@ -103,7 +103,7 @@ driOpenDriver(const char *driverName) > int len; > > /* Attempt to make sure libGL symbols will be visible to the > driver */ > - glhandle = dlopen(GL_LIB_NAME, RTLD_NOW | RTLD_GLOBAL); > + glhandle = dlopen(GL_LIB_NAME, RTLD_LAZY | RTLD_GLOBAL); > > libPaths = NULL; > if (geteuid() == getuid()) { > @@ -131,14 +131,14 @@ driOpenDriver(const char *driverName) > snprintf(realDriverName, sizeof realDriverName, > "%.*s/tls/%s_dri.so", len, p, driverName); > InfoMessageF("OpenDriver: trying %s\n", realDriverName); > - handle = dlopen(realDriverName, RTLD_NOW | RTLD_GLOBAL); > + handle = dlopen(realDriverName, RTLD_LAZY | RTLD_GLOBAL); > #endif > > if (handle == NULL) { > snprintf(realDriverName, sizeof realDriverName, > "%.*s/%s_dri.so", len, p, driverName); > InfoMessageF("OpenDriver: trying %s\n", realDriverName); > - handle = dlopen(realDriverName, RTLD_NOW | RTLD_GLOBAL); > + handle = dlopen(realDriverName, RTLD_LAZY | RTLD_GLOBAL); > }
this is IMO micro-optimization in the wrong place. RTLD_NOW also guarantees that symbols were successfully resolved. Changing it to lazy may hide bugs by deferring failure to future point in the execution. Jan > > if (handle != NULL) > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev -- Jan Vesely <jan.ves...@rutgers.edu>
signature.asc
Description: This is a digitally signed message part
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev