Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp733411pxb; Wed, 6 Oct 2021 14:18:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwuzMfQdsg1DlUVWMeGFrbr4WnUu1fOp8SdiELDcEEPJ9FkXsFqqYXdfO1XMcM7soCBmQx X-Received: by 2002:a50:9d42:: with SMTP id j2mr766510edk.7.1633555097367; Wed, 06 Oct 2021 14:18:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633555097; cv=none; d=google.com; s=arc-20160816; b=wUFzHgiCDaEn9TuVlRvO6zwzaW7+n5/LCnF2NhuxKI2eSOsjnKVvysh2GCoJCM4bnv YWpieheR2Y6MMyaccDFHvzgCOtePDwZ2rQtZXY/EkMMenbVO4TVb3/mtKX7YGt192dl8 Qj4D0MYCfECp200SSGyd1eO1QwJ94BS49tstzgDVQEVCHIjU02u8aDuC7asVE5OBF9uV obkYSMRPJa4OjW0Slca9YVE6mAXd07kTOi4S0BLS4N9mJACN5wZfKgergzfV8TDHddb6 9lyXdF+tfl+5w7gJVFC9nWARpk3bbMjOpslwY2CQU1EzNkfi3IOVfAmUJzI73VBDBpKE d6DA== 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=zMN0PJSw/kmUZUYUDBwwSaq1S7W29aD0DpcprY8DFv4=; b=wC54yzV71svgwZkLnCDODH+2flBq0zZBEbOOSa2cqN6Oz6Eob7nOGbjkAYhqLMx2o+ W/6oCpW2NJbkk2jOVwi8ff89O9pNrPVvT6U7jTKj89hJKIo/c7/kG6UWQ0OnTcPNWYAQ dgaEty/5B4TO09i3DIawdajSUICRAf5tSzKwfSg38Kw4tngJtfr5xUMXrIz4/ZUj64V8 yJxtoVf0R2BsI44IA/3UdNEHldkTz3DhiE0sUziCikEpr40KszEhHL1d/MMN+MaXvqDz 8Q6sxQ4SmxLvKToHFuToeh9K7uvqozktt1X5dX5JlsN/mq2ILATJKeW187ZEc9kbPjRP zkRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hE2qO9ic; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a11si5496098edf.98.2021.10.06.14.17.54; Wed, 06 Oct 2021 14:18:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hE2qO9ic; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239661AbhJFVSH (ORCPT + 99 others); Wed, 6 Oct 2021 17:18:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230060AbhJFVSG (ORCPT ); Wed, 6 Oct 2021 17:18:06 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FD76C061746; Wed, 6 Oct 2021 14:16:14 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id y12so1197014eda.4; Wed, 06 Oct 2021 14:16:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=zMN0PJSw/kmUZUYUDBwwSaq1S7W29aD0DpcprY8DFv4=; b=hE2qO9icgWR8ZPz/2jEIQl00Qag1SjF69Ny2CrM4gRr8etxmUy44XIx1agYFaTBYWU fpSn0Nf7qfJh6EdvtqjHtlLF+cm0qJkijWh+y9CNRQG1461benzB/nJxxJzkj5sonXA6 ZrlrZmIt8xvpwN+POKgybkmAbvjLBWPc8Lnqbo9lEBrKyYdf0tiJwP94hLNwmakC7Yul Pu368inQjZ+zbSWOJWEEkVgfDbB84nJ1N/3hSWqxKdxvor0jKJyfwOqbOsxgeHg0gt4b p5KCici5eWg0s2XEYHTAZQnCOmVWsuVOl69Tm3b6T5r3Bd3YpsoOW2SqMiZkcFkuc7rW BnkQ== 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=zMN0PJSw/kmUZUYUDBwwSaq1S7W29aD0DpcprY8DFv4=; b=sjenEmuqHanWu0m2YNw7DjoJwoNa0m0Rnn2djEjzJuL2yy5XscZcn0U+iQj+iCshro PKpG02O90u97fWniIKbCZmWVQhlghk/onuUOOPjRl3O9xFg6VETG+puRZbX5zyKeKeN6 jgHVTr0L8HbuWouh5evXHZJAm+ygqzFck2mW8cj+ea6D5vvK3M8A00/iPbJju/E1MVNF /ozh3XC2+NWWfZv8QKLkunmQdz7uB78MLCwDuTuWubes/uvPuVDCRNz+Pkre1Mkkl0Ex yj/dEWyE7RelNAbWeo6VXVzF85RocOqtXQKsYx8KIUrAWvPzqqF2yHyv+Nc8Gs/O2jIr 9PnA== X-Gm-Message-State: AOAM5305B/BGtAp+5MPA5D7w8F5ABDRbQ/Hwd8DlLr9JNuAMvNyPdhyK TcfXIMv/7sLY44V5Mo7tDnfbRuyABD7b23tH7Xxyhw== X-Received: by 2002:a17:906:3d22:: with SMTP id l2mr650852ejf.187.1633554972793; Wed, 06 Oct 2021 14:16:12 -0700 (PDT) Received: from ?IPv6:2a04:241e:501:3870:473a:8ebc:828b:d6c6? ([2a04:241e:501:3870:473a:8ebc:828b:d6c6]) by smtp.gmail.com with ESMTPSA id fx4sm9375832ejb.113.2021.10.06.14.16.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Oct 2021 14:16:12 -0700 (PDT) Subject: Re: [PATCH 05/11] selftests: net/fcnal: kill_procs via spin instead of sleep To: David Ahern , Jakub Kicinski , Shuah Khan , David Ahern Cc: "David S. Miller" , Ido Schimmel , Seth David Schoen , netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org References: From: Leonard Crestez Message-ID: <7ac2b77d-4633-bd3e-c24f-ec87d34b4516@gmail.com> Date: Thu, 7 Oct 2021 00:16:11 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: 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 06.10.2021 17:45, David Ahern wrote: > On 10/6/21 5:47 AM, Leonard Crestez wrote: >> Sleeping for one second after a kill is not necessary and adds up quite >> quickly. Replace with a fast loop spinning until pidof returns nothing. >> >> Signed-off-by: Leonard Crestez >> --- >> tools/testing/selftests/net/fcnal-test.sh | 11 +++++++++-- >> 1 file changed, 9 insertions(+), 2 deletions(-) >> >> diff --git a/tools/testing/selftests/net/fcnal-test.sh b/tools/testing/selftests/net/fcnal-test.sh >> index 0bd60cd3bc06..b7fda51deb3f 100755 >> --- a/tools/testing/selftests/net/fcnal-test.sh >> +++ b/tools/testing/selftests/net/fcnal-test.sh >> @@ -176,12 +176,19 @@ show_hint() >> fi >> } >> >> kill_procs() >> { >> - killall nettest ping ping6 >/dev/null 2>&1 >> - sleep 1 >> + local pids >> + while true; do >> + pids=$(pidof nettest ping ping6) >> + if [[ -z $pids ]]; then >> + break >> + fi >> + kill $pids >> + sleep 0.01 >> + done >> } >> >> do_run_cmd() >> { >> local cmd="$*" >> > > ideally the script keeps track of processes it launches and only kills > those. The original killall was just a stop gap until the process > tracking was added. That's harder to do. This is much faster and not in any way worse than killall + sleep. Some sort of a wrapper would have to added for each process running the background, for each run_ping_bg. If nettest forks by itself then $! won't work, maybe some sort of --pid-file switch would be required? -- Regards, Leonard