/** * Listens over TCP for a set amount of time, if no message is found * the modules are checked for errors * * @param[in] void * * @return success */ bool barsmRun(child_pid_list *node_to_use) { bool handleError; bool success = true; handleError = rcv_errMsgs(); /* check if any of the processes have gone zombie or killed */ /* list back to first node */ if (!handleError) { printf("EXECUTING: BARSM health monitoring system\n"); success = check_modules(clientSocket_TCP, node_to_use); if (true == success) { printf("SUCCESS: Health monitoring sequence complete\n"); } else { printf("ERROR: While checking the health of the apps/modules\n"); } } return success; }
apr_status_t h2_conn_child_init(apr_pool_t *pool, server_rec *s) { apr_status_t status = APR_SUCCESS; int minw, maxw; int max_threads_per_child = 0; int idle_secs = 0; check_modules(1); ap_mpm_query(AP_MPMQ_MAX_THREADS, &max_threads_per_child); status = ap_mpm_query(AP_MPMQ_IS_ASYNC, &async_mpm); if (status != APR_SUCCESS) { /* some MPMs do not implemnent this */ async_mpm = 0; status = APR_SUCCESS; } h2_config_init(pool); h2_get_num_workers(s, &minw, &maxw); idle_secs = h2_config_sgeti(s, H2_CONF_MAX_WORKER_IDLE_SECS); ap_log_error(APLOG_MARK, APLOG_TRACE3, 0, s, "h2_workers: min=%d max=%d, mthrpchild=%d, idle_secs=%d", minw, maxw, max_threads_per_child, idle_secs); workers = h2_workers_create(s, pool, minw, maxw, idle_secs); ap_register_input_filter("H2_IN", h2_filter_core_input, NULL, AP_FTYPE_CONNECTION); status = h2_mplx_child_init(pool, s); if (status == APR_SUCCESS) { status = apr_socket_create(&dummy_socket, APR_INET, SOCK_STREAM, APR_PROTO_TCP, pool); } return status; }
static module *h2_conn_mpm_module(void) { check_modules(0); return mpm_module; }
int h2_mpm_supported(void) { check_modules(0); return mpm_supported; }
const char *h2_conn_mpm_name(void) { check_modules(0); return mpm_module? mpm_module->name : "unknown"; }
h2_mpm_type_t h2_conn_mpm_type(void) { check_modules(0); return mpm_type; }
apr_status_t h2_conn_child_init(apr_pool_t *pool, server_rec *s) { const h2_config *config = h2_config_sget(s); apr_status_t status = APR_SUCCESS; int minw, maxw, max_tx_handles, n; int max_threads_per_child = 0; int idle_secs = 0; check_modules(1); ap_mpm_query(AP_MPMQ_MAX_THREADS, &max_threads_per_child); status = ap_mpm_query(AP_MPMQ_IS_ASYNC, &async_mpm); if (status != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_TRACE1, status, s, "querying MPM for async"); /* some MPMs do not implemnent this */ async_mpm = 0; status = APR_SUCCESS; } h2_config_init(pool); minw = h2_config_geti(config, H2_CONF_MIN_WORKERS); maxw = h2_config_geti(config, H2_CONF_MAX_WORKERS); if (minw <= 0) { minw = max_threads_per_child; } if (maxw <= 0) { maxw = minw; } /* How many file handles is it safe to use for transfer * to the master connection to be streamed out? * Is there a portable APR rlimit on NOFILES? Have not * found it. And if, how many of those would we set aside? * This leads all into a process wide handle allocation strategy * which ultimately would limit the number of accepted connections * with the assumption of implicitly reserving n handles for every * connection and requiring modules with excessive needs to allocate * from a central pool. */ n = h2_config_geti(config, H2_CONF_SESSION_FILES); if (n < 0) { max_tx_handles = maxw * 2; } else { max_tx_handles = maxw * n; } ap_log_error(APLOG_MARK, APLOG_TRACE3, 0, s, "h2_workers: min=%d max=%d, mthrpchild=%d, tx_files=%d", minw, maxw, max_threads_per_child, max_tx_handles); workers = h2_workers_create(s, pool, minw, maxw, max_tx_handles); idle_secs = h2_config_geti(config, H2_CONF_MAX_WORKER_IDLE_SECS); h2_workers_set_max_idle_secs(workers, idle_secs); ap_register_input_filter("H2_IN", h2_filter_core_input, NULL, AP_FTYPE_CONNECTION); status = h2_mplx_child_init(pool, s); return status; }
int main(int argc, char *argv[]) { int op; int rc; char buf[BUFSIZ]; uint32_t count = 0; uint32_t i, threads = 0; uint32_t ring_size, queue_depth = 0; uint32_t transfer_size, order = 0; uint64_t total_size, copied = 0; uint64_t elapsed_time = 0; uint64_t total_time = 0; uint64_t perf, total_copied = 0; char channel[1024]; if (check_modules("ioatdma")) { fprintf(stderr, "Ioat driver not loaded," " run `modprobe -v ioatdma` first\n"); return -1; } if (check_modules("dmaperf")) { fprintf(stderr, "Kernel Ioat test driver not loaded," " run `insmod dmaperf.ko` in the kmod directory\n"); return -1; } count = get_dma_channel_count(); if (!count) { fprintf(stderr, "No DMA channel found\n"); return -1; } ring_size = 1UL << 16; while ((op = getopt(argc, argv, "hn:q:s:t:")) != -1) { switch (op) { case 'n': threads = atoi(optarg); if (threads > count) { fprintf(stderr, "Error: Total channel count %u\n", count); return -1; } rc = put_u32_to_file("/sys/kernel/debug/dmaperf/dmaperf/threads", threads); if (rc < 0) { fprintf(stderr, "Cannot set dma channels\n"); return -1; } break; case 'q': queue_depth = atoi(optarg); if (queue_depth > ring_size) { fprintf(stderr, "Max Ioat DMA ring size %d\n", ring_size); return -1; } rc = put_u32_to_file("/sys/kernel/debug/dmaperf/dmaperf/queue_depth", queue_depth); if (rc < 0) { fprintf(stderr, "Cannot set queue depth\n"); return -1; } break; case 's': order = atoi(optarg); rc = put_u32_to_file("/sys/kernel/debug/dmaperf/dmaperf/transfer_size_order", order); if (rc < 0) { fprintf(stderr, "Cannot set descriptor transfer size order\n"); return -1; } break; case 't': order = atoi(optarg); rc = put_u32_to_file("/sys/kernel/debug/dmaperf/dmaperf/total_size_order", order); if (rc < 0) { fprintf(stderr, "Cannot set channel total transfer size order\n"); return -1; } break; case 'h' : usage(argv[0]); exit(0); default: usage(argv[0]); exit(1); } } /* get driver configuration */ rc = get_u32_from_file("/sys/kernel/debug/dmaperf/dmaperf/transfer_size_order", &order); if (rc < 0) { fprintf(stderr, "Cannot get channel descriptor transfer size\n"); return -1; } transfer_size = 1UL << order; rc = get_u32_from_file("/sys/kernel/debug/dmaperf/dmaperf/total_size_order", &order); if (rc < 0) { fprintf(stderr, "Cannot get channel total transfer size\n"); return -1; } total_size = 1ULL << order; rc = get_u32_from_file("/sys/kernel/debug/dmaperf/dmaperf/threads", &threads); if (rc < 0) { fprintf(stderr, "Cannot get dma channel threads\n"); return -1; } rc = get_u32_from_file("/sys/kernel/debug/dmaperf/dmaperf/queue_depth", &queue_depth); if (rc < 0) { fprintf(stderr, "Cannot get queue depth\n"); return -1; } fprintf(stdout, "Total %d Channels, Queue_Depth %d, Transfer Size %d Bytes, Total Transfer Size %"PRIu64" GB\n", threads, queue_depth, transfer_size, total_size >> 30ULL); /* run the channels */ rc = put_u32_to_file("/sys/kernel/debug/dmaperf/dmaperf/run", 1); if (rc < 0) { fprintf(stderr, "Cannot run the channels\n"); return -1; } fprintf(stdout, "Running I/O "); fflush(stdout); memset(buf, 0, BUFSIZ); /* wait all the channels to be idle */ do { fprintf(stdout, ". "); fflush(stdout); sleep(1); if (strstr(buf, "idle") != NULL) { fprintf(stdout, "\n"); fflush(stdout); sleep(1); break; } } while (!get_str_from_file("/sys/kernel/debug/dmaperf/dmaperf/status", buf, BUFSIZ)); /* collect each channel performance data */ for (i = 0; i < threads; i++) { /* total data transfer length for the DMA channel in Bytes */ sprintf(channel, "/sys/kernel/debug/dmaperf/dmaperf/thread_%u/copied", i); rc = get_u64_from_file(channel, &copied); if (rc < 0) { fprintf(stderr, "Cannot get channel copied data\n"); return -1; } /* time in microseconds for total data transfer length */ sprintf(channel, "/sys/kernel/debug/dmaperf/dmaperf/thread_%u/elapsed_time", i); /* elapsed_time is in microsecond */ rc = get_u64_from_file(channel, &elapsed_time); if (rc < 0) { fprintf(stderr, "Cannot get channel elapsed time\n"); return -1; } assert(elapsed_time != 0); perf = (copied * 1000 * 1000) / (elapsed_time * 1024 * 1024); total_copied += copied; total_time = ioat_max(elapsed_time, total_time); fprintf(stdout, "Channel %d Bandwidth %"PRIu64" MiB/s\n", i, perf); } if (total_time && threads) { fprintf(stdout, "Total Channel Bandwidth: %"PRIu64" MiB/s\n", total_copied / total_time); fprintf(stdout, "Average Bandwidth Per Channel: %"PRIu64" MiB/s\n", (total_copied * 1000 * 1000) / (total_time * threads * 1024 * 1024)); } return 0; }