From owner-svn-ports-head@freebsd.org Sun Sep 11 19:19:00 2016 Return-Path: Delivered-To: svn-ports-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7D68ABD680B; Sun, 11 Sep 2016 19:19:00 +0000 (UTC) (envelope-from amdmi3@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5609A9AA; Sun, 11 Sep 2016 19:19:00 +0000 (UTC) (envelope-from amdmi3@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u8BJIx1t031646; Sun, 11 Sep 2016 19:18:59 GMT (envelope-from amdmi3@FreeBSD.org) Received: (from amdmi3@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u8BJIxHY031642; Sun, 11 Sep 2016 19:18:59 GMT (envelope-from amdmi3@FreeBSD.org) Message-Id: <201609111918.u8BJIxHY031642@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: amdmi3 set sender to amdmi3@FreeBSD.org using -f From: Dmitry Marakasov Date: Sun, 11 Sep 2016 19:18:59 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r421871 - in head/sysutils/i7z: . files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Sep 2016 19:19:00 -0000 Author: amdmi3 Date: Sun Sep 11 19:18:59 2016 New Revision: 421871 URL: https://svnweb.freebsd.org/changeset/ports/421871 Log: - Fix broken cpuid implementation to fix segfaults and remove need of optimization removal hacks PR: 199186 Submitted by: dim Approved by: maintainer timeout (zont, 1 year) Modified: head/sysutils/i7z/Makefile head/sysutils/i7z/files/patch-helper_functions.c head/sysutils/i7z/files/patch-i7z.c Modified: head/sysutils/i7z/Makefile ============================================================================== --- head/sysutils/i7z/Makefile Sun Sep 11 19:03:16 2016 (r421870) +++ head/sysutils/i7z/Makefile Sun Sep 11 19:18:59 2016 (r421871) @@ -2,7 +2,7 @@ PORTNAME= i7z PORTVERSION= 0.27.2 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= sysutils MASTER_SITES= GOOGLE_CODE @@ -20,10 +20,6 @@ PLIST_FILES= bin/${PORTNAME} \ ONLY_FOR_ARCHS= i386 amd64 -# Disable scheduling flags as they cause segfaults since they are enabled at -# default FreeBSD optimization levels (-O2, -O3, -Os) -CFLAGS+= -fno-schedule-insns2 -fno-schedule-insns -fno-caller-saves - do-install: ${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME} ${STAGEDIR}${PREFIX}/bin ${INSTALL_MAN} ${WRKSRC}/doc/${PORTNAME}.man \ Modified: head/sysutils/i7z/files/patch-helper_functions.c ============================================================================== --- head/sysutils/i7z/files/patch-helper_functions.c Sun Sep 11 19:03:16 2016 (r421870) +++ head/sysutils/i7z/files/patch-helper_functions.c Sun Sep 11 19:18:59 2016 (r421871) @@ -1,5 +1,5 @@ --- ./helper_functions.c.orig 2012-09-11 08:15:54.000000000 +0200 -+++ ./helper_functions.c 2012-12-11 14:41:28.000000000 +0100 ++++ ./helper_functions.c 2015-04-05 20:52:59.850869370 +0200 @@ -30,6 +30,11 @@ #include #include @@ -27,7 +27,38 @@ int Get_Bits_Value(unsigned long val,int highbit, int lowbit){ unsigned long data = val; int bits = highbit - lowbit + 1; -@@ -234,7 +247,7 @@ +@@ -92,14 +105,22 @@ + static inline void cpuid (unsigned int info, unsigned int *eax, unsigned int *ebx, + unsigned int *ecx, unsigned int *edx) + { +- unsigned int _eax = info, _ebx, _ecx, _edx; +- asm volatile ("mov %%ebx, %%edi;" // save ebx (for PIC) +- "cpuid;" +- "mov %%ebx, %%esi;" // pass to caller +- "mov %%edi, %%ebx;" // restore ebx +- :"+a" (_eax), "=S" (_ebx), "=c" (_ecx), "=d" (_edx) +- : /* inputs: eax is handled above */ +- :"edi" /* clobbers: we hit edi directly */); ++ unsigned int _eax, _ebx, _ecx, _edx; ++ asm volatile ( ++#ifdef __i386__ ++ "pushl %%ebx\n" // save ebx (for PIC) ++#else // __x86_64__ ++ "pushq %%rbx\n" // save rbx (for PIC) ++#endif ++ "cpuid\n" ++ "mov %%ebx, %1\n" // pass to caller ++#ifdef __i386__ ++ "popl %%ebx\n" // restore ebx ++#else // __x86_64__ ++ "popq %%rbx\n" // restore rbx ++#endif ++ :"=a" (_eax), "=r" (_ebx), "=c" (_ecx), "=d" (_edx) ++ :"0" (info)); + if (eax) *eax = _eax; + if (ebx) *ebx = _ebx; + if (ecx) *ecx = _ecx; +@@ -234,7 +255,7 @@ int bits; *error_indx =0; @@ -36,7 +67,7 @@ fd = open (msr_file_name, O_RDONLY); if (fd < 0) { -@@ -255,11 +268,21 @@ +@@ -255,11 +276,21 @@ } } @@ -58,7 +89,7 @@ close (fd); -@@ -287,7 +310,7 @@ +@@ -287,7 +318,7 @@ int fd; char msr_file_name[64]; @@ -67,7 +98,7 @@ fd = open (msr_file_name, O_WRONLY); if (fd < 0) { -@@ -304,11 +327,21 @@ +@@ -304,11 +335,21 @@ } } @@ -89,7 +120,7 @@ close(fd); return(1); } -@@ -487,10 +520,10 @@ +@@ -487,10 +528,10 @@ void Test_Or_Make_MSR_DEVICE_FILES() { //test if the msr file exists @@ -103,7 +134,7 @@ { //a system mght have been set with msr allowable to be written //by a normal user so... -@@ -505,6 +538,7 @@ +@@ -505,6 +546,7 @@ printf ("i7z DEBUG: msr device files DONOT exist, trying out a makedev script\n"); if (geteuid () == 0) { @@ -111,7 +142,7 @@ //Try the Makedev script //sourced from MAKEDEV-cpuid-msr script in msr-tools system ("msr_major=202; \ -@@ -519,6 +553,9 @@ +@@ -519,6 +561,9 @@ "); printf ("i7z DEBUG: modprobbing for msr\n"); system ("modprobe msr"); @@ -121,7 +152,7 @@ } else { printf ("i7z DEBUG: You DONOT have root privileges, mknod to create device entries won't work out\n"); printf ("i7z DEBUG: A solution is to run this program as root\n"); -@@ -526,6 +563,7 @@ +@@ -526,6 +571,7 @@ } } } @@ -129,7 +160,7 @@ double cpufreq_info() { //CPUINFO is wrong for i7 but correct for the number of physical and logical cores present -@@ -543,6 +581,21 @@ +@@ -543,6 +589,21 @@ fclose (tmp_file); return atof(tmp_str); } @@ -151,7 +182,7 @@ int check_and_return_processor(char*strinfo) { -@@ -669,6 +722,7 @@ +@@ -669,6 +730,7 @@ printf("Socket-%d [num of cpus %d physical %d logical %d] %s\n",socket->socket_num,socket->max_cpu,socket->num_physical_cores,socket->num_logical_cores,socket_list); } @@ -159,7 +190,7 @@ void construct_CPU_Heirarchy_info(struct cpu_heirarchy_info* chi) { FILE *fp = fopen("/proc/cpuinfo","r"); -@@ -715,7 +769,51 @@ +@@ -715,7 +777,51 @@ chi->max_online_cpu = it_processor_num+1; fclose(fp); } Modified: head/sysutils/i7z/files/patch-i7z.c ============================================================================== --- head/sysutils/i7z/files/patch-i7z.c Sun Sep 11 19:03:16 2016 (r421870) +++ head/sysutils/i7z/files/patch-i7z.c Sun Sep 11 19:18:59 2016 (r421871) @@ -1,5 +1,68 @@ --- ./i7z.c.orig 2012-09-11 08:15:54.000000000 +0200 +++ ./i7z.c 2012-12-11 14:41:28.000000000 +0100 +@@ -184,11 +184,11 @@ + { + //below when just logging + if(prog_options.logging==1) { +- fprintf(fp_log_file_freq,"%d.%.9d\n",value->tv_sec,value->tv_nsec); //newline, replace \n with \t to get everything separated with tabs ++ fprintf(fp_log_file_freq,"%jd.%.9ld\n",(intmax_t)value->tv_sec,value->tv_nsec); //newline, replace \n with \t to get everything separated with tabs + } + //below when appending + if(prog_options.logging==2) { +- fprintf(fp_log_file_freq,"%d.%.9d\t",value->tv_sec,value->tv_nsec); ++ fprintf(fp_log_file_freq,"%jd.%.9ld\t",(intmax_t)value->tv_sec,value->tv_nsec); + } + } + +@@ -264,20 +264,20 @@ + if(socket_num==0){ + //below when just logging + if(prog_options.logging==1) +- fprintf(fp_log_file_freq_1,"%d.%.9d\n",value->tv_sec,value->tv_nsec); //newline, replace \n with \t to get everything separated with tabs ++ fprintf(fp_log_file_freq_1,"%jd.%.9ld\n",(intmax_t)value->tv_sec,value->tv_nsec); //newline, replace \n with \t to get everything separated with tabs + + //below when appending + if(prog_options.logging==2) +- fprintf(fp_log_file_freq_1,"%d.%.9d\t",value->tv_sec,value->tv_nsec); ++ fprintf(fp_log_file_freq_1,"%jd.%.9ld\t",(intmax_t)value->tv_sec,value->tv_nsec); + } + if(socket_num==1){ + //below when just logging + if(prog_options.logging==1) +- fprintf(fp_log_file_freq_2,"%d.%.9d\n",value->tv_sec,value->tv_nsec); //newline, replace \n with \t to get everything separated with tabs ++ fprintf(fp_log_file_freq_2,"%jd.%.9ld\n",(intmax_t)value->tv_sec,value->tv_nsec); //newline, replace \n with \t to get everything separated with tabs + + //below when appending + if(prog_options.logging==2) +- fprintf(fp_log_file_freq_2,"%d.%.9d\t",value->tv_sec,value->tv_nsec); ++ fprintf(fp_log_file_freq_2,"%jd.%.9ld\t",(intmax_t)value->tv_sec,value->tv_nsec); + } + } + +@@ -315,7 +315,7 @@ + { + //below when just logging + if(prog_options.logging != 0) { +- fprintf(fp_log_file_Cstates,"%d.%.9d",value->tv_sec,value->tv_nsec); //newline, replace \n with \t to get everything separated with tabs ++ fprintf(fp_log_file_Cstates,"%jd.%.9ld",(intmax_t)value->tv_sec,value->tv_nsec); //newline, replace \n with \t to get everything separated with tabs + } + } + +@@ -366,12 +366,12 @@ + if(socket_num==0){ + //below when just logging + if(prog_options.logging != 0) +- fprintf(fp_log_file_Cstates_1,"%d.%.9d",value->tv_sec,value->tv_nsec); //newline, replace \n with \t to get everything separated with tabs ++ fprintf(fp_log_file_Cstates_1,"%jd.%.9ld",(intmax_t)value->tv_sec,value->tv_nsec); //newline, replace \n with \t to get everything separated with tabs + } + if(socket_num==1){ + //below when just logging + if(prog_options.logging != 0) +- fprintf(fp_log_file_Cstates_2,"%d.%.9d",value->tv_sec,value->tv_nsec); //newline, replace \n with \t to get everything separated with tabs ++ fprintf(fp_log_file_Cstates_2,"%jd.%.9ld",(intmax_t)value->tv_sec,value->tv_nsec); //newline, replace \n with \t to get everything separated with tabs + } + } + @@ -386,7 +386,11 @@ void modprobing_msr()