From patchwork Wed Feb 15 08:32:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaopeng Tan X-Patchwork-Id: 57428 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp75212wrn; Wed, 15 Feb 2023 00:42:40 -0800 (PST) X-Google-Smtp-Source: AK7set8KZBZ6VcE6CsRbT3tim6M0H0TgK+VSzqqIWDIR3eLHXv3/M5G1CFfhMDLkDUcMZfxU5Yy5 X-Received: by 2002:a05:6a20:914b:b0:c6:babf:e49a with SMTP id x11-20020a056a20914b00b000c6babfe49amr1209460pzc.48.1676450560042; Wed, 15 Feb 2023 00:42:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676450560; cv=none; d=google.com; s=arc-20160816; b=joT0yCOKjG9SFaw6+syp1pO8YDHP9vSAtuAxdna/Z6cbECsZ7JlhmA7KD1VP3Hh4Ud cyuz+jNE19pgYMKhBi6ny1T+DYqBDtNd0b+p1Qz3sZ5j6WrOFP/FaTtJ782/U1cfFMXe CtSzeHLRSFwoUH8rhuJJGMGt+gKgJuazyrW1HNoIM27S8e7Z76WSvAeaCdUmUw9ueWiY ZArOWvcPpgZm9DuFlLGur3vY95Vm+ymOKLunGvqcAgokUZZB5/MGhzV5L9lqn5OZLv2Z 4jmxaCZQEXH41Krqebar/RWLrl1rVwarc6oiY1xLRy888I+Wqx5Hbjw1h8Br1B3B77dJ ZXig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=wYTzPhAoPASzVpquX795fAXLMs/YFWC7OVR2RczSzdI=; b=y4PpwPU3jOcSyu4UayEC3qTTyZlTuGJnOYqE+FKZDZXzdA991fI7RgXt2q8riuw+qv UFXcpqVnkDuP2KdB6LeCWItNSZRLX7dLJ2I9ilsKDGzGTMnagADCi24i7//U9XIN53Pi lANpzXC8SmBuHQTB8fAlOcFjl0Ze8K4DSktwhtmsNiqrjKy5Z2G8FEWXVJKoAZYWGyD0 KrVrju3qevG0HXw1pyZ48XsxEll8PMgUATShQKFC537I1g96fE61Q0JmTOJV6P6c0bRo +SNlo572PvHgrTp5qED0WvT+PDPJk9dxeifdlajgZb7AJGXBW4daWBfC0saGMRI/cCxP Nh6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y7-20020aa793c7000000b005659a66d652si16703246pff.229.2023.02.15.00.42.27; Wed, 15 Feb 2023 00:42:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233807AbjBOIgx (ORCPT + 99 others); Wed, 15 Feb 2023 03:36:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233971AbjBOIgp (ORCPT ); Wed, 15 Feb 2023 03:36:45 -0500 Received: from esa6.hc1455-7.c3s2.iphmx.com (esa6.hc1455-7.c3s2.iphmx.com [68.232.139.139]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 274AA25B9C; Wed, 15 Feb 2023 00:36:42 -0800 (PST) X-IronPort-AV: E=McAfee;i="6500,9779,10621"; a="107664990" X-IronPort-AV: E=Sophos;i="5.97,299,1669042800"; d="scan'208";a="107664990" Received: from unknown (HELO yto-r2.gw.nic.fujitsu.com) ([218.44.52.218]) by esa6.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Feb 2023 17:36:40 +0900 Received: from yto-m4.gw.nic.fujitsu.com (yto-nat-yto-m4.gw.nic.fujitsu.com [192.168.83.67]) by yto-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id 42986D6246; Wed, 15 Feb 2023 17:36:38 +0900 (JST) Received: from yto-om3.fujitsu.com (yto-om3.o.css.fujitsu.com [10.128.89.164]) by yto-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id 90B46D3F21; Wed, 15 Feb 2023 17:36:37 +0900 (JST) Received: from cn-r05-10.example.com (n3235113.np.ts.nmh.cs.fujitsu.co.jp [10.123.235.113]) by yto-om3.fujitsu.com (Postfix) with ESMTP id 69252400C0299; Wed, 15 Feb 2023 17:36:37 +0900 (JST) From: Shaopeng Tan To: Fenghua Yu , Reinette Chatre , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, tan.shaopeng@jp.fujitsu.com Subject: [PATCH v8 4/6] selftests/resctrl: Cleanup properly when an error occurs in CAT test Date: Wed, 15 Feb 2023 17:32:28 +0900 Message-Id: <20230215083230.3155897-5-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230215083230.3155897-1-tan.shaopeng@jp.fujitsu.com> References: <20230215083230.3155897-1-tan.shaopeng@jp.fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757885822756954602?= X-GMAIL-MSGID: =?utf-8?q?1757885822756954602?= After creating a child process with fork() in CAT test, if an error occurs when parent process runs cat_val() or check_results(), the child process will not be killed and also resctrlfs is not unmounted. Also if an error occurs when child process runs cat_val() or check_results(), the parent process will wait for the pipe message from the child process which will never be sent by the child process and the parent process cannot proceed to unmount resctrlfs. Synchronize the exits between the parent and child. An error could occur whether in parent process or child process. The parent process always kills the child process and runs umount_resctrlfs(). The child process always waits to be killed by the parent process. Reviewed-by: Reinette Chatre Signed-off-by: Shaopeng Tan --- tools/testing/selftests/resctrl/cat_test.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index 6a8306b0a109..477b62dac546 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -186,23 +186,20 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) remove(param.filename); ret = cat_val(¶m); - if (ret) - return ret; - - ret = check_results(¶m); - if (ret) - return ret; + if (ret == 0) + ret = check_results(¶m); if (bm_pid == 0) { /* Tell parent that child is ready */ close(pipefd[0]); pipe_message = 1; if (write(pipefd[1], &pipe_message, sizeof(pipe_message)) < - sizeof(pipe_message)) { - close(pipefd[1]); + sizeof(pipe_message)) + /* + * Just print the error message. + * Let while(1) run and wait for itself to be killed. + */ perror("# failed signaling parent process"); - return errno; - } close(pipefd[1]); while (1) @@ -226,5 +223,5 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) if (bm_pid) umount_resctrlfs(); - return 0; + return ret; }