diff -Nru numatop-1.0.3/common/disp.c numatop-1.0.4/common/disp.c --- numatop-1.0.3/common/disp.c 2014-07-01 00:40:53.000000000 +0000 +++ numatop-1.0.4/common/disp.c 2015-12-14 00:38:02.000000000 +0000 @@ -427,7 +427,8 @@ cmd_t cmd; boolean_t quit, pagelist_inited = B_FALSE; struct timespec timeout; - uint64_t start_ms, diff_ms; + uint64_t start_ms; + int64_t diff_ms; /* * Wait cons thread to complete initialization. @@ -614,35 +615,35 @@ if (select(s_cons_ctl.pipe[0] + 1, &s_cons_ctl.fds, NULL, NULL, NULL) > 0) { if (FD_ISSET(s_cons_ctl.pipe[0], &s_cons_ctl.fds)) { - (void) read(s_cons_ctl.pipe[0], &ch, 1); - - /* - * Character is from pipe. - */ - if (ch == PIPE_CHAR_QUIT) { + if (read(s_cons_ctl.pipe[0], &ch, 1) == 1) { /* - * Received a QUIT notification, - * "console thread" will be quit + * Character is from pipe. */ - debug_print(NULL, 2, "cons: " - "received PIPE_CHAR_QUIT\n"); - break; - } - - if (ch == PIPE_CHAR_RESIZE) { - /* - * Send the "RESIZE" command - * to "display thread". - */ - (void) pthread_mutex_lock( - &s_disp_ctl.mutex); + if (ch == PIPE_CHAR_QUIT) { + /* + * Received a QUIT notification, + * "console thread" will be quit + */ + debug_print(NULL, 2, "cons: " + "received PIPE_CHAR_QUIT\n"); + break; + } + + if (ch == PIPE_CHAR_RESIZE) { + /* + * Send the "RESIZE" command + * to "display thread". + */ + (void) pthread_mutex_lock( + &s_disp_ctl.mutex); - CMD_ID_SET(&s_disp_ctl.cmd, - CMD_RESIZE_ID); + CMD_ID_SET(&s_disp_ctl.cmd, + CMD_RESIZE_ID); dispthr_flagset_nolock(DISP_FLAG_CMD); (void) pthread_mutex_unlock( &s_disp_ctl.mutex); + } } } else { /* diff -Nru numatop-1.0.3/common/include/types.h numatop-1.0.4/common/include/types.h --- numatop-1.0.3/common/include/types.h 2014-08-05 06:00:32.000000000 +0000 +++ numatop-1.0.4/common/include/types.h 2015-12-14 00:38:02.000000000 +0000 @@ -51,10 +51,11 @@ CPU_NHM_EP, CPU_WSM_EP, CPU_IVB_EX, - CPU_HSX + CPU_HSX, + CPU_BDX } cpu_type_t; -#define CPU_TYPE_NUM 8 +#define CPU_TYPE_NUM 9 typedef enum { SORT_KEY_INVALID = -1, diff -Nru numatop-1.0.3/common/os/map.c numatop-1.0.4/common/os/map.c --- numatop-1.0.3/common/os/map.c 2014-07-01 00:40:53.000000000 +0000 +++ numatop-1.0.4/common/os/map.c 2015-12-14 00:38:02.000000000 +0000 @@ -349,8 +349,8 @@ map_map2numa(track_proc_t *proc, map_entry_t *map_entry) { void *addr_arr[NUMA_MOVE_NPAGES]; - unsigned int npages_total, npages_tomove, npages_moved = 0; - int node_arr[NUMA_MOVE_NPAGES], i; + unsigned int i, npages_total, npages_tomove, npages_moved = 0; + int node_arr[NUMA_MOVE_NPAGES]; numa_entry_t *last_entry = NULL; numa_map_fini(map_entry); diff -Nru numatop-1.0.3/common/os/os_util.c numatop-1.0.4/common/os/os_util.c --- numatop-1.0.3/common/os/os_util.c 2014-07-01 00:40:53.000000000 +0000 +++ numatop-1.0.4/common/os/os_util.c 2015-12-14 00:38:02.000000000 +0000 @@ -196,7 +196,7 @@ calibrate_cpuinfo(double *nsofclk, uint64_t *clkofsec) { FILE *f; - char *line = NULL, unit[10]; + char *line = NULL, unit[11]; size_t len = 0; double freq = 0.0; diff -Nru numatop-1.0.3/common/os/os_win.c numatop-1.0.4/common/os/os_win.c --- numatop-1.0.3/common/os/os_win.c 2014-07-01 00:40:53.000000000 +0000 +++ numatop-1.0.4/common/os/os_win.c 2015-12-14 00:38:02.000000000 +0000 @@ -479,16 +479,25 @@ strncpy(dyn->desc, cmd->desc, WIN_DESCBUF_SIZE); dyn->desc[WIN_DESCBUF_SIZE - 1] = 0; - i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD); - i = reg_init(&dyn->buf_caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE); - i = reg_init(&dyn->buf_data, 0, i, g_scr_width, 1, 0); - i = reg_init(&dyn->chain_caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE); - i = reg_init(&dyn->pad, 0, i, g_scr_width, 1, 0); - reg_init(&dyn->chain_data, 0, i, g_scr_width, g_scr_height - i - 2, 0); + if ((i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD)) < 0) + goto L_EXIT; + if ((i = reg_init(&dyn->buf_caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE)) < 0) + goto L_EXIT; + if ((i = reg_init(&dyn->buf_data, 0, i, g_scr_width, 1, 0)) < 0) + goto L_EXIT; + if ((i = reg_init(&dyn->chain_caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE)) < 0) + goto L_EXIT; + if ((i = reg_init(&dyn->pad, 0, i, g_scr_width, 1, 0)) < 0) + goto L_EXIT; + if ((reg_init(&dyn->chain_data, 0, i, g_scr_width, g_scr_height - i - 2, 0)) < 0) + goto L_EXIT; reg_buf_init(&dyn->chain_data, NULL, win_callchain_line_get); reg_scroll_init(&dyn->chain_data, B_TRUE); return (dyn); +L_EXIT: + free(dyn); + return (NULL); } void diff -Nru numatop-1.0.3/common/os/pfwrapper.c numatop-1.0.4/common/os/pfwrapper.c --- numatop-1.0.3/common/os/pfwrapper.c 2014-07-01 00:40:53.000000000 +0000 +++ numatop-1.0.4/common/os/pfwrapper.c 2015-12-14 00:38:02.000000000 +0000 @@ -254,8 +254,8 @@ { struct { uint32_t pid, tid; } id; count_value_t *countval = &rec->countval; - uint64_t time_enabled, time_running, nr, value, *ips; - int i, j, ret = -1; + uint64_t i, time_enabled, time_running, nr, value, *ips; + int j, ret = -1; /* * struct read_format { @@ -473,8 +473,8 @@ pf_ll_rec_t *rec) { struct { uint32_t pid, tid; } id; - uint64_t addr, cpu, weight, nr, value, *ips; - int i, j, ret = -1; + uint64_t i, addr, cpu, weight, nr, value, *ips; + int j, ret = -1; /* * struct read_format { @@ -588,14 +588,12 @@ pf_ll_rec_t rec; int size; - if (nrec != NULL) { - *nrec = 0; - } + *nrec = 0; for (;;) { if (mmap_buffer_read(mhdr, &ehdr, sizeof(ehdr)) == -1) { /* No valid record in ring buffer. */ - return; + return; } if ((size = ehdr.size - sizeof (ehdr)) <= 0) { diff -Nru numatop-1.0.3/common/os/plat.c numatop-1.0.4/common/os/plat.c --- numatop-1.0.3/common/os/plat.c 2014-08-05 06:00:56.000000000 +0000 +++ numatop-1.0.4/common/os/plat.c 2015-12-14 01:26:33.000000000 +0000 @@ -41,6 +41,7 @@ #include "../../intel/include/nhm.h" #include "../../intel/include/wsm.h" #include "../../intel/include/snb.h" +#include "../../intel/include/bdw.h" static pfn_plat_profiling_config_t s_plat_profiling_config[CPU_TYPE_NUM] = { @@ -51,7 +52,8 @@ nhmep_profiling_config, wsmep_profiling_config, snbep_profiling_config, - snbep_profiling_config + snbep_profiling_config, + bdw_profiling_config }; static pfn_plat_ll_config_t @@ -63,7 +65,8 @@ nhmep_ll_config, wsmep_ll_config, snbep_ll_config, - snbep_ll_config + snbep_ll_config, + bdw_ll_config }; static pfn_plat_offcore_num_t @@ -75,7 +78,8 @@ nhm_offcore_num, wsm_offcore_num, snb_offcore_num, - snb_offcore_num + snb_offcore_num, + bdw_offcore_num }; static cpu_type_t s_cpu_type; @@ -105,6 +109,8 @@ case CPU_IVB_EX: /* fall through */ case CPU_HSX: + /* fall through */ + case CPU_BDX: return (0); default: diff -Nru numatop-1.0.3/common/reg.c numatop-1.0.4/common/reg.c --- numatop-1.0.3/common/reg.c 2014-07-01 00:40:53.000000000 +0000 +++ numatop-1.0.4/common/reg.c 2015-12-14 00:38:02.000000000 +0000 @@ -402,6 +402,7 @@ { (void) initscr(); (void) refresh(); + (void) use_default_colors(); (void) start_color(); (void) keypad(stdscr, TRUE); (void) nonl(); diff -Nru numatop-1.0.3/common/util.c numatop-1.0.4/common/util.c --- numatop-1.0.3/common/util.c 2014-08-05 06:46:31.000000000 +0000 +++ numatop-1.0.4/common/util.c 2015-12-14 00:38:02.000000000 +0000 @@ -396,6 +396,9 @@ case 63: type = CPU_HSX; break; + case 79: + type = CPU_BDX; + break; } } diff -Nru numatop-1.0.3/common/win.c numatop-1.0.4/common/win.c --- numatop-1.0.3/common/win.c 2014-07-01 00:40:53.000000000 +0000 +++ numatop-1.0.4/common/win.c 2015-12-14 00:38:02.000000000 +0000 @@ -258,19 +258,22 @@ void *buf; int i; - if ((dyn = zalloc(sizeof (dyn_topnproc_t))) == NULL) { - return (NULL); - } - if ((buf = zalloc(sizeof (topnproc_line_t) * WIN_NLINES_MAX)) == NULL) { - free(dyn); return (NULL); } + if ((dyn = zalloc(sizeof (dyn_topnproc_t))) == NULL) { + free(buf); + return (NULL); + } + - i = reg_init(&dyn->summary, 0, 1, g_scr_width, 2, A_BOLD); - i = reg_init(&dyn->caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE); - i = reg_init(&dyn->data, 0, i, g_scr_width, g_scr_height - i - 5, 0); + if ((i = reg_init(&dyn->summary, 0, 1, g_scr_width, 2, A_BOLD)) < 0) + goto L_EXIT; + if ((i = reg_init(&dyn->caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE)) < 0) + goto L_EXIT; + if ((i = reg_init(&dyn->data, 0, i, g_scr_width, g_scr_height - i - 5, 0)) < 0) + goto L_EXIT; if (type == WIN_TYPE_TOPNPROC) { reg_buf_init(&dyn->data, buf, topnproc_line_get); @@ -282,6 +285,10 @@ (void) reg_init(&dyn->hint, 0, i, g_scr_width, g_scr_height - i - 1, A_BOLD); return (dyn); +L_EXIT: + free(dyn); + free(buf); + return (NULL); } /* @@ -655,21 +662,23 @@ int i, nnodes; nnodes = node_num(); - if ((dyn = zalloc(sizeof (dyn_moniproc_t))) == NULL) { + if ((buf_cur = zalloc(sizeof (moni_line_t) * nnodes)) == NULL) { return (NULL); } - - if ((buf_cur = zalloc(sizeof (moni_line_t) * nnodes)) == NULL) { - free(dyn); + if ((dyn = zalloc(sizeof (dyn_moniproc_t))) == NULL) { + free(buf_cur); return (NULL); } dyn->pid = pid; - i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD); - i = reg_init(&dyn->caption_cur, 0, i, g_scr_width, 2, - A_BOLD | A_UNDERLINE); - i = reg_init(&dyn->data_cur, 0, i, g_scr_width, nnodes, 0); + if ((i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD)) < 0) + goto L_EXIT; + if ((i = reg_init(&dyn->caption_cur, 0, i, g_scr_width, 2, + A_BOLD | A_UNDERLINE)) < 0) + goto L_EXIT; + if ((i = reg_init(&dyn->data_cur, 0, i, g_scr_width, nnodes, 0)) < 0) + goto L_EXIT; reg_buf_init(&dyn->data_cur, buf_cur, moni_line_get); reg_scroll_init(&dyn->data_cur, B_TRUE); @@ -677,6 +686,10 @@ (void) reg_init(&dyn->hint, 0, i, g_scr_width, g_scr_height - i - 1, A_BOLD); return (dyn); +L_EXIT: + free(dyn); + free(buf_cur); + return (NULL); } /* @@ -691,22 +704,24 @@ int i, nnodes; nnodes = node_num(); - if ((dyn = zalloc(sizeof (dyn_monilwp_t))) == NULL) { + if ((buf_cur = zalloc(sizeof (moni_line_t) * nnodes)) == NULL) { return (NULL); } - - if ((buf_cur = zalloc(sizeof (moni_line_t) * nnodes)) == NULL) { - free(dyn); + if ((dyn = zalloc(sizeof (dyn_monilwp_t))) == NULL) { + free(buf_cur); return (NULL); } dyn->pid = pid; dyn->lwpid = lwpid; - i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD); - i = reg_init(&dyn->caption_cur, 0, i, g_scr_width, 2, - A_BOLD | A_UNDERLINE); - i = reg_init(&dyn->data_cur, 0, i, g_scr_width, nnodes, 0); + if ((i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD)) < 0) + goto L_EXIT; + if ((i = reg_init(&dyn->caption_cur, 0, i, g_scr_width, 2, + A_BOLD | A_UNDERLINE)) < 0) + goto L_EXIT; + if ((i = reg_init(&dyn->data_cur, 0, i, g_scr_width, nnodes, 0)) < 0) + goto L_EXIT; reg_buf_init(&dyn->data_cur, buf_cur, moni_line_get); reg_scroll_init(&dyn->data_cur, B_TRUE); @@ -714,6 +729,10 @@ (void) reg_init(&dyn->hint, 0, i, g_scr_width, g_scr_height - i - 1, A_BOLD); return (dyn); +L_EXIT: + free(dyn); + free(buf_cur); + return (NULL); } /* @@ -1185,20 +1204,22 @@ cmd_lwp_t *cmd_lwp = (cmd_lwp_t *)(&page->cmd); pid_t pid = cmd_lwp->pid; - if ((dyn = zalloc(sizeof (dyn_topnlwp_t))) == NULL) { + if ((buf = zalloc(sizeof (topnlwp_line_t) * WIN_NLINES_MAX)) == NULL) { return (NULL); } - - if ((buf = zalloc(sizeof (topnlwp_line_t) * WIN_NLINES_MAX)) == NULL) { - free(dyn); + if ((dyn = zalloc(sizeof (dyn_topnlwp_t))) == NULL) { + free(buf); return (NULL); } dyn->pid = pid; - i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD); - i = reg_init(&dyn->caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE); - i = reg_init(&dyn->data, 0, i, g_scr_width, g_scr_height - i - 4, 0); + if ((i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD)) < 0) + goto L_EXIT; + if ((i = reg_init(&dyn->caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE)) < 0) + goto L_EXIT; + if ((i = reg_init(&dyn->data, 0, i, g_scr_width, g_scr_height - i - 4, 0)) < 0) + goto L_EXIT; reg_buf_init(&dyn->data, buf, topnlwp_line_get); reg_scroll_init(&dyn->data, B_TRUE); @@ -1206,6 +1227,10 @@ (void) reg_init(&dyn->hint, 0, i, g_scr_width, g_scr_height - i - 1, A_BOLD); return (dyn); +L_EXIT: + free(dyn); + free(buf); + return (NULL); } /* @@ -1441,19 +1466,21 @@ int i, nnodes; nnodes = node_num(); - if ((dyn = zalloc(sizeof (dyn_nodeoverview_t))) == NULL) { + if ((buf_cur = zalloc(sizeof (nodeoverview_line_t) * nnodes)) == NULL) { return (NULL); } - - if ((buf_cur = zalloc(sizeof (nodeoverview_line_t) * nnodes)) == NULL) { - free(dyn); + if ((dyn = zalloc(sizeof (dyn_nodeoverview_t))) == NULL) { + free(buf_cur); return (NULL); } - i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD); - i = reg_init(&dyn->caption_cur, 0, i, g_scr_width, 2, - A_BOLD | A_UNDERLINE); - i = reg_init(&dyn->data_cur, 0, i, g_scr_width, nnodes, 0); + if ((i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD)) < 0) + goto L_EXIT; + if ((i = reg_init(&dyn->caption_cur, 0, i, g_scr_width, 2, + A_BOLD | A_UNDERLINE)) < 0) + goto L_EXIT; + if ((i = reg_init(&dyn->data_cur, 0, i, g_scr_width, nnodes, 0)) < 0) + goto L_EXIT; reg_buf_init(&dyn->data_cur, buf_cur, nodeoverview_line_get); reg_scroll_init(&dyn->data_cur, B_TRUE); @@ -1461,6 +1488,10 @@ (void) reg_init(&dyn->hint, 0, i, g_scr_width, g_scr_height - i - 1, A_BOLD); return (dyn); +L_EXIT: + free(dyn); + free(buf_cur); + return (NULL); } /* @@ -1683,16 +1714,20 @@ dyn->nid = CMD_NODE_DETAIL(&page->cmd)->nid; node = node_get(dyn->nid); if (!NODE_VALID(node)) { - free(dyn); win_warn_msg(WARN_INVALID_NID); - return (NULL); + goto L_EXIT; } - i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD | A_UNDERLINE); - i = reg_init(&dyn->node_data, 0, i, g_scr_width, - g_scr_height - i - 4, 0); + if ((i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD | A_UNDERLINE)) < 0) + goto L_EXIT; + if ((i = reg_init(&dyn->node_data, 0, i, g_scr_width, + g_scr_height - i - 4, 0)) < 0) + goto L_EXIT; (void) reg_init(&dyn->hint, 0, i, g_scr_width, 3, A_BOLD); return (dyn); +L_EXIT: + free(dyn); + return NULL; } static boolean_t @@ -1810,15 +1845,22 @@ dyn->lwpid = cmd_callchain->lwpid; dyn->countid = COUNT_RMA; - i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD); - i = reg_init(&dyn->caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE); - i = reg_init(&dyn->pad, 0, i, g_scr_width, 1, 0); - i = reg_init(&dyn->data, 0, i, g_scr_width, g_scr_height - i - 4, 0); + if ((i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD)) < 0) + goto L_EXIT; + if ((i = reg_init(&dyn->caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE)) < 0) + goto L_EXIT; + if ((i = reg_init(&dyn->pad, 0, i, g_scr_width, 1, 0)) < 0) + goto L_EXIT; + if ((i = reg_init(&dyn->data, 0, i, g_scr_width, g_scr_height - i - 4, 0)) < 0) + goto L_EXIT; reg_buf_init(&dyn->data, NULL, win_callchain_line_get); reg_scroll_init(&dyn->data, B_TRUE); (void) reg_init(&dyn->hint, 0, i, g_scr_width, g_scr_height - i - 1, A_BOLD); return (dyn); +L_EXIT: + free(dyn); + return (NULL); } /* @@ -2061,8 +2103,10 @@ return (NULL); } - i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD); - i = reg_init(&dyn->caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE); + if ((i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD)) < 0) + goto L_EXIT; + if ((i = reg_init(&dyn->caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE)) < 0) + goto L_EXIT; (void) reg_init(&dyn->data, 0, i, g_scr_width, g_scr_height - i - 2, 0); reg_buf_init(&dyn->data, NULL, lat_line_get); @@ -2076,6 +2120,9 @@ } return (dyn); +L_EXIT: + free(dyn); + return (NULL); } /* @@ -2410,9 +2457,12 @@ return (NULL); } - i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD); - i = reg_init(&dyn->note, 0, i, g_scr_width, 2, A_BOLD); - i = reg_init(&dyn->caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE); + if ((i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD)) < 0) + goto L_EXIT; + if ((i = reg_init(&dyn->note, 0, i, g_scr_width, 2, A_BOLD)) < 0) + goto L_EXIT; + if ((i = reg_init(&dyn->caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE)) < 0) + goto L_EXIT; (void) reg_init(&dyn->data, 0, i, g_scr_width, g_scr_height - i - 2, 0); reg_buf_init(&dyn->data, NULL, lat_line_get); @@ -2428,6 +2478,9 @@ dyn->addr = cmd->addr; dyn->size = cmd->size; return (dyn); +L_EXIT: + free(dyn); + return (NULL); } /* @@ -2504,19 +2557,21 @@ cmd_accdst_t *cmd_accdst = CMD_ACCDST(&page->cmd); nnodes = node_num(); - if ((dyn = zalloc(sizeof (dyn_accdst_t))) == NULL) { + if ((buf = zalloc(sizeof (accdst_line_t) * nnodes)) == NULL) { return (NULL); } - - if ((buf = zalloc(sizeof (accdst_line_t) * nnodes)) == NULL) { - free(dyn); + if ((dyn = zalloc(sizeof (dyn_accdst_t))) == NULL) { + free(buf); return (NULL); } - i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD); - i = reg_init(&dyn->caption, 0, i, g_scr_width, 2, - A_BOLD | A_UNDERLINE); - i = reg_init(&dyn->data, 0, i, g_scr_width, nnodes, 0); + if ((i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD)) < 0) + goto L_EXIT; + if ((i = reg_init(&dyn->caption, 0, i, g_scr_width, 2, + A_BOLD | A_UNDERLINE)) < 0) + goto L_EXIT; + if ((i = reg_init(&dyn->data, 0, i, g_scr_width, nnodes, 0)) < 0) + goto L_EXIT; reg_buf_init(&dyn->data, buf, accdst_line_get); reg_scroll_init(&dyn->data, B_TRUE); (void) reg_init(&dyn->hint, 0, i, g_scr_width, @@ -2530,6 +2585,10 @@ } return (dyn); +L_EXIT: + free(dyn); + free(buf); + return (NULL); } /* @@ -2638,7 +2697,7 @@ track_lwp_t *lwp = NULL; void **addr_arr = NULL; int *lat_arr = NULL; - int addr_num, i, nnodes, naccess_total; + int addr_num, i, nnodes, naccess_total = 0; map_nodedst_t nodedst_arr[NNODES_MAX]; accdst_line_t *lines; char content[WIN_LINECHAR_MAX], intval_buf[16]; @@ -2776,7 +2835,8 @@ char content[WIN_LINECHAR_MAX]; int i; - i = reg_init(&dyn.msg, 0, 1, g_scr_width, 4, A_BOLD); + if ((i = reg_init(&dyn.msg, 0, 1, g_scr_width, 4, A_BOLD)) < 0) + return; (void) reg_init(&dyn.pad, 0, i, g_scr_width, g_scr_height - i - 2, 0); diff -Nru numatop-1.0.3/debian/changelog numatop-1.0.4/debian/changelog --- numatop-1.0.3/debian/changelog 2015-09-28 21:05:47.000000000 +0000 +++ numatop-1.0.4/debian/changelog 2015-12-20 13:32:49.000000000 +0000 @@ -1,3 +1,11 @@ +numatop (1.0.4-1) unstable; urgency=medium + + * Sync with upstream 1.0.4 release + * Remove patches that are now in 1.0.4 release + * Refresh hardening patch for Makefile + + -- Colin King Sun, 20 Dec 2015 12:53:00 +0000 + numatop (1.0.3-2) unstable; urgency=medium * Fix sign comparison issue comparing g_run_secs and diff_ms diff -Nru numatop-1.0.3/debian/patches/0001-calibrate_cpuinfo-ensure-we-do-not-overflow-buffer-u.patch numatop-1.0.4/debian/patches/0001-calibrate_cpuinfo-ensure-we-do-not-overflow-buffer-u.patch --- numatop-1.0.3/debian/patches/0001-calibrate_cpuinfo-ensure-we-do-not-overflow-buffer-u.patch 2015-08-18 04:07:34.000000000 +0000 +++ numatop-1.0.4/debian/patches/0001-calibrate_cpuinfo-ensure-we-do-not-overflow-buffer-u.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -From 0a01f1a06227b2c3fa599ac048a5bf3dda3cefdd Mon Sep 17 00:00:00 2001 -From: Colin Ian King -Date: Sun, 23 Mar 2014 10:29:33 +0000 -Subject: [PATCH 1/7] calibrate_cpuinfo: ensure we do not overflow buffer unit - -cppcheck found a potential buffer overflow: - -[common/os/os_util.c:212]: (error) Width 10 given in format string - (no. 2) is larger than destination buffer 'unit[10]', use %9s to - prevent overflowing it. - -Increase unit array to 11 bytes. - -Signed-off-by: Colin Ian King ---- - common/os/os_util.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/common/os/os_util.c b/common/os/os_util.c -index cd73aae..68edaf7 100644 ---- a/common/os/os_util.c -+++ b/common/os/os_util.c -@@ -196,7 +196,7 @@ static int - calibrate_cpuinfo(double *nsofclk, uint64_t *clkofsec) - { - FILE *f; -- char *line = NULL, unit[10]; -+ char *line = NULL, unit[11]; - size_t len = 0; - double freq = 0.0; - --- -2.5.0 - diff -Nru numatop-1.0.3/debian/patches/0001--hardnen-changes-for-makefile.patch numatop-1.0.4/debian/patches/0001--hardnen-changes-for-makefile.patch --- numatop-1.0.3/debian/patches/0001--hardnen-changes-for-makefile.patch 1970-01-01 00:00:00.000000000 +0000 +++ numatop-1.0.4/debian/patches/0001--hardnen-changes-for-makefile.patch 2015-12-20 13:32:02.000000000 +0000 @@ -0,0 +1,32 @@ +Index: numatop-1.0.4/Makefile +=================================================================== +--- numatop-1.0.4.orig/Makefile ++++ numatop-1.0.4/Makefile +@@ -4,8 +4,8 @@ MANDIR = /usr/share/man/man8 + PROG = numatop + CC = gcc + LD = gcc +-CFLAGS = -g -Wall -O2 +-LDFLAGS = -g ++CFLAGS += -g -Wall -O2 ++LDFLAGS += -g + LDLIBS = -lncurses -lpthread -lnuma + + COMMON_OBJS = cmd.o disp.o lwp.o numatop.o page.o perf.o \ +@@ -22,13 +22,13 @@ $(PROG): $(COMMON_OBJS) $(OS_OBJS) $(INT + $(LD) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(OS_OBJS) $(INTEL_OBJS) $(LDLIBS) + + %.o: ./common/%.c ./common/include/*.h ./common/include/os/*.h +- $(CC) $(CFLAGS) -o $@ -c $< ++ $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $< + + %.o: ./common/os/%.c ./common/include/*.h ./common/include/os/*.h +- $(CC) $(CFLAGS) -o $@ -c $< ++ $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $< + + %.o: ./intel/%.c ./intel/include/*.h +- $(CC) $(CFLAGS) -o $@ -c $< ++ $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $< + + install: $(PROG) + install -m 0755 $(PROG) $(PREFIXDIR)$(BINDIR)/ diff -Nru numatop-1.0.3/debian/patches/0002-mgen-calibrate_cpuinfo-ensure-we-do-not-overflow-buf.patch numatop-1.0.4/debian/patches/0002-mgen-calibrate_cpuinfo-ensure-we-do-not-overflow-buf.patch --- numatop-1.0.3/debian/patches/0002-mgen-calibrate_cpuinfo-ensure-we-do-not-overflow-buf.patch 2015-08-18 04:07:34.000000000 +0000 +++ numatop-1.0.4/debian/patches/0002-mgen-calibrate_cpuinfo-ensure-we-do-not-overflow-buf.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -From 27404944c305a9b6aee6521b31a91fb212b17178 Mon Sep 17 00:00:00 2001 -From: Colin Ian King -Date: Sun, 23 Mar 2014 10:33:39 +0000 -Subject: [PATCH 2/7] mgen: calibrate_cpuinfo: ensure we do not overflow buffer - unit - -cppcheck found a potential buffer overflow: - -[test/mgen/mgen.c:219]: (error) Width 10 given in format string - (no. 2) is larger than destination buffer 'unit[10]', use %9s - to prevent overflowing it. - -Increase unit array to 11 bytes. - -Signed-off-by: Colin Ian King ---- - test/mgen/mgen.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/test/mgen/mgen.c b/test/mgen/mgen.c -index 8e99f6e..30cb2ac 100644 ---- a/test/mgen/mgen.c -+++ b/test/mgen/mgen.c -@@ -203,7 +203,7 @@ static int - calibrate_cpuinfo(double *nsofclk, double *clkofns, uint64_t *clkofsec) - { - FILE *f; -- char *line = NULL, unit[10]; -+ char *line = NULL, unit[11]; - size_t len = 0; - double freq = 0.0; - --- -2.5.0 - diff -Nru numatop-1.0.3/debian/patches/0003-tty-colors-are-broken-without-using-use_default_colo.patch numatop-1.0.4/debian/patches/0003-tty-colors-are-broken-without-using-use_default_colo.patch --- numatop-1.0.3/debian/patches/0003-tty-colors-are-broken-without-using-use_default_colo.patch 2015-08-18 04:07:34.000000000 +0000 +++ numatop-1.0.4/debian/patches/0003-tty-colors-are-broken-without-using-use_default_colo.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -From 35639cc0ae2cdf0d42f299675af8bff7f9485751 Mon Sep 17 00:00:00 2001 -From: Colin Ian King -Date: Mon, 24 Mar 2014 15:35:38 +0000 -Subject: [PATCH 3/7] tty colors are broken without using use_default_colors() - -use_default_colors() is required to make the output look -correct in my gnome-terminal - -Signed-off-by: Colin Ian King ---- - common/reg.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/common/reg.c b/common/reg.c -index 08fc9c9..1a87161 100644 ---- a/common/reg.c -+++ b/common/reg.c -@@ -402,6 +402,7 @@ reg_curses_init(boolean_t first_load) - { - (void) initscr(); - (void) refresh(); -+ (void) use_default_colors(); - (void) start_color(); - (void) keypad(stdscr, TRUE); - (void) nonl(); --- -2.5.0 - diff -Nru numatop-1.0.3/debian/patches/0004-Only-process-pipe-read-if-read-was-successful.patch numatop-1.0.4/debian/patches/0004-Only-process-pipe-read-if-read-was-successful.patch --- numatop-1.0.3/debian/patches/0004-Only-process-pipe-read-if-read-was-successful.patch 2015-08-18 04:07:34.000000000 +0000 +++ numatop-1.0.4/debian/patches/0004-Only-process-pipe-read-if-read-was-successful.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -From dfabff1efdd614d804664b0bbb46fc1fbe150d40 Mon Sep 17 00:00:00 2001 -From: Colin Ian King -Date: Mon, 17 Nov 2014 12:59:50 +0000 -Subject: [PATCH 4/7] Only process pipe read if read was successful - -Signed-off-by: Colin Ian King ---- - common/disp.c | 42 +++++++++++++++++++++--------------------- - 1 file changed, 21 insertions(+), 21 deletions(-) - -diff --git a/common/disp.c b/common/disp.c -index ffb3070..2b32021 100644 ---- a/common/disp.c -+++ b/common/disp.c -@@ -614,35 +614,35 @@ cons_handler(void *arg) - if (select(s_cons_ctl.pipe[0] + 1, &s_cons_ctl.fds, - NULL, NULL, NULL) > 0) { - if (FD_ISSET(s_cons_ctl.pipe[0], &s_cons_ctl.fds)) { -- (void) read(s_cons_ctl.pipe[0], &ch, 1); -- -- /* -- * Character is from pipe. -- */ -- if (ch == PIPE_CHAR_QUIT) { -+ if (read(s_cons_ctl.pipe[0], &ch, 1) == 1) { - /* -- * Received a QUIT notification, -- * "console thread" will be quit -+ * Character is from pipe. - */ -- debug_print(NULL, 2, "cons: " -- "received PIPE_CHAR_QUIT\n"); -- break; -- } -+ if (ch == PIPE_CHAR_QUIT) { -+ /* -+ * Received a QUIT notification, -+ * "console thread" will be quit -+ */ -+ debug_print(NULL, 2, "cons: " -+ "received PIPE_CHAR_QUIT\n"); -+ break; -+ } - -- if (ch == PIPE_CHAR_RESIZE) { -- /* -- * Send the "RESIZE" command -- * to "display thread". -- */ -- (void) pthread_mutex_lock( -- &s_disp_ctl.mutex); -+ if (ch == PIPE_CHAR_RESIZE) { -+ /* -+ * Send the "RESIZE" command -+ * to "display thread". -+ */ -+ (void) pthread_mutex_lock( -+ &s_disp_ctl.mutex); - -- CMD_ID_SET(&s_disp_ctl.cmd, -- CMD_RESIZE_ID); -+ CMD_ID_SET(&s_disp_ctl.cmd, -+ CMD_RESIZE_ID); - dispthr_flagset_nolock(DISP_FLAG_CMD); - - (void) pthread_mutex_unlock( - &s_disp_ctl.mutex); -+ } - } - } else { - /* --- -2.5.0 - diff -Nru numatop-1.0.3/debian/patches/0005-Add-BDX-EP-support.patch numatop-1.0.4/debian/patches/0005-Add-BDX-EP-support.patch --- numatop-1.0.3/debian/patches/0005-Add-BDX-EP-support.patch 2015-08-18 04:07:34.000000000 +0000 +++ numatop-1.0.4/debian/patches/0005-Add-BDX-EP-support.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ -From 22f5e20e897b8e9dab305cb80545a855fda84290 Mon Sep 17 00:00:00 2001 -From: Jin Yao -Date: Tue, 4 Aug 2015 10:29:41 +0800 -Subject: [PATCH 5/7] Add BDX-EP support - -Signed-off-by: Jin Yao ---- - common/include/types.h | 5 +++-- - common/os/plat.c | 5 +++++ - common/util.c | 3 +++ - 3 files changed, 11 insertions(+), 2 deletions(-) - mode change 100755 => 100644 common/include/types.h - mode change 100755 => 100644 common/os/plat.c - mode change 100755 => 100644 common/util.c - -diff --git a/common/include/types.h b/common/include/types.h -old mode 100755 -new mode 100644 -index 0eca0cf..08a4821 ---- a/common/include/types.h -+++ b/common/include/types.h -@@ -51,10 +51,11 @@ typedef enum { - CPU_NHM_EP, - CPU_WSM_EP, - CPU_IVB_EX, -- CPU_HSX -+ CPU_HSX, -+ CPU_BDX - } cpu_type_t; - --#define CPU_TYPE_NUM 8 -+#define CPU_TYPE_NUM 9 - - typedef enum { - SORT_KEY_INVALID = -1, -diff --git a/common/os/plat.c b/common/os/plat.c -old mode 100755 -new mode 100644 -index 3a3681d..f5b3dd5 ---- a/common/os/plat.c -+++ b/common/os/plat.c -@@ -51,6 +51,7 @@ s_plat_profiling_config[CPU_TYPE_NUM] = { - nhmep_profiling_config, - wsmep_profiling_config, - snbep_profiling_config, -+ snbep_profiling_config, - snbep_profiling_config - }; - -@@ -63,6 +64,7 @@ s_plat_ll_config[CPU_TYPE_NUM] = { - nhmep_ll_config, - wsmep_ll_config, - snbep_ll_config, -+ snbep_ll_config, - snbep_ll_config - }; - -@@ -75,6 +77,7 @@ s_plat_offcore_num[CPU_TYPE_NUM] = { - nhm_offcore_num, - wsm_offcore_num, - snb_offcore_num, -+ snb_offcore_num, - snb_offcore_num - }; - -@@ -105,6 +108,8 @@ plat_detect(void) - case CPU_IVB_EX: - /* fall through */ - case CPU_HSX: -+ /* fall through */ -+ case CPU_BDX: - return (0); - - default: -diff --git a/common/util.c b/common/util.c -old mode 100755 -new mode 100644 -index 3352a20..dc4c8a1 ---- a/common/util.c -+++ b/common/util.c -@@ -396,6 +396,9 @@ cpu_type_get(void) - case 63: - type = CPU_HSX; - break; -+ case 79: -+ type = CPU_BDX; -+ break; - } - } - --- -2.5.0 - diff -Nru numatop-1.0.3/debian/patches/0006-common-os-map-tidy-up-gcc-warning-make-i-an-unsigned.patch numatop-1.0.4/debian/patches/0006-common-os-map-tidy-up-gcc-warning-make-i-an-unsigned.patch --- numatop-1.0.3/debian/patches/0006-common-os-map-tidy-up-gcc-warning-make-i-an-unsigned.patch 2015-08-18 04:07:34.000000000 +0000 +++ numatop-1.0.4/debian/patches/0006-common-os-map-tidy-up-gcc-warning-make-i-an-unsigned.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -From 24c274d5f6e4cb9c4e11031d6aee18b5134cd81a Mon Sep 17 00:00:00 2001 -From: Colin Ian King -Date: Mon, 17 Aug 2015 13:06:17 -0700 -Subject: [PATCH 6/7] common/os: map: tidy up gcc warning, make i an unsigned - int - -Fixes the following warning with gcc-5, -Wextra: -common/os/map.c:361:17: warning: comparison between signed and - unsigned integer expressions [-Wsign-compare] - -Signed-off-by: Colin Ian King ---- - common/os/map.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/common/os/map.c b/common/os/map.c -index 9543897..f52b661 100644 ---- a/common/os/map.c -+++ b/common/os/map.c -@@ -349,8 +349,8 @@ int - map_map2numa(track_proc_t *proc, map_entry_t *map_entry) - { - void *addr_arr[NUMA_MOVE_NPAGES]; -- unsigned int npages_total, npages_tomove, npages_moved = 0; -- int node_arr[NUMA_MOVE_NPAGES], i; -+ unsigned int i, npages_total, npages_tomove, npages_moved = 0; -+ int node_arr[NUMA_MOVE_NPAGES]; - numa_entry_t *last_entry = NULL; - - numa_map_fini(map_entry); --- -2.5.0 - diff -Nru numatop-1.0.3/debian/patches/0007-common-os-pfwrapper-make-loop-index-a-uint64_t-type.patch numatop-1.0.4/debian/patches/0007-common-os-pfwrapper-make-loop-index-a-uint64_t-type.patch --- numatop-1.0.3/debian/patches/0007-common-os-pfwrapper-make-loop-index-a-uint64_t-type.patch 2015-08-18 04:07:34.000000000 +0000 +++ numatop-1.0.4/debian/patches/0007-common-os-pfwrapper-make-loop-index-a-uint64_t-type.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -From 79cbb73bfaedc549c257ccbe00aa64e33884036f Mon Sep 17 00:00:00 2001 -From: Colin Ian King -Date: Mon, 17 Aug 2015 13:16:06 -0700 -Subject: [PATCH 7/7] common/os: pfwrapper: make loop index a uint64_t type - -gcc-5 with -Wextra is warning about comparing signed and unsigned integers: -common/os/pfwrapper.c:519:16: warning: comparison between signed and - unsigned integer expressions [-Wsign-compare] - -make loop index unsigned and also the same size as nr to avoid any theoretical -loop integer overflows. - -Signed-off-by: Colin Ian King ---- - common/os/pfwrapper.c | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/common/os/pfwrapper.c b/common/os/pfwrapper.c -index aa110e8..cfadbc9 100644 ---- a/common/os/pfwrapper.c -+++ b/common/os/pfwrapper.c -@@ -254,8 +254,8 @@ profiling_sample_read(struct perf_event_mmap_page *mhdr, int size, - { - struct { uint32_t pid, tid; } id; - count_value_t *countval = &rec->countval; -- uint64_t time_enabled, time_running, nr, value, *ips; -- int i, j, ret = -1; -+ uint64_t i, time_enabled, time_running, nr, value, *ips; -+ int j, ret = -1; - - /* - * struct read_format { -@@ -473,8 +473,8 @@ ll_sample_read(struct perf_event_mmap_page *mhdr, int size, - pf_ll_rec_t *rec) - { - struct { uint32_t pid, tid; } id; -- uint64_t addr, cpu, weight, nr, value, *ips; -- int i, j, ret = -1; -+ uint64_t i, addr, cpu, weight, nr, value, *ips; -+ int j, ret = -1; - - /* - * struct read_format { --- -2.5.0 - diff -Nru numatop-1.0.3/debian/patches/0008-hardnen-changes-for-makefile.patch numatop-1.0.4/debian/patches/0008-hardnen-changes-for-makefile.patch --- numatop-1.0.3/debian/patches/0008-hardnen-changes-for-makefile.patch 2015-08-18 04:49:21.000000000 +0000 +++ numatop-1.0.4/debian/patches/0008-hardnen-changes-for-makefile.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -Index: numatop/Makefile -=================================================================== ---- numatop.orig/Makefile -+++ numatop/Makefile -@@ -4,8 +4,8 @@ MANDIR = /usr/share/man/man8 - PROG = numatop - CC = gcc - LD = gcc --CFLAGS = -g -Wall -O2 --LDFLAGS = -g -+CFLAGS += -g -Wall -O2 -+LDFLAGS += -g - LDLIBS = -lncurses -lpthread -lnuma - - COMMON_OBJS = cmd.o disp.o lwp.o numatop.o page.o perf.o \ -@@ -22,13 +22,13 @@ $(PROG): $(COMMON_OBJS) $(OS_OBJS) $(INT - $(LD) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(OS_OBJS) $(INTEL_OBJS) $(LDLIBS) - - %.o: ./common/%.c ./common/include/*.h ./common/include/os/*.h -- $(CC) $(CFLAGS) -o $@ -c $< -+ $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $< - - %.o: ./common/os/%.c ./common/include/*.h ./common/include/os/*.h -- $(CC) $(CFLAGS) -o $@ -c $< -+ $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $< - - %.o: ./intel/%.c ./intel/include/*.h -- $(CC) $(CFLAGS) -o $@ -c $< -+ $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $< - - install: $(PROG) - install -m 0755 $(PROG) $(PREFIXDIR)$(BINDIR)/ diff -Nru numatop-1.0.3/debian/patches/0009-Initialize-naccess_total-to-zero.patch numatop-1.0.4/debian/patches/0009-Initialize-naccess_total-to-zero.patch --- numatop-1.0.3/debian/patches/0009-Initialize-naccess_total-to-zero.patch 2015-09-14 09:03:15.000000000 +0000 +++ numatop-1.0.4/debian/patches/0009-Initialize-naccess_total-to-zero.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -From 10410182b67f276105ba6a557155fa44f76bca54 Mon Sep 17 00:00:00 2001 -From: Colin Ian King -Date: Fri, 28 Aug 2015 08:06:14 +0100 -Subject: [PATCH] Initialize naccess_total to zero - -Static analysis by CoverityScan detected that naccess_total can be -accessed when it is not unitialized, so initialize it to zero. - -CID 136427 (#1 of 1): Uninitialized scalar variable (UNINIT) - uninit_use_in_call: Using uninitialized value naccess_total when - calling accdst_data_save. - -Signed-off-by: Colin Ian King ---- - common/win.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/common/win.c b/common/win.c -index 7454da0..2579078 100644 ---- a/common/win.c -+++ b/common/win.c -@@ -2638,7 +2638,7 @@ accdst_data_show(track_proc_t *proc, dyn_accdst_t *dyn, boolean_t *note_out) - track_lwp_t *lwp = NULL; - void **addr_arr = NULL; - int *lat_arr = NULL; -- int addr_num, i, nnodes, naccess_total; -+ int addr_num, i, nnodes, naccess_total = 0; - map_nodedst_t nodedst_arr[NNODES_MAX]; - accdst_line_t *lines; - char content[WIN_LINECHAR_MAX], intval_buf[16]; --- -2.5.0 - diff -Nru numatop-1.0.3/debian/patches/0010-remove-null-pointer-check-on-nrec-it-is-always-non-N.patch numatop-1.0.4/debian/patches/0010-remove-null-pointer-check-on-nrec-it-is-always-non-N.patch --- numatop-1.0.3/debian/patches/0010-remove-null-pointer-check-on-nrec-it-is-always-non-N.patch 2015-09-14 09:03:47.000000000 +0000 +++ numatop-1.0.4/debian/patches/0010-remove-null-pointer-check-on-nrec-it-is-always-non-N.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -From 673ff8ebb136b6d1afc3c15e5e89e74db11c07af Mon Sep 17 00:00:00 2001 -From: Colin Ian King -Date: Fri, 28 Aug 2015 08:23:23 +0100 -Subject: [PATCH] remove null pointer check on nrec, it is always non-NULL - -Static analysis by CoverityScan showed that nrec checking for a -NULL was suspect; the code calls ll_recbuf_update() passing -nrec which assumes it is non-NULL. The only call to pf_ll_record -passes a non-NULL nrec, so we may as well just remove the NULL -check since it is not required. - -Also fix identation on a return - -Signed-off-by: Colin Ian King ---- - common/os/pfwrapper.c | 6 ++---- - 1 file changed, 2 insertions(+), 4 deletions(-) - -diff --git a/common/os/pfwrapper.c b/common/os/pfwrapper.c -index cfadbc9..3da7369 100644 ---- a/common/os/pfwrapper.c -+++ b/common/os/pfwrapper.c -@@ -588,14 +588,12 @@ pf_ll_record(struct _perf_cpu *cpu, pf_ll_rec_t *rec_arr, int *nrec) - pf_ll_rec_t rec; - int size; - -- if (nrec != NULL) { -- *nrec = 0; -- } -+ *nrec = 0; - - for (;;) { - if (mmap_buffer_read(mhdr, &ehdr, sizeof(ehdr)) == -1) { - /* No valid record in ring buffer. */ -- return; -+ return; - } - - if ((size = ehdr.size - sizeof (ehdr)) <= 0) { --- -2.5.0 - diff -Nru numatop-1.0.3/debian/patches/0011-Add-sanity-checking-to-reg_init-errors.patch numatop-1.0.4/debian/patches/0011-Add-sanity-checking-to-reg_init-errors.patch --- numatop-1.0.3/debian/patches/0011-Add-sanity-checking-to-reg_init-errors.patch 2015-09-14 09:04:15.000000000 +0000 +++ numatop-1.0.4/debian/patches/0011-Add-sanity-checking-to-reg_init-errors.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,423 +0,0 @@ -From d34f06420662099a1e12179b44712172fb668db2 Mon Sep 17 00:00:00 2001 -From: Colin Ian King -Date: Tue, 1 Sep 2015 12:21:00 +0100 -Subject: [PATCH] Add sanity checking to reg_init() errors - -It is possible that reg_init() returns a negative error value that -can cause subsequent calls to reg_init() to fail when passing the -ve -return value into the following call. Add failure detection checks to -reg_init() calls and bail out cleanly. - -Signed-off-by: Colin Ian King ---- - common/os/os_win.c | 21 ++++-- - common/win.c | 184 +++++++++++++++++++++++++++++++++++------------------ - 2 files changed, 137 insertions(+), 68 deletions(-) - -diff --git a/common/os/os_win.c b/common/os/os_win.c -index 1fb1781..31be841 100644 ---- a/common/os/os_win.c -+++ b/common/os/os_win.c -@@ -479,16 +479,25 @@ os_llcallchain_dyn_create(page_t *page) - strncpy(dyn->desc, cmd->desc, WIN_DESCBUF_SIZE); - dyn->desc[WIN_DESCBUF_SIZE - 1] = 0; - -- i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD); -- i = reg_init(&dyn->buf_caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE); -- i = reg_init(&dyn->buf_data, 0, i, g_scr_width, 1, 0); -- i = reg_init(&dyn->chain_caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE); -- i = reg_init(&dyn->pad, 0, i, g_scr_width, 1, 0); -- reg_init(&dyn->chain_data, 0, i, g_scr_width, g_scr_height - i - 2, 0); -+ if ((i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD)) < 0) -+ goto L_EXIT; -+ if ((i = reg_init(&dyn->buf_caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE)) < 0) -+ goto L_EXIT; -+ if ((i = reg_init(&dyn->buf_data, 0, i, g_scr_width, 1, 0)) < 0) -+ goto L_EXIT; -+ if ((i = reg_init(&dyn->chain_caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE)) < 0) -+ goto L_EXIT; -+ if ((i = reg_init(&dyn->pad, 0, i, g_scr_width, 1, 0)) < 0) -+ goto L_EXIT; -+ if ((reg_init(&dyn->chain_data, 0, i, g_scr_width, g_scr_height - i - 2, 0)) < 0) -+ goto L_EXIT; - reg_buf_init(&dyn->chain_data, NULL, win_callchain_line_get); - reg_scroll_init(&dyn->chain_data, B_TRUE); - - return (dyn); -+L_EXIT: -+ free(dyn); -+ return (NULL); - } - - void -diff --git a/common/win.c b/common/win.c -index 2579078..034481d 100644 ---- a/common/win.c -+++ b/common/win.c -@@ -258,19 +258,22 @@ topnproc_dyn_create(int type) - void *buf; - int i; - -- if ((dyn = zalloc(sizeof (dyn_topnproc_t))) == NULL) { -- return (NULL); -- } -- - if ((buf = zalloc(sizeof (topnproc_line_t) * - WIN_NLINES_MAX)) == NULL) { -- free(dyn); - return (NULL); - } -+ if ((dyn = zalloc(sizeof (dyn_topnproc_t))) == NULL) { -+ free(buf); -+ return (NULL); -+ } -+ - -- i = reg_init(&dyn->summary, 0, 1, g_scr_width, 2, A_BOLD); -- i = reg_init(&dyn->caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE); -- i = reg_init(&dyn->data, 0, i, g_scr_width, g_scr_height - i - 5, 0); -+ if ((i = reg_init(&dyn->summary, 0, 1, g_scr_width, 2, A_BOLD)) < 0) -+ goto L_EXIT; -+ if ((i = reg_init(&dyn->caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE)) < 0) -+ goto L_EXIT; -+ if ((i = reg_init(&dyn->data, 0, i, g_scr_width, g_scr_height - i - 5, 0)) < 0) -+ goto L_EXIT; - - if (type == WIN_TYPE_TOPNPROC) { - reg_buf_init(&dyn->data, buf, topnproc_line_get); -@@ -282,6 +285,10 @@ topnproc_dyn_create(int type) - (void) reg_init(&dyn->hint, 0, i, g_scr_width, - g_scr_height - i - 1, A_BOLD); - return (dyn); -+L_EXIT: -+ free(dyn); -+ free(buf); -+ return (NULL); - } - - /* -@@ -655,21 +662,23 @@ moniproc_dyn_create(pid_t pid) - int i, nnodes; - - nnodes = node_num(); -- if ((dyn = zalloc(sizeof (dyn_moniproc_t))) == NULL) { -+ if ((buf_cur = zalloc(sizeof (moni_line_t) * nnodes)) == NULL) { - return (NULL); - } -- -- if ((buf_cur = zalloc(sizeof (moni_line_t) * nnodes)) == NULL) { -- free(dyn); -+ if ((dyn = zalloc(sizeof (dyn_moniproc_t))) == NULL) { -+ free(buf_cur); - return (NULL); - } - - dyn->pid = pid; - -- i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD); -- i = reg_init(&dyn->caption_cur, 0, i, g_scr_width, 2, -- A_BOLD | A_UNDERLINE); -- i = reg_init(&dyn->data_cur, 0, i, g_scr_width, nnodes, 0); -+ if ((i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD)) < 0) -+ goto L_EXIT; -+ if ((i = reg_init(&dyn->caption_cur, 0, i, g_scr_width, 2, -+ A_BOLD | A_UNDERLINE)) < 0) -+ goto L_EXIT; -+ if ((i = reg_init(&dyn->data_cur, 0, i, g_scr_width, nnodes, 0)) < 0) -+ goto L_EXIT; - - reg_buf_init(&dyn->data_cur, buf_cur, moni_line_get); - reg_scroll_init(&dyn->data_cur, B_TRUE); -@@ -677,6 +686,10 @@ moniproc_dyn_create(pid_t pid) - (void) reg_init(&dyn->hint, 0, i, g_scr_width, - g_scr_height - i - 1, A_BOLD); - return (dyn); -+L_EXIT: -+ free(dyn); -+ free(buf_cur); -+ return (NULL); - } - - /* -@@ -691,22 +704,24 @@ monilwp_dyn_create(pid_t pid, id_t lwpid) - int i, nnodes; - - nnodes = node_num(); -- if ((dyn = zalloc(sizeof (dyn_monilwp_t))) == NULL) { -+ if ((buf_cur = zalloc(sizeof (moni_line_t) * nnodes)) == NULL) { - return (NULL); - } -- -- if ((buf_cur = zalloc(sizeof (moni_line_t) * nnodes)) == NULL) { -- free(dyn); -+ if ((dyn = zalloc(sizeof (dyn_monilwp_t))) == NULL) { -+ free(buf_cur); - return (NULL); - } - - dyn->pid = pid; - dyn->lwpid = lwpid; - -- i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD); -- i = reg_init(&dyn->caption_cur, 0, i, g_scr_width, 2, -- A_BOLD | A_UNDERLINE); -- i = reg_init(&dyn->data_cur, 0, i, g_scr_width, nnodes, 0); -+ if ((i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD)) < 0) -+ goto L_EXIT; -+ if ((i = reg_init(&dyn->caption_cur, 0, i, g_scr_width, 2, -+ A_BOLD | A_UNDERLINE)) < 0) -+ goto L_EXIT; -+ if ((i = reg_init(&dyn->data_cur, 0, i, g_scr_width, nnodes, 0)) < 0) -+ goto L_EXIT; - - reg_buf_init(&dyn->data_cur, buf_cur, moni_line_get); - reg_scroll_init(&dyn->data_cur, B_TRUE); -@@ -714,6 +729,10 @@ monilwp_dyn_create(pid_t pid, id_t lwpid) - (void) reg_init(&dyn->hint, 0, i, g_scr_width, - g_scr_height - i - 1, A_BOLD); - return (dyn); -+L_EXIT: -+ free(dyn); -+ free(buf_cur); -+ return (NULL); - } - - /* -@@ -1185,20 +1204,22 @@ topnlwp_dyn_create(page_t *page) - cmd_lwp_t *cmd_lwp = (cmd_lwp_t *)(&page->cmd); - pid_t pid = cmd_lwp->pid; - -- if ((dyn = zalloc(sizeof (dyn_topnlwp_t))) == NULL) { -+ if ((buf = zalloc(sizeof (topnlwp_line_t) * WIN_NLINES_MAX)) == NULL) { - return (NULL); - } -- -- if ((buf = zalloc(sizeof (topnlwp_line_t) * WIN_NLINES_MAX)) == NULL) { -- free(dyn); -+ if ((dyn = zalloc(sizeof (dyn_topnlwp_t))) == NULL) { -+ free(buf); - return (NULL); - } - - dyn->pid = pid; - -- i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD); -- i = reg_init(&dyn->caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE); -- i = reg_init(&dyn->data, 0, i, g_scr_width, g_scr_height - i - 4, 0); -+ if ((i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD)) < 0) -+ goto L_EXIT; -+ if ((i = reg_init(&dyn->caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE)) < 0) -+ goto L_EXIT; -+ if ((i = reg_init(&dyn->data, 0, i, g_scr_width, g_scr_height - i - 4, 0)) < 0) -+ goto L_EXIT; - - reg_buf_init(&dyn->data, buf, topnlwp_line_get); - reg_scroll_init(&dyn->data, B_TRUE); -@@ -1206,6 +1227,10 @@ topnlwp_dyn_create(page_t *page) - (void) reg_init(&dyn->hint, 0, i, g_scr_width, - g_scr_height - i - 1, A_BOLD); - return (dyn); -+L_EXIT: -+ free(dyn); -+ free(buf); -+ return (NULL); - } - - /* -@@ -1441,19 +1466,21 @@ nodeoverview_dyn_create(void) - int i, nnodes; - - nnodes = node_num(); -- if ((dyn = zalloc(sizeof (dyn_nodeoverview_t))) == NULL) { -+ if ((buf_cur = zalloc(sizeof (nodeoverview_line_t) * nnodes)) == NULL) { - return (NULL); - } -- -- if ((buf_cur = zalloc(sizeof (nodeoverview_line_t) * nnodes)) == NULL) { -- free(dyn); -+ if ((dyn = zalloc(sizeof (dyn_nodeoverview_t))) == NULL) { -+ free(buf_cur); - return (NULL); - } - -- i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD); -- i = reg_init(&dyn->caption_cur, 0, i, g_scr_width, 2, -- A_BOLD | A_UNDERLINE); -- i = reg_init(&dyn->data_cur, 0, i, g_scr_width, nnodes, 0); -+ if ((i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD)) < 0) -+ goto L_EXIT; -+ if ((i = reg_init(&dyn->caption_cur, 0, i, g_scr_width, 2, -+ A_BOLD | A_UNDERLINE)) < 0) -+ goto L_EXIT; -+ if ((i = reg_init(&dyn->data_cur, 0, i, g_scr_width, nnodes, 0)) < 0) -+ goto L_EXIT; - - reg_buf_init(&dyn->data_cur, buf_cur, nodeoverview_line_get); - reg_scroll_init(&dyn->data_cur, B_TRUE); -@@ -1461,6 +1488,10 @@ nodeoverview_dyn_create(void) - (void) reg_init(&dyn->hint, 0, i, g_scr_width, - g_scr_height - i - 1, A_BOLD); - return (dyn); -+L_EXIT: -+ free(dyn); -+ free(buf_cur); -+ return (NULL); - } - - /* -@@ -1683,16 +1714,20 @@ nodedetail_dyn_create(page_t *page) - dyn->nid = CMD_NODE_DETAIL(&page->cmd)->nid; - node = node_get(dyn->nid); - if (!NODE_VALID(node)) { -- free(dyn); - win_warn_msg(WARN_INVALID_NID); -- return (NULL); -+ goto L_EXIT; - } - -- i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD | A_UNDERLINE); -- i = reg_init(&dyn->node_data, 0, i, g_scr_width, -- g_scr_height - i - 4, 0); -+ if ((i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD | A_UNDERLINE)) < 0) -+ goto L_EXIT; -+ if ((i = reg_init(&dyn->node_data, 0, i, g_scr_width, -+ g_scr_height - i - 4, 0)) < 0) -+ goto L_EXIT; - (void) reg_init(&dyn->hint, 0, i, g_scr_width, 3, A_BOLD); - return (dyn); -+L_EXIT: -+ free(dyn); -+ return NULL; - } - - static boolean_t -@@ -1810,15 +1845,22 @@ callchain_dyn_create(page_t *page) - dyn->lwpid = cmd_callchain->lwpid; - dyn->countid = COUNT_RMA; - -- i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD); -- i = reg_init(&dyn->caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE); -- i = reg_init(&dyn->pad, 0, i, g_scr_width, 1, 0); -- i = reg_init(&dyn->data, 0, i, g_scr_width, g_scr_height - i - 4, 0); -+ if ((i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD)) < 0) -+ goto L_EXIT; -+ if ((i = reg_init(&dyn->caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE)) < 0) -+ goto L_EXIT; -+ if ((i = reg_init(&dyn->pad, 0, i, g_scr_width, 1, 0)) < 0) -+ goto L_EXIT; -+ if ((i = reg_init(&dyn->data, 0, i, g_scr_width, g_scr_height - i - 4, 0)) < 0) -+ goto L_EXIT; - reg_buf_init(&dyn->data, NULL, win_callchain_line_get); - reg_scroll_init(&dyn->data, B_TRUE); - (void) reg_init(&dyn->hint, 0, i, g_scr_width, - g_scr_height - i - 1, A_BOLD); - return (dyn); -+L_EXIT: -+ free(dyn); -+ return (NULL); - } - - /* -@@ -2061,8 +2103,10 @@ lat_dyn_create(page_t *page, win_type_t *type) - return (NULL); - } - -- i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD); -- i = reg_init(&dyn->caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE); -+ if ((i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD)) < 0) -+ goto L_EXIT; -+ if ((i = reg_init(&dyn->caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE)) < 0) -+ goto L_EXIT; - (void) reg_init(&dyn->data, 0, i, g_scr_width, g_scr_height - i - 2, 0); - - reg_buf_init(&dyn->data, NULL, lat_line_get); -@@ -2076,6 +2120,9 @@ lat_dyn_create(page_t *page, win_type_t *type) - } - - return (dyn); -+L_EXIT: -+ free(dyn); -+ return (NULL); - } - - /* -@@ -2410,9 +2457,12 @@ latnode_dyn_create(page_t *page, win_type_t *type) - return (NULL); - } - -- i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD); -- i = reg_init(&dyn->note, 0, i, g_scr_width, 2, A_BOLD); -- i = reg_init(&dyn->caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE); -+ if ((i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD)) < 0) -+ goto L_EXIT; -+ if ((i = reg_init(&dyn->note, 0, i, g_scr_width, 2, A_BOLD)) < 0) -+ goto L_EXIT; -+ if ((i = reg_init(&dyn->caption, 0, i, g_scr_width, 2, A_BOLD | A_UNDERLINE)) < 0) -+ goto L_EXIT; - (void) reg_init(&dyn->data, 0, i, g_scr_width, g_scr_height - i - 2, 0); - - reg_buf_init(&dyn->data, NULL, lat_line_get); -@@ -2428,6 +2478,9 @@ latnode_dyn_create(page_t *page, win_type_t *type) - dyn->addr = cmd->addr; - dyn->size = cmd->size; - return (dyn); -+L_EXIT: -+ free(dyn); -+ return (NULL); - } - - /* -@@ -2504,19 +2557,21 @@ accdst_dyn_create(page_t *page, win_type_t *type) - cmd_accdst_t *cmd_accdst = CMD_ACCDST(&page->cmd); - - nnodes = node_num(); -- if ((dyn = zalloc(sizeof (dyn_accdst_t))) == NULL) { -+ if ((buf = zalloc(sizeof (accdst_line_t) * nnodes)) == NULL) { - return (NULL); - } -- -- if ((buf = zalloc(sizeof (accdst_line_t) * nnodes)) == NULL) { -- free(dyn); -+ if ((dyn = zalloc(sizeof (dyn_accdst_t))) == NULL) { -+ free(buf); - return (NULL); - } - -- i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD); -- i = reg_init(&dyn->caption, 0, i, g_scr_width, 2, -- A_BOLD | A_UNDERLINE); -- i = reg_init(&dyn->data, 0, i, g_scr_width, nnodes, 0); -+ if ((i = reg_init(&dyn->msg, 0, 1, g_scr_width, 2, A_BOLD)) < 0) -+ goto L_EXIT; -+ if ((i = reg_init(&dyn->caption, 0, i, g_scr_width, 2, -+ A_BOLD | A_UNDERLINE)) < 0) -+ goto L_EXIT; -+ if ((i = reg_init(&dyn->data, 0, i, g_scr_width, nnodes, 0)) < 0) -+ goto L_EXIT; - reg_buf_init(&dyn->data, buf, accdst_line_get); - reg_scroll_init(&dyn->data, B_TRUE); - (void) reg_init(&dyn->hint, 0, i, g_scr_width, -@@ -2530,6 +2585,10 @@ accdst_dyn_create(page_t *page, win_type_t *type) - } - - return (dyn); -+L_EXIT: -+ free(dyn); -+ free(buf); -+ return (NULL); - } - - /* -@@ -2776,7 +2835,8 @@ win_warn_msg(warn_type_t warn_type) - char content[WIN_LINECHAR_MAX]; - int i; - -- i = reg_init(&dyn.msg, 0, 1, g_scr_width, 4, A_BOLD); -+ if ((i = reg_init(&dyn.msg, 0, 1, g_scr_width, 4, A_BOLD)) < 0) -+ return; - (void) reg_init(&dyn.pad, 0, i, g_scr_width, - g_scr_height - i - 2, 0); - --- -2.5.0 - diff -Nru numatop-1.0.3/debian/patches/0012-Fix-sign-comparison-issue-comparing-g_run_secs-and-d.patch numatop-1.0.4/debian/patches/0012-Fix-sign-comparison-issue-comparing-g_run_secs-and-d.patch --- numatop-1.0.3/debian/patches/0012-Fix-sign-comparison-issue-comparing-g_run_secs-and-d.patch 2015-09-14 09:04:36.000000000 +0000 +++ numatop-1.0.4/debian/patches/0012-Fix-sign-comparison-issue-comparing-g_run_secs-and-d.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -From d966f216485e3b22eb054771b5807cc7281f1e0b Mon Sep 17 00:00:00 2001 -From: Colin Ian King -Date: Tue, 1 Sep 2015 13:39:29 +0100 -Subject: [PATCH] Fix sign comparison issue comparing g_run_secs and diff_ms - -Fix a a signed vs unsigned comparison warning . unsigned diff_ms -should be signed (because it is the difference between two unsigned -values, and there is the theoretical potential it could be -ve if -gettimeofday failed at some point). - -common/disp.c:477:18: warning: comparison of integers of different -signs: 'int' and 'unsigned long' [-Wsign-compare] - if (g_run_secs <= diff_ms / MS_SEC) { - -Signed-off-by: Colin Ian King ---- - common/disp.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/common/disp.c b/common/disp.c -index 2b32021..12d9aaa 100644 ---- a/common/disp.c -+++ b/common/disp.c -@@ -427,7 +427,8 @@ disp_handler(void *arg) - cmd_t cmd; - boolean_t quit, pagelist_inited = B_FALSE; - struct timespec timeout; -- uint64_t start_ms, diff_ms; -+ uint64_t start_ms; -+ int64_t diff_ms; - - /* - * Wait cons thread to complete initialization. --- -2.5.0 - diff -Nru numatop-1.0.3/debian/patches/series numatop-1.0.4/debian/patches/series --- numatop-1.0.3/debian/patches/series 2015-09-14 09:04:40.000000000 +0000 +++ numatop-1.0.4/debian/patches/series 2015-12-20 13:30:13.000000000 +0000 @@ -1,12 +1 @@ -0001-calibrate_cpuinfo-ensure-we-do-not-overflow-buffer-u.patch -0002-mgen-calibrate_cpuinfo-ensure-we-do-not-overflow-buf.patch -0003-tty-colors-are-broken-without-using-use_default_colo.patch -0004-Only-process-pipe-read-if-read-was-successful.patch -0005-Add-BDX-EP-support.patch -0006-common-os-map-tidy-up-gcc-warning-make-i-an-unsigned.patch -0007-common-os-pfwrapper-make-loop-index-a-uint64_t-type.patch -0008-hardnen-changes-for-makefile.patch -0009-Initialize-naccess_total-to-zero.patch -0010-remove-null-pointer-check-on-nrec-it-is-always-non-N.patch -0011-Add-sanity-checking-to-reg_init-errors.patch -0012-Fix-sign-comparison-issue-comparing-g_run_secs-and-d.patch +0001--hardnen-changes-for-makefile.patch diff -Nru numatop-1.0.3/intel/bdw.c numatop-1.0.4/intel/bdw.c --- numatop-1.0.3/intel/bdw.c 1970-01-01 00:00:00.000000000 +0000 +++ numatop-1.0.4/intel/bdw.c 2015-12-14 01:23:40.000000000 +0000 @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2013, Intel Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* This file contains the bdw platform specific functions. */ + +#include +#include +#include +#include +#include +#include +#include +#include "../common/include/types.h" +#include "../common/include/os/linux/perf_event.h" +#include "../common/include/os/plat.h" +#include "../common/include/os/os_perf.h" +#include "include/bdw.h" + +static plat_event_config_t s_bdw_config[COUNT_NUM] = { + { PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES, 0x53, 0, "cpu_clk_unhalted.core" }, + { PERF_TYPE_RAW, 0x01B7, 0x53, 0x638000001, "off_core_response_0" }, + { PERF_TYPE_HARDWARE, PERF_COUNT_HW_REF_CPU_CYCLES, 0x53, 0, "cpu_clk_unhalted.ref" }, + { PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS, 0x53, 0, "instr_retired.any" }, + { PERF_TYPE_RAW, 0x01BB, 0x53, 0x604000001, "off_core_response_1" } +}; + +static plat_event_config_t s_bdw_ll = { + PERF_TYPE_RAW, 0x01CD, 0x53, LL_THRESH, "mem_trans_retired.latency_above_threshold" +}; + +void +bdw_profiling_config(count_id_t count_id, plat_event_config_t *cfg) +{ + plat_config_get(count_id, cfg, s_bdw_config); +} + +void +bdw_ll_config(plat_event_config_t *cfg) +{ + memcpy(cfg, &s_bdw_ll, sizeof (plat_event_config_t)); +} + +int +bdw_offcore_num(void) +{ + return (2); +} diff -Nru numatop-1.0.3/intel/include/bdw.h numatop-1.0.4/intel/include/bdw.h --- numatop-1.0.3/intel/include/bdw.h 1970-01-01 00:00:00.000000000 +0000 +++ numatop-1.0.4/intel/include/bdw.h 2015-12-14 01:23:53.000000000 +0000 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2013, Intel Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _NUMATOP_BDW_H +#define _NUMATOP_BDW_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "../../common/include/types.h" + +struct _plat_event_config; + +extern void bdw_profiling_config(count_id_t, struct _plat_event_config *); +extern void bdw_ll_config(struct _plat_event_config *); +extern int bdw_offcore_num(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _NUMATOP_BDW_H */ diff -Nru numatop-1.0.3/Makefile numatop-1.0.4/Makefile --- numatop-1.0.3/Makefile 2014-07-01 00:40:53.000000000 +0000 +++ numatop-1.0.4/Makefile 2015-12-14 01:26:33.000000000 +0000 @@ -1,39 +1,39 @@ -PREFIXDIR = /usr/local -BINDIR = /bin -MANDIR = /usr/share/man/man8 -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 \ - proc.o reg.o util.o win.o - -OS_OBJS = os_cmd.o os_perf.o os_win.o node.o map.o \ - os_util.o plat.o pfwrapper.o sym.o os_page.o - -INTEL_OBJS = wsm.o snb.o nhm.o - -all: $(PROG) - -$(PROG): $(COMMON_OBJS) $(OS_OBJS) $(INTEL_OBJS) - $(LD) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(OS_OBJS) $(INTEL_OBJS) $(LDLIBS) - -%.o: ./common/%.c ./common/include/*.h ./common/include/os/*.h - $(CC) $(CFLAGS) -o $@ -c $< - -%.o: ./common/os/%.c ./common/include/*.h ./common/include/os/*.h - $(CC) $(CFLAGS) -o $@ -c $< - -%.o: ./intel/%.c ./intel/include/*.h - $(CC) $(CFLAGS) -o $@ -c $< - -install: $(PROG) - install -m 0755 $(PROG) $(PREFIXDIR)$(BINDIR)/ - gzip -c numatop.8 > numatop.8.gz - mv -f numatop.8.gz $(MANDIR)/ - -clean: - rm -rf *.o $(PROG) +PREFIXDIR = /usr/local +BINDIR = /bin +MANDIR = /usr/share/man/man8 +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 \ + proc.o reg.o util.o win.o + +OS_OBJS = os_cmd.o os_perf.o os_win.o node.o map.o \ + os_util.o plat.o pfwrapper.o sym.o os_page.o + +INTEL_OBJS = wsm.o snb.o nhm.o bdw.o + +all: $(PROG) + +$(PROG): $(COMMON_OBJS) $(OS_OBJS) $(INTEL_OBJS) + $(LD) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(OS_OBJS) $(INTEL_OBJS) $(LDLIBS) + +%.o: ./common/%.c ./common/include/*.h ./common/include/os/*.h + $(CC) $(CFLAGS) -o $@ -c $< + +%.o: ./common/os/%.c ./common/include/*.h ./common/include/os/*.h + $(CC) $(CFLAGS) -o $@ -c $< + +%.o: ./intel/%.c ./intel/include/*.h + $(CC) $(CFLAGS) -o $@ -c $< + +install: $(PROG) + install -m 0755 $(PROG) $(PREFIXDIR)$(BINDIR)/ + gzip -c numatop.8 > numatop.8.gz + mv -f numatop.8.gz $(MANDIR)/ + +clean: + rm -rf *.o $(PROG) diff -Nru numatop-1.0.3/test/mgen/mgen.c numatop-1.0.4/test/mgen/mgen.c --- numatop-1.0.3/test/mgen/mgen.c 2014-07-01 00:40:53.000000000 +0000 +++ numatop-1.0.4/test/mgen/mgen.c 2015-12-14 00:38:02.000000000 +0000 @@ -203,7 +203,7 @@ calibrate_cpuinfo(double *nsofclk, double *clkofns, uint64_t *clkofsec) { FILE *f; - char *line = NULL, unit[10]; + char *line = NULL, unit[11]; size_t len = 0; double freq = 0.0;