From patchwork Mon Jul 30 16:05:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael David Tinoco X-Patchwork-Id: 143147 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4251046ljj; Mon, 30 Jul 2018 09:05:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcJAo/FCvz8iBhIDOx01J9Wp0ibyOFEia2C/uXIO9jbeKjs7q0WQ5dEGdgON9HsMMu5v3JZ X-Received: by 2002:a62:1b07:: with SMTP id b7-v6mr18546579pfb.70.1532966754441; Mon, 30 Jul 2018 09:05:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532966754; cv=none; d=google.com; s=arc-20160816; b=umSAsAhxCFNvFVV1nE3UD/3m4wzqE90C/tAOIaoQZd9Oq8ZFfgt8P7u69rCsVvvORy ngXycXU9fnHKp9NCVMRJUoOgFtS093SYJ7C/UtZHTLbaJT17IzoXyDWcF6ZaUFp/fXWU Vwkhn7P12zb2U02nEnPVNmDNi6PMslEyElBnLOlH1ndAcEC41Z9J4rqfqWXcHxPd2xen kxegPhK2Ihq0MAjl7QMdxVr3E7rIGRHnFfuOEXj9u7Dyxoi4ncMVLEM2lTez55aNL7S5 JJWsbqZRWbaWTF4940wWGdG+SlyuqHhzn7nY/ATEKoJw8hZjBa0msQygr3zDCplBGRIZ zu5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=U04gvzZIH4nq8t0sikdcItNY74are8cfO7wsEHewwUw=; b=jpOx6qP0fgftPyL1BACWHMVMUL5w3aUB5giGpT+MkAbn1pIBgaPhuGVtDixUa1VrDg e9AZnMzLnvAFtxG0E2Ha4KCFk7pzxU7zuFWgM1qkU6ztK2SbfR/fU4ARpydGTy706sDQ G1wtKq4AJmh6Uap2u8hb2HltVClWhjIt10+56iUuHXXhdSBw5vyrtwUFCPqghJumGKNY yh4G19YrBHZVhq2fX+IU3HFO9rQYUUfExhngE0bOlO9P1jl1fwpPvM4smTEICf8iOx6i ERhaTxdZseHjEG5UtcwkWRrWiVVZvsWvMdK0NrS+d5pqT0JcpWhm30IX3I5rHNYZGlIE cK4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hZ16V+mR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x37-v6si10592108pgl.544.2018.07.30.09.05.53; Mon, 30 Jul 2018 09:05:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hZ16V+mR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730482AbeG3Rl3 (ORCPT + 31 others); Mon, 30 Jul 2018 13:41:29 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:34972 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727037AbeG3Rl3 (ORCPT ); Mon, 30 Jul 2018 13:41:29 -0400 Received: by mail-qt0-f194.google.com with SMTP id a5-v6so12637967qtp.2 for ; Mon, 30 Jul 2018 09:05:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=U04gvzZIH4nq8t0sikdcItNY74are8cfO7wsEHewwUw=; b=hZ16V+mRE6VpkYYJGJXjQ1EO0WFmabRXvW52RZZ3g5z1P3DiA8gZyiCI07dARUEGR3 NrUXHKYxzfsItk0esUoaiH+8uAwPRkxqbMofYmH2LuWOvpptjz+XINEZGqCHaTTuuvXi hxADe34Fo2ZJTAbEVpZSKZ6ILGIlqiNoEHvG4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=U04gvzZIH4nq8t0sikdcItNY74are8cfO7wsEHewwUw=; b=f6jJ6DHLc3hgzgHtqeFo2WcpHZdHHW1SLsnY5mU6vgO8p3I/26hvWoHo7vqs1HjZyI ZT/41CW7tLbMjAVcARQS0tgNaKD94gQ8xviohkRmYxX+2cqrw/hDWuWsY3XlnrMoQEkJ glxmhPEBl9SkDwAcPkuiRmm3w+lPFvr+uFqVqL0HMj3SYAvHRp/XCE0pGfP992Qsggfc Rgopq9KEfzZLMKBUvBhd2l733g7THQFJmohG2aRdnX7Tb4nJAaELDJNW4e8f2Jwwo+0b EbC6dmLvc0GOLw7wLQqXkNq9YivG6ybIRT+9DDxTNhxlNy2FicpIoym/rYX+pc1H/v1K Er9Q== X-Gm-Message-State: AOUpUlF/tb7MY+9s3aE3kPACT/n4P4c66563s+ZqHtAKq8ovyGefJ3vN sgbk0+tgIxDMUGi9YR26iDO/8gEHZxwdpg== X-Received: by 2002:ac8:32a:: with SMTP id q42-v6mr17315902qtg.343.1532966749204; Mon, 30 Jul 2018 09:05:49 -0700 (PDT) Received: from mobile.celeiro.br ([138.204.25.60]) by smtp.gmail.com with ESMTPSA id h68-v6sm7258974qkc.97.2018.07.30.09.05.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jul 2018 09:05:48 -0700 (PDT) From: Rafael David Tinoco To: linux-kernel@vger.kernel.org Cc: linux-kselftest@vger.kernel.org, gregkh@linuxfoundation.org, rafael.tinoco@linaro.org, mathieu.desnoyers@efficios.com, mingo@kernel.org, peterz@infradead.org, tglx@linutronix.de, shuah@kernel.org Subject: [PATCH] selftests: membarrier: fix test by checking supported commands Date: Mon, 30 Jul 2018 13:05:43 -0300 Message-Id: <20180730160543.19056-1-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.18.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Makes membarrier_test compatible with older kernels (LTS) by checking if the membarrier features exist before running the tests. Link: https://bugs.linaro.org/show_bug.cgi?id=3771 Signed-off-by: Rafael David Tinoco Cc: #v4.17 --- .../selftests/membarrier/membarrier_test.c | 69 +++++++++++-------- 1 file changed, 41 insertions(+), 28 deletions(-) -- 2.18.0 Acked-by: Mathieu Desnoyers diff --git a/tools/testing/selftests/membarrier/membarrier_test.c b/tools/testing/selftests/membarrier/membarrier_test.c index 6793f8ecc8e7..b96caa096e2f 100644 --- a/tools/testing/selftests/membarrier/membarrier_test.c +++ b/tools/testing/selftests/membarrier/membarrier_test.c @@ -225,7 +225,14 @@ static int test_membarrier_global_expedited_success(void) static int test_membarrier(void) { - int status; + int supported, status; + + supported = sys_membarrier(MEMBARRIER_CMD_QUERY, 0); + if (supported < 0) { + ksft_test_result_fail( + "sys_membarrier() failed to query supported cmds\n"); + return supported; + } status = test_membarrier_cmd_fail(); if (status) @@ -236,21 +243,22 @@ static int test_membarrier(void) status = test_membarrier_global_success(); if (status) return status; - status = test_membarrier_private_expedited_fail(); - if (status) - return status; - status = test_membarrier_register_private_expedited_success(); - if (status) - return status; - status = test_membarrier_private_expedited_success(); - if (status) - return status; - status = sys_membarrier(MEMBARRIER_CMD_QUERY, 0); - if (status < 0) { - ksft_test_result_fail("sys_membarrier() failed\n"); - return status; + + /* commit 22e4ebb975822833b083533035233d128b30e98f added this feature */ + if (supported & MEMBARRIER_CMD_PRIVATE_EXPEDITED) { + status = test_membarrier_private_expedited_fail(); + if (status) + return status; + status = test_membarrier_register_private_expedited_success(); + if (status) + return status; + status = test_membarrier_private_expedited_success(); + if (status) + return status; } - if (status & MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE) { + + /* commit 70216e18e519a54a2f13569e8caff99a092a92d6 added this feature */ + if (supported & MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE) { status = test_membarrier_private_expedited_sync_core_fail(); if (status) return status; @@ -261,19 +269,24 @@ static int test_membarrier(void) if (status) return status; } - /* - * It is valid to send a global membarrier from a non-registered - * process. - */ - status = test_membarrier_global_expedited_success(); - if (status) - return status; - status = test_membarrier_register_global_expedited_success(); - if (status) - return status; - status = test_membarrier_global_expedited_success(); - if (status) - return status; + + /* commit c5f58bd58f432be5d92df33c5458e0bcbee3aadf added this feature */ + if (supported & MEMBARRIER_CMD_GLOBAL_EXPEDITED) { + /* + * It is valid to send a global membarrier from a non-registered + * process. + */ + status = test_membarrier_global_expedited_success(); + if (status) + return status; + status = test_membarrier_register_global_expedited_success(); + if (status) + return status; + status = test_membarrier_global_expedited_success(); + if (status) + return status; + } + return 0; }