Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1703795pxb; Thu, 16 Sep 2021 13:26:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSUvWf1ZgSFO7Zb/1Ld9V9/pbFTXRCgcHr8OI7VmSL8+w+DCNF1PxA+v3X2RPWgzoPdAZL X-Received: by 2002:a17:906:1b08:: with SMTP id o8mr8257762ejg.21.1631823978465; Thu, 16 Sep 2021 13:26:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631823978; cv=none; d=google.com; s=arc-20160816; b=zgJ7z0JcUZT0aCrBhzWe9Qd7LTeTpO07iBGeFP7VeEb//krX/xP1Ch5WZCXTyKAuBT vpFx6s51IFxnTgReyXx58RX13D5MXC6uv2Wo1FNQMfRY/4/0pnPshIAtPK/wK6pInA6U 5/uHIVkIgP0Cg6DHcaWIBvBusm35nyCWcuSdD65ETE8/g8NJn9Rf3svO6JICn84sC4mt RJinn49aLLLzWElU0qTHqYcY25dXo/l9vJS8sUBNkgB6Y9MDHdksNaF32CYWpoSQK1xo q3a6nlWY8WDnAYEvwEHszjteMppk1+5hlOdJTO2fw8gwcrxZ8CvZnWthLjYXV6L3SXhE ympA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jiliigHMtQDX1BVtKklROL2lXoRkRDy+bFlzWHe24Fw=; b=u0T+qnzxF/ct5jawoUXgmAcDdp+U+eggGO5OJ7d6Ebtu3kXFOReTdjTGDSi4uVl1Gk hRPoY1wPlBcFf1iSkbQFMoE0puEgnAlVWiaEq19yr/XTr19MIOw7B1jiDxRMOjcBWnLX YWqLALpeLL8xsstGYlW7LjVnTnGxfQkmMcH5I1xSyw+1Y2evct5EvXP6TDXtypKGqGPD RiZa1QIYZTkr6bKuRBTbWJfV3XdIJd14Xz5TWS74wN4S6CsIBQBREAVvLhGnqeT9Z39K 3k2indp7OgIKCRTnzEghVRay2aEmyjnknQPQXOxyJLNEQpsJfqrwLW1uk+5fT+soVE/h kimA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="djF/8/R/"; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cy12si5217275edb.311.2021.09.16.13.25.47; Thu, 16 Sep 2021 13:26:18 -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=@linuxfoundation.org header.s=korg header.b="djF/8/R/"; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235676AbhIPQ1U (ORCPT + 99 others); Thu, 16 Sep 2021 12:27:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:55042 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241127AbhIPQTR (ORCPT ); Thu, 16 Sep 2021 12:19:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BEFA76135A; Thu, 16 Sep 2021 16:13:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808796; bh=NyYDkBj2exwUxrdJ3yy0kdAm2cAfu+ZrmkTsZjwhJdw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=djF/8/R/B7BHGk9IBR5vQWX0LTiY8cskw1t7C/OYjUKQs3Jfdd6eAUmcvars81nKq JvjYrkQvCIgUnUDU89GdxCFLj7OIPbGyRIKj+nyiGlkwd8KXEc1Lvz9lt+oj+PWJeB ASOacEcKDmfLUBLGcHtD6BiGWm41AOtNhyjBkEM0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yonghong Song , Andrii Nakryiko , Sasha Levin Subject: [PATCH 5.10 226/306] selftests/bpf: Fix flaky send_signal test Date: Thu, 16 Sep 2021 17:59:31 +0200 Message-Id: <20210916155801.749730750@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yonghong Song [ Upstream commit b16ac5bf732a5e23d164cf908ec7742d6a6120d3 ] libbpf CI has reported send_signal test is flaky although I am not able to reproduce it in my local environment. But I am able to reproduce with on-demand libbpf CI ([1]). Through code analysis, the following is possible reason. The failed subtest runs bpf program in softirq environment. Since bpf_send_signal() only sends to a fork of "test_progs" process. If the underlying current task is not "test_progs", bpf_send_signal() will not be triggered and the subtest will fail. To reduce the chances where the underlying process is not the intended one, this patch boosted scheduling priority to -20 (highest allowed by setpriority() call). And I did 10 runs with on-demand libbpf CI with this patch and I didn't observe any failures. [1] https://github.com/libbpf/libbpf/actions/workflows/ondemand.yml Signed-off-by: Yonghong Song Signed-off-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20210817190923.3186725-1-yhs@fb.com Signed-off-by: Sasha Levin --- .../selftests/bpf/prog_tests/send_signal.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/send_signal.c b/tools/testing/selftests/bpf/prog_tests/send_signal.c index 7043e6ded0e6..75b72c751772 100644 --- a/tools/testing/selftests/bpf/prog_tests/send_signal.c +++ b/tools/testing/selftests/bpf/prog_tests/send_signal.c @@ -1,5 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include +#include #include "test_send_signal_kern.skel.h" static volatile int sigusr1_received = 0; @@ -41,12 +43,23 @@ static void test_send_signal_common(struct perf_event_attr *attr, } if (pid == 0) { + int old_prio; + /* install signal handler and notify parent */ signal(SIGUSR1, sigusr1_handler); close(pipe_c2p[0]); /* close read */ close(pipe_p2c[1]); /* close write */ + /* boost with a high priority so we got a higher chance + * that if an interrupt happens, the underlying task + * is this process. + */ + errno = 0; + old_prio = getpriority(PRIO_PROCESS, 0); + ASSERT_OK(errno, "getpriority"); + ASSERT_OK(setpriority(PRIO_PROCESS, 0, -20), "setpriority"); + /* notify parent signal handler is installed */ CHECK(write(pipe_c2p[1], buf, 1) != 1, "pipe_write", "err %d\n", -errno); @@ -62,6 +75,9 @@ static void test_send_signal_common(struct perf_event_attr *attr, /* wait for parent notification and exit */ CHECK(read(pipe_p2c[0], buf, 1) != 1, "pipe_read", "err %d\n", -errno); + /* restore the old priority */ + ASSERT_OK(setpriority(PRIO_PROCESS, 0, old_prio), "setpriority"); + close(pipe_c2p[1]); close(pipe_p2c[0]); exit(0); -- 2.30.2