Re: [PATCH] fixdep: faster CONFIG_ search

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

 



Dne 23.8.2016 v 20:47 Alexey Dobriyan napsal(a):
> Do you think kernel build is 100% dominated by gcc? You are wrong!
> One small utility called "fixdep" consistently manages to sneak into
> profile's first page (unless you have small monitor of course).
> 
> The choke point is this clever code:
> 
> 	for (; m < end; m++) {
> 		if (*m == INT_CONF) { p = (char *) m  ; goto conf; }
> 		if (*m == INT_ONFI) { p = (char *) m-1; goto conf; }
> 		if (*m == INT_NFIG) { p = (char *) m-2; goto conf; }
> 		if (*m == INT_FIG_) { p = (char *) m-3; goto conf; }
> 
> 4 branches per 4 characters is not fast.
> 
> Use strstr(3), so that SSE2 etc can be used.

It should be noted that the previous code also matched nested CONFIG_*
strings, like CONFIG_PROC inside CONFIG_IKCONFIG_PROC. But these are
pointless, so your patch is removing a few false matches.


> With this patch, fixdep is so deep at the bottom, it is hard to find it.

Nice.


> -		if (*m == INT_CONF) { p = (char *) m  ; goto conf; }
> -		if (*m == INT_ONFI) { p = (char *) m-1; goto conf; }
> -		if (*m == INT_NFIG) { p = (char *) m-2; goto conf; }
> -		if (*m == INT_FIG_) { p = (char *) m-3; goto conf; }

Please also remove the INT_* definitions and the test at startup.


> +	map = malloc(st.st_size + 1);
> +	if (!map) {
> +		perror("fixdep: malloc");
>  		close(fd);
>  		return;
>  	}
> +	if (read(fd, map, st.st_size) != st.st_size) {
> +		perror("fixdep: read");
> +		close(fd);
> +		return;
> +	}

I wanted to suggest memmem() instead of strstr() to avoid the extra
copy, but that would make use depend on glibc (this _might_ have been
the reason to use the manual string search, in fact). So let's leave
this as.

Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux