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: 10549257 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B0A714E0 for ; Mon, 30 Jul 2018 16:05:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A46628722 for ; Mon, 30 Jul 2018 16:05:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0A0B2A2FE; Mon, 30 Jul 2018 16:05:51 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 8941828722 for ; Mon, 30 Jul 2018 16:05:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726722AbeG3Rl2 (ORCPT ); Mon, 30 Jul 2018 13:41:28 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:38562 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726758AbeG3Rl2 (ORCPT ); Mon, 30 Jul 2018 13:41:28 -0400 Received: by mail-qt0-f196.google.com with SMTP id y19-v6so12635856qto.5 for ; Mon, 30 Jul 2018 09:05:49 -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=SQ95MpbnluX7FpN6Ih5M/ItTJHqPzaB3sZHJFrabZyLAeAivtKH9IcksKQ9gkIbH9t OvJjIKnXnusQB8FTPxtzQG1WthoaWwdgnEXDRmXCqgF9QMe81n1S2uwJqYQi6tWCZsrp 2Qx0HeMN2aeCgmBrjfJYPr59NBmq1cN7c8KZwpDVVaOCmzUqzG8YFWQ94CjTeQUI7Zn2 B1uiMuKmhJPUjwWf5Mfx+Vlvzk1yLPvAwI1bvupzEg0ygHpuOmjl7gpcyYWc2xxTZuuB U63G62EGgo9r7uFZTeLUvudaAiIfYht8KWxsrXBNg8qirG8WtStyOySP6VFhW6+9DIHA LdXg== X-Gm-Message-State: AOUpUlENzQ62dLTfyXVbGaXRs3k6GGhBTnKLCT5FqcuP3XN4uzhnS4PT xgZV4zFTXweA8jyp2FkT+/eNyQ== X-Google-Smtp-Source: AAOMgpd2p1KQUUWztvc2LHynkdg0LnP47ke2N1bYnwtqjQypdZ7bUJtsA+UgB32CNN1LDERoWNtXtQ== 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-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Mathieu Desnoyers --- .../selftests/membarrier/membarrier_test.c | 69 +++++++++++-------- 1 file changed, 41 insertions(+), 28 deletions(-) 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; }