From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C52E8C433FE for ; Fri, 18 Feb 2022 20:10:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239031AbiBRUKb (ORCPT ); Fri, 18 Feb 2022 15:10:31 -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-Google-Smtp-Source: ABdhPJwqQDwxWISKZBWY0L8hGgo42UBhTa//k+554mx88o/db9mFUtSqS7l2M7uBvWV9mNbGfDmPWg== 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 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