From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [kvm-unit-tests PATCH v5 07/11] new arm/tlbflush-test: TLB torture test Date: Fri, 31 Jul 2015 16:53:57 +0100 Message-ID: <1438358041-18021-8-git-send-email-alex.bennee@linaro.org> References: <1438358041-18021-1-git-send-email-alex.bennee@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: qemu-devel@nongnu.org, peter.maydell@linaro.org, a.spyridakis@virtualopensystems.com, drjones@redhat.com, a.rigo@virtualopensystems.com, claudio.fontana@huawei.com, kvm@vger.kernel.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= To: mttcg@listserver.greensocs.com, mark.burton@greensocs.com, fred.konrad@greensocs.com Return-path: Received: from mail-wi0-f177.google.com ([209.85.212.177]:37799 "EHLO mail-wi0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752418AbbGaPya (ORCPT ); Fri, 31 Jul 2015 11:54:30 -0400 Received: by wibud3 with SMTP id ud3so37564195wib.0 for ; Fri, 31 Jul 2015 08:54:28 -0700 (PDT) In-Reply-To: <1438358041-18021-1-git-send-email-alex.bennee@linaro.org> Sender: kvm-owner@vger.kernel.org List-ID: This adds a fairly brain dead torture test for TLB flushes intended for stressing the MTTCG QEMU build. It takes the usual -smp option for multiple CPUs. By default it CPU0 will do a TLBIALL flush after each cycle. You can pass options via -append to control additional aspects of the test: - "page" flush each page in turn (one per function) - "self" do the flush after each computation cycle - "verbose" report progress on each computation cycle Signed-off-by: Alex Benn=C3=A9e --- v2 - rename to tlbflush-test - made makefile changes cleaner - added self/other flush mode - create specific prefix - whitespace fixes --- arm/tlbflush-test.c | 194 +++++++++++++++++++++++++++++++++++= ++++++++ config/config-arm-common.mak | 7 +- 2 files changed, 198 insertions(+), 3 deletions(-) create mode 100644 arm/tlbflush-test.c diff --git a/arm/tlbflush-test.c b/arm/tlbflush-test.c new file mode 100644 index 0000000..0375ad9 --- /dev/null +++ b/arm/tlbflush-test.c @@ -0,0 +1,194 @@ +#include +#include +#include +#include +#include + +#define SEQ_LENGTH 10 +#define SEQ_HASH 0x7cd707fe + +static cpumask_t smp_test_complete; +static int flush_count =3D 1000000; +static int flush_self =3D 0; +static int flush_page =3D 0; +static int flush_verbose =3D 0; + +/* Work functions + * + * These work functions need to be: + * + * - page aligned, so we can flush one function at a time + * - have branches, so QEMU TCG generates multiple basic blocks + * - call across pages, so we exercise the TCG basic block slow path + */ + +/* Adler32 */ +__attribute__((aligned(PAGE_SIZE))) uint32_t hash_array(const void *bu= f, + size_t buflen) +{ + const uint8_t *data =3D (uint8_t *) buf; + uint32_t s1 =3D 1; + uint32_t s2 =3D 0; + + for (size_t n =3D 0; n < buflen; n++) { + s1 =3D (s1 + data[n]) % 65521; + s2 =3D (s2 + s1) % 65521; + } + return (s2 << 16) | s1; +} + +__attribute__((aligned(PAGE_SIZE))) void create_fib_sequence(int lengt= h, + unsigned int *array) +{ + int i; + + /* first two values */ + array[0] =3D 0; + array[1] =3D 1; + for (i=3D2; i