From 812fac5a019271833a9acbae9fb043706643c55b Mon Sep 17 00:00:00 2001 From: Dridi Boukelmoune Date: Tue, 17 Sep 2013 11:02:16 +0200 Subject: [PATCH] Initial import (#991221) --- .gitignore | 1 + numatop.cpuid.patch | 171 ++++++++++++++++++++++++++++++++++++++++++++ numatop.spec | 61 ++++++++++++++++ sources | 1 + 4 files changed, 234 insertions(+) create mode 100644 numatop.cpuid.patch create mode 100644 numatop.spec diff --git a/.gitignore b/.gitignore index e69de29..5c3cce0 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/numatop_linux_1.0.1.tar.gz diff --git a/numatop.cpuid.patch b/numatop.cpuid.patch new file mode 100644 index 0000000..742fe9d --- /dev/null +++ b/numatop.cpuid.patch @@ -0,0 +1,171 @@ +diff --git a/Makefile b/Makefile +index 15bab5e..100944f 100644 +--- a/Makefile ++++ b/Makefile +@@ -5,6 +5,7 @@ PROG = numatop + CC = gcc + LD = gcc + CFLAGS = -g -Wall -O2 ++LDFLAGS = -g + LDLIBS = -lncurses -lpthread -lnuma + + COMMON_OBJS = cmd.o disp.o lwp.o numatop.o page.o perf.o \ +@@ -18,7 +19,7 @@ INTEL_OBJS = wsm.o snb.o nhm.o + all: $(PROG) + + $(PROG): $(COMMON_OBJS) $(OS_OBJS) $(INTEL_OBJS) +- $(LD) -o $@ $(COMMON_OBJS) $(OS_OBJS) $(INTEL_OBJS) $(LDLIBS) ++ $(LD) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(OS_OBJS) $(INTEL_OBJS) $(LDLIBS) + + %.o: ./common/%.c ./common/include/*.h ./common/include/os/*.h + $(CC) $(CFLAGS) -o $@ -c $< +diff --git a/common/numatop.c b/common/numatop.c +index 03a7d66..0bdfaa1 100644 +--- a/common/numatop.c ++++ b/common/numatop.c +@@ -72,7 +72,7 @@ main(int argc, char *argv[]) + { + int ret = 1, debug_level = 0; + FILE *log = NULL, *dump = NULL; +- boolean_t locked; ++ boolean_t locked = B_FALSE; + char c; + + if (!os_authorized()) { +diff --git a/common/os/os_win.c b/common/os/os_win.c +index b80bcdf..1fb1781 100644 +--- a/common/os/os_win.c ++++ b/common/os/os_win.c +@@ -889,11 +889,11 @@ latnode_data_show(track_proc_t *proc, dyn_latnode_t *dyn, map_entry_t *entry, + win_size2str(dyn->size, size_str, sizeof (size_str)); + if (lwp != NULL) { + (void) snprintf(content, sizeof (content), +- "Memory area(%lX, %s), thread(%d)", ++ "Memory area(%"PRIX64", %s), thread(%d)", + dyn->addr, size_str, lwp->id); + } else { + (void) snprintf(content, sizeof (content), +- "Memory area(%lX, %s), process(%d)", ++ "Memory area(%"PRIX64", %s), process(%d)", + dyn->addr, size_str, proc->pid); + } + +diff --git a/common/util.c b/common/util.c +index eab06b3..e9afea9 100644 +--- a/common/util.c ++++ b/common/util.c +@@ -126,7 +126,7 @@ debug_print(FILE *out, int level, const char *fmt, ...) + if (s_logfile != NULL) { + (void) pthread_mutex_lock(&s_debug_ctl.mutex); + (void) fprintf(s_logfile, +- "%lu: ", current_ms() / 1000); ++ "%"PRIu64": ", current_ms() / 1000); + va_start(ap, fmt); + (void) vfprintf(s_logfile, fmt, ap); + va_end(ap); +@@ -137,7 +137,7 @@ debug_print(FILE *out, int level, const char *fmt, ...) + } else { + (void) pthread_mutex_lock(&s_debug_ctl.mutex); + (void) fprintf(out, +- "%lu: ", current_ms() / 1000); ++ "%"PRIu64": ", current_ms() / 1000); + va_start(ap, fmt); + (void) vfprintf(out, fmt, ap); + va_end(ap); +@@ -319,6 +319,7 @@ static void + cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx, + unsigned int *edx) + { ++#if __x86_64 + __asm volatile( + "cpuid\n\t" + :"=a" (*eax), +@@ -326,6 +327,19 @@ cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx, + "=c" (*ecx), + "=d" (*edx) + :"a" (*eax)); ++#else ++ __asm volatile( ++ "push %%ebx\n\t" ++ "cpuid\n\t" ++ "mov %%ebx, (%4)\n\t" ++ "pop %%ebx" ++ :"=a" (*eax), ++ "=c" (*ecx), ++ "=d" (*edx) ++ :"0" (*eax), ++ "S" (ebx) ++ :"memory"); ++#endif + } + + /* +diff --git a/common/win.c b/common/win.c +index 3321a00..7454da0 100644 +--- a/common/win.c ++++ b/common/win.c +@@ -1979,17 +1979,17 @@ win_size2str(uint64_t size, char *buf, int bufsize) + * "buf" points to a big enough buffer. + */ + if ((i = (size / KB_BYTES)) < KB_BYTES) { +- (void) snprintf(buf, bufsize, "%luK", i); ++ (void) snprintf(buf, bufsize, "%"PRIu64"K", i); + } else if ((j = i / KB_BYTES) < KB_BYTES) { + if ((i % KB_BYTES) == 0) { +- (void) snprintf(buf, bufsize, "%luM", j); ++ (void) snprintf(buf, bufsize, "%"PRIu64"M", j); + } else { + (void) snprintf(buf, bufsize, "%.1fM", + (double)i / (double)KB_BYTES); + } + } else { + if ((j % KB_BYTES) == 0) { +- (void) snprintf(buf, bufsize, "%luG", j / KB_BYTES); ++ (void) snprintf(buf, bufsize, "%"PRIu64"G", j / KB_BYTES); + } else { + (void) snprintf(buf, bufsize, "%.1fG", + (double)j / (double)KB_BYTES); +@@ -2021,16 +2021,16 @@ win_lat_str_build(char *buf, int size, int idx, void *pv) + win_size2str(line->bufaddr.size, size_str, sizeof (size_str)); + + if (!line->nid_show) { +- (void) snprintf(buf, size, "%16lX%8s%10.1f%11lu%34s", ++ (void) snprintf(buf, size, "%16"PRIX64"%8s%10.1f%11"PRIu64"%34s", + line->bufaddr.addr, size_str, hit * 100.0, cyc2ns(lat), + line->desc); + } else { + if (line->nid < 0) { +- (void) snprintf(buf, size, "%16lX%8s%8s%10.1f%11lu", ++ (void) snprintf(buf, size, "%16"PRIX64"%8s%8s%10.1f%11"PRIu64, + line->bufaddr.addr, size_str, "-", hit * 100.0, + cyc2ns(lat)); + } else { +- (void) snprintf(buf, size, "%16lX%8s%8d%10.1f%11lu", ++ (void) snprintf(buf, size, "%16"PRIX64"%8s%8d%10.1f%11"PRIu64, + line->bufaddr.addr, size_str, line->nid, + hit * 100.0, cyc2ns(lat)); + } +@@ -2314,12 +2314,12 @@ win_lat_data_show(track_proc_t *proc, dyn_lat_t *dyn, boolean_t *note_out) + if (lwp == NULL) { + (void) snprintf(content, sizeof (content), + "Monitoring memory areas (pid: %d, " +- "AVG.LAT: %luns, interval: %s)", ++ "AVG.LAT: %"PRIu64"ns, interval: %s)", + proc->pid, cyc2ns(lat), intval_buf); + } else { + (void) snprintf(content, sizeof (content), + "Monitoring memory areas (lwpid: %d, " +- "AVG.LAT: %luns, interval: %s)", ++ "AVG.LAT: %"PRIu64"ns, interval: %s)", + lwp->id, cyc2ns(lat), intval_buf); + } + +@@ -2462,7 +2462,7 @@ accdst_str_build(char *buf, int size, int idx, void *pv) + accdst_line_t *lines = (accdst_line_t *)pv; + accdst_line_t *line = &lines[idx]; + +- (void) snprintf(buf, size, "%5d%14.1f%15lu", ++ (void) snprintf(buf, size, "%5d%14.1f%15"PRIu64, + line->nid, line->access_ratio * 100.0, cyc2ns(line->latency)); + } + diff --git a/numatop.spec b/numatop.spec new file mode 100644 index 0000000..047cd5a --- /dev/null +++ b/numatop.spec @@ -0,0 +1,61 @@ +%global _hardened_build 1 + +Name: numatop +Version: 1.0.1 +Release: 4%{?dist} +Summary: Memory access locality characterization and analysis + +License: BSD +URL: https://01.org/numatop +Source0: https://01.org/sites/default/files/downloads/%{name}_linux_%{version}.tar.gz +BuildRequires: numactl-devel ncurses-devel + +# https://github.com/01org/numatop/pull/5 +Patch0: numatop.cpuid.patch + +ExcludeArch: %{arm} + + +%description +NumaTOP is an observation tool for runtime memory locality characterization and +analysis of processes and threads running on a NUMA system. It helps the user +characterize the NUMA behavior of processes and threads and identify where the +NUMA-related performance bottlenecks reside. + +NumaTOP supports the Intel Xeon processors. + + +%prep +%setup -q -n %{name} +%patch0 -p 1 + + +%build +make CFLAGS="%{optflags}" %{?_smp_mflags} + + +%install +mkdir -p %{buildroot}%{_bindir} +mkdir -p %{buildroot}%{_mandir}/man8 +make install PREFIXDIR=%{buildroot}%{_prefix} MANDIR=%{buildroot}%{_mandir}/man8 + + +%files +%doc AUTHORS COPYING README +%{_bindir}/%{name} +%{_mandir}/man8/%{name}.8* + + +%changelog +* Fri Sep 13 2013 Dridi Boukelmoune - 1.0.1-4 +- Patch for the 32bit hardened build. + +* Sun Aug 25 2013 Dridi Boukelmoune - 1.0.1-3 +- Hardened build. +- Automatic requires. + +* Fri Aug 02 2013 Dridi Boukelmoune - 1.0.1-2 +- Fix the license tag. + +* Thu Aug 01 2013 Dridi Boukelmoune - 1.0.1-1 +- Initial spec. diff --git a/sources b/sources index e69de29..c5b8afe 100644 --- a/sources +++ b/sources @@ -0,0 +1 @@ +325389acd2d4ba40cfbc6ad3b839de7a numatop_linux_1.0.1.tar.gz