From patchwork Mon Jul 29 21:31:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 18652 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f197.google.com (mail-vc0-f197.google.com [209.85.220.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 546592486F for ; Mon, 29 Jul 2013 21:31:42 +0000 (UTC) Received: by mail-vc0-f197.google.com with SMTP id ha11sf4126049vcb.8 for ; Mon, 29 Jul 2013 14:31:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=brep9oLNwPTa8GwWhcFsHRc+Brc4h9rwdxw4cqyldnY=; b=nxFs6Ntlj6hDr9IoWgwcUeKajAEQkGU+dKh/2nDZdzys+sJctGJHdLD4QFuiE5jLIY iirDbIuF10jBAOa4Shm3Kpqj/Zlvz6pnXtdHxZH02FgTPLiyXxIyhKVU4XBXo8SW7+hU uyQIlBOPTKyMh/wE2n+zAvD/0j9+omP8lkaFreMdS5dFy35b6S010cUd6s7N0o0Jb4yR 3EdcRT8qV9pVe60dvJbE7TyyJIE1jkWBSN7WRBPznNbr6IXoeQ1GIgOksu/L2LGBgFzJ 1TeInhxjzJLxSJx4bg871eFWySyrJGORUamGLRl6Izc4Efnvfddr26Rb2yOHWMOmnEGB 3qIw== X-Received: by 10.236.190.72 with SMTP id d48mr8461379yhn.0.1375133501955; Mon, 29 Jul 2013 14:31:41 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.70.228 with SMTP id p4ls1039498qeu.43.gmail; Mon, 29 Jul 2013 14:31:41 -0700 (PDT) X-Received: by 10.221.4.138 with SMTP id oc10mr9330454vcb.26.1375133501772; Mon, 29 Jul 2013 14:31:41 -0700 (PDT) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) by mx.google.com with ESMTPS id un5si5991875vcb.97.2013.07.29.14.31.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 29 Jul 2013 14:31:41 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.172; Received: by mail-ve0-f172.google.com with SMTP id oz10so3387713veb.31 for ; Mon, 29 Jul 2013 14:31:41 -0700 (PDT) X-Received: by 10.52.180.229 with SMTP id dr5mr1870050vdc.20.1375133501670; Mon, 29 Jul 2013 14:31:41 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.11.8 with SMTP id pc8csp138461vcb; Mon, 29 Jul 2013 14:31:41 -0700 (PDT) X-Received: by 10.68.137.170 with SMTP id qj10mr22338133pbb.31.1375133500832; Mon, 29 Jul 2013 14:31:40 -0700 (PDT) Received: from mail-pd0-f182.google.com (mail-pd0-f182.google.com [209.85.192.182]) by mx.google.com with ESMTPS id tl4si14665425pac.137.2013.07.29.14.31.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 29 Jul 2013 14:31:40 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.182 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.192.182; Received: by mail-pd0-f182.google.com with SMTP id r11so1665762pdi.27 for ; Mon, 29 Jul 2013 14:31:40 -0700 (PDT) X-Received: by 10.66.178.143 with SMTP id cy15mr66991062pac.105.1375133500307; Mon, 29 Jul 2013 14:31:40 -0700 (PDT) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id om2sm21331095pbc.30.2013.07.29.14.31.39 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 29 Jul 2013 14:31:39 -0700 (PDT) From: John Stultz To: Dhaval Giani Cc: John Stultz Subject: [PATCH 5/7] volatile-ranges: Add better argument parsing and pressure option Date: Mon, 29 Jul 2013 14:31:18 -0700 Message-Id: <1375133480-5597-6-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1375133480-5597-1-git-send-email-john.stultz@linaro.org> References: <1375133480-5597-1-git-send-email-john.stultz@linaro.org> X-Gm-Message-State: ALoCoQnK3kyYZEuZI9UliJL3mPeQehXgEQkhBrnCtJE2K4ncOuihWzErFjaZLuCN3hH5QWUYFEAq X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add better argument parsing as well as a pressure option to specify the amount of pressure to generate. Signed-off-by: John Stultz --- volatile-test-signal.c | 27 ++++++++++++++++++++++++--- volatile-test.c | 38 ++++++++++++++++++++++++++------------ 2 files changed, 50 insertions(+), 15 deletions(-) diff --git a/volatile-test-signal.c b/volatile-test-signal.c index 4434525..57d0899 100644 --- a/volatile-test-signal.c +++ b/volatile-test-signal.c @@ -110,12 +110,33 @@ void register_signal_handler() int main(int argc, char *argv[]) { int i, purged; - char* file; + char* file = NULL; int fd; + int pressure = 0; + int opt; + //signal(SIGBUS, signal_handler_sigbusy //sigaction(SIGBUS, sigaction_sigbusy, NULL); register_signal_handler(); - if (argc > 1) { + + /* Process arguments */ + while ((opt = getopt(argc, argv, "p:f:"))!=-1) { + switch(opt) { + case 'p': + pressure = atoi(optarg); + break; + case 'f': + file = optarg; + break; + default: + printf("Usage: %s [-p ] [-f ]\n", argv[0]); + printf(" -p: Amount of memory pressure to generate\n"); + printf(" -f: Use a file\n"); + exit(-1); + } + } + + if (file) { file = argv[1]; fd = open(file, O_RDWR); vaddr = mmap(0, FULLSIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); @@ -139,7 +160,7 @@ int main(int argc, char *argv[]) // for(i=0; i < CHUNKNUM; i++) // printf("%c\n", vaddr[i*CHUNK]); - generate_pressure(3); + generate_pressure(pressure); // for(i=0; i < CHUNKNUM; i++) // printf("%c\n", vaddr[i*CHUNK]); diff --git a/volatile-test.c b/volatile-test.c index 153bd6d..fe6ed7a 100644 --- a/volatile-test.c +++ b/volatile-test.c @@ -55,8 +55,6 @@ void generate_pressure(megs) int i, status; child = fork(); - - if (!child) { for (i=0; i < megs; i++) { addr = malloc(one_meg); @@ -72,10 +70,30 @@ void generate_pressure(megs) int main(int argc, char *argv[]) { int i, purged; - char* file; + char* file = NULL; int fd; - if (argc > 1) { - file = argv[1]; + int pressure = 0; + int opt; + + /* Process arguments */ + while ((opt = getopt(argc, argv, "p:f:"))!=-1) { + switch(opt) { + case 'p': + pressure = atoi(optarg); + break; + case 'f': + file = optarg; + break; + default: + printf("Usage: %s [-p ] [-f ]\n", argv[0]); + printf(" -p: Amount of memory pressure to generate\n"); + printf(" -f: Use a file\n"); + exit(-1); + } + } + + if (file) { + printf("Using file %s\n", file); fd = open(file, O_RDWR); vaddr = mmap(0, FULLSIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); } else { @@ -95,13 +113,8 @@ int main(int argc, char *argv[]) i+=2; } -// for(i=0; i < CHUNKNUM; i++) -// printf("%c\n", vaddr[i*CHUNK]); - - generate_pressure(3); - -// for(i=0; i < CHUNKNUM; i++) -// printf("%c\n", vaddr[i*CHUNK]); + printf("Generating %i megs of pressure\n", pressure); + generate_pressure(pressure); for(i=0; i < CHUNKNUM; ) { mnovolatile(vaddr + (i*CHUNK), CHUNK, &purged); @@ -110,6 +123,7 @@ int main(int argc, char *argv[]) if (purged) printf("Data purged!\n"); + for(i=0; i < CHUNKNUM; i++) printf("%c\n", vaddr[i*CHUNK]);