[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

X Strike Force X.Org X11 SVN commit: r1400 - in branches/modular/xserver/xorg-server-X11R7.0-1.0.1/debian: . patches



Author: dnusinow
Date: 2006-03-05 21:59:13 -0500 (Sun, 05 Mar 2006)
New Revision: 1400

Added:
   branches/modular/xserver/xorg-server-X11R7.0-1.0.1/debian/patches/10_loader_speed_hack.diff
Modified:
   branches/modular/xserver/xorg-server-X11R7.0-1.0.1/debian/changelog
   branches/modular/xserver/xorg-server-X11R7.0-1.0.1/debian/patches/series
Log:
* Port patches from trunk
  + general/028_loader_speed_hack.diff


Modified: branches/modular/xserver/xorg-server-X11R7.0-1.0.1/debian/changelog
===================================================================
--- branches/modular/xserver/xorg-server-X11R7.0-1.0.1/debian/changelog	2006-03-06 02:55:14 UTC (rev 1399)
+++ branches/modular/xserver/xorg-server-X11R7.0-1.0.1/debian/changelog	2006-03-06 02:59:13 UTC (rev 1400)
@@ -11,13 +11,14 @@
     + general/099e_xorgconf_manpage_overhaul.diff
     + s390/500_s390_support.diff
     + debian/910_debian_Xserver_RTFF.diff
+    + general/028_loader_speed_hack.diff
   * add 04_read_rom_in_chunks.diff. This reads PCI ROM in large chunks rather
     than one byte at a time. This patch by Alex Williamson and forwarded to us
     by Dann Frazier. Thanks to both of them. (closes: #353168)
   * Don't build xserver-xorg-core on s390. This means putting all the other
     arches as being explicitly listed. Damn !s390.
 
- -- David Nusinow <dnusinow@debian.org>  Sun,  5 Mar 2006 19:52:48 -0500
+ -- David Nusinow <dnusinow@debian.org>  Sun,  5 Mar 2006 21:58:07 -0500
 
 xorg-server (1:1.0.1-1) experimental; urgency=low
 

Added: branches/modular/xserver/xorg-server-X11R7.0-1.0.1/debian/patches/10_loader_speed_hack.diff
===================================================================
--- branches/modular/xserver/xorg-server-X11R7.0-1.0.1/debian/patches/10_loader_speed_hack.diff	2006-03-06 02:55:14 UTC (rev 1399)
+++ branches/modular/xserver/xorg-server-X11R7.0-1.0.1/debian/patches/10_loader_speed_hack.diff	2006-03-06 02:59:13 UTC (rev 1400)
@@ -0,0 +1,344 @@
+$Id: 028_loader_speed_hack.diff 867 2005-11-13 16:29:11Z dnusinow $
+
+This is the first (and most important) loader speed hack: instead of walking
+the entire directory tree, stat()ing every file, and running a regex on it,
+we just stat the directoires themselves, and attempt to open the files.
+
+The directory search order has also been arranged to be more optimal.
+
+Appending linux/ to every directory name should probably go, but causes
+mysterious segfaults deep in hardware access, with a smashed stack. Tricky.
+
+Also, ignore requests to load speedo and GLcore, which shouldn't be loaded in
+any case.
+
+Author: Daniel Stone <daniel.stone@ubuntu.com>
+
+Index: xc/programs/Xserver/hw/xfree86/common/xf86Config.c
+===================================================================
+--- xc/programs/Xserver/hw/xfree86/common/xf86Config.c.orig	2005-11-13 10:56:18.000000000 -0500
++++ xc/programs/Xserver/hw/xfree86/common/xf86Config.c	2005-11-13 10:56:20.000000000 -0500
+@@ -253,6 +253,9 @@
+     char **modulearray;
+     pointer *optarray;
+     XF86LoadPtr modp;
++    /* we pretend these modules don't exist */
++    char *ignore[] = { "GLcore", "speedo" };
++    int i = 0, doignore = 0;
+     
+     /*
+      * make sure the config file has been parsed and that we have a
+@@ -287,6 +290,17 @@
+     if (xf86configptr->conf_modules) {
+ 	modp = xf86configptr->conf_modules->mod_load_lst;
+ 	while (modp) {
++	    for (i = 0, doignore = 0; i < 2; i++) {
++                if (strcmp(modp->load_name, ignore[i]) == 0) {
++                    xf86Msg(X_WARNING, "Ignoring request to load module %s\n",
++                            modp->load_name);
++		    doignore = 1;
++		}
++            }
++	    if (doignore) {
++                modp = (XF86LoadPtr) modp->list.next;
++                continue;
++           }
+ 	    modulearray[count] = modp->load_name;
+ 	    optarray[count] = modp->load_opt;
+ 	    count++;
+Index: xc/programs/Xserver/hw/xfree86/loader/loadmod.c
+===================================================================
+--- xc/programs/Xserver/hw/xfree86/loader/loadmod.c.orig	2005-11-13 10:56:18.000000000 -0500
++++ xc/programs/Xserver/hw/xfree86/loader/loadmod.c	2005-11-13 10:56:20.000000000 -0500
+@@ -218,79 +218,6 @@
+     NULL
+ };
+ 
+-/*
+- * Standard set of module name patterns to check, in order of preference
+- * These are regular expressions (suitable for use with POSIX regex(3)).
+- */
+-static PatternRec stdPatterns[] = {
+-    {"^lib(.*)\\.so$",},
+-    {"^lib(.*)\\.a$",},
+-    {"(.*)_drv\\.so$",},
+-    {"(.*)_drv\\.o$",},
+-    {"(.*)\\.so$",},
+-    {"(.*)\\.a$",},
+-    {"(.*)\\.o$",},
+-    {NULL,}
+-};
+-
+-static PatternPtr
+-InitPatterns(const char **patternlist)
+-{
+-    char errmsg[80];
+-    int i, e;
+-    PatternPtr patterns = NULL;
+-    PatternPtr p = NULL;
+-    static int firstTime = 1;
+-    const char **s;
+-
+-    if (firstTime) {
+-	/* precompile stdPatterns */
+-	firstTime = 0;
+-	for (p = stdPatterns; p->pattern; p++)
+-	    if ((e = regcomp(&p->rex, p->pattern, REG_EXTENDED)) != 0) {
+-		regerror(e, &p->rex, errmsg, sizeof(errmsg));
+-		FatalError("InitPatterns: regcomp error for `%s': %s\n",
+-			   p->pattern, errmsg);
+-	    }
+-    }
+-
+-    if (patternlist) {
+-	for (i = 0, s = patternlist; *s; i++, s++)
+-	    if (*s == DEFAULT_LIST)
+-		i += sizeof(stdPatterns) / sizeof(stdPatterns[0]) - 1 - 1;
+-	patterns = xalloc((i + 1) * sizeof(PatternRec));
+-	if (!patterns) {
+-	    return NULL;
+-	}
+-	for (i = 0, s = patternlist; *s; i++, s++)
+-	    if (*s != DEFAULT_LIST) {
+-		p = patterns + i;
+-		p->pattern = *s;
+-		if ((e = regcomp(&p->rex, p->pattern, REG_EXTENDED)) != 0) {
+-		    regerror(e, &p->rex, errmsg, sizeof(errmsg));
+-		    ErrorF("InitPatterns: regcomp error for `%s': %s\n",
+-			   p->pattern, errmsg);
+-		    i--;
+-		}
+-	    } else {
+-		for (p = stdPatterns; p->pattern; p++, i++)
+-		    patterns[i] = *p;
+-		if (p != stdPatterns)
+-		    i--;
+-	    }
+-	patterns[i].pattern = NULL;
+-    } else
+-	patterns = stdPatterns;
+-    return patterns;
+-}
+-
+-static void
+-FreePatterns(PatternPtr patterns)
+-{
+-    if (patterns && patterns != stdPatterns)
+-	xfree(patterns);
+-}
+-
+ static const char **
+ InitSubdirs(const char **subdirlist)
+ {
+@@ -479,18 +406,15 @@
+ }
+ 
+ char **
+-LoaderListDirs(const char **subdirlist, const char **patternlist)
++LoaderListDirs(const char **subdirlist, const char **unused)
+ {
+     char buf[PATH_MAX + 1];
+     char **pathlist;
+     char **elem;
+     const char **subdirs;
+     const char **s;
+-    PatternPtr patterns;
+-    PatternPtr p;
+     DIR *d;
+     struct dirent *dp;
+-    regmatch_t match[2];
+     struct stat stat_buf;
+     int len, dirlen;
+     char *fp;
+@@ -504,11 +428,6 @@
+ 	FreePathList(pathlist);
+ 	return NULL;
+     }
+-    if (!(patterns = InitPatterns(patternlist))) {
+-	FreePathList(pathlist);
+-	FreeSubdirs(subdirs);
+-	return NULL;
+-    }
+ 
+     for (elem = pathlist; *elem; elem++) {
+ 	for (s = subdirs; *s; s++) {
+@@ -516,52 +435,24 @@
+ 		continue;
+ 	    strcpy(buf, *elem);
+ 	    strcat(buf, *s);
+-	    fp = buf + dirlen;
+-	    if (stat(buf, &stat_buf) == 0 && S_ISDIR(stat_buf.st_mode) &&
+-		(d = opendir(buf))) {
++	    if (d = opendir(buf)) {
+ 		if (buf[dirlen - 1] != '/') {
+ 		    buf[dirlen++] = '/';
+-		    fp++;
+ 		}
+ 		while ((dp = readdir(d))) {
+ 		    if (dirlen + strlen(dp->d_name) > PATH_MAX)
+ 			continue;
+-		    strcpy(fp, dp->d_name);
+ 		    if (!(stat(buf, &stat_buf) == 0 &&
+ 			  S_ISREG(stat_buf.st_mode)))
+ 			continue;
+-		    for (p = patterns; p->pattern; p++) {
+-			if (regexec(&p->rex, dp->d_name, 2, match, 0) == 0 &&
+-			    match[1].rm_so != -1) {
+-			    len = match[1].rm_eo - match[1].rm_so;
+-			    save = listing;
+-			    listing = xrealloc(listing,
+-					       (n + 2) * sizeof(char *));
+-			    if (!listing) {
+-				if (save) {
+-				    save[n] = NULL;
+-				    FreeStringList(save);
+-				}
+-				FreePathList(pathlist);
+-				FreeSubdirs(subdirs);
+-				FreePatterns(patterns);
+-				return NULL;
+-			    }
+-			    listing[n] = xalloc(len + 1);
+-			    if (!listing[n]) {
+-				FreeStringList(listing);
+-				FreePathList(pathlist);
+-				FreeSubdirs(subdirs);
+-				FreePatterns(patterns);
+-				return NULL;
+-			    }
+-			    strncpy(listing[n], dp->d_name + match[1].rm_so,
+-				    len);
+-			    listing[n][len] = '\0';
+-			    n++;
+-			    break;
+-			}
+-		    }
++                    fp = LoaderGetCanonicalName(buf, NULL);
++                    if (fp && strcmp(buf, fp) != 0) {
++			listing = xrealloc(listing, (n + 2)*sizeof(char *));
++                        listing[n] = xalloc(strlen(fp) + 1);
++			strncpy(listing[n], fp, strlen(fp));
++			listing[n][strlen(fp)] = '\0';
++			n++;
++                    }
+ 		}
+ 		closedir(d);
+ 	    }
+@@ -757,7 +648,7 @@
+ 
+ ModuleDescPtr
+ LoadSubModule(ModuleDescPtr parent, const char *module,
+-	      const char **subdirlist, const char **patternlist,
++	      const char **subdirlist, const char **unused,
+ 	      pointer options, const XF86ModReqInfo * modreq,
+ 	      int *errmaj, int *errmin)
+ {
+@@ -782,7 +673,7 @@
+ 	return NULL;
+     }
+ 
+-    submod = LoadModule(module, NULL, subdirlist, patternlist, options,
++    submod = LoadModule(module, NULL, subdirlist, NULL, options,
+ 			modreq, errmaj, errmin);
+     if (submod) {
+ 	parent->child = AddSibling(parent->child, submod);
+@@ -833,12 +724,7 @@
+  * subdirlist   A NULL terminated list of subdirectories to search.  When
+  *              NULL, the default "stdSubdirs" list is used.  The default
+  *              list is also substituted for entries with value DEFAULT_LIST.
+- * patternlist  A NULL terminated list of regular expressions used to find
+- *              module filenames.  Each regex should contain exactly one
+- *              subexpression that corresponds to the canonical module name.
+- *              When NULL, the default "stdPatterns" list is used.  The
+- *              default list is also substituted for entries with value
+- *              DEFAULT_LIST.
++ * patternlist  This parameter is deprecated, and should always be NULL.
+  * options      A NULL terminated list of Options that are passed to the
+  *              module's SetupProc function.
+  * modreq       An optional XF86ModReqInfo* containing
+@@ -863,7 +749,7 @@
+ 
+ ModuleDescPtr
+ LoadModule(const char *module, const char *path, const char **subdirlist,
+-	   const char **patternlist, pointer options,
++	   const char **unused, pointer options,
+ 	   const XF86ModReqInfo * modreq, int *errmaj, int *errmin)
+ {
+     XF86ModuleData *initdata = NULL;
+@@ -874,15 +760,14 @@
+     char *p = NULL;
+     ModuleDescPtr ret = NULL;
+     int wasLoaded = 0;
+-    PatternPtr patterns = NULL;
+     int noncanonical = 0;
+     char *m = NULL;
+ 
+     /*xf86Msg(X_INFO,"OS2DIAG: LoadModule: %s\n",module); */
+     xf86MsgVerb(X_INFO, 3, "LoadModule: \"%s\"", module);
+ 
+-    patterns = InitPatterns(patternlist);
+-    name = LoaderGetCanonicalName(module, patterns);
++    name = LoaderGetCanonicalName(module, NULL);
++
+     noncanonical = (name && strcmp(module, name) != 0);
+     if (noncanonical) {
+ 	xf86ErrorFVerb(3, " (%s)\n", name);
+@@ -934,7 +819,7 @@
+ #endif
+     path_elem = pathlist;
+     while (!found && *path_elem != NULL) {
+-	found = FindModule(m, *path_elem, subdirlist, patterns);
++	found = FindModule(m, *path_elem, subdirlist, NULL);
+ 	path_elem++;
+ 	/*
+ 	 * When the module name isn't the canonical name, search for the
+@@ -1049,7 +934,6 @@
+ 
+   LoadModule_exit:
+     FreePathList(pathlist);
+-    FreePatterns(patterns);
+     TestFree(found);
+     TestFree(name);
+     TestFree(p);
+@@ -1282,13 +1166,11 @@
+ 
+ /* Given a module path or file name, return the module's canonical name */
+ static char *
+-LoaderGetCanonicalName(const char *modname, PatternPtr patterns)
++LoaderGetCanonicalName(const char *modname, PatternPtr unused)
+ {
+-    char *str;
++    char *str, tmpBuf[102];
+     const char *s;
+     int len;
+-    PatternPtr p;
+-    regmatch_t match[2];
+ 
+     /* Strip off any leading path */
+     s = strrchr(modname, '/');
+@@ -1297,17 +1179,14 @@
+     else
+ 	s++;
+ 
+-    /* Find the first regex that is matched */
+-    for (p = patterns; p->pattern; p++)
+-	if (regexec(&p->rex, s, 2, match, 0) == 0 && match[1].rm_so != -1) {
+-	    len = match[1].rm_eo - match[1].rm_so;
+-	    str = xalloc(len + 1);
+-	    if (!str)
+-		return NULL;
+-	    strncpy(str, s + match[1].rm_so, len);
+-	    str[len] = '\0';
+-	    return str;
+-	}
++    if (sscanf(s, "lib%s.a", tmpBuf) == 1)
++        return xstrdup(tmpBuf);
++    if (sscanf(s, "%s_drv.o", tmpBuf) == 1)
++        return xstrdup(tmpBuf);
++    if (sscanf(s, "lib%s.so", tmpBuf) == 1)
++        return xstrdup(tmpBuf);
++    if (sscanf(s, "%s_drv.so", tmpBuf) == 1)
++        return xstrdup(tmpBuf);
+ 
+     /* If there is no match, return the whole name minus the leading path */
+     return xstrdup(s);

Modified: branches/modular/xserver/xorg-server-X11R7.0-1.0.1/debian/patches/series
===================================================================
--- branches/modular/xserver/xorg-server-X11R7.0-1.0.1/debian/patches/series	2006-03-06 02:55:14 UTC (rev 1399)
+++ branches/modular/xserver/xorg-server-X11R7.0-1.0.1/debian/patches/series	2006-03-06 02:59:13 UTC (rev 1400)
@@ -7,3 +7,4 @@
 07_xorgconf_manpage_overhaul.diff -p0
 08_s390_servermd.diff -p3
 09_debian_xserver_rtff.diff -p0
+10_loader_speed_hack.diff -p3



Reply to: