Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp452912pxb; Thu, 9 Sep 2021 04:57:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdcYJMNDOoWZcJ2Pc3WIELvGxfvd/FYVrun9YxD9aXgINp2b01I+fGY9TrVwmwFfBpNPNY X-Received: by 2002:a92:6e05:: with SMTP id j5mr1942554ilc.252.1631188645075; Thu, 09 Sep 2021 04:57:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631188645; cv=none; d=google.com; s=arc-20160816; b=NL9YrJX3yyP0wqITxbtkT6xLxVvxU2i6EfveqOopg7TwMDjlJ3y2WHB9qeXATAktDB irHtXpxoj8KUPDsTmoFIG8XkZUm8oTcyjj5IteA1SD6LeRmduY6El8DlhlxAUd1fqG+V OQhLN8BglM1Q4j5CJJ49iN1Shxmka9kaahmQ4pq5VMRAa1Mon/PrdjgylNGGX/T01Vrb CqEEi09olTSJhYWMcHccZnKz4DwqohxC4sXykN+BRBrJxAEsQVrWw4bw6aDI3a/SU3dj VWc2tX3BjES35oy5cGghKSEx+SP64cNYjDHQAFyleyBy2xFRYqG78a8Jt244gXrQbPA+ aZ7Q== 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 :dkim-signature; bh=4mXLj0P+mWCq2xkxfIabJyE9APyAtt4lL7ntk5P5aJk=; b=OvWeKfU5AE9b8SU4aJoJbjbSd420QOKuehrg+OFEkIttBayCrYRIF4zj4DUO/gIIum dvjEXjQMYHqh57nW8KtyRelmZg7+pS9uUOWaUs/7raI/l9/hAb2XbjxsFDFIfYPZHeiv YTeoRNV0xIcH4Fi7AkU8GRuxWwA6MEkbJZ5RglU4D2Plrv82ubIjeEteVAsJ+k+P2xqw k7rxtRToSFMSdsfrwrfM1E+CgimWakuYGY3TrpqTyUZpq1kElOkEK2+LiPi5/n/c5Dlf /FYd83k6KvDr1HBTWSchy/hEjTj5hynLlK7AfbBPItbwbHB4eNSFQ5XR9xPyHqQa6adp kyiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eGMHqfxQ; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q11si1514509ilg.114.2021.09.09.04.57.12; Thu, 09 Sep 2021 04:57:25 -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=@kernel.org header.s=k20201202 header.b=eGMHqfxQ; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241798AbhIIL5j (ORCPT + 99 others); Thu, 9 Sep 2021 07:57:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:34380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244216AbhIILyb (ORCPT ); Thu, 9 Sep 2021 07:54:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 51239613CE; Thu, 9 Sep 2021 11:44:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187890; bh=8c/eQqw1Q4DZpbkkKK58w3TPYSvDluXMkTalTg9CsI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eGMHqfxQgOzV5bHJilCBOFViuX9OCsdxU5B8VkwO6B1O94cjHi5PNphogCRHv5y0f gN9BnGb1jo6jZeh4mCXUSP5VuP9ZYfvhCJMd3S4yNhyWHwb6Fph/wT6EzmEw2tGH0v ulUKTMQxDa72ImeGjQ9XHRNG16seG8jt6/9EGEXFx3kCch1onv3gZ9erLy50ndHGpo dFVZrLwWfbpcNUnObNp3DkvusfPjzVBqYyrLdA97C7qzok5jcwPLZNVsrrVidy5GEh UpOM76sBA/dYzZjdSa+dChm+T7KbRjFAjLHDSxRlreSLZHjhUzWnutsj8jXJolmtpq OL71cKulxqrJw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Yonghong Song , Andrii Nakryiko , Sasha Levin , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH AUTOSEL 5.14 171/252] selftests/bpf: Fix flaky send_signal test Date: Thu, 9 Sep 2021 07:39:45 -0400 Message-Id: <20210909114106.141462-171-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 023cc532992d..839f7ddaec16 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" 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