Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp7360908rwn; Tue, 13 Sep 2022 19:27:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR6GAPwllVjOO6e3c/mzhyUF3LMss7Fn+zEHKbnishbPr2qYp2ZLnHzZMBrstqtUKz9bKDTQ X-Received: by 2002:a63:68e:0:b0:438:e83a:c35c with SMTP id 136-20020a63068e000000b00438e83ac35cmr12322132pgg.312.1663122449229; Tue, 13 Sep 2022 19:27:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663122449; cv=none; d=google.com; s=arc-20160816; b=zrJj/iIjBGFgJmzlMun5Ebr6axpkQN3WAUGNjih04b+Tzio6QYUmHZwzFbMtHC2OnI j6yV+Ry3FgB8TxuCA/OE66SFU8vKBtE+FPZ3vFPY7NOcN6dLv1zyM6eT592DfnX509cp n0aAZqNgC+9RsyhUqVuoTknukdpUToqSi7tbKDV4u+TyNQ56HY7RgEkJE1rJ2ui0YaZz is8Zn2haFehgFa1FNrW5um3xSPm+7ui1/6pgMFXcdZo1fzAmTubALB8SjOS8r3K++8D9 RWjTWMRC2HWxuVcDSgGK1XE7Di3N8O4gUtf3JxmtayTyofI5EChRnCey/zdBHbhTBYvj VdBA== 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=sMDi5Guv3Z4SIce/+/id+5+ZKXVs97VfFEtGrVZLgAM=; b=b+43t2ztvkrgUY0Xgx+E8dKc2dv3TX4n/kXJXcx2zldSinqqyY+rMXS/E07pdwMdUG SZP9KH63IZQiQC7nYlnEKpqQaZ9fhwM/46RgjGIIag4edr6+KpygQ45JNAcbTYalmQLC GokYN0tLfKnkprQX/9TR5cVF7Cm9cHxIugwkUQplCdiOEXo+J4So7jSjFctzaBceK0IQ 8rfA9DfZqYslMokXn65j77IvcYVIGyyQCRlkcZv9zHtgjk7wd0PMhTY4E5KTvTgMalOj KaGz8n3km8yBCCNBVYbMqM+YOOq/yLvgWvuUF+W7w/6tBpwvjB6fqGkX+2WU+t00zx3c ytRQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jd12-20020a170903260c00b0017669d005casi1347143plb.595.2022.09.13.19.27.16; Tue, 13 Sep 2022 19:27:29 -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 S229911AbiINCSr (ORCPT + 99 others); Tue, 13 Sep 2022 22:18:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229637AbiINCSq (ORCPT ); Tue, 13 Sep 2022 22:18:46 -0400 Received: from esa9.hc1455-7.c3s2.iphmx.com (esa9.hc1455-7.c3s2.iphmx.com [139.138.36.223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46077564D1 for ; Tue, 13 Sep 2022 19:18:44 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6500,9779,10469"; a="76604947" X-IronPort-AV: E=Sophos;i="5.93,313,1654527600"; d="scan'208";a="76604947" Received: from unknown (HELO yto-r2.gw.nic.fujitsu.com) ([218.44.52.218]) by esa9.hc1455-7.c3s2.iphmx.com with ESMTP; 14 Sep 2022 10:55:07 +0900 Received: from yto-m2.gw.nic.fujitsu.com (yto-nat-yto-m2.gw.nic.fujitsu.com [192.168.83.65]) by yto-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id D6F41D6252; Wed, 14 Sep 2022 10:55:06 +0900 (JST) Received: from oym-om3.fujitsu.com (oym-om3.o.css.fujitsu.com [10.85.58.163]) by yto-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 2C70FD35C1; Wed, 14 Sep 2022 10:55:06 +0900 (JST) Received: from cn-r05-10.example.com (n3235113.np.ts.nmh.cs.fujitsu.co.jp [10.123.235.113]) by oym-om3.fujitsu.com (Postfix) with ESMTP id F031F403E0598; Wed, 14 Sep 2022 10:55:05 +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 4/5] selftests/resctrl: Kill the child process before exiting the parent process if an exception occurs Date: Wed, 14 Sep 2022 10:51:46 +0900 Message-Id: <20220914015147.3071025-6-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220914015147.3071025-1-tan.shaopeng@jp.fujitsu.com> References: <20220914015147.3071025-1-tan.shaopeng@jp.fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 After creating a child process with fork() in CAT test, if there is an exception occurs, the parent process will be terminated immediately, but the child process will not be killed and umount_resctrlfs() will not be called. When fork() is used in CMT/MBA/MBM tests. If an exception occurs, before parent process exiting, the child process is killed and umount_resctrlfs() is called. Kill the child process before exiting the parent process if an exception occurs in CAT test, like in CMT/MBA/MBM tests. Signed-off-by: Shaopeng Tan --- tools/testing/selftests/resctrl/cat_test.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index d1134f66469f..f62da445acbb 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -186,11 +186,11 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) ret = cat_val(¶m); if (ret) - return ret; + goto out; ret = check_results(¶m); if (ret) - return ret; + goto out; if (bm_pid == 0) { /* Tell parent that child is ready */ @@ -200,7 +200,8 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) sizeof(pipe_message)) { close(pipefd[1]); perror("# failed signaling parent process"); - return errno; + ret = errno; + goto out; } close(pipefd[1]); @@ -218,11 +219,11 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) } } close(pipefd[0]); - kill(bm_pid, SIGKILL); } - if (bm_pid) - umount_resctrlfs(); +out: + kill(bm_pid, SIGKILL); + umount_resctrlfs(); - return 0; + return ret; } -- 2.27.0