From patchwork Mon Jul 29 21:31:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 18654 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gg0-f197.google.com (mail-gg0-f197.google.com [209.85.161.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EF01C248D1 for ; Mon, 29 Jul 2013 21:31:44 +0000 (UTC) Received: by mail-gg0-f197.google.com with SMTP id l4sf3869601ggi.0 for ; Mon, 29 Jul 2013 14:31:44 -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=5gWVJu/sDif1v6FEaYqPaAPt3Myv4x0CQ2aIATIBu1Y=; b=EQH/9sROme9Zfb2z0ozY0UxWwby0FKdNMsYtnkAqG+VUcvN3X29wd15rpjI4Kx5ThF NZbrJ/50fla3418hc8De1cickRtVfws7b/Dz66vFd2+Oy3F6rLNQ7q+cn672j0jeRbp/ COo8JEvGLEF/uy5kuFYLiWYK443tm2a/TLtGrQorv2If90nkzRxbdQiZWH9pUyYGcZTD 8t8//ZPvh1R7jVh2r5WylZ2QEBo5aqhuElK1L6YJqv5c/q6LRRnWxsimV4UHH8AX/9ed au9U1z7JmkLS35puefF0bmywJDq8IVLkqX3pzaKi0AHp674rAFeZ9dckpEXnmfiaXknk l3Bg== X-Received: by 10.236.91.173 with SMTP id h33mr31781788yhf.17.1375133504708; Mon, 29 Jul 2013 14:31:44 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.58.4 with SMTP id m4ls2242673qeq.52.gmail; Mon, 29 Jul 2013 14:31:44 -0700 (PDT) X-Received: by 10.52.122.113 with SMTP id lr17mr22076017vdb.100.1375133504572; Mon, 29 Jul 2013 14:31:44 -0700 (PDT) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id ha3si18031818vdb.108.2013.07.29.14.31.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 29 Jul 2013 14:31:44 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.176; Received: by mail-vc0-f176.google.com with SMTP id ha11so2476050vcb.21 for ; Mon, 29 Jul 2013 14:31:44 -0700 (PDT) X-Received: by 10.58.211.227 with SMTP id nf3mr26571626vec.20.1375133504363; Mon, 29 Jul 2013 14:31:44 -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 pc8csp138467vcb; Mon, 29 Jul 2013 14:31:43 -0700 (PDT) X-Received: by 10.66.246.225 with SMTP id xz1mr46771557pac.110.1375133503431; Mon, 29 Jul 2013 14:31:43 -0700 (PDT) Received: from mail-pb0-f53.google.com (mail-pb0-f53.google.com [209.85.160.53]) by mx.google.com with ESMTPS id gg2si761328pac.72.2013.07.29.14.31.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 29 Jul 2013 14:31:43 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.53 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.160.53; Received: by mail-pb0-f53.google.com with SMTP id up15so4508801pbc.12 for ; Mon, 29 Jul 2013 14:31:43 -0700 (PDT) X-Received: by 10.66.161.138 with SMTP id xs10mr58251pab.56.1375133502891; Mon, 29 Jul 2013 14:31:42 -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.41 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 29 Jul 2013 14:31:42 -0700 (PDT) From: John Stultz To: Dhaval Giani Cc: John Stultz Subject: [PATCH 7/7] volatile-test: Get rid of CLRF endlines Date: Mon, 29 Jul 2013 14:31:20 -0700 Message-Id: <1375133480-5597-8-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: ALoCoQlXCn3PCwFHATb3ti2li6Teytvgrx1C392raop7uzx6t6JYC4tlp+eavvPH+UEz2otJn2Iz X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.176 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: , Get rid of the CLRF endlines. Tisk tisk, someone is using windows. ;) Signed-off-by: John Stultz --- volatile-test-signal.c | 363 ++++++++++++++++++++++++------------------------- volatile-test.c | 266 ++++++++++++++++++------------------ 2 files changed, 312 insertions(+), 317 deletions(-) diff --git a/volatile-test-signal.c b/volatile-test-signal.c index 57d0899..8a24cb1 100644 --- a/volatile-test-signal.c +++ b/volatile-test-signal.c @@ -1,183 +1,180 @@ - -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define SYS_vrange 314 - -#define VRANGE_VOLATILE 0 /* unpin all pages so VM can discard them */ -#define VRANGE_NOVOLATILE 1 /* pin all pages so VM can't discard them */ - -#define VRANGE_MODE_SHARED 0x1 /* discard all pages of the range */ - - - -#define VRANGE_MODE 0x1 - -static int vrange(unsigned long start, size_t length, int mode, int *purged) -{ - return syscall(SYS_vrange, start, length, mode, purged); -} - - -static int mvolatile(void *addr, size_t length) -{ - return vrange((long)addr, length, VRANGE_VOLATILE, 0); -} - - -static int mnovolatile(void *addr, size_t length, int* purged) -{ - return vrange((long)addr, length, VRANGE_NOVOLATILE, purged); -} - - -char* vaddr; -#define PAGE_SIZE (4*1024) -#define CHUNK (4*1024*4) -#define CHUNKNUM 26 -#define FULLSIZE (CHUNK*CHUNKNUM + 2*PAGE_SIZE) - -void generate_pressure(megs) -{ - pid_t child; - int one_meg = 1024*1024; - char *addr; - int i, status; - - child = fork(); - - - if (!child) { - for (i=0; i < megs; i++) { - addr = malloc(one_meg); - bzero(addr, one_meg); - } - exit(0); - } - - waitpid(child, &status, 0); - return; -} - -void sigaction_sigbusy(int signum, siginfo_t *info, void *ctxt) -{ - char *ptr; - int ret; - char x; - long len; - if (signum != SIGBUS) - return; - - ptr = info->si_addr; - - mnovolatile(ptr, CHUNK, &ret); - printf("Fixing up data\n"); - len = (ptr - vaddr)/CHUNK; - x = 'A' + len; - memset(ptr, x, CHUNK); - printf("%c\n", x); - -} - -void signal_handler_sigbusy(int signum) -{ - if (signum == SIGBUS) { - printf("We received SIGBUSY\n"); - } -} - -void register_signal_handler() -{ - struct sigaction action; - action.sa_sigaction = &sigaction_sigbusy; - sigemptyset(&action.sa_mask); - action.sa_flags = SA_SIGINFO; - action.sa_restorer = NULL; - sigaction(SIGBUS, &action, NULL); -} - -int main(int argc, char *argv[]) -{ - int i, purged; - char* file = NULL; - int fd; - int pressure = 0; - int opt; - - //signal(SIGBUS, signal_handler_sigbusy - //sigaction(SIGBUS, sigaction_sigbusy, NULL); - register_signal_handler(); - - /* 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); - } else { - vaddr = malloc(FULLSIZE); - } - - purged = 0; - vaddr += PAGE_SIZE-1; - vaddr -= (long)vaddr % PAGE_SIZE; - - for(i=0; i < CHUNKNUM; i++) - memset(vaddr + (i*CHUNK), 'A'+i, CHUNK); - - - for(i=0; i < CHUNKNUM; ) { - mvolatile(vaddr + (i*CHUNK), CHUNK); - i+=2; - } - -// for(i=0; i < CHUNKNUM; i++) -// printf("%c\n", vaddr[i*CHUNK]); - - generate_pressure(pressure); - -// for(i=0; i < CHUNKNUM; i++) -// printf("%c\n", vaddr[i*CHUNK]); - - /*for(i=0; i < CHUNKNUM; ) { - int ret; - ret = mnovolatile(vaddr + (i*CHUNK), CHUNK, &purged); - i+=2; - }*/ - - if (purged) - printf("Data purged!\n"); - for(i=0; i < CHUNKNUM; i++) - printf("%c\n", vaddr[i*CHUNK]); - - - - return 0; -} - + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SYS_vrange 314 + +#define VRANGE_VOLATILE 0 /* unpin all pages so VM can discard them */ +#define VRANGE_NOVOLATILE 1 /* pin all pages so VM can't discard them */ + +#define VRANGE_MODE_SHARED 0x1 /* discard all pages of the range */ + + + +#define VRANGE_MODE 0x1 + +static int vrange(unsigned long start, size_t length, int mode, int *purged) +{ + return syscall(SYS_vrange, start, length, mode, purged); +} + + +static int mvolatile(void *addr, size_t length) +{ + return vrange((long)addr, length, VRANGE_VOLATILE, 0); +} + + +static int mnovolatile(void *addr, size_t length, int* purged) +{ + return vrange((long)addr, length, VRANGE_NOVOLATILE, purged); +} + + +char* vaddr; +#define PAGE_SIZE (4*1024) +#define CHUNK (4*1024*4) +#define CHUNKNUM 26 +#define FULLSIZE (CHUNK*CHUNKNUM + 2*PAGE_SIZE) + +void generate_pressure(megs) +{ + pid_t child; + int one_meg = 1024*1024; + char *addr; + int i, status; + + child = fork(); + + + if (!child) { + for (i=0; i < megs; i++) { + addr = malloc(one_meg); + bzero(addr, one_meg); + } + exit(0); + } + + waitpid(child, &status, 0); + return; +} + +void sigaction_sigbusy(int signum, siginfo_t *info, void *ctxt) +{ + char *ptr; + int ret; + char x; + long len; + if (signum != SIGBUS) + return; + + ptr = info->si_addr; + + mnovolatile(ptr, CHUNK, &ret); + printf("Fixing up data\n"); + len = (ptr - vaddr)/CHUNK; + x = 'A' + len; + memset(ptr, x, CHUNK); + printf("%c\n", x); +} + +void signal_handler_sigbusy(int signum) +{ + if (signum == SIGBUS) { + printf("We received SIGBUSY\n"); + } +} + +void register_signal_handler() +{ + struct sigaction action; + action.sa_sigaction = &sigaction_sigbusy; + sigemptyset(&action.sa_mask); + action.sa_flags = SA_SIGINFO; + action.sa_restorer = NULL; + sigaction(SIGBUS, &action, NULL); +} + +int main(int argc, char *argv[]) +{ + int i, purged; + char* file = NULL; + int fd; + int pressure = 0; + int opt; + + //signal(SIGBUS, signal_handler_sigbusy + //sigaction(SIGBUS, sigaction_sigbusy, NULL); + register_signal_handler(); + + /* 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); + } else { + vaddr = malloc(FULLSIZE); + } + + purged = 0; + vaddr += PAGE_SIZE-1; + vaddr -= (long)vaddr % PAGE_SIZE; + + for(i=0; i < CHUNKNUM; i++) + memset(vaddr + (i*CHUNK), 'A'+i, CHUNK); + + + for(i=0; i < CHUNKNUM; ) { + mvolatile(vaddr + (i*CHUNK), CHUNK); + i+=2; + } + +// for(i=0; i < CHUNKNUM; i++) +// printf("%c\n", vaddr[i*CHUNK]); + + generate_pressure(pressure); + +// for(i=0; i < CHUNKNUM; i++) +// printf("%c\n", vaddr[i*CHUNK]); + + /*for(i=0; i < CHUNKNUM; ) { + int ret; + ret = mnovolatile(vaddr + (i*CHUNK), CHUNK, &purged); + i+=2; + }*/ + + if (purged) + printf("Data purged!\n"); + for(i=0; i < CHUNKNUM; i++) + printf("%c\n", vaddr[i*CHUNK]); + + return 0; +} + diff --git a/volatile-test.c b/volatile-test.c index fe6ed7a..3199754 100644 --- a/volatile-test.c +++ b/volatile-test.c @@ -1,134 +1,132 @@ - -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define SYS_vrange 314 - -#define VRANGE_VOLATILE 0 /* unpin all pages so VM can discard them */ -#define VRANGE_NOVOLATILE 1 /* pin all pages so VM can't discard them */ - -#define VRANGE_MODE_SHARED 0x1 /* discard all pages of the range */ - - - -#define VRANGE_MODE 0x1 - -static int vrange(unsigned long start, size_t length, int mode, int *purged) -{ - return syscall(SYS_vrange, start, length, mode, purged); -} - - -static int mvolatile(void *addr, size_t length) -{ - return vrange((long)addr, length, VRANGE_VOLATILE, 0); -} - - -static int mnovolatile(void *addr, size_t length, int* purged) -{ - return vrange((long)addr, length, VRANGE_NOVOLATILE, purged); -} - - -char* vaddr; -#define PAGE_SIZE (4*1024) -#define CHUNK (4*1024*4) -#define CHUNKNUM 26 -#define FULLSIZE (CHUNK*CHUNKNUM + 2*PAGE_SIZE) - -void generate_pressure(megs) -{ - pid_t child; - int one_meg = 1024*1024; - char *addr; - int i, status; - - child = fork(); - if (!child) { - for (i=0; i < megs; i++) { - addr = malloc(one_meg); - bzero(addr, one_meg); - } - exit(0); - } - - waitpid(child, &status, 0); - return; -} - -int main(int argc, char *argv[]) -{ - int i, purged; - char* file = NULL; - int fd; - 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 { - vaddr = malloc(FULLSIZE); - } - - purged = 0; - vaddr += PAGE_SIZE-1; - vaddr -= (long)vaddr % PAGE_SIZE; - - for(i=0; i < CHUNKNUM; i++) - memset(vaddr + (i*CHUNK), 'A'+i, CHUNK); - - - for(i=0; i < CHUNKNUM; ) { - mvolatile(vaddr + (i*CHUNK), CHUNK); - i+=2; - } - - printf("Generating %i megs of pressure\n", pressure); - generate_pressure(pressure); - - for(i=0; i < CHUNKNUM; ) { - mnovolatile(vaddr + (i*CHUNK), CHUNK, &purged); - i+=2; - } - - if (purged) - printf("Data purged!\n"); - - for(i=0; i < CHUNKNUM; i++) - printf("%c\n", vaddr[i*CHUNK]); - - - - return 0; -} - + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SYS_vrange 314 + +#define VRANGE_VOLATILE 0 /* unpin all pages so VM can discard them */ +#define VRANGE_NOVOLATILE 1 /* pin all pages so VM can't discard them */ + +#define VRANGE_MODE_SHARED 0x1 /* discard all pages of the range */ + + + +#define VRANGE_MODE 0x1 + +static int vrange(unsigned long start, size_t length, int mode, int *purged) +{ + return syscall(SYS_vrange, start, length, mode, purged); +} + + +static int mvolatile(void *addr, size_t length) +{ + return vrange((long)addr, length, VRANGE_VOLATILE, 0); +} + + +static int mnovolatile(void *addr, size_t length, int* purged) +{ + return vrange((long)addr, length, VRANGE_NOVOLATILE, purged); +} + + +char* vaddr; +#define PAGE_SIZE (4*1024) +#define CHUNK (4*1024*4) +#define CHUNKNUM 26 +#define FULLSIZE (CHUNK*CHUNKNUM + 2*PAGE_SIZE) + +void generate_pressure(megs) +{ + pid_t child; + int one_meg = 1024*1024; + char *addr; + int i, status; + + child = fork(); + if (!child) { + for (i=0; i < megs; i++) { + addr = malloc(one_meg); + bzero(addr, one_meg); + } + exit(0); + } + + waitpid(child, &status, 0); + return; +} + +int main(int argc, char *argv[]) +{ + int i, purged; + char* file = NULL; + int fd; + 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 { + vaddr = malloc(FULLSIZE); + } + + purged = 0; + vaddr += PAGE_SIZE-1; + vaddr -= (long)vaddr % PAGE_SIZE; + + for(i=0; i < CHUNKNUM; i++) + memset(vaddr + (i*CHUNK), 'A'+i, CHUNK); + + + for(i=0; i < CHUNKNUM; ) { + mvolatile(vaddr + (i*CHUNK), CHUNK); + i+=2; + } + + printf("Generating %i megs of pressure\n", pressure); + generate_pressure(pressure); + + for(i=0; i < CHUNKNUM; ) { + mnovolatile(vaddr + (i*CHUNK), CHUNK, &purged); + i+=2; + } + + if (purged) + printf("Data purged!\n"); + + for(i=0; i < CHUNKNUM; i++) + printf("%c\n", vaddr[i*CHUNK]); + + return 0; +} +