From owner-svn-src-user@freebsd.org Mon Mar 2 07:33:16 2020 Return-Path: Delivered-To: svn-src-user@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0488525CD1A for ; Mon, 2 Mar 2020 07:33:16 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48WBhC63Xlz46dB; Mon, 2 Mar 2020 07:33:15 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AC5A019027; Mon, 2 Mar 2020 07:33:15 +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 0227XF50092837; Mon, 2 Mar 2020 07:33:15 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0227XFE9092836; Mon, 2 Mar 2020 07:33:15 GMT (envelope-from pho@FreeBSD.org) Message-Id: <202003020733.0227XFE9092836@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Mon, 2 Mar 2020 07:33:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r358529 - user/pho/stress2/testcases/swap X-SVN-Group: user X-SVN-Commit-Author: pho X-SVN-Commit-Paths: user/pho/stress2/testcases/swap X-SVN-Commit-Revision: 358529 X-SVN-Commit-Repository: base 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.29 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: Mon, 02 Mar 2020 07:33:16 -0000 Author: pho Date: Mon Mar 2 07:33:15 2020 New Revision: 358529 URL: https://svnweb.freebsd.org/changeset/base/358529 Log: Fix compiler warnings. Added environment variable MAXSWAPPCT to controll max vVM pressure. Modified: user/pho/stress2/testcases/swap/swap.c Modified: user/pho/stress2/testcases/swap/swap.c ============================================================================== --- user/pho/stress2/testcases/swap/swap.c Mon Mar 2 07:13:00 2020 (r358528) +++ user/pho/stress2/testcases/swap/swap.c Mon Mar 2 07:33:15 2020 (r358529) @@ -46,37 +46,52 @@ __FBSDID("$FreeBSD$"); #define MINLEFT (1024LL * 1024 * 1024) #endif -static unsigned long size; +static int64_t size; int setup(int nb) { struct rlimit rlp; - int64_t swapinfo; - unsigned long mem; - int pct; + int64_t mem, swapinfo; + int mi, mx, pct; + char *cp; if (nb == 0) { mem = usermem(); swapinfo = swap(); pct = 0; - if (op->hog == 0) - pct = random_int(80, 100); + if (op->hog == 0) { + mi = 80; + mx = 100; + } - if (op->hog == 1) - pct = random_int(100, 110); + if (op->hog == 1) { + mi = 100; + mx = 110; + } - if (op->hog == 2) - pct = random_int(110, 120); + if (op->hog == 2) { + mi = 110; + mx = 120; + } - if (op->hog >= 3) - pct = random_int(120, 130); + if (op->hog >= 3) { + mi = 120; + mx = 130; + } + if ((cp = getenv("MAXSWAPPCT")) != NULL && *cp != '\0') { + mx = atoi(cp); + mi = mx - 10; + } + pct = random_int(mi, mx); if (swapinfo == 0) { pct = random_int(30, 50); - if (mem <= MINLEFT) + if (mem <= MINLEFT) { + putval(0); _exit(1); + } mem -= MINLEFT; size = mem / 100 * pct; } else { @@ -93,16 +108,21 @@ setup(int nb) err(1,"getrlimit"); rlp.rlim_cur -= 1024 * 1024; - if (size > (unsigned long)rlp.rlim_cur) + if (size > rlp.rlim_cur) size = rlp.rlim_cur; putval(size); if (op->verbose > 1 && nb == 0) - printf("setup: pid %d, %d%%. Total %luMb\n", - getpid(), pct, size / 1024 / 1024 * op->incarnations); + printf("setup: pid %d, %d%%. Total %dMb, %d thread(s).\n", + getpid(), pct, (int)(size / 1024 / 1024 * + op->incarnations), op->incarnations); } else size = getval(); + + if (size == 0) + exit(1); + return (0); } @@ -115,10 +135,12 @@ int test(void) { time_t start; - unsigned long i, oldsize; + int64_t i, oldsize; int page; volatile char *c; + if (size == 0) + return (0); oldsize = size; c = malloc(size); while (c == NULL && done_testing == 0) { @@ -126,8 +148,8 @@ test(void) c = malloc(size); } if (op->verbose > 1 && size != oldsize) - printf("Malloc size changed from %ld Mb to %ld Mb\n", - oldsize / 1024 / 1024, size / 1024 / 1024); + printf("Malloc size changed from %d Mb to %d Mb\n", + (int)(oldsize / 1024 / 1024), (int)(size / 1024 / 102)); page = getpagesize(); start = time(NULL); /* Livelock workaround */ while (done_testing == 0 &&