From patchwork Wed Sep 21 18:13:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 609476 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 790B4ECAAD8 for ; Wed, 21 Sep 2022 18:17:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230443AbiIUSRg (ORCPT ); Wed, 21 Sep 2022 14:17:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231136AbiIUSRf (ORCPT ); Wed, 21 Sep 2022 14:17:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2EDEA3455 for ; Wed, 21 Sep 2022 11:17:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6ACDD6273F for ; Wed, 21 Sep 2022 18:17:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1958EC433D7; Wed, 21 Sep 2022 18:17:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663784252; bh=aBVGz+eB0d+PppDzgEG+bs/DglPpA5TFJNyvW0qmRck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KTftuE5dHlO+zicA9hwG12XhFiQUKuPJoJsKFXJ2rzPZtwueEU1z6JaFVAiRi10lt 8wagfBekXwZlyHEu9LeQw1lhycxwhVjS//zSaaTavfjKpxPV22/A4SdZsOs84VjfPG IKjxVcwV5IK35aHByRO31lAcJN3TCrezz9CT9vWkQ0mPFcSS/GPzMlUaSzVORZzFsW SVdOmGQDGYvVVv9e4LkfKIw3PsTZBX4HvA47sO3IbbQsCd9wwfWEEdAYiF0sdeRDsZ DgxH/QBJcJTe9Ee6/No0CJLOb7vZ9nEVDDUIRt8EDARVkmq0bWxvNhhxhAq1bD4Nlp a/kgmbOHKVpXA== From: Mark Brown To: Catalin Marinas , Will Deacon , Shuah Khan , Shuah Khan Cc: linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH v1 1/3] kselftest/arm64: Don't repeat termination handler for fp-stress Date: Wed, 21 Sep 2022 19:13:43 +0100 Message-Id: <20220921181345.618085-2-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220921181345.618085-1-broonie@kernel.org> References: <20220921181345.618085-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=996; i=broonie@kernel.org; h=from:subject; bh=aBVGz+eB0d+PppDzgEG+bs/DglPpA5TFJNyvW0qmRck=; b=owGbwMvMwMWocq27KDak/QLjabUkhmTtkLCzEUdLFlieSerJfxmUsP7AsawiNfFUicBZLjy9aUzJ YTadjMYsDIxcDLJiiixrn2WsSg+X2Dr/0fxXMINYmUCmMHBxCsBE1p9l/8Mjx64ks4XVvk7EJ/ZXhu iKF9xcGf2eUtGqd18bPXsd1tuvMPNRZKAkz9bEoMk+azcf+lHauFyz79b0lQ3dr9+dvicg23hEeBLD rZVaKu4GSlbZ3Gf35hnsj2zjbTzUIX2sZU31lpA38/4u+XBkTaT9hvzjMtGd+9/uvWorqrgqNOd1pP rSz/J562c5ctzy32Z7dvvetqxaqQgv5ti7myY93yDg0Baje5jfplNomeLRGBbLoOeuXGGt50SdOnxj i85Jn33TI7T+zKyQ7QYnkprquGIs1nIo/N0dvrC2wvpLmW1pcs2MtveyMlVF60XlPmzUUJ20xlj8gd zlp8FZV+c/YtteEbybxynIzX8OAA== X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org When fp-stress gets a termination signal it sets a flag telling itself to exit and sends a termination signal to all the children. If the flag is set then don't bother repeating this process, it isn't going to accomplish anything other than consume CPU time which can be an issue when running in emulation. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/fp/fp-stress.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/arm64/fp/fp-stress.c b/tools/testing/selftests/arm64/fp/fp-stress.c index a5c0ebef2419..4387c3cacaa7 100644 --- a/tools/testing/selftests/arm64/fp/fp-stress.c +++ b/tools/testing/selftests/arm64/fp/fp-stress.c @@ -255,6 +255,10 @@ static void handle_exit_signal(int sig, siginfo_t *info, void *context) { int i; + /* If we're already exiting then don't signal again */ + if (terminate) + return; + ksft_print_msg("Got signal, exiting...\n"); terminate = true; From patchwork Wed Sep 21 18:13:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 608093 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93E6EC6FA82 for ; Wed, 21 Sep 2022 18:17:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230267AbiIUSRk (ORCPT ); Wed, 21 Sep 2022 14:17:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230153AbiIUSRj (ORCPT ); Wed, 21 Sep 2022 14:17:39 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE203A2AB3 for ; Wed, 21 Sep 2022 11:17:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6AE12B82257 for ; Wed, 21 Sep 2022 18:17:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E961C4347C; Wed, 21 Sep 2022 18:17:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663784256; bh=/wdRky+c8y5l3fJkLz0auwkKRLAnk4y+UX2JK1z0b2g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=po/ol3IPWt8YBOCQ1vJXV/hJOK6whpgqRs/Wl0JDxpAJbkQ+z2eBm89uzcLnAywvv 5+pu99Mp3XHyQcRU3qkXPa9/MyE/f3gRHuX4NCu8j2S3LjKAo+Z2jhgo9mFa3ReIGG nPtmuxFi5maXrFLaTm2i925Cry6bJLyzSMQ7AeXgP9jVlbzwvBwlTN1V4Zebj7mmFp +AYyFszFkYIYDy67d4TnPlRwbdcu/ZRZ6RbYtdX0AiIS82Invwup3Z4s/zpGR8Q9nE zgq3SRMjXYAXBMS/tNHdj/Te+Ae+kLr5OJ4tu7ZcFwWYFjkulNSEqCw/pZ/3cCq6sG dCHsRzPrIBSdg== From: Mark Brown To: Catalin Marinas , Will Deacon , Shuah Khan , Shuah Khan Cc: linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH v1 2/3] kselftest/arm64: Flag fp-stress as exiting when we begin finishing up Date: Wed, 21 Sep 2022 19:13:44 +0100 Message-Id: <20220921181345.618085-3-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220921181345.618085-1-broonie@kernel.org> References: <20220921181345.618085-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=748; i=broonie@kernel.org; h=from:subject; bh=/wdRky+c8y5l3fJkLz0auwkKRLAnk4y+UX2JK1z0b2g=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBjK1RXdlt6shqQ7vIW+4y9Upo6Pe000MEzEXJULCzd 9qohDaGJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYytUVwAKCRAk1otyXVSH0HXXB/ 4yEdYyrzIR1QlHgLr49Qg1Ht4wmVkHOIbipF9+PDm+CXZ9CtXwc0v+iN+Ocr+t2+mgHvM8k7wRzVh5 A8B+PC5cP0nAxCpEyn1hmReTsF01/bF5B+uGiKL450hEosRKAZPfG8ps+D6tCkKr91oWLI6RO2mcc3 wsIFZP3fJ0/qyASezrCu6uO3JZPoeZT+EXgKd5bgRBRmTBm4Ai5L8+j+cPsIaxOCLexYLMRjqiLcnK pgnEdGcvgJrAFq52qcywnYo43Kf9Nw88f5Mak0K5jy6IWJS9fRKBTCCjkXzUFXjEYIdBBZh62SFDH7 mZcsEt3stg9WEGlHWGa0syuGkqRkv7 X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Once we have started exiting the termination handler will have the same effect as what we're already running so set the termination flag at that point. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/fp/fp-stress.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/arm64/fp/fp-stress.c b/tools/testing/selftests/arm64/fp/fp-stress.c index 4387c3cacaa7..03ce3936220a 100644 --- a/tools/testing/selftests/arm64/fp/fp-stress.c +++ b/tools/testing/selftests/arm64/fp/fp-stress.c @@ -522,6 +522,7 @@ int main(int argc, char **argv) } ksft_print_msg("Finishing up...\n"); + terminate = true; for (i = 0; i < tests; i++) child_stop(&children[i]); From patchwork Wed Sep 21 18:13:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 609475 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2EE7C6FA82 for ; Wed, 21 Sep 2022 18:17:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229842AbiIUSRo (ORCPT ); Wed, 21 Sep 2022 14:17:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229727AbiIUSRn (ORCPT ); Wed, 21 Sep 2022 14:17:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23E22A3450 for ; Wed, 21 Sep 2022 11:17:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CC852B82257 for ; Wed, 21 Sep 2022 18:17:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D77A4C433D6; Wed, 21 Sep 2022 18:17:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663784259; bh=/kCtptTTWEb3AePTiK49kvfDAIqsfjXBgTxkdXkZuoQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tvyy+vdYMjjKMP/ZKpA9BIKOVeCiSgIvyqopDWASdkyslBAgg35WzcHJzntlWMr+v 9RYMSwGN7y8/8jHpL9vcVlWRsutyAxFAclbR9uYI5PFJL+LmhA5Jzg/wxItTiCoxua mYIBMlDnQWnjW7ortqQfKxsIVdahKDlPEHCjIK/hcq5F2eDz31GdO9P3zipCgkMX3n kanxN2sPZdNcPFSIXR9I5ziCZMi3TCDCW/BL7y7jGkkygWrN+6I05mVAO80hUaTlwy W/EaMTCu3G9Q3TeP9/80ESH3xT8M0OAh/OZGALVH6mbzjF0FKpQg/xg3tlvatzmecY W8DR6kZ4lnfBw== From: Mark Brown To: Catalin Marinas , Will Deacon , Shuah Khan , Shuah Khan Cc: linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH v1 3/3] kselftest/arm64: Handle EINTR while reading data from children Date: Wed, 21 Sep 2022 19:13:45 +0100 Message-Id: <20220921181345.618085-4-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220921181345.618085-1-broonie@kernel.org> References: <20220921181345.618085-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3556; i=broonie@kernel.org; h=from:subject; bh=/kCtptTTWEb3AePTiK49kvfDAIqsfjXBgTxkdXkZuoQ=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBjK1RYELy0MkuqmGPtQHXduRGLPKoxcv4c1Lgvf7bt WOAbetaJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYytUWAAKCRAk1otyXVSH0Pv2B/ 0SmfKAEzq2JtcU4oidByx+8xgLBDKk0Eg1QBbmdkA2+8CH17qO/NCZ7nLAeFV4mEOYn4XDaJKyZTmM 8GBUABCCKz/euC0kdGosBaiwMQZiMDsDnJ1+yH2yuulXB9gtU7fsuIifBB2rEn3mKcf3BrzYdkyk3i J2HBRl9WRlQkVxBGslEZyCNj38ybbs/NdQ0VnM4+JFnUdsJAARgg2Syib/+0oItgFnKaXNcWVFcNAj b6L63a5JixdXQmM4BIOQAZklXPB6RSalZ8HADcSEDedxqQDY5WOxk01cEig0n5BqSud02KzRlmUT5F Wb4Qezf/hM+I7AQ6jvBrxm9Hz+YNUC X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Currently we treat any error when reading from the child as a failure and don't read any more output from that child as a result. This ignores the fact that it is valid for read() to return EINTR as the error code if there is a signal pending so we could stop handling the output of children, especially during exit when we will get some SIGCHLD signals delivered to us. Fix this by pulling the read handling out into a separate function which returns a flag if reads should be continued and wrapping it in a loop. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/fp/fp-stress.c | 85 ++++++++++++-------- 1 file changed, 50 insertions(+), 35 deletions(-) diff --git a/tools/testing/selftests/arm64/fp/fp-stress.c b/tools/testing/selftests/arm64/fp/fp-stress.c index 03ce3936220a..4e62a9199f97 100644 --- a/tools/testing/selftests/arm64/fp/fp-stress.c +++ b/tools/testing/selftests/arm64/fp/fp-stress.c @@ -121,55 +121,70 @@ static void child_start(struct child_data *child, const char *program) } } -static void child_output(struct child_data *child, uint32_t events, - bool flush) +static bool child_output_read(struct child_data *child) { char read_data[1024]; char work[1024]; int ret, len, cur_work, cur_read; - if (events & EPOLLIN) { - ret = read(child->stdout, read_data, sizeof(read_data)); - if (ret < 0) { - ksft_print_msg("%s: read() failed: %s (%d)\n", - child->name, strerror(errno), errno); - return; - } - len = ret; + ret = read(child->stdout, read_data, sizeof(read_data)); + if (ret < 0) { + if (errno == EINTR) + return true; - child->output_seen = true; + ksft_print_msg("%s: read() failed: %s (%d)\n", + child->name, strerror(errno), + errno); + return false; + } + len = ret; - /* Pick up any partial read */ - if (child->output) { - strncpy(work, child->output, sizeof(work) - 1); - cur_work = strnlen(work, sizeof(work)); - free(child->output); - child->output = NULL; - } else { - cur_work = 0; - } + child->output_seen = true; - cur_read = 0; - while (cur_read < len) { - work[cur_work] = read_data[cur_read++]; + /* Pick up any partial read */ + if (child->output) { + strncpy(work, child->output, sizeof(work) - 1); + cur_work = strnlen(work, sizeof(work)); + free(child->output); + child->output = NULL; + } else { + cur_work = 0; + } - if (work[cur_work] == '\n') { - work[cur_work] = '\0'; - ksft_print_msg("%s: %s\n", child->name, work); - cur_work = 0; - } else { - cur_work++; - } - } + cur_read = 0; + while (cur_read < len) { + work[cur_work] = read_data[cur_read++]; - if (cur_work) { + if (work[cur_work] == '\n') { work[cur_work] = '\0'; - ret = asprintf(&child->output, "%s", work); - if (ret == -1) - ksft_exit_fail_msg("Out of memory\n"); + ksft_print_msg("%s: %s\n", child->name, work); + cur_work = 0; + } else { + cur_work++; } } + if (cur_work) { + work[cur_work] = '\0'; + ret = asprintf(&child->output, "%s", work); + if (ret == -1) + ksft_exit_fail_msg("Out of memory\n"); + } + + return false; +} + +static void child_output(struct child_data *child, uint32_t events, + bool flush) +{ + bool read_more; + + if (events & EPOLLIN) { + do { + read_more = child_output_read(child); + } while (read_more); + } + if (events & EPOLLHUP) { close(child->stdout); child->stdout = -1;