From patchwork Tue Feb 20 00:22:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Bur X-Patchwork-Id: 875353 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zlhfm3R1rz9ryy for ; Tue, 20 Feb 2018 11:42:56 +1100 (AEDT) Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3zlhfm28dDzDrYg for ; Tue, 20 Feb 2018 11:42:56 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=softfail (mailfrom) smtp.mailfrom=gmail.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=cyrilbur@gmail.com; receiver=) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3zlhCz4xpYzF0V8 for ; Tue, 20 Feb 2018 11:23:11 +1100 (AEDT) Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1K0IsA8051599 for ; Mon, 19 Feb 2018 19:23:10 -0500 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 2g80r1twge-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 19 Feb 2018 19:23:09 -0500 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 20 Feb 2018 00:23:03 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 20 Feb 2018 00:23:00 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1K0N0fX47841432; Tue, 20 Feb 2018 00:23:00 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 780314C050; Tue, 20 Feb 2018 00:16:38 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AEB9A4C044; Tue, 20 Feb 2018 00:16:37 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 20 Feb 2018 00:16:37 +0000 (GMT) Received: from camb691.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 4EF66A03B1; Tue, 20 Feb 2018 11:22:56 +1100 (AEDT) From: Cyril Bur To: mikey@neuling.org, benh@kernel.crashing.org, linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH 12/12] [WIP] selftests/powerpc: Remove incorrect tm-syscall selftest Date: Tue, 20 Feb 2018 11:22:41 +1100 X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180220002241.29648-1-cyrilbur@gmail.com> References: <20180220002241.29648-1-cyrilbur@gmail.com> X-TM-AS-GCONF: 00 x-cbid: 18022000-0040-0000-0000-000004145B03 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18022000-0041-0000-0000-0000261765DF Message-Id: <20180220002241.29648-13-cyrilbur@gmail.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-19_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1034 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802200002 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Currently we perform transactional memory work at late as possible. That is we run in the kernel with the userspace checkpointed state on the CPU untill we absolultely must remove it and store it away. Likely a process switch, but possibly also signals or ptrace. What this means is that if userspace does a system call in suspended mode, it is possible that we will handle the system call and return them without the need to to a reclaim/recheckpoint and so they can expect to resume their transaction. This is what tm-syscall tests for - the ability to perform a system call in suspended state and still resume it afterwards. TM reworks have meant that we now deal with any transactional state on entry to the kernel, no matter the reason for entry (some expections apply). We will categorically doom any suspended transaction that makes a system call, making that transaction unresumeable. This test will now always fail no matter what. I would like to note here that this new behaviour does not break userspace at all. Hardware Transactional Memory gives zero guarantee of forward progress and any correct userspace has already had and will always have to implement a non HTM fallback. Relying on this specific kernel behaviour also meant relying on the stars aligning in the hardware such that there was no cache overlaps and that it had a large enough footprint to handle any system call without dooming a transaction. --- tools/testing/selftests/powerpc/tm/Makefile | 4 +- .../testing/selftests/powerpc/tm/tm-syscall-asm.S | 28 ------ tools/testing/selftests/powerpc/tm/tm-syscall.c | 106 --------------------- 3 files changed, 1 insertion(+), 137 deletions(-) delete mode 100644 tools/testing/selftests/powerpc/tm/tm-syscall-asm.S delete mode 100644 tools/testing/selftests/powerpc/tm/tm-syscall.c diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/selftests/powerpc/tm/Makefile index 7a1e53297588..88d6edffcb24 100644 --- a/tools/testing/selftests/powerpc/tm/Makefile +++ b/tools/testing/selftests/powerpc/tm/Makefile @@ -2,7 +2,7 @@ SIGNAL_CONTEXT_CHK_TESTS := tm-signal-context-chk-gpr tm-signal-context-chk-fpu \ tm-signal-context-chk-vmx tm-signal-context-chk-vsx -TEST_GEN_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack \ +TEST_GEN_PROGS := tm-resched-dscr tm-signal-msr-resv tm-signal-stack \ tm-vmxcopy tm-fork tm-tar tm-tmspr tm-vmx-unavail tm-unavailable tm-trap \ tm-signal-drop-transaction \ $(SIGNAL_CONTEXT_CHK_TESTS) @@ -13,8 +13,6 @@ $(TEST_GEN_PROGS): ../harness.c ../utils.c CFLAGS += -mhtm -$(OUTPUT)/tm-syscall: tm-syscall-asm.S -$(OUTPUT)/tm-syscall: CFLAGS += -I../../../../../usr/include $(OUTPUT)/tm-tmspr: CFLAGS += -pthread $(OUTPUT)/tm-vmx-unavail: CFLAGS += -pthread -m64 $(OUTPUT)/tm-resched-dscr: ../pmu/lib.o diff --git a/tools/testing/selftests/powerpc/tm/tm-syscall-asm.S b/tools/testing/selftests/powerpc/tm/tm-syscall-asm.S deleted file mode 100644 index bd1ca25febe4..000000000000 --- a/tools/testing/selftests/powerpc/tm/tm-syscall-asm.S +++ /dev/null @@ -1,28 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#include -#include - - .text -FUNC_START(getppid_tm_active) - tbegin. - beq 1f - li r0, __NR_getppid - sc - tend. - blr -1: - li r3, -1 - blr - -FUNC_START(getppid_tm_suspended) - tbegin. - beq 1f - li r0, __NR_getppid - tsuspend. - sc - tresume. - tend. - blr -1: - li r3, -1 - blr diff --git a/tools/testing/selftests/powerpc/tm/tm-syscall.c b/tools/testing/selftests/powerpc/tm/tm-syscall.c deleted file mode 100644 index 454b965a2db3..000000000000 --- a/tools/testing/selftests/powerpc/tm/tm-syscall.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2015, Sam Bobroff, IBM Corp. - * Licensed under GPLv2. - * - * Test the kernel's system call code to ensure that a system call - * made from within an active HTM transaction is aborted with the - * correct failure code. - * Conversely, ensure that a system call made from within a - * suspended transaction can succeed. - */ - -#include -#include -#include -#include -#include -#include - -#include "utils.h" -#include "tm.h" - -extern int getppid_tm_active(void); -extern int getppid_tm_suspended(void); - -unsigned retries = 0; - -#define TEST_DURATION 10 /* seconds */ -#define TM_RETRIES 100 - -pid_t getppid_tm(bool suspend) -{ - int i; - pid_t pid; - - for (i = 0; i < TM_RETRIES; i++) { - if (suspend) - pid = getppid_tm_suspended(); - else - pid = getppid_tm_active(); - - if (pid >= 0) - return pid; - - if (failure_is_persistent()) { - if (failure_is_syscall()) - return -1; - - printf("Unexpected persistent transaction failure.\n"); - printf("TEXASR 0x%016lx, TFIAR 0x%016lx.\n", - __builtin_get_texasr(), __builtin_get_tfiar()); - exit(-1); - } - - retries++; - } - - printf("Exceeded limit of %d temporary transaction failures.\n", TM_RETRIES); - printf("TEXASR 0x%016lx, TFIAR 0x%016lx.\n", - __builtin_get_texasr(), __builtin_get_tfiar()); - - exit(-1); -} - -int tm_syscall(void) -{ - unsigned count = 0; - struct timeval end, now; - - SKIP_IF(!have_htm_nosc()); - - setbuf(stdout, NULL); - - printf("Testing transactional syscalls for %d seconds...\n", TEST_DURATION); - - gettimeofday(&end, NULL); - now.tv_sec = TEST_DURATION; - now.tv_usec = 0; - timeradd(&end, &now, &end); - - for (count = 0; timercmp(&now, &end, <); count++) { - /* - * Test a syscall within a suspended transaction and verify - * that it succeeds. - */ - FAIL_IF(getppid_tm(true) == -1); /* Should succeed. */ - - /* - * Test a syscall within an active transaction and verify that - * it fails with the correct failure code. - */ - FAIL_IF(getppid_tm(false) != -1); /* Should fail... */ - FAIL_IF(!failure_is_persistent()); /* ...persistently... */ - FAIL_IF(!failure_is_syscall()); /* ...with code syscall. */ - gettimeofday(&now, 0); - } - - printf("%d active and suspended transactions behaved correctly.\n", count); - printf("(There were %d transaction retries.)\n", retries); - - return 0; -} - -int main(void) -{ - return test_harness(tm_syscall, "tm_syscall"); -}