Message ID | 20220718025826.29148-1-lizhijian@fujitsu.com |
---|---|
State | Superseded |
Headers | show
Return-Path: <linux-kselftest-owner@kernel.org> 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 B56A9C43334 for <linux-kselftest@archiver.kernel.org>; Mon, 18 Jul 2022 02:58:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229770AbiGRC6s (ORCPT <rfc822;linux-kselftest@archiver.kernel.org>); Sun, 17 Jul 2022 22:58:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbiGRC6r (ORCPT <rfc822;linux-kselftest@vger.kernel.org>); Sun, 17 Jul 2022 22:58:47 -0400 Received: from esa2.fujitsucc.c3s2.iphmx.com (esa2.fujitsucc.c3s2.iphmx.com [68.232.152.246]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C37F8216; Sun, 17 Jul 2022 19:58:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj1; t=1658113126; x=1689649126; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=nWz9yqU65FqOTAAyCAFqZLellw9vcuTqNn7PtzRmbHE=; b=kDItVc1JGppTUAJ0kDOxgIioxcrn1l4npv7eWZ7UOvpQBtzivf/1ZPoy jmbrnjqKgaLMbVsE5ljTkuvts2827/o3B7XdS2HAzFPZ3wcTzX0Ds+z+1 f4jGOuGLCphfMNv4M5egVC7v3SLTvZoyn4qaxvHP+IDG+yLlwIF0KgD4w d8Bde6rwwt2W9iIWwq4QIjIR3+0l/M91p8N1Vxz5dsog8OBnWRunwFdB0 i9JvVgP8Y9ZgBfELYMIY5LTZYc2HiM1aI+7skSWn2QZTCJG3pBJKWNUUM GI6d6maULn+ZP7FS81hROseBe5fi2L+R+zYlK7KgkeBX4wCR7CroJhvOz g==; X-IronPort-AV: E=McAfee;i="6400,9594,10411"; a="68828619" X-IronPort-AV: E=Sophos;i="5.92,280,1650898800"; d="scan'208";a="68828619" Received: from mail-os0jpn01lp2104.outbound.protection.outlook.com (HELO JPN01-OS0-obe.outbound.protection.outlook.com) ([104.47.23.104]) by ob1.fujitsucc.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2022 11:58:42 +0900 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pe1KG80nkj+ShptGmilabnsPxXp+X16/qWQz3+RMviKQns+WnUWU7BvzVsRWuZxYjL4RwBz/Y2Pj4p1lQJAsJbBi541kkuByMMwx752Uvn7pcR/S7loE2PxNqvHs83Rp0wIiu10UJF5PLdq8cUPgCYyTkU8mgqbCwx8Ncx6IIkbF6pSSSw4FQqhvM19gF6/9UoUSzsZOBzLvNXyvEPWKkXmZAhOwUFkB5ik34CNJyo87N0hwsLqMtTVqNSkIBOCWMb+otY1qtf6lO+5XPs6agFfywn6mVf0rLoscDafpXL3GxY+ZRC2wQoK/OGwmPqneiPd7v3hZvbhW1MQZa9GE5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nWz9yqU65FqOTAAyCAFqZLellw9vcuTqNn7PtzRmbHE=; b=Va/p+PpiL+yoYAA1kufyrjg3O3B/degfp3bzfGUFQJjBOb4G0p+AG+/edaG/4NvFargad67IduhyISlWNI1Z/WCoLlS+Nm9TEAXtyzIBPEFJD51Ke9PRKEE7PzED82Sgz5JA1rsiEPd4o4K/7x0MUDa2kg6K2dwyt57w1E2inuTytUV3EZDMoXu7GyWs71s/ktMlNcnh29oOSSo+NIr868HqAzbfP0wOWuPVKi+ae80gL2TTVnkYcwa8XNGeYnaejujEi7IK6JdsulFQbHM8YQLduehJRZI3+TZjYIwlnvrGB6AkhaZ/e6AWGSaw4Vupzxp2TKpzrDCkGiUgUqdt6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=fujitsu.com; dmarc=pass action=none header.from=fujitsu.com; dkim=pass header.d=fujitsu.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.onmicrosoft.com; s=selector2-fujitsu-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nWz9yqU65FqOTAAyCAFqZLellw9vcuTqNn7PtzRmbHE=; b=H5MHjEDK0ktKDkChdGpjs+mQpi6YOtljZ+7Ti5mZpfLiERaMkcChA/y3tRjHx7iiH/tkhMslJttm3hcDQtAPoCTtr96shbonRjqLmNA89dqVLwYfP7ZgcDGcHc1WbVnBEkxk3UjgF51oDY5aBLKv4H5/BJHKwUZraY73Uyx/2SM= Received: from TYCPR01MB9305.jpnprd01.prod.outlook.com (2603:1096:400:196::10) by OSBPR01MB2901.jpnprd01.prod.outlook.com (2603:1096:604:1d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.19; Mon, 18 Jul 2022 02:58:39 +0000 Received: from TYCPR01MB9305.jpnprd01.prod.outlook.com ([fe80::8d7a:baa8:3b18:cd93]) by TYCPR01MB9305.jpnprd01.prod.outlook.com ([fe80::8d7a:baa8:3b18:cd93%7]) with mapi id 15.20.5438.023; Mon, 18 Jul 2022 02:58:39 +0000 From: "lizhijian@fujitsu.com" <lizhijian@fujitsu.com> To: Christian Brauner <brauner@kernel.org>, Shuah Khan <shuah@kernel.org> CC: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "linux-kselftest@vger.kernel.org" <linux-kselftest@vger.kernel.org>, "lizhijian@fujitsu.com" <lizhijian@fujitsu.com>, Philip Li <philip.li@intel.com>, kernel test robot <lkp@intel.com> Subject: [PATCH] ksefltest: pidfd: Fix wait_states: Test terminated by timeout Thread-Topic: [PATCH] ksefltest: pidfd: Fix wait_states: Test terminated by timeout Thread-Index: AQHYmlJIC25sNz3jw0SpQWU1Pz6Prw== Date: Mon, 18 Jul 2022 02:58:39 +0000 Message-ID: <20220718025826.29148-1-lizhijian@fujitsu.com> Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.36.0 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=fujitsu.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 9d928727-0198-4516-8fd4-08da68696a83 x-ms-traffictypediagnostic: OSBPR01MB2901:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: VBIdV98rSvclcXKruzr0Fe7xRsJ5y+8H0OPhgi/ZvaqWyA4DcR0bcOIN6Cz/DUMb+fWmF3T7p488kyVjJCyxg9FYWFm9srvIch9yUV5/60zaM+wtbhgCwI6ZFegh7K058NzHSqEwJR1Vdg6sDeLRy4MpRZPMmxVGBKtgVRmXiFcC3BZoSzCi8uV1bQuS1sy5mhrR+eQmInOmM/ZU6ddrl7q+15RnXqcNZKn7fT+ZYRz6msl/Ekyuq57CPKntFnfaVeMI9tbJOUIdRr0fg1yYerRWUyCN5Iz0d9fhT4LDTiFXaxSeguD5yKXC6m+TwYUNU/bkhcO+EKA7qk1QKBZUyJQnbYqIa0nIF9hc6zZ5zXwytEW8ipVjFsMGgJmQmgBeWa3UHrLqc8bNpJUg08uafYl9xFFqaJ7VNrnZi3rt7I3bOdMPHrSa+d2Jl9/UuXbBMPPIRCbClCVXLLZH5kp2InpegwyFjG7WWjKN3BSuR5DY1+bYkJzMYF/n7dRHipEeTZ/VrYXgqiWdbxW1i7y4lW2LzvPpVJ/eaigUnsuL1Y44R/5GhVN5LZopAEgCQqERciljSbsOJajLqRTRAmPfFATysXhGu4H3WYbvpqCRA8UIjfwlLA5rGMKgT048ISTPmZ5k2r1mQMuCDzJrHc7X94doIUUkDjFgupTdkQ18I1DeZJ5YZmhL4fUq2vz8FYF3c0Tp3l7MyoYDltiowNS1g/syRAfkQNCaFbd99PCewDuONaoTkoXQO8Sf5fewRWp6Wb+GUqSvmG0HrJLBt2v5/S0/D59EsKVRUeGHAAZR+5559Rt8oMyrVXB7GcGb57Tw x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYCPR01MB9305.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(346002)(136003)(396003)(366004)(376002)(39860400002)(1076003)(2616005)(186003)(6512007)(26005)(41300700001)(83380400001)(5660300002)(6486002)(122000001)(2906002)(478600001)(71200400001)(38070700005)(38100700002)(76116006)(4326008)(8676002)(66556008)(66946007)(66476007)(66446008)(64756008)(8936002)(86362001)(82960400001)(54906003)(316002)(36756003)(6506007)(85182001)(91956017)(110136005);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?eucgb2312_cn?b?dmIydlJNWUZNSHB1aWV0QkRM?= =?eucgb2312_cn?b?TC9GN3A3ZTdTcTB0bjkvVkR1czVyOHIyVjV0dlZONmlGb0twRC9xUmhmNE45eGhz?= =?eucgb2312_cn?b?cHM3cS9XQkpXczhweTZsMmhxV1pzblliUHplQTkvV1BsY1BvbUc5M0E5RVBFYkd6?= =?eucgb2312_cn?b?bXE1T0pxd3pNTDRQRk5jNmo3RXA3NkhIZFRTcGdSLzZNMm1TUG84WFowcE83QWNy?= =?eucgb2312_cn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pWUHgzeGdnM245UGFNOEVza2x2U3U4T0xMMlFEcEo2SWhSNy9ZbCtjTVFv?= =?eucgb2312_cn?b?cGRUQTA1anhjTVhON2ZOU2NxNzdIRGFmM2FHY2dvUVo0bE02Qlk5dE9La3ZsVExD?= =?eucgb2312_cn?b?Rm9SY1ZpSUdscHlwekxCVEh0RFJCQ2gvdFNETEt5Y21TUXc4Wm41VXNLcjFqMnNj?= =?eucgb2312_cn?b?dUFVdm94Y3ZPT0MvdDhRQWIxd01GdGN2R3ZKeGhKRXBYNEc1WHJVTDU1Q0wwRHV5?= =?eucgb2312_cn?b?YnBVS0xLN0NvbFZ1UG04WCsvQWc9PQ==?= Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-OriginatorOrg: fujitsu.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB9305.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9d928727-0198-4516-8fd4-08da68696a83 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Jul 2022 02:58:39.3739 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a19f121d-81e1-4858-a9d8-736e267fd4c7 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: W0j/N6mwx/+N1JbVaFZiCpNzRaCGrKIk56naa6hr/D2pN3uQeC/B1PRyUPhOmaUTyDvIvrweM0YTNt8wGYf4xg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSBPR01MB2901 Precedence: bulk List-ID: <linux-kselftest.vger.kernel.org> X-Mailing-List: linux-kselftest@vger.kernel.org |
Series |
ksefltest: pidfd: Fix wait_states: Test terminated by timeout
|
expand
|
diff --git a/tools/testing/selftests/pidfd/pidfd_wait.c b/tools/testing/selftests/pidfd/pidfd_wait.c index 070c1c876df1..3f7bc6517dea 100644 --- a/tools/testing/selftests/pidfd/pidfd_wait.c +++ b/tools/testing/selftests/pidfd/pidfd_wait.c @@ -95,20 +95,27 @@ TEST(wait_states) .flags = CLONE_PIDFD | CLONE_PARENT_SETTID, .exit_signal = SIGCHLD, }; + int ret, pfd[2]; pid_t pid; siginfo_t info = { .si_signo = 0, }; + ASSERT_EQ(pipe(pfd), 0); pid = sys_clone3(&args); ASSERT_GE(pid, 0); if (pid == 0) { + char buf[2]; + close(pfd[1]); kill(getpid(), SIGSTOP); + ASSERT_EQ(read(pfd[0], buf, 1), 1); + close(pfd[0]); kill(getpid(), SIGSTOP); exit(EXIT_SUCCESS); } + close(pfd[0]); ASSERT_EQ(sys_waitid(P_PIDFD, pidfd, &info, WSTOPPED, NULL), 0); ASSERT_EQ(info.si_signo, SIGCHLD); ASSERT_EQ(info.si_code, CLD_STOPPED); @@ -117,6 +124,8 @@ TEST(wait_states) ASSERT_EQ(sys_pidfd_send_signal(pidfd, SIGCONT, NULL, 0), 0); ASSERT_EQ(sys_waitid(P_PIDFD, pidfd, &info, WCONTINUED, NULL), 0); + ASSERT_EQ(write(pfd[1], "C", 1), 1); + close(pfd[1]); ASSERT_EQ(info.si_signo, SIGCHLD); ASSERT_EQ(info.si_code, CLD_CONTINUED); ASSERT_EQ(info.si_pid, parent_tid);
0Day/LKP observed that the kselftest blocks forever since one of the pidfd_wait doesn't terminate in 1 of 30 runs. After digging into the source, we found that it blocks at: ASSERT_EQ(sys_waitid(P_PIDFD, pidfd, &info, WCONTINUED, NULL), 0); wait_states has below testing flow: CHILD PARENT ---------------+-------------- 1 STOP itself 2 WAIT for CHILD STOPPED 3 SIGNAL CHILD to CONT 4 CONT 5 STOP itself 5' WAIT for CHILD CONT 6 WAIT for CHILD STOPPED The problem is that the kernel cannot ensure the order of 5 and 5', once 5's goes first, the test will fail. we can reproduce it by: $ while true; do make run_tests -C pidfd; done Introduce a blocking read in child process to make sure the parent can check its WCONTINUED. CC: Philip Li <philip.li@intel.com> Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Li Zhijian <lizhijian@fujitsu.com> --- I have almost forgotten this patch since the former version post over 6 months ago. This time I just do a rebase and update the comments. V2: rewrite with pipe to avoid usleep --- tools/testing/selftests/pidfd/pidfd_wait.c | 9 +++++++++ 1 file changed, 9 insertions(+)