From patchwork Thu Apr 13 07:22:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaopeng Tan X-Patchwork-Id: 82837 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp848166vqo; Thu, 13 Apr 2023 00:27:05 -0700 (PDT) X-Google-Smtp-Source: AKy350b2ismU2AAVCaZHSCBtRN9IN7oWUCzi4mhL/ZBh5wZv/HonCcH7bAVS4SBkkN80nWYZp6Oe X-Received: by 2002:a05:6402:202f:b0:504:b324:9ec3 with SMTP id ay15-20020a056402202f00b00504b3249ec3mr1464769edb.1.1681370825032; Thu, 13 Apr 2023 00:27:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681370825; cv=none; d=google.com; s=arc-20160816; b=Yx3dRjfsrjVxvzC9h9z5KIBPL6bHylc1IEtfBMt07w+z63WI/0t8dFRzFkAcnNg0U2 X9mhYj3wgEFcaVTP/zwo2TYRFznaNrMWKvn8A71WqewPOnJdKlRGRLrq5wWJ3DdBSb6a 3Xk03ynHGTBH9nDb52tjD74B7w+agoPj/XtVkOhd+1o9vOYBDlcZZABXkYF+JY42hsnd Eyk5QlnX4yJYJfSRYKWiSUk4QUgS3fqHyrdVf1VQL543W3jJ5/8EBerLxxs1tmYuc0Hu kHEljQe6zpjsEEBeUNd866q6Z2yMyaEW7SBhaferlF18USx5rrDLnyL26yBsiKL+byZi qLGA== 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=JHqM3cHHDkhvpOJaQfb/y/hGDqM+UYhuF/3C9EyhjEU=; b=Qe3wgCQGSyzkA1hdOpRVWctaX99IfKVYgOMMG3wF+Vn9UmgJGV/Fm2+6HLRPuR+0AY vFiX3yws+TBX3EuzKNPiMtaxRbYtzZarl5ftcBuygzjPSpXPZxJ54qW1R5nvgN90eTnm RvJV7tarzFUxqpw7P6lkhRVKDBrUgFeAWOfrHmHSDEEVW4LOzhE/RBP5fKtWg98yDQDh /tnTfTuKWDeRb64I77lR/xU3eriC1OlOdB6UtC4WBuCWcp55y1Da2YdlxfPv79eKAyd9 6YRGsG8pCngzxBRAZmCsG2GKEOgxeeqXn21uWby1cbsbcjiybXVDqB3rBJUuutOxcMDs PMxQ== 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 o13-20020a056402038d00b004bf5fd5d860si1161214edv.606.2023.04.13.00.26.40; Thu, 13 Apr 2023 00:27:05 -0700 (PDT) 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 S229733AbjDMHY3 (ORCPT + 99 others); Thu, 13 Apr 2023 03:24:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229876AbjDMHYV (ORCPT ); Thu, 13 Apr 2023 03:24:21 -0400 Received: from esa11.hc1455-7.c3s2.iphmx.com (esa11.hc1455-7.c3s2.iphmx.com [207.54.90.137]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 211754C19; Thu, 13 Apr 2023 00:24:17 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6600,9927,10678"; a="92663594" X-IronPort-AV: E=Sophos;i="5.98,339,1673881200"; d="scan'208";a="92663594" Received: from unknown (HELO oym-r1.gw.nic.fujitsu.com) ([210.162.30.89]) by esa11.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2023 16:23:05 +0900 Received: from oym-m3.gw.nic.fujitsu.com (oym-nat-oym-m3.gw.nic.fujitsu.com [192.168.87.60]) by oym-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id CD97ADF1B6; Thu, 13 Apr 2023 16:23:02 +0900 (JST) Received: from yto-om3.fujitsu.com (yto-om3.o.css.fujitsu.com [10.128.89.164]) by oym-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id 083E0D94A9; Thu, 13 Apr 2023 16:23:02 +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 B123B400C07D1; Thu, 13 Apr 2023 16:23:01 +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 v9 4/6] selftests/resctrl: Cleanup properly when an error occurs in CAT test Date: Thu, 13 Apr 2023 16:22:57 +0900 Message-Id: <20230413072259.2089348-5-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230413072259.2089348-1-tan.shaopeng@jp.fujitsu.com> References: <20230413072259.2089348-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?1763045093913048304?= X-GMAIL-MSGID: =?utf-8?q?1763045093913048304?= 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 38c10a8c1814..0880575840f9 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; }