From patchwork Tue Feb 13 16:23:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 10216645 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BBFBC60329 for ; Tue, 13 Feb 2018 16:23:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD46D28E39 for ; Tue, 13 Feb 2018 16:23:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A202D28EA4; Tue, 13 Feb 2018 16:23:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4996728EA2 for ; Tue, 13 Feb 2018 16:23:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934884AbeBMQXn (ORCPT ); Tue, 13 Feb 2018 11:23:43 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51434 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934921AbeBMQXl (ORCPT ); Tue, 13 Feb 2018 11:23:41 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 036B58182D2E; Tue, 13 Feb 2018 16:23:41 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-104.ams2.redhat.com [10.36.117.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7A04213AEE1; Tue, 13 Feb 2018 16:23:39 +0000 (UTC) From: David Hildenbrand To: kvm@vger.kernel.org Cc: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Thomas Huth , Cornelia Huck , Christian Borntraeger , David Hildenbrand Subject: [PATCH kvm-unit-tests v3 11/11] s390x: add sieve test Date: Tue, 13 Feb 2018 17:23:21 +0100 Message-Id: <20180213162321.20522-12-david@redhat.com> In-Reply-To: <20180213162321.20522-1-david@redhat.com> References: <20180213162321.20522-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 13 Feb 2018 16:23:41 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 13 Feb 2018 16:23:41 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'david@redhat.com' RCPT:'' Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. 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