From owner-p4-projects@FreeBSD.ORG Fri Dec 14 00:20:08 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8FC526A; Fri, 14 Dec 2012 00:20:08 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 47EF21000 for ; Fri, 14 Dec 2012 00:20:08 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id 2BC388FC14 for ; Fri, 14 Dec 2012 00:20:08 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.5/8.14.5) with ESMTP id qBE0K87r069237 for ; Fri, 14 Dec 2012 00:20:08 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.5/8.14.5/Submit) id qBE0K7dH069234 for perforce@freebsd.org; Fri, 14 Dec 2012 00:20:07 GMT (envelope-from brooks@freebsd.org) Date: Fri, 14 Dec 2012 00:20:07 GMT Message-Id: <201212140020.qBE0K7dH069234@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis Subject: PERFORCE change 219906 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Dec 2012 00:20:08 -0000 http://p4web.freebsd.org/@@219906?ac=10 Change 219906 by brooks@brooks_zenith on 2012/12/14 00:19:39 Snapshot the cycle counter at four points in the png decoding process: - As the sandbox specific function is entered. - As the core decoding function is entered and exited. - As late as possible without waiting for a call to read_png_finish() which may take an indefinite amout of time. Add a pair of accessor functions to retrieve the total runtime and the decoding time. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/ctsrd-lib/libimagebox/decode_png.c#6 edit .. //depot/projects/ctsrd/cheribsd/src/ctsrd-lib/libimagebox/imagebox.h#5 edit .. //depot/projects/ctsrd/cheribsd/src/ctsrd-lib/libimagebox/pngbox.c#10 edit .. //depot/projects/ctsrd/cheribsd/src/ctsrd/libexec/readpng-cheri/Makefile#3 edit .. //depot/projects/ctsrd/cheribsd/src/ctsrd/libexec/readpng-cheri/readpng-cheri.c#7 edit .. //depot/projects/ctsrd/cheribsd/src/ctsrd/libexec/readpng-cheri/sysarch.S#1 add .. //depot/projects/ctsrd/cheribsd/src/ctsrd/libexec/readpng/readpng.c#5 edit Differences ... ==== //depot/projects/ctsrd/cheribsd/src/ctsrd-lib/libimagebox/decode_png.c#6 (text+ko) ==== @@ -30,6 +30,8 @@ #include +#include + #include #include #include @@ -53,6 +55,8 @@ png_infop end_info = NULL; png_bytep *rows = NULL; + ids->is->times[1] = sysarch(MIPS_GET_COUNT, 0); + if ((png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL)) == NULL) { ids->is->error = 1; @@ -125,6 +129,7 @@ error: png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); close(ids->fd); + ids->is->times[2] = sysarch(MIPS_GET_COUNT, 0); free(rows); } ==== //depot/projects/ctsrd/cheribsd/src/ctsrd-lib/libimagebox/imagebox.h#5 (text+ko) ==== @@ -45,6 +45,7 @@ volatile uint32_t passes_remaining; volatile uint32_t error; volatile uint32_t *buffer; + volatile uint32_t times[4]; void *private; }; @@ -53,6 +54,9 @@ void iboxstate_free(struct iboxstate *ps); +uint32_t iboxstate_get_dtime(struct iboxstate *is); +uint32_t iboxstate_get_ttime(struct iboxstate *is); + struct iboxstate* png_read_start(int pfd, uint32_t maxw, uint32_t maxh, enum sbtype); int png_read_finish(struct iboxstate *ps); ==== //depot/projects/ctsrd/cheribsd/src/ctsrd-lib/libimagebox/pngbox.c#10 (text+ko) ==== @@ -37,6 +37,7 @@ #include #include +#include #include #include @@ -70,6 +71,8 @@ decode_png(ids, NULL, NULL); + ids->is->times[3] = sysarch(MIPS_GET_COUNT, NULL); + free(ids); pthread_exit(NULL); @@ -89,6 +92,7 @@ is->width = width; is->height = height; is->passes_remaining = UINT32_MAX; + is->times[0] = sysarch(MIPS_GET_COUNT, NULL); if ((pdp = malloc(sizeof(*pdp))) == NULL) goto error; @@ -145,6 +149,7 @@ is->width = width; is->height = height; is->passes_remaining = UINT32_MAX; + is->times[0] = sysarch(MIPS_GET_COUNT, NULL); if ((bfd = shm_open(SHM_ANON, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR)) == -1) @@ -219,7 +224,7 @@ /* * XXX: rwatson reports that capabilities end up misaligned on the stack. */ -static struct chericap c1, c2; +static struct chericap c1, c2, c3; static struct iboxstate* cheri_png_read_start(char *pngbuffer, size_t pnglen, @@ -236,6 +241,7 @@ is->width = width; is->height = height; is->passes_remaining = UINT32_MAX; + is->times[0] = sysarch(MIPS_GET_COUNT, NULL); if ((is->buffer = malloc(is->width * is->height * sizeof(*is->buffer))) == NULL) @@ -259,12 +265,18 @@ CHERI_CANDPERM(10, 10, CHERI_PERM_LOAD); CHERI_CSC(10, 0, &c2, 0); + CHERI_CINCBASE(10, 0, is->times + 1); + CHERI_CSETLEN(10, 10, sizeof(uint32_t) * 2); + CHERI_CANDPERM(10, 10, CHERI_PERM_STORE); + CHERI_CSC(10, 0, &c3, 0); + v = sandbox_invoke(sandbox, width, height, pnglen, 0, - &c1, &c2, NULL, NULL, NULL, NULL, NULL); + &c1, &c2, &c3, NULL, NULL, NULL, NULL); if (ibox_verbose) printf("%s: sandbox returned %ju\n", __func__, (uintmax_t)v); is->valid_rows = height; is->passes_remaining = 0; + is->times[3] = sysarch(MIPS_GET_COUNT, NULL); return (is); error: munmap(pngbuffer, pnglen); @@ -403,3 +415,25 @@ break; } } + +static uint32_t +counter_diff(uint32_t first, uint32_t second) +{ + + if (first < second) + return (second - first); + else + return (second + (UINT32_MAX - first)); +} + +uint32_t +iboxstate_get_ttime(struct iboxstate *is) { + + return (counter_diff(is->times[0], is->times[3])); +} + +uint32_t +iboxstate_get_dtime(struct iboxstate *is) { + + return (counter_diff(is->times[1], is->times[2])); +} ==== //depot/projects/ctsrd/cheribsd/src/ctsrd/libexec/readpng-cheri/Makefile#3 (text+ko) ==== @@ -14,6 +14,7 @@ setjmp.S \ strcpy.c \ execve.S \ + sysarch.S \ cerror.S .PATH: ${.CURDIR}/../../../ctsrd-lib/libimagebox ==== //depot/projects/ctsrd/cheribsd/src/ctsrd/libexec/readpng-cheri/readpng-cheri.c#7 (text+ko) ==== @@ -34,6 +34,7 @@ #include #include +#include #include #include @@ -108,5 +109,7 @@ if (is.error == 0) memcpy_tocap(1, ids.buffer, 0, sizeof(uint32_t) * a0 * a1); + memcpy_tocap(3, is.times + 1, 0, sizeof(uint32_t) * 2); + return (is.error); } ==== //depot/projects/ctsrd/cheribsd/src/ctsrd/libexec/readpng/readpng.c#5 (text+ko) ==== @@ -32,6 +32,8 @@ #include #include +#include + #include #include #include @@ -63,5 +65,6 @@ err(1, "mmap buffer"); decode_png(&ids, NULL, NULL); + ids.is->times[3] = sysarch(MIPS_GET_COUNT, NULL); return (0); }