From owner-svn-src-user@freebsd.org Fri Mar 31 11:57:36 2017 Return-Path: Delivered-To: svn-src-user@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 9303CD260BC for ; Fri, 31 Mar 2017 11:57:36 +0000 (UTC) (envelope-from pho@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 6D8B48C0; Fri, 31 Mar 2017 11:57:36 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2VBf0wF025090; Fri, 31 Mar 2017 11:41:00 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2VBf0d2025085; Fri, 31 Mar 2017 11:41:00 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201703311141.v2VBf0d2025085@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Fri, 31 Mar 2017 11:41:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r316331 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Mar 2017 11:57:36 -0000 Author: pho Date: Fri Mar 31 11:40:59 2017 New Revision: 316331 URL: https://svnweb.freebsd.org/changeset/base/316331 Log: Limit VM usage by introducing a max queue length. Sponsored by: Dell EMC Isilon Modified: user/pho/stress2/misc/pthread2.sh user/pho/stress2/misc/pthread7.sh Modified: user/pho/stress2/misc/pthread2.sh ============================================================================== --- user/pho/stress2/misc/pthread2.sh Fri Mar 31 10:26:14 2017 (r316330) +++ user/pho/stress2/misc/pthread2.sh Fri Mar 31 11:40:59 2017 (r316331) @@ -46,9 +46,7 @@ for i in `jot 5`; do for i in `jot 8`; do /tmp/pthread2 & done - for i in `jot 8`; do - wait - done + wait ' done > $log 2>&1 rm -f /tmp/pthread2 @@ -115,6 +113,8 @@ struct files { static struct files newfiles; static struct files renamedfiles; +#define MAXQ 100000 /* Max create queue length */ +#define MESSAGES 10000000; static void hand(int i __unused) { /* handler */ @@ -168,7 +168,7 @@ pwait(pthread_cond_t *c, pthread_mutex_t void * loop_create(void *arg __unused) { - int i, j; + int i; struct file *file; #ifdef __NP__ @@ -183,9 +183,8 @@ loop_create(void *arg __unused) ncreate++; UNLOCK(newfiles); SIGNAL(newfiles); - if ((bench == 0) && (i > 0) && (i % 100000 == 0)) - for (j = 0; j < 10 && ncreate != nrename; j++) - usleep(400); + if (ncreate - nrename > MAXQ) + usleep(400); } return (NULL); } @@ -255,7 +254,7 @@ main(void) bench = getenv("bench") != NULL; asprintf(&dirname1, "%s.1", "f1"); asprintf(&dirname2, "%s.2", "f2"); - max = 15000000; + max = MESSAGES; STAILQ_INIT(&newfiles.list); STAILQ_INIT(&renamedfiles.list); Modified: user/pho/stress2/misc/pthread7.sh ============================================================================== --- user/pho/stress2/misc/pthread7.sh Fri Mar 31 10:26:14 2017 (r316330) +++ user/pho/stress2/misc/pthread7.sh Fri Mar 31 11:40:59 2017 (r316331) @@ -31,13 +31,12 @@ # PTHREAD_PRIO_INHERIT version of pthread2.sh . ../default.cfg -[ `swapinfo | wc -l` -eq 1 ] && exit 0 # kstack allocation failed export LANG=C here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > pthread7.c -mycc -o pthread7 -Wall -Wextra -O2 -g -gdwarf-2 pthread7.c -lpthread || exit 1 +mycc -o pthread7 -Wall -Wextra -O2 -g pthread7.c -lpthread || exit 1 rm -f pthread7.c for i in `jot 5`; do @@ -81,7 +80,7 @@ EOF #define WAIT(x) pwait(&x.wait, &x.mtx) long ncreate, nrename, nunlink; -int bench, max; +int max; char *dirname1; char *dirname2; @@ -99,6 +98,8 @@ struct files { static struct files newfiles; static struct files renamedfiles; +#define MAXQ 100000 /* Max create queue length */ +#define MESSAGES 10000000; static void hand(int i __unused) { /* handler */ @@ -152,7 +153,7 @@ pwait(pthread_cond_t *c, pthread_mutex_t void * loop_create(void *arg __unused) { - int i, j; + int i; struct file *file; #ifdef __NP__ @@ -167,9 +168,8 @@ loop_create(void *arg __unused) ncreate++; UNLOCK(newfiles); SIGNAL(newfiles); - if ((bench == 0) && (i > 0) && (i % 100000 == 0)) - for (j = 0; j < 10 && ncreate != nrename; j++) - usleep(400); + if (ncreate - nrename > MAXQ) + usleep(400); } return (NULL); } @@ -237,10 +237,9 @@ main(void) pthread_t tid[3]; pthread_mutexattr_t attr, *pattr = NULL; - bench = getenv("bench") != NULL; asprintf(&dirname1, "%s.1", "f1"); asprintf(&dirname2, "%s.2", "f2"); - max = 15000000; + max = MESSAGES; STAILQ_INIT(&newfiles.list); STAILQ_INIT(&renamedfiles.list); @@ -260,7 +259,7 @@ main(void) signal(SIGINFO, hand); signal(SIGALRM, ahand); - alarm(400); + alarm(300); if ((rc = pthread_create(&tid[0], NULL, loop_create, NULL)) != 0) errc(1, rc, "pthread_create()"); if ((rc = pthread_create(&tid[1], NULL, loop_rename, NULL)) != 0)