Changeset 5703

Fix CPU binding/speed setting when doing translation timings

Comitted by:  mjagdis
Date:  Jun 04 2010 * 23:10 (about 1 year ago)

Affected files:

callweaver/trunk/corelib/translate.c (unified diff)

r5680r5703
727727 {
728728 #ifdef __linux__
729729 char governor[sizeof("performance")];
730 int governor_len;
730731 #endif
731732 #if HAVE_SETAFFINITY
732733 cpu_set_t old_cpuset, new_cpuset;
734 int affinity;
733735 #endif
734736 pthread_mutex_t serialize = PTHREAD_MUTEX_INITIALIZER;
735737 struct rebuild_matrix_args args;
736738 struct trans_state *old_tr, *new_tr;
737 int affinity;
738739 int changed, x, y, z;
739740
740741 if (option_debug)
------
793794 * fact that CPU0 could be disabled, offline or just not in our set
794795 * would require root privs with the current (kernel 2.6.25) sysfs.
795796 */
796 governor[0] = '\0';
797 if (affinity == 0
798 && lseek(cw_cpu0_governor_fd, SEEK_SET, 0) == 0
799 && read(cw_cpu0_governor_fd, governor, sizeof(governor) - 1) > 0
800 && governor[strlen(governor) - 1] == '\n') {
797 governor_len = 0;
798 if (
799 #if HAVE_SETAFFINITY
800 affinity == 0
801 &&
802 #endif
803 lseek(cw_cpu0_governor_fd, SEEK_SET, 0) == 0
804 && (governor_len = read(cw_cpu0_governor_fd, governor, sizeof(governor) - 1)) > 0
805 && governor[governor_len - 1] == '\n') {
801806 lseek(cw_cpu0_governor_fd, SEEK_SET, 0);
802807 write(cw_cpu0_governor_fd, "performance\n", sizeof("performance\n") - 1);
803 } else
804 governor[0] = '\0';
808 }
805809 #endif
806810
807811 /* Do a dummy run of each translator to grow heap/stack space appropriately
------
821825
822826 #ifdef __linux__
823827 /* Restore the original cpufreq governor */
824 if (governor[0])
825 write(cw_cpu0_governor_fd, governor, strlen(governor));
828 if (governor_len > 0)
829 write(cw_cpu0_governor_fd, governor, governor_len);
826830 #endif
827831
828832 #if HAVE_SETAFFINITY
829833 /* Restore the original CPU affinity */
830 if (affinity != -1)
834 if (affinity != CPU_SETSIZE)
831835 sched_setaffinity(0, sizeof(old_cpuset), &old_cpuset);
832836 #endif
833837