From patchwork Thu Jan 30 20:40:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 860932 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A158196DB1; Thu, 30 Jan 2025 20:40:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738269661; cv=fail; b=SN3grfVojyDVl7JG+4siOBEEQ9paqyPpO986BcSULPAe+qtJOwYxbOTgZsb4RGMmG0kFAfxFa6g/6ii876wPqsVb5JlsbTFsTdBcmfYjptRG/6MnERRTfzxLWXDbjh/KnlvElMU+s0dxlJrxSku2fzMxa5yJGO1vAJtOkKcXrjs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738269661; c=relaxed/simple; bh=iRA/0hkf6a/kgkw6I4c73WI2GiGtTtVmI9lePLQKUOU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=B0McEuM4RiFqJt8GOXTDKWlMxjfURwXxdTGwLSHc+5ulpDWbD9Jg253ojTV+40V+g7sM/S+C0IDcBKL8IcXgbF3vBIw7kDz/c/syoRGvKutPxyYXAaWqkhQaIKR5FgJOHsPWp0ocaQGkZIsstPquU0M1FRajtPeC6Brt74f3ta4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=iT4TF+rV; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=bOByOcZS; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="iT4TF+rV"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="bOByOcZS" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50UKHJ9Z027216; Thu, 30 Jan 2025 20:40:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=dPJtjvvQZ3Lra/UAEbGgucANXzUDJXoWlZKWCd1+jBY=; b= iT4TF+rVwlr3tcYdisEPnNJ6InyDIE/rE9LB0Pcdiie5zWxtVctCWYUfYsDc6Z5b JKIe8HZHDVEsC62KANZ8mkU0PLBgoYtge7KFuboDgJB6bAwZMwIdtyA1fI0xM9jZ QNDiggmPxjLy0zG3dYBPc2EmpCEz2Q0TwZDECDuXBQ0vXVFBWb+R/I0AYU1/3CMH FmrOR8ynogNHyXF5oNW4bfxQ3h+Nnmdh/lrVJEMC/0GB1lxsKK6dyNld9iDzb6dB AJap2hyXF7sFHPQD9063cDmghq8xyXJKjduSfNOR9e/y+pCNIsLBM2bhe8s8CiBb isYNExcgL/UFZ0Kch3rceQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 44ggaqg1u1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jan 2025 20:40:44 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 50UJ4pdr032289; Thu, 30 Jan 2025 20:40:43 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2048.outbound.protection.outlook.com [104.47.66.48]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 44gf933y11-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jan 2025 20:40:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=A5oBPzSZNZj5yuNYiOa802BKR2nkptiO3R3dYqUs0mNVqrSDzocRVV8dQ85G6bhCj/BJ4w9yBbsJWQ+H/bN8ViCyIOA865AhwG62HEopsmzUtCJU1qgOadbNnHie2AbFii9fwFkzinmgvD2ig6ZxQQg386gQt9Kpiag/CS64Gv28/m3ikLtkdYFTVxT1oohOTVCI0GuECsRtiO4GbkseZWXYzmnID8JPkpRRlD3LWgVI9QGS9LlhqvHHfQtg/wnrAOhl42QLVP53Gs4TywzCH+uGv3KPI0/IljmIMfwRz0Y20lmKPRMPU7nXpDPEY81mx7UVrXEDV/8s1nEALSv6Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=dPJtjvvQZ3Lra/UAEbGgucANXzUDJXoWlZKWCd1+jBY=; b=EDKpqQHTazcRhhRqepXjFj16cHtwWSPLp+RcwVo0eLy9B3ISAZ/jCHuCR81mf5oobc2q5FPLy8oHjtyXDpsJEd+JNhecA4FfUFY3LpYmfma70WhnICwdpT46s9zOuiCS9TWzJ2+Bho2ZLSc+mfHcLvnqXRRMGYTwoxa5Zz0F0j2eC9GrjiuD/7zDuR+5uKDbXoQIkStymC+qGPQmQQG6wRU0rBH3Mp3zxjgopRD7lzvz1nuESWLQc6mJdks2XpXxlHnbbUqVqg9Mx/VGc33E2i7x22xIn6qAaiTKFAd2oNsp3DB+Sdg+wmgSNH/EClACDYsMK4aLP9X/A/1quHmxZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dPJtjvvQZ3Lra/UAEbGgucANXzUDJXoWlZKWCd1+jBY=; b=bOByOcZSrCXPWEH7yHEcyrjfnTFyMu6YDx55E1OadJ9DzlxAxhRfIYYkI9HnZtgyZoTnuEQRwlC6jHnZGlkfl/QYtrxVnnLzm/gjex+F2oK/vekFP/zcHCS2xA3flwHxktHLge/OG8GQ2tVi79VMGnmdxujh1iQTo+cg2C6RlkM= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by SN7PR10MB6547.namprd10.prod.outlook.com (2603:10b6:806:2aa::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.23; Thu, 30 Jan 2025 20:40:40 +0000 Received: from BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9]) by BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9%6]) with mapi id 15.20.8398.018; Thu, 30 Jan 2025 20:40:40 +0000 From: Lorenzo Stoakes To: Christian Brauner Cc: Shuah Khan , "Liam R . Howlett" , Suren Baghdasaryan , Vlastimil Babka , pedro.falcato@gmail.com, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, Oliver Sang , John Hubbard , Tejun Heo , Johannes Weiner , Michal Koutny , Andrew Morton , Shakeel Butt Subject: [PATCH v7 2/6] selftests/pidfd: add missing system header imcludes to pidfd tests Date: Thu, 30 Jan 2025 20:40:27 +0000 Message-ID: X-Mailer: git-send-email 2.48.1 In-Reply-To: References: X-ClientProxiedBy: LO4P123CA0057.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:153::8) To BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3366:EE_|SN7PR10MB6547:EE_ X-MS-Office365-Filtering-Correlation-Id: 924c1ac0-c788-4100-f4fd-08dd416e5c00 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|366016|1800799024; X-Microsoft-Antispam-Message-Info: YcxMBomw8EwefaAtqIPxLNVd5EVa7sdtXbJE2xRjQZwmGVjIEW7WHuzOvlDGzyAv8+qem8fJ3+V65di555ecefzBPTDMU9MIb1nocHvZG/dwwrr0R3vBU0DvbfXlrxxsLjZ8TRgpu/46Gx0F2L5QLD4e4AwXzwFqfDa3z35ElBQyGfZ0ZBGhtVCow8N7EAaNdjRWOEjr1Yo8GeJj+4zOl0/JqwZf03/Vp+y5eRet45uYZYqeFOGtm+1ZpwrpsjXSCBlQS5dbVeev/wSp+M6RacQX5V/7nMUiJtwa48UGs/gisENoK6I5EYE4nVqfwo4Pg7XuMEbTclOtHwMGdUyKSSjk7YDiSc3T0UtMoZJJXPiMq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Y:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3366.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(366016)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: s8Di3So8K8KjftcTe/GWZ3jlLIWSJIkm/ufLWFqNla5R373pGPzXFwRYvfModDn73OejbRpYlxmCOsZlhebIRWAMAcjsHOKtqvCu2JsT+HTWDnxdh5FqWdevdMaBJAUx/ReKDhnnRwjhaTxBvI6VXuhUHg+Ag8JR+pzoP4z5amM2s6lVyYAEr5HD3ZE9WNx9ZVEC4hm0Oo2NgoFc/KgEKeh8F6l77ULMchiX2qSYmgC+fJ9MxrwVdLvuKmMNRHW/h4oigwX1xFzKPpTyHW28TCBJHvzY2LLTG+oNCmsiCnwfn2y9SwANZzFUPDHbwEBGlVWp4+URidC7GXbSCDgc+OTyVc0zQZN4TMtSz3iaG16a4JolYMViYwEJbbYu6yuxydHmxlDCvU6Rgt5RaGYHsq/UoQDUIYn02cnLLO4j3b0ntFS77sV3B7pepRtWPv55FQ8soZ1r8/0HsX46vwdjNVZNwUvV95qmCLb3ohwSuvHtdjZAcvcDOTLPR04ufDe1D6QbHAHU3rx/vpBilMjuGWpf4aDMOfjzdzB4VZvyL5FpSXAco2CESBuxfuud1xMiUgjkj0BOdLYikNiKuvqcWbBp1OSQTsg6M1RihfiPAhCPGSLyzq4gmAm8sR9sH8gft3ipxk3ISSO+9NaxqMpw+QzPDLPEt6pE6b8DiJgqjnbNJBVPdjJlnOJwWCXX2+GMBsowvjRVHfB8dEeBHKd14puAb4Ut5rc6bvLWspLZe6JLMIzQvt53CoPP208wKw4+U7cCXCvSGpECHsehGsWrOId9UbEbuTgE6fHn1nE7GYaD80UNLcbb3BsdIqlAZ92N/rOoHBRNVM0MhIfItN2fOEzRsfWv8aAn5OZWROHMEHSpgJotM6cVPwpTGC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KWGpcrphxyV8h1jyXe95yYtWAlMrkAhzBvAG1ZROdxcF5JL9IsfOTu0vc2Az3JtvQI2rw8CI493QHQ703DQNFf4HW2OIAPP9RIAmKhQCAVob0ejNh6uiCleJCcB8/QUD3FUfhkancoju+hNVGfbh2kSbT9qMlSxro3CoCRixveakXl5lEHtsGj+h7CGkPH4XNGCYoXvfyqlf461eAldAqC+k/XgGPsABEC5hqJFqSnU3DdedpPl7+uxe021U2/M5lw+okdiy++47j7t8rKy44bXNR7vW3UhI6cGPfAAWfR9DA5pHWMr+XAhzdvFlVQOWOKx5SkTD62jkJ2ahbU5sk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 924c1ac0-c788-4100-f4fd-08dd416e5c00 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2025 20:40:40.3981 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BJAKGlXMzQflyVa6TlHSHULgGIpqx0f+cnYIwsZ3P6xWNu+AO8hWGF6QUbapuI/pCYqi9jZ70TSaisPtjoqwLoSlRvaCRH84bWf3b+MnEU8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6547 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-30_09,2025-01-30_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 mlxscore=0 suspectscore=0 spamscore=0 phishscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2501170000 definitions=main-2501300158 X-Proofpoint-ORIG-GUID: UzroupIA3wow-Tie3e_ryVGE_tQOMcma X-Proofpoint-GUID: UzroupIA3wow-Tie3e_ryVGE_tQOMcma The pidfd_fdinfo_test.c and pidfd_setns_test.c tests appear to be missing fundamental system header imports required to execute correctly. Add these. Signed-off-by: Lorenzo Stoakes --- tools/testing/selftests/pidfd/pidfd_fdinfo_test.c | 1 + tools/testing/selftests/pidfd/pidfd_setns_test.c | 1 + 2 files changed, 2 insertions(+) diff --git a/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c b/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c index f062a986e382..f718aac75068 100644 --- a/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c +++ b/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "pidfd.h" #include "../kselftest.h" diff --git a/tools/testing/selftests/pidfd/pidfd_setns_test.c b/tools/testing/selftests/pidfd/pidfd_setns_test.c index 222f8131283b..a55f6641e0b6 100644 --- a/tools/testing/selftests/pidfd/pidfd_setns_test.c +++ b/tools/testing/selftests/pidfd/pidfd_setns_test.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include From patchwork Thu Jan 30 20:40:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 860930 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1F041F2391; Thu, 30 Jan 2025 20:41:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738269669; cv=fail; b=V4FxnskI8jMFxKzFVGMUVDCQI/H0kCTGXw0kUmGNY+R6o84RpGgVhY7BNyQgpkOVPD1W7erMgxRvoQeqvvin3ROdBs9OdFRF6Is8UzN6W+lZ+Nc44Uwy5W5d6C5E4D+mT69Ui78l/QdO8gWG7PexCT1HKVb3twJLQfhkqGIsM8Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738269669; c=relaxed/simple; bh=H5sZ4kJJBfU7I6JbbUYcA52nUoFS5oJF/KYpRfx0Gjk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=UJX/KjsIbXA5/+Z1Yst5bz1RYRbweoU7O3jVvQFHEEHo0sqh3I2Tb+t/GXLWJa1b0VVlShjQN7IfbePt25ZHEboEtCnt09nFHon5NmsQGmXJwN/5RaBsG6A7i0h0xrbLhIAraB+627X+FRZbS4iSWVQET8LieF5/0YvK+oPdDDI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=Ft7g8fPr; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=hS3yGOQJ; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Ft7g8fPr"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="hS3yGOQJ" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50UKH0et026817; Thu, 30 Jan 2025 20:40:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=Bk4iEJmNOs0gKjCIyK6jOaRhyYYz7iRVbjW4yL2p6M4=; b= Ft7g8fPr0hn07dsuEe9MphtGbWYQsT77SEDgmFoXA4pRYxWdybufzqdJZBPQ/Lj0 O5mE+QifF3YWv3YAcHKWO9aK2Ouu48rveN0Ov4O6e6XM5E3QrpQPp/vTXR/23NTr b79SXAXLRgLQlT3vhbow+IjSIMVuntbc3OdonmxDbPbj9d+uU9Rf1haqwVFEBrIB 4q3EEHYd4kgMB6+h5KBv5P+2GmSCQXn93UXp1bnj2b8/DQh/KVJhEAm56Jv6D8OL ++d6Ta1d7X1ujHY1K3NZ+lD/Q4DPCowvo1cjJhh8eIvfd8Qgh1Gdy44sFxZ++btq O9LAsSE9RryB6pyKr2Sn7A== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 44ggaqg1u5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jan 2025 20:40:52 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 50UJNXhp006240; Thu, 30 Jan 2025 20:40:51 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2045.outbound.protection.outlook.com [104.47.66.45]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 44gfhtk6tc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jan 2025 20:40:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=piHxRbML8qMkjDXY/3cFu/kMLrVXnSRk9bPO94SoqBJjCVEY9aFaVqSNPbSj9X5BBI0atUWP/RyPJUhoYfVzp6LUikHxoYp1gny7xFC9OIa27yULyKJEKWh4jhQDoAZasqM+Ryp3M7Lo8DBpPW/hzzkEd6H2LCFPz8PbkBzxOxfesmO1AIh2HaDeNCWoJngYEswq8gEXGMImaIxQYUi/8N5HkBqzBblNiBNpu3HEj/2Nithz7quVOEX1MkDw9ZVru4dTey7mYOTWYK3Trh6iVNQ0H9tJqhM1dSncAbL0JzC+eyYKhXEuxbSVQDTMRSdAxYm/5TjC+cmZBneFLdLeCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Bk4iEJmNOs0gKjCIyK6jOaRhyYYz7iRVbjW4yL2p6M4=; b=zJeX/fgL59OnUTOPwFNZPA+REpZavGL/XP/rbVsc9DH0PKvp0XyAv0MA52FCAf4k7UXAFgma8m/+ThcTsRclqnVExkwyy2jWZ4gCN/MoI+b6DbbDr+hwfoLxUKB0VCSySUK3cjDUcShvz8MXszQEuWnBP33fChyLkoOmvXqOWY6drJKEuM4+CY5l2oCpG012NIviB55KNhTx2uaIMxQxQgDSbXWICdviatwlYTVR5IhFEo2JEMCeIsCZ9WVtgXa5uTlYDADxx3/OyPdlIiJ0BH8D9+0GhIZyjUcg1RPuezmZMm9lzA4gMQFbEF81UT9pOuP4Tkw8dzfdSxxMNZOsOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Bk4iEJmNOs0gKjCIyK6jOaRhyYYz7iRVbjW4yL2p6M4=; b=hS3yGOQJ5k56H2UXrCj/p74sktNsUgJvZBbnlr80xyhdlXi47gz4Aar+a+gqURqZPfobnYJmKsoK6h/ewb1n6GzRjvkCWlRnDZKpsoBXTIGL0oVqTzGKLtVwhOs8+VbSqFT+AMyqf3M3GGf5XpDzmBXKKylfiYPVh5cNs4EjOWY= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by SN7PR10MB6547.namprd10.prod.outlook.com (2603:10b6:806:2aa::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.23; Thu, 30 Jan 2025 20:40:49 +0000 Received: from BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9]) by BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9%6]) with mapi id 15.20.8398.018; Thu, 30 Jan 2025 20:40:49 +0000 From: Lorenzo Stoakes To: Christian Brauner Cc: Shuah Khan , "Liam R . Howlett" , Suren Baghdasaryan , Vlastimil Babka , pedro.falcato@gmail.com, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, Oliver Sang , John Hubbard , Tejun Heo , Johannes Weiner , Michal Koutny , Andrew Morton , Shakeel Butt Subject: [PATCH v7 5/6] selftests: pidfd: add tests for PIDFD_SELF_* Date: Thu, 30 Jan 2025 20:40:30 +0000 Message-ID: <7ab0e48b26ba53abf7b703df2dd11a2e99b8efb2.1738268370.git.lorenzo.stoakes@oracle.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: X-ClientProxiedBy: LO4P265CA0072.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2af::21) To BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3366:EE_|SN7PR10MB6547:EE_ X-MS-Office365-Filtering-Correlation-Id: 3634b2da-05bf-40d8-d37b-08dd416e6129 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|366016|1800799024; X-Microsoft-Antispam-Message-Info: eJgoeI35AdpeIo9siq0kV42bzU9vaEM0IRlu6XcaVrI0p+SjU5zmRG/B4UJl0GNxfE2KOFiMlmJmqc+obdhFkI16vl1q7btYKrJVZP52r0c4muGN3YQAghQ6rK/YHQBNK0Xg7z6a7YKHtxSPpUiXnT4PO1qckWs5f5xA6PppkKE9O4yiYiESAkE6PQCZ5isYoxKz8WIC/HE5om9QEEoilD+wS62GdWLFWazRcEHMBK8/AnIhyehgN+R5zDVQv2gDt3eH5bfbLUUcuRBpSRmHo2CYcN/P+w0+VcNoyKyDji6X+Fu1hPlQoFSFRPJszPS+GLR9TKGNhJal2TYon7uFfyRbwsq9CxkDITsswQxBVxZkX7E9Tidxb/kRTRBNaCHFfKdSxq+NBe0YwQV3NnagKtTSz1Jjbuse7fqWonYYSveVqvgMLcL54uX/Az+jP0/4IBN7rmtn+p6Piuq/qntqxvM+pSsjA9FvCtNotmYulG2oykmyJv77q/4VmTkgbLZzWCeOkhg38jfFoQNM33x8yJWOIOWKsWlwgCxXiT9nS2niG0e1vJ8W3/yTl8vsbrsUx4PQ1CmiWGolDv2gjPfejble4ijd668G+9o8M4p/xrk+D98us/9ZkgtOYJlnJO4w1i0CMA20/bHOn98BAGFpP3/KSgcHPYMOgSOLQYCH3E8xDLUeXhiJoauiAjqHdRrkQhGR/R4u4Rfy+L14JZJ3HXPbJs6Lekm2XQ0DeuKizR5WzCrupVd6JfkjKf+Phhd2pwyd4H/++CxSonvtau4g9GWCKDCHnfl1P2/ucOshS9aXPnlboCPO97w5QQYKyZPvGgMZQGPh+PDQ949KzmHwxy4FQYIQBGVgAoUSxEb5Z3g8gh/q3aQLpMJQ/VW/yo8BsL51LBPk5W0o5zxGDkr0KcKwfORbYyi4kSwkJsWSnquf5j/8Bnz7teixCXfzf06xpc+d+i0BgET4r1mv/dCjr0VZVC+WtgE+QbRStAr/by4jb4YzmZfMSOIjek+IA76w0c7vGP/8FeqzVhtTSpjxQcI5kJHaFzfaNSRRi481XdHYRwe4wdB53+o6HhQjop8hvdN+7ht7HGjDdjp5QgNVMPk6eERNsvz3Dd5o1d7Phwe88zInJwdCsu18v1rUYkDMD8LX5Vuj2R2hE09X7SYZK81r43AzZnb8l1NJDN6/+MHURV7H/HXur1//lAXDCcfROoCcUXjhrco62dqH0ZIOyTljIMGKj8vEBbVeeYwEhIlasyrSksIF1Q3vQ6R8QXas+Fpwpho+4+qDvtFEwRkewVL7pnITUchrIVz+sscKa50din4q9eBHKWdzrfkj/eU+D1xRfLXGSNxe8m8HJHlKXzi/j5U+FfjBf5dNOcMY84EEzFkjbyeGB13FXkB4knTr X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3366.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(366016)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wfABsDEwsqh9BaLFFQ3I1ELdWJ8cbdCESevd1/yHV5QSKN8TpXLpB8SxDgyXbkdTVIfrymz+QzVZRBqPA82bq35Hp+aK2rpQLxk5kRQNODZbVg9pCmZRTJp0xilaxa8ksQwON9hZPn/T/yC1FooKFhTvtbXTBFl9VCN1fWcB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OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3634b2da-05bf-40d8-d37b-08dd416e6129 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2025 20:40:48.9776 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 99vuMzWRjg0R4X33wE3RdCyXTK0VwXBp655ufj129knETZL7+unesUVW7QHYTebZHqQhMQ8vyKQCXF7mtcoNyikfMQ5Ag5ML0UOmocFS130= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6547 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-30_09,2025-01-30_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 malwarescore=0 mlxscore=0 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2501170000 definitions=main-2501300158 X-Proofpoint-ORIG-GUID: 6jpQdmPgzVkG9Pnyrlra1A1ppx64t9wS X-Proofpoint-GUID: 6jpQdmPgzVkG9Pnyrlra1A1ppx64t9wS Add tests to assert that PIDFD_SELF* correctly refers to the current thread and process. We explicitly test pidfd_send_signal(), however We defer testing of mm-specific functionality which uses pidfd, namely process_madvise() and process_mrelease() to mm testing (though note the latter can not be sensibly tested as it would require the testing process to be dying). We also correct the pidfd_open_test.c fields which refer to .request_mask whereas the UAPI header refers to .mask, which otherwise break the import of the UAPI header. Signed-off-by: Lorenzo Stoakes --- tools/testing/selftests/pidfd/pidfd.h | 2 + .../testing/selftests/pidfd/pidfd_open_test.c | 6 +- tools/testing/selftests/pidfd/pidfd_test.c | 76 ++++++++++++++++--- 3 files changed, 69 insertions(+), 15 deletions(-) diff --git a/tools/testing/selftests/pidfd/pidfd.h b/tools/testing/selftests/pidfd/pidfd.h index d02cfc5ef77b..cc684d872253 100644 --- a/tools/testing/selftests/pidfd/pidfd.h +++ b/tools/testing/selftests/pidfd/pidfd.h @@ -15,6 +15,8 @@ #include #include +#include + #include "../kselftest.h" #include "../clone3/clone3_selftests.h" #include "pidfd_helpers.h" diff --git a/tools/testing/selftests/pidfd/pidfd_open_test.c b/tools/testing/selftests/pidfd/pidfd_open_test.c index ce413a221bac..9a40ccb1ff6d 100644 --- a/tools/testing/selftests/pidfd/pidfd_open_test.c +++ b/tools/testing/selftests/pidfd/pidfd_open_test.c @@ -31,7 +31,7 @@ #define PIDFD_INFO_CGROUPID (1UL << 0) struct pidfd_info { - __u64 request_mask; + __u64 mask; __u64 cgroupid; __u32 pid; __u32 tgid; @@ -148,7 +148,7 @@ static pid_t get_pid_from_fdinfo_file(int pidfd, const char *key, size_t keylen) int main(int argc, char **argv) { struct pidfd_info info = { - .request_mask = PIDFD_INFO_CGROUPID, + .mask = PIDFD_INFO_CGROUPID, }; int pidfd = -1, ret = 1; pid_t pid; @@ -227,7 +227,7 @@ int main(int argc, char **argv) getegid(), info.sgid); goto on_error; } - if ((info.request_mask & PIDFD_INFO_CGROUPID) && info.cgroupid == 0) { + if ((info.mask & PIDFD_INFO_CGROUPID) && info.cgroupid == 0) { ksft_print_msg("cgroupid should not be 0 when PIDFD_INFO_CGROUPID is set\n"); goto on_error; } diff --git a/tools/testing/selftests/pidfd/pidfd_test.c b/tools/testing/selftests/pidfd/pidfd_test.c index e9728e86b4f2..fcd85cad9f18 100644 --- a/tools/testing/selftests/pidfd/pidfd_test.c +++ b/tools/testing/selftests/pidfd/pidfd_test.c @@ -42,12 +42,41 @@ static pid_t pidfd_clone(int flags, int *pidfd, int (*fn)(void *)) #endif } -static int signal_received; +static pthread_t signal_received; static void set_signal_received_on_sigusr1(int sig) { if (sig == SIGUSR1) - signal_received = 1; + signal_received = pthread_self(); +} + +static int send_signal(int pidfd) +{ + int ret = 0; + + if (sys_pidfd_send_signal(pidfd, SIGUSR1, NULL, 0) < 0) { + ret = -EINVAL; + goto exit; + } + + if (signal_received != pthread_self()) { + ret = -EINVAL; + goto exit; + } + +exit: + signal_received = 0; + return ret; +} + +static void *send_signal_worker(void *arg) +{ + int pidfd = (int)(intptr_t)arg; + int ret; + + /* We forward any errors for the caller to handle. */ + ret = send_signal(pidfd); + return (void *)(intptr_t)ret; } /* @@ -56,8 +85,11 @@ static void set_signal_received_on_sigusr1(int sig) */ static int test_pidfd_send_signal_simple_success(void) { - int pidfd, ret; + int pidfd; const char *test_name = "pidfd_send_signal send SIGUSR1"; + pthread_t thread; + void *thread_res; + int err; if (!have_pidfd_send_signal) { ksft_test_result_skip( @@ -66,25 +98,45 @@ static int test_pidfd_send_signal_simple_success(void) return 0; } + signal(SIGUSR1, set_signal_received_on_sigusr1); + + /* Try sending a signal to ourselves via /proc/self. */ pidfd = open("/proc/self", O_DIRECTORY | O_CLOEXEC); if (pidfd < 0) ksft_exit_fail_msg( "%s test: Failed to open process file descriptor\n", test_name); + err = send_signal(pidfd); + if (err) + ksft_exit_fail_msg( + "%s test: Error %d on sending pidfd signal\n", + test_name, err); + close(pidfd); - signal(SIGUSR1, set_signal_received_on_sigusr1); + /* Now try the same thing only using PIDFD_SELF_THREAD_GROUP. */ + err = send_signal(PIDFD_SELF_THREAD_GROUP); + if (err) + ksft_exit_fail_msg( + "%s test: Error %d on PIDFD_SELF_THREAD_GROUP signal\n", + test_name, err); - ret = sys_pidfd_send_signal(pidfd, SIGUSR1, NULL, 0); - close(pidfd); - if (ret < 0) - ksft_exit_fail_msg("%s test: Failed to send signal\n", + /* + * Now try the same thing in a thread and assert thread ID is equal to + * worker thread ID. + */ + if (pthread_create(&thread, NULL, send_signal_worker, + (void *)(intptr_t)PIDFD_SELF_THREAD)) + ksft_exit_fail_msg("%s test: Failed to create thread\n", test_name); - - if (signal_received != 1) - ksft_exit_fail_msg("%s test: Failed to receive signal\n", + if (pthread_join(thread, &thread_res)) + ksft_exit_fail_msg("%s test: Failed to join thread\n", test_name); + err = (int)(intptr_t)thread_res; + if (err) + ksft_exit_fail_msg( + "%s test: Error %d on PIDFD_SELF_THREAD signal\n", + test_name, err); - signal_received = 0; ksft_test_result_pass("%s test: Sent signal\n", test_name); return 0; }