Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp1788615pxb; Fri, 18 Feb 2022 15:47:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJzztEJSbJX+9rW9eZ5fb1/f1iNjFmCNXU77q9MvyOYIoPLcgAgU1OKqRp6Ykmd6I9DGgZqe X-Received: by 2002:a17:906:8a58:b0:6ce:b104:6af5 with SMTP id gx24-20020a1709068a5800b006ceb1046af5mr8290469ejc.732.1645228035310; Fri, 18 Feb 2022 15:47:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645228035; cv=none; d=google.com; s=arc-20160816; b=r9qXgfCcFNpeBnuvjF/xabvuh6LvhtlISQugLi2lTnFG0xgymWxfDOPom+wz9fCx10 aZdVKesfDgewjfSxmzDQsD8MFLYP8Bz87iSp0qCIOfCPz/fknMdrp0lz/MGitVwvII26 LUb6GD+WNuDH/XacsQGGPhooCAmnIe+RtrzjuzCjy89b4guH9SxTssaUFBcam/M2fUUf 7V7ugd7xPh1v1j4VlF9A6sQ0AeJ+fdwJMhemVT1RVL1cToDUQi+9XVn35GxJ8KEVPi/K 1p7ztKVTwtGs0GiONM2eJKGaZKfJfknzYEQ9b7TDuuU6TVvPxHvbuoNidjJTj3PbLAaw cvdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=YIWJpKEENbFmbXbEyafcxIcJq6TphA9pvUdJgiZAvyE=; b=1D0gWS7DmO+FGm84tzdyDe9FAI9wYXTb2TfsC84FHFBzbEq9wi2x1s2gUGH+dwF/Om b9sZW4Pny4lijjY+PEjFFRfm4Hz11+hVF5hK0yGg14GeDK+hsNQUdxWrE6g9eH00/lDh HLN2vC9JHDfsJ+Tf/1uwvV2VPSnQrA/SsKy1Zo505Z7Ru3z/ZcGszEFgTMeayA+5Vuyt 2TrPoU0BnN17NE4qHJ4KfxhMR4ZCB7LUTyrlZkJ/VlFUeDTxxDLEMZuvLjYOHDdM3Mi6 BbHGIsP/hQ8w3qXuqU3KicBH9dJWlKfukT3nmb6uDephaTSNuA5RNjzejdaWx1wbb2nU B0Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=HlutxaM+; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s23si6296520edr.659.2022.02.18.15.46.53; Fri, 18 Feb 2022 15:47:15 -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; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=HlutxaM+; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239040AbiBRUKa (ORCPT + 99 others); Fri, 18 Feb 2022 15:10:30 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:34626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236962AbiBRUK3 (ORCPT ); Fri, 18 Feb 2022 15:10:29 -0500 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75BBA24B2A5 for ; Fri, 18 Feb 2022 12:10:12 -0800 (PST) Received: by mail-io1-xd2b.google.com with SMTP id q8so8918319iod.2 for ; Fri, 18 Feb 2022 12:10:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=YIWJpKEENbFmbXbEyafcxIcJq6TphA9pvUdJgiZAvyE=; b=HlutxaM+IbO8xNMZTBAF65o2Cc5yGGegUjfKlJS1Zty5V2H/VvESFd2K1dklflc3BZ ukF56mfOCn1pWBx/sK+pnhYEcjKzeVeHKwJr2jtw9f0lreeHxy/qdqFZz80CVvIuVNOd yKuIXBusqH+gm6OCwpgcJIb3mJakayN7ht+6Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=YIWJpKEENbFmbXbEyafcxIcJq6TphA9pvUdJgiZAvyE=; b=m45XOWuiLho19AdkiR1A//LS88P8EKiSVN7G7xPtTZJd4JzIz58nP2mJ6b701SA31c GsQpd3GO0/Th4oAfF5+PtO+NvLOoGlcGFmo0KcHE1X8x2p2bBWHsLUWDGbU+RPhdPkHK tQESybn+1SpQ9UwUvrY82dUjbMg/JI4SKC5rceslWFcdBXLrxfOYr+jqslH07TbfqVrx PYb8hUWqqLgm5CKZAauz0+96RZwu73k0nghhtq8mFLwou6wHray2ioN5rVQEMGIc+R6R ylY/xDfS2e7+TsAD9tlJ+yk2lyXHYFMqYmdEwREHYtA+wvH/F4NYZ9/qccp5+5Qdn8fw zAeQ== X-Gm-Message-State: AOAM530D3BGmn6RY6RqYcuvT2Bj3oGJR3oJKH41CWBRynECHdHzszBfL 8oWIBe14HcMzMrpfG+wVPg8rbw== X-Received: by 2002:a05:6602:15cf:b0:614:52d4:952 with SMTP id f15-20020a05660215cf00b0061452d40952mr6527679iow.185.1645215011808; Fri, 18 Feb 2022 12:10:11 -0800 (PST) Received: from [192.168.1.128] ([71.205.29.0]) by smtp.gmail.com with ESMTPSA id y6sm4213205ilv.3.2022.02.18.12.10.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Feb 2022 12:10:11 -0800 (PST) Subject: Re: [PATCH v3 1/5] selftests/resctrl: Kill child process before parent process terminates if SIGTERM is received To: Shaopeng Tan , Fenghua Yu , Reinette Chatre , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Shuah Khan References: <20220216022641.2998318-1-tan.shaopeng@jp.fujitsu.com> <20220216022641.2998318-2-tan.shaopeng@jp.fujitsu.com> From: Shuah Khan Message-ID: Date: Fri, 18 Feb 2022 13:10:10 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20220216022641.2998318-2-tan.shaopeng@jp.fujitsu.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On 2/15/22 7:26 PM, Shaopeng Tan wrote: > In kselftest framework, a sub test is run using the timeout utility > and it will send SIGTERM to the test upon timeout. > > In resctrl_tests, a child process is created by fork() to > run benchmark but SIGTERM is not set in sigaction(). > If SIGTERM signal is received, the parent process will be killed, > but the child process still exists. > > kill child process before parent process terminates > if SIGTERM signal is received. > > Signed-off-by: Shaopeng Tan > --- > Some important feedbacks from v1&v2 are addressed as follows: > > - Change the order so that current patch 3/3 becomes 1/3. Since without > the SIGTERM fix, the test would hang if run from the kselftest framework. > => I changed the order and the SIGTERM fix now becomes patch [1/5]. > > - Describe that the test is run using the timeout utility and > it will send SIGTERM to the test upon timeout. > => I updated the changelog to include this information. > > - Describe changes in imperative mood, and address this in all patches. > See Documentation/process/submitting-patches.rst for more details. > => I described all my patches' changelog in imperative mood and > deleted "This commit". > > - + sigaction(SIGTERM, &sigact, NULL) || > This snippet is preceded with a comment that describes its usage > you could also update it with the expanded use of the kselftest framework. > => I don't think it is necessary to add other comments. > Since the current comment already states "Register CTRL-C handler for parent, > as it has to kill benchmark before exiting", So, when SIGTERM comes, > the benchmark(child process) should be killed before parent process terminates, > but it was missing. > > tools/testing/selftests/resctrl/resctrl_val.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c > index 95224345c78e..b32b96356ec7 100644 > --- a/tools/testing/selftests/resctrl/resctrl_val.c > +++ b/tools/testing/selftests/resctrl/resctrl_val.c > @@ -678,6 +678,7 @@ int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param) > sigemptyset(&sigact.sa_mask); > sigact.sa_flags = SA_SIGINFO; > if (sigaction(SIGINT, &sigact, NULL) || > + sigaction(SIGTERM, &sigact, NULL) || > sigaction(SIGHUP, &sigact, NULL)) { > perror("# sigaction"); > ret = errno; > This looks good to me. Reviewed-by: Shuah Khan thanks, -- Shuah