From patchwork Mon Feb 13 06:24:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaopeng Tan X-Patchwork-Id: 56051 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2199898wrn; Sun, 12 Feb 2023 22:29:09 -0800 (PST) X-Google-Smtp-Source: AK7set9VrmoeQ7+L5N7ZqxtzjJXAIN9XLDPrpmB94o966UDzBgNDn9ULw3ytHSHU+SciCmir3dYG X-Received: by 2002:a17:902:e185:b0:19a:a647:1891 with SMTP id y5-20020a170902e18500b0019aa6471891mr1009987pla.67.1676269748973; Sun, 12 Feb 2023 22:29:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676269748; cv=none; d=google.com; s=arc-20160816; b=ecTvpv6oqYzwZOlo9ez7swPVIxea5wA+yjamzQgWBGSjgQ+KpQtPwH2wuCTYqyJMru +7T+Axn6xcjtzhD3nTS/UBp4iDyjJfnlleVjZx6a+1UCMOQF5rDUmgQHPs+Mm3DMOL9V smJ35HLjqeIlt5dG8Q/QD3lcyWQ4VYBlBjyc5KtbnLve7292uXXvmcBuTuJYbncrtJqp z1oPO71Bh4adztOrToAoKqNPvbVlPN/emm4Nsd4wuZKVaoFAUMmEI+W9fnoZge/pwVnn n/hyURjmznhj/YRs2aKTJFHqfpZOyEmPBtkS22r32YtNogqiKPgvfosYO9IdNE/6aWTT 5Lzw== 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=wJaQCw3Hll6T505oOvhfRHzwxUA0PZt+L+qFP1+c3Fc=; b=aEJEaMbIzATbkKbbsY/GvaGhwD2tgY2zSWQk6pz7ohH4NBSNs8ffRbDpes3Xily4I8 9j4/ZVugFJ/Udvjd/TACwjEnVHnNR/q12ef4y/lY6YwXvzt4rCMKW+D0/JrXI1TmVYR4 yXjutX7wFxGec3QDKC/2JYpb7XNOIxvBTuV6eCU63w4UEXNow0T6Zk6EydLN0dXeaHva FLPb0dhENRupm9QMyJV4RWiAswIOjtqqsWPqv9r98+7IxhYykWJfqINbk4uOyDYT1y/v BEdVvxXZh8pz1+qAceACdbNZ0FL3L6lM99PJA55aZGJrVZh2aeaoQMVwpR0co6/5Ai2r OZcA== 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 e21-20020a170902ed9500b0019a997e5675si2730573plj.197.2023.02.12.22.28.56; Sun, 12 Feb 2023 22:29:08 -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 S229756AbjBMG2q (ORCPT + 99 others); Mon, 13 Feb 2023 01:28:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229770AbjBMG2o (ORCPT ); Mon, 13 Feb 2023 01:28:44 -0500 Received: from esa1.hc1455-7.c3s2.iphmx.com (esa1.hc1455-7.c3s2.iphmx.com [207.54.90.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 921FFEB42; Sun, 12 Feb 2023 22:28:34 -0800 (PST) X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="106341812" X-IronPort-AV: E=Sophos;i="5.97,293,1669042800"; d="scan'208";a="106341812" Received: from unknown (HELO oym-r1.gw.nic.fujitsu.com) ([210.162.30.89]) by esa1.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 15:28:32 +0900 Received: from oym-m1.gw.nic.fujitsu.com (oym-nat-oym-m1.gw.nic.fujitsu.com [192.168.87.58]) by oym-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id E9E18DF10F; Mon, 13 Feb 2023 15:28:29 +0900 (JST) Received: from yto-om1.fujitsu.com (yto-om1.o.css.fujitsu.com [10.128.89.162]) by oym-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id 35179D88B4; Mon, 13 Feb 2023 15:28:29 +0900 (JST) Received: from cn-r05-10.example.com (n3235113.np.ts.nmh.cs.fujitsu.co.jp [10.123.235.113]) by yto-om1.fujitsu.com (Postfix) with ESMTP id 007D6404AF8A3; Mon, 13 Feb 2023 15:28:28 +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 v7 4/6] selftests/resctrl: Cleanup properly when an error occurs in CAT test Date: Mon, 13 Feb 2023 15:24:26 +0900 Message-Id: <20230213062428.1721572-5-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230213062428.1721572-1-tan.shaopeng@jp.fujitsu.com> References: <20230213062428.1721572-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?1757696228149928973?= X-GMAIL-MSGID: =?utf-8?q?1757696228149928973?= 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 child process is returned, but the parent process will wait pipe message from child. Synchronize the exits between the parent and child. An error occurs whether in parents process or child process, the parents process always kills child process and runs umount_resctrlfs(), and the child process always waits to be killed by the parent process. Signed-off-by: Shaopeng Tan Reviewed-by: Reinette Chatre --- 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; }