From: Christian Borntraeger Subject: Re: [PATCH kvm-unit-tests v3 11/11] s390x: add sieve test Date: Tue, 13 Feb 2018 17:26:38 +0100 Message-ID: References: <20180213162321.20522-1-david@redhat.com> <20180213162321.20522-12-david@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Thomas Huth , Cornelia Huck To: David Hildenbrand , kvm@vger.kernel.org Return-path: Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:55842 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934832AbeBMQ0q (ORCPT ); Tue, 13 Feb 2018 11:26:46 -0500 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1DGOKKQ034200 for ; Tue, 13 Feb 2018 11:26:45 -0500 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2g40xmynbt-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 13 Feb 2018 11:26:44 -0500 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 13 Feb 2018 16:26:42 -0000 In-Reply-To: <20180213162321.20522-12-david@redhat.com> Content-Language: en-US Sender: kvm-owner@vger.kernel.org List-ID: On 02/13/2018 05:23 PM, David Hildenbrand wrote: > Copied from x86/sieve.c. Modifications: > - proper code formatting. > - as setup_vm() is already called, temporarily disable DAT. > > The test takes fairly long, especially because we only have 128MB of ram > and allocate 3 times in a row ~100mb of virtual memory. Does it make sense to change the memory size in the unittests.cfg file? e.g. via extra_params? > > Signed-off-by: David Hildenbrand > --- > s390x/Makefile | 1 + > s390x/sieve.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++ > s390x/unittests.cfg | 6 ++++++ > 3 files changed, 66 insertions(+) > create mode 100644 s390x/sieve.c > > diff --git a/s390x/Makefile b/s390x/Makefile > index d9bef37..2d3336c 100644 > --- a/s390x/Makefile > +++ b/s390x/Makefile > @@ -1,6 +1,7 @@ > tests = $(TEST_DIR)/selftest.elf > tests += $(TEST_DIR)/intercept.elf > tests += $(TEST_DIR)/emulator.elf > +tests += $(TEST_DIR)/sieve.elf > > all: directories test_cases > > diff --git a/s390x/sieve.c b/s390x/sieve.c > new file mode 100644 > index 0000000..28d4d1e > --- /dev/null > +++ b/s390x/sieve.c > @@ -0,0 +1,59 @@ > +/* > + * Copied from x86/sieve.c > + */ > + > +#include > +#include > +#include > + > +int sieve(char* data, int size) > +{ > + int i, j, r = 0; > + > + for (i = 0; i < size; ++i) > + data[i] = 1; > + > + data[0] = data[1] = 0; > + > + for (i = 2; i < size; ++i) > + if (data[i]) { > + ++r; > + for (j = i * 2; j < size; j += i) > + data[j] = 0; > + } > + return r; > +} > + > +void test_sieve(const char *msg, char *data, int size) > +{ > + int r; > + > + printf("%s:", msg); > + r = sieve(data, size); > + printf("%d out of %d\n", r, size); > +} > + > +#define STATIC_SIZE 1000000 > +#define VSIZE 100000000 > +char static_data[STATIC_SIZE]; > + > +int main() > +{ > + void *v; > + int i; > + > + printf("starting sieve\n"); > + > + configure_dat(0); > + test_sieve("static", static_data, STATIC_SIZE); > + configure_dat(1); > + > + test_sieve("mapped", static_data, STATIC_SIZE); > + for (i = 0; i < 3; ++i) { > + v = malloc(VSIZE); > + test_sieve("virtual", v, VSIZE); > + free(v); > + } > + > + return 0; > +} > diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg > index 1343a19..4a1e469 100644 > --- a/s390x/unittests.cfg > +++ b/s390x/unittests.cfg > @@ -28,3 +28,9 @@ file = intercept.elf > > [emulator] > file = emulator.elf > + > +[sieve] > +file = sieve.elf > +groups = selftest > +# can take fairly long even on KVM guests > +timeout = 600 >