From patchwork Thu Nov 28 11:37:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13887916 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D9E5D690FD for ; Thu, 28 Nov 2024 11:37:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9F6FF6B0083; Thu, 28 Nov 2024 06:37:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9A6026B0085; Thu, 28 Nov 2024 06:37:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D2236B0088; Thu, 28 Nov 2024 06:37:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5AF0E6B0083 for ; Thu, 28 Nov 2024 06:37:46 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id DBB03121BCF for ; Thu, 28 Nov 2024 11:37:45 +0000 (UTC) X-FDA: 82835304048.02.A5B7CB3 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf20.hostedemail.com (Postfix) with ESMTP id 55CBF1C000D for ; Thu, 28 Nov 2024 11:37:34 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=AA7wcMkH; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=kxOYqtjo; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf20.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732793858; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=Bz4o8lxrezFtawmh1FzMWrNtgUynmFS1bW/ByXlc1LE=; b=3HwhGyHAcHIdsHB8HWRr83RxJMWjal17goV2v4AJ4muGTS+ORiJ5xjYC0o6eIraplQ9VD4 +6tn8oirR2R8x3kaqTIK8g598RyHqt9s1oSn4MbYpljazNmpZhcrOUkZa/ivGVQAH3UFZ1 gFIaSQ56xdGG/cOyPkPIlvwBsAa4V04= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1732793858; a=rsa-sha256; cv=pass; b=vP8dfumQlcZbAqYEAVf38xxs8qatiBTTjRET/QqK/KpzGaLJ2UK03BkkCP0plQ+i5xdfoH +OJEtbTLBhDNdTaz25cMSGAnEnH+l0s5zJaGrIUszBT2JL1GFQdD4mROWg6ii9pFUpObsv O9/369HvNQ0feZxuJorrieQYRyY47o0= ARC-Authentication-Results: i=2; imf20.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=AA7wcMkH; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=kxOYqtjo; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf20.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AS3thB1027535; Thu, 28 Nov 2024 11:37:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=corp-2023-11-20; bh=Bz4o8lxrezFtawmh 1FzMWrNtgUynmFS1bW/ByXlc1LE=; b=AA7wcMkHTDvgeHp0Yu9K+7yWxaC8AcrW YVOV7841T/d6x3xH+ZT4n+hILFlqWkrhi5NO97zoB1os7zyO/bcacT4FboOS01dY FcaQsa5Q9vQ1esijoA1OVs+OQjnhk0JSv1Kh4NUYMgwlXd6yjM2PsJ+Wbw257Z5g xOFHqx4mzOyQERJWQRRLFZEksErOohVbkZEpUGuw9jswr2qjZEIsUyHWbOToGjpt 0rveqHpfm5z54WhhtU6smgOVX6ytOb9BCjyRSU7pqfw/1YXX0ewBCG6lMMC2jxkd er32gQ9EoMtGMiABrJDa3J3iou0i2Zq1OlAXaxMvCLIaoi/lLebreQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4366xw9qqf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Nov 2024 11:37:25 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4AS9jU8i014263; Thu, 28 Nov 2024 11:37:24 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2048.outbound.protection.outlook.com [104.47.70.48]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4366yygxnj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Nov 2024 11:37:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZVk5jYmxVZYPmLmB3yGvY5ySgp3mn1+NdrLWviVo+b4hdyYUcJ2GtGkkA4Jjs2efT5YWDE8AuQSU0zKlYGE7G1h1SanWykRNyziyT+uwV/hahszcC+tLMITnA70O0xs8r+SFJeaf1TBV6CXMJ434Ew+DKDBwSO3iL4ldzxVCNSXpWUPvhYk2AV3Wybo3P18yFHXLJposcImzbTul6HS/cJal29mmxRvBPH02SK3CuC6ichaHG0sIafp1RglCtr0b7Y2YXyqYIy5BOPhHpWmhyNPvVctcC5LzLJYOnkTpa15UN0q41up8GQAJL8F7x/j3TQIUPoN5T8A0oShyJiw85Q== 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=Bz4o8lxrezFtawmh1FzMWrNtgUynmFS1bW/ByXlc1LE=; b=s9HfdHOJ58aZwopZOgbDURG4rv4lJlTu5gkxBx3rVIGqqsYKwAY+RS0dXQWqoLNAQo44RqD91/BKScWGD+VhEeB1UnLVoMGkykU8gxYe9ThkWJdKqUGym1x3cWkvS1cIwC/G6kGaQCAHEFUc/fWals2fNZ/qo3ihwZz6oxgESO9Bg8ZZ/gKGMRsBfmhPP6RsYr1S8ziRH+L5LNWnXiPJFhMsYYUQ8wdK/1q5ADL0x/jK9Z/tgx4FrsgUs0m/ZZX/tr4/MAGIml2ruiyayxEJnr93/Yy6QIOM1Uom1KyeDjAOHbJCxfk0dhjKC+PpQc6JfdEuFRd/w+3wMkL6q7Bpog== 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=Bz4o8lxrezFtawmh1FzMWrNtgUynmFS1bW/ByXlc1LE=; b=kxOYqtjod+XBGd2Wnk+H5jJAuelKJhz9RCZL1VJSIJF/LF45KG5vtKd/9S6EUkAOb1nVcEEsR8HjyhSPbRiTU9XY74uZr/gtZvN+N/JacTO0hJqkok7cVPoAH3C70VLGoU1hS8npfhUCWJi6pkRM+E2J3iGOLTRx435x++mrjZA= Received: from MN2PR10MB3374.namprd10.prod.outlook.com (2603:10b6:208:12b::29) by DS0PR10MB8104.namprd10.prod.outlook.com (2603:10b6:8:1f4::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.13; Thu, 28 Nov 2024 11:37:22 +0000 Received: from MN2PR10MB3374.namprd10.prod.outlook.com ([fe80::eab5:3c8c:1b35:4348]) by MN2PR10MB3374.namprd10.prod.outlook.com ([fe80::eab5:3c8c:1b35:4348%4]) with mapi id 15.20.8207.010; Thu, 28 Nov 2024 11:37:21 +0000 From: Lorenzo Stoakes To: Peter Zijlstra Cc: Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Matthew Wilcox Subject: [PATCH] perf: map pages in advance Date: Thu, 28 Nov 2024 11:37:14 +0000 Message-ID: <20241128113714.492474-1-lorenzo.stoakes@oracle.com> X-Mailer: git-send-email 2.47.0 X-ClientProxiedBy: LO6P123CA0027.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:313::19) To MN2PR10MB3374.namprd10.prod.outlook.com (2603:10b6:208:12b::29) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR10MB3374:EE_|DS0PR10MB8104:EE_ X-MS-Office365-Filtering-Correlation-Id: 878543cd-2fc3-463e-f4b8-08dd0fa1059d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|7416014|376014; X-Microsoft-Antispam-Message-Info: e1go6UCuCmg8WTUaj6pBgGlRJJaIt+yxhQDRxWQ92vGhgK2m58tzmcXack/Py1nD4Nr9vDHV/uNmCr2HslJetmv9LRDajrDgDrr9FyVAHJhoQeEAXdBJPSADsPciMpO84SR1n4QvGS6fEOa648P77X8TkYdlQxRfWAIOnRkKmAOx/YXjqyKiiYR8BqtdHYmAeuDoXDqqOYWNH1RFVG2lZm77/FiLz5ZkcJ3xF6/VGRUSh2cgzpkufvd1cZeq6cJ0dOj1mhrRl9K+93PVQLss8BxnDoYwPZsrdGB8zb1jJRQI2dWAMy/mJ6F6IAz4fJ6k4JPEEYW7iTA3JBI8scHmPWYxuzim85GSZvZECdwwSS7FOmQ16XCmg3aX17uy5HAv6nTVWEZojDx0cXL2hOZEWe3JCkYvDGJouNa3wZPIrSMC2oUJ66y93vjdDapW2DpSRzZHR982jiyVmEK1NzMc6o1GA/krNxeVn2XTwYXi9vUycEkhqYnwV8awCfJ4gLkfD3wXTk4z8mskoQyCE67Nl9aP7cPIRixVEW57pOMYFRLlf4ee++JwkvrvlEP3rYXCdzSmJtU0VIoUgV1vsBWpVMQ1xXTUaihl/tI7rul6r+ZClSnprdYR/SymFSdRqOzghLYktUTbKMfbUL/kXTDst0MO1XoVVjbvSIvfC+L6SeDmiL8hMB0WR6MeUDnHMYjCX6BuiPTvkhhb1UDTS6L5x6M9CSPn9bKrfJk5Z5GEYFNujrlAbgnBr+heOMCtXXVCLNXTN+VcrwKo1dwPADlzzOE0gFOkjDcfjrHumcfSGUiIfRc1jvX7fLKEfH6OdNqrYPeoVw/U3p8WCoOrXOTSddkEURzCKhAIE4b4Do5NxjRrAv2M1MCRDxVsp4orSdDl7wxIbKQXLoicj5R9BXgxnqJLH5Uo9RbzihOi+Ry0IcfUP0yzN89bsg98sFxGnwlgrA42S7s9Dg6I86f0y6LCM88woycnqHIS6YNO94Buk5hSIEm6ZeHb2x9jhTndC+h0UrE/0WDXs+vg7UPIOjmrTbRB5ZMF8qwhgwDMTUt6YwYLayhpCPLdtbkzbSbWmoXCsmsCw1BWkFUhFjtPcwRdsR0GprzeI5efSPJkDLm3R+sMa8FnfN55XR+scih6aYGJTGAqEKk0yD2/1JAk49KQXR1kWnM3ncppyycTLX8RTDRAGMn1sIVxIK9UKtmpWs4ScRkPy5QBatbfpzZbNucIyuPtgrsJbOH/WvATpRkc+KKxMgpHfwIrTPtq2ztJNknep+cCDn4/6VXpQJbrV/4s6LDsOswX3Zuf95lthT5IrWYu9X301dcextOP7auz8XwbTtnK0lmV7WMGDlQSOFJNWA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR10MB3374.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(7416014)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cRsQxlW0eVy7I70M+CEZuL5h5QIDmq10ee7cwV7RWfsVNXuFU/UXzHq+Iy6PauRM4HmvyqyAu6tAx5rSu8NgX6sDGRv7DeBcj1A9BwSvawT6M1WSmAB5/dryYMPa2YsxV/uWVbqjwrG0+sq7SQdG3XU1oM7G6vIec/2ItnEJU0wcT0YcZmusHhtj4/yLvRuy+VPrPB8mt+BMN7gp5b6al5nuG5uaBOlVOFbUnIeX2sFP+nOF1S2aXfcTo8uqBNZVkLU0EhP6ofkqDtML+A3AUXon9OU/ilUHqSEkPggtNUkbHZAM4YOkZZs6l5Y7E6nnlosyX3NHINwTTocAOGw3Un8uiG6T1WKFyUtXGB8P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lYl51MdAe8vn8Emhbl0m1CBbuwQ1OrviUbSXPfVl/MIyEjx3t7JN6OARGpz5M64YHwKFxq1+E3Ep9kptzqgiXqrneh5zru313mGMKy5wwi8EO+yXXirmYAQfHibB3DcxubKbLm1Hp+mP+dRJ118G18HRnsiYiEgH4JebgBEVSgiA6Upi22GvgPA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: mEuPSLsoDzJ7w5l8WJBFhPcDQLszDvJmZHB7kB+JRtu0ne3Lmp6HCxIDyMdzFMZt1U2YXNXjsoTMqlZXO1saO4lQwh8oHF2A3kSwbvhdSGvUwdbYKntlZCLGXW5nBEeAtMVuqe84WtThU/lahiUgD6TMLxX688pMWKXBb789B0Hvs08yCmyI6wbt+vhu4/cA4w6oGYxWmD3h14pEDeMj5CIChgoxLd00ti9HydS/ggHSRAZdxHjZltOParRfw20By7wVF2v7lC7BSeBo6kSbwN9mr3oQ07l2lFiR0VGiXseFMCc1VJhI2JMu4JpedDXRChJClPf2uA9X/KYwTh7fM+9f0qnyxVvm1QJ2iYT5mJ4YiyZybwaDAtdCPyFRP3AqEE5ebwS8I+hv/GcEejgcZ9UawxULxN2zOiOkBGE6JaeDTUSVCeAVAtbcuJsr6V3PQKZqInHWI19iIkzdyGmkgqr5zqdP4h413GTAXg5DtBqpOnHwZG4c62HlzjsUTnKvxfkLGCmF1aoDG6ftt6bG074h540G3IKjrxVGtyOt55CHhGKaxhB2tXRZigYVgdAxI7pON6OAq089xb92GlZzjWhVmNd9WQq/u8uiBZCx/Is= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 878543cd-2fc3-463e-f4b8-08dd0fa1059d X-MS-Exchange-CrossTenant-AuthSource: MN2PR10MB3374.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Nov 2024 11:37:21.8080 (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: dUYxwjVYBFOCW9GkQa7HdOYVJdqBkfZ8pmeDTGwKHd/VqgCalsh5O21hPrRPZ0qwYWPdKFPQYiZB6XPcfhfz8VXX4RCse+1L+KdEwpVApc8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB8104 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=2024-11-28_10,2024-11-27_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 suspectscore=0 spamscore=0 phishscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2411280091 X-Proofpoint-GUID: RK2dz1GIdFwwK2mZrgu57Hyamu3HADvj X-Proofpoint-ORIG-GUID: RK2dz1GIdFwwK2mZrgu57Hyamu3HADvj X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 55CBF1C000D X-Stat-Signature: incc5e6rzd3tuhbdnqnxejhmc8hoqbbq X-Rspam-User: X-HE-Tag: 1732793854-658339 X-HE-Meta: U2FsdGVkX1976ztf1uo/l7VScyZAAhqW/YpN50h5BZOBthE3KMXzd86pw0zJCgIYzGMjJHAOEQFQkJz22Gk6cPzqEP3DKzwOs+8ARehU8yvWi7wYQ4YHVoY58Sod/pWnLUT6vXr3MonUKXp7zGgqzppBT4jOZ4Q+bS/SyKBIuSb5OLuYZGrJ7JDgucVYI58DMnO7AJr/QFMuulzilbnMZ1c4zW/sm7YD7U6WbezvUpVHJsC+Cc/5/jhEvzoTn9afAxDGpkXY4CPDI3o8C3yArvr6H7YYJP98bXVJstY8Nb3PJupgJycU6km7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rPkx+cTq/ve5+UDEzyh2anKGtiUHZfqzibDUl4r/yvtoBzF7OY5+pkkg4Y/3V8UZIHU+js8h8GSZn/kO2xTDDNl5x5fioajIi8TL5aH72DBMdsUeuoCJt8eQsCUdhsngBT2TKb0YCfeuB3c5+aj7kO2zjhQ9A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: We are current refactoring struct page to make it smaller, removing unneeded fields that correctly belong to struct folio. Two of those fields are page->index and page->mapping. Perf is currently making use of both of these, so this patch removes this usage as it turns out it is unnecessary. Perf establishes its own internally controlled memory-mapped pages using vm_ops hooks. The first page in the mapping is the read/write user control page, and the rest of the mapping consists of read-only pages. The VMA is backed by kernel memory either from the buddy allocator or vmalloc depending on configuration. It is intended to be mapped read/write, but because it has a page_mkwrite() hook, vma_wants_writenotify() indicaets that it should be mapped read-only. When a write fault occurs, the provided page_mkwrite() hook, perf_mmap_fault() (doing double duty handing faults as well) uses the vmf->pgoff field to determine if this is the first page, allowing for the desired read/write first page, read-only rest mapping. For this to work the implementation has to carefully work around faulting logic. When a page is write-faulted, the fault() hook is called first, then its page_mkwrite() hook is called (to allow for dirty tracking in file systems). On fault we set the folio's mapping in perf_mmap_fault(), this is because when do_page_mkwrite() is subsequently invoked, it treats a missing mapping as an indicator that the fault should be retried. We also set the folio's index so, given the folio is being treated as faux user memory, it correctly references its offset within the VMA. This explains why the mapping and index fields are used - but it's not necessary. We preallocate pages when perf_mmap() is called for the first time via rb_alloc(), and further allocate auxiliary pages via rb_aux_alloc() as needed if the mapping requires it. This allocation is done in the f_ops->mmap() hook provided in perf_mmap(), and so we can instead simply map all the memory right away here - there's no point in handling (read) page faults when we don't demand page nor need to be notified about them (perf does not). This patch therefore changes this logic to map everything when the mmap() hook is called, establishing a PFN map. It implements vm_ops->pfn_mkwrite() to provide the required read/write vs. read-only behaviour, which does not require the previously implemented workarounds. It makes sense semantically to establish a PFN map too - we are managing the pages internally and so it is appropriate to mark this as a special mapping. There should be no change to actual functionality as a result of this change. Signed-off-by: Lorenzo Stoakes --- kernel/events/core.c | 76 +++++++++++++++++++------------------ kernel/events/ring_buffer.c | 19 +--------- 2 files changed, 40 insertions(+), 55 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 5d4a54f50826..0754b070497f 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -6284,41 +6284,6 @@ void perf_event_update_userpage(struct perf_event *event) } EXPORT_SYMBOL_GPL(perf_event_update_userpage); -static vm_fault_t perf_mmap_fault(struct vm_fault *vmf) -{ - struct perf_event *event = vmf->vma->vm_file->private_data; - struct perf_buffer *rb; - vm_fault_t ret = VM_FAULT_SIGBUS; - - if (vmf->flags & FAULT_FLAG_MKWRITE) { - if (vmf->pgoff == 0) - ret = 0; - return ret; - } - - rcu_read_lock(); - rb = rcu_dereference(event->rb); - if (!rb) - goto unlock; - - if (vmf->pgoff && (vmf->flags & FAULT_FLAG_WRITE)) - goto unlock; - - vmf->page = perf_mmap_to_page(rb, vmf->pgoff); - if (!vmf->page) - goto unlock; - - get_page(vmf->page); - vmf->page->mapping = vmf->vma->vm_file->f_mapping; - vmf->page->index = vmf->pgoff; - - ret = 0; -unlock: - rcu_read_unlock(); - - return ret; -} - static void ring_buffer_attach(struct perf_event *event, struct perf_buffer *rb) { @@ -6558,13 +6523,47 @@ static void perf_mmap_close(struct vm_area_struct *vma) ring_buffer_put(rb); /* could be last */ } +static vm_fault_t perf_mmap_pfn_mkwrite(struct vm_fault *vmf) +{ + /* The first page is the user control page, others are read-only. */ + return vmf->pgoff == 0 ? 0 : VM_FAULT_SIGBUS; +} + static const struct vm_operations_struct perf_mmap_vmops = { .open = perf_mmap_open, .close = perf_mmap_close, /* non mergeable */ - .fault = perf_mmap_fault, - .page_mkwrite = perf_mmap_fault, + .pfn_mkwrite = perf_mmap_pfn_mkwrite, }; +static int map_range(struct perf_buffer *rb, struct vm_area_struct *vma) +{ + unsigned long nr_pages = vma_pages(vma); + int err = 0; + unsigned long pgoff; + + for (pgoff = 0; pgoff < nr_pages; pgoff++) { + unsigned long va = vma->vm_start + PAGE_SIZE * pgoff; + struct page *page = perf_mmap_to_page(rb, pgoff); + + if (page == NULL) { + err = -EINVAL; + break; + } + + /* Map readonly, perf_mmap_pfn_mkwrite() called on write fault. */ + err = remap_pfn_range(vma, va, page_to_pfn(page), PAGE_SIZE, + vm_get_page_prot(vma->vm_flags & ~VM_SHARED)); + if (err) + break; + } + + /* Clear any partial mappings on error. */ + if (err) + zap_page_range_single(vma, vma->vm_start, nr_pages * PAGE_SIZE, NULL); + + return err; +} + static int perf_mmap(struct file *file, struct vm_area_struct *vma) { struct perf_event *event = file->private_data; @@ -6783,6 +6782,9 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma) vm_flags_set(vma, VM_DONTCOPY | VM_DONTEXPAND | VM_DONTDUMP); vma->vm_ops = &perf_mmap_vmops; + if (!ret) + ret = map_range(rb, vma); + if (event->pmu->event_mapped) event->pmu->event_mapped(event, vma->vm_mm); diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c index 4f46f688d0d4..180509132d4b 100644 --- a/kernel/events/ring_buffer.c +++ b/kernel/events/ring_buffer.c @@ -643,7 +643,6 @@ static void rb_free_aux_page(struct perf_buffer *rb, int idx) struct page *page = virt_to_page(rb->aux_pages[idx]); ClearPagePrivate(page); - page->mapping = NULL; __free_page(page); } @@ -819,7 +818,6 @@ static void perf_mmap_free_page(void *addr) { struct page *page = virt_to_page(addr); - page->mapping = NULL; __free_page(page); } @@ -890,28 +888,13 @@ __perf_mmap_to_page(struct perf_buffer *rb, unsigned long pgoff) return vmalloc_to_page((void *)rb->user_page + pgoff * PAGE_SIZE); } -static void perf_mmap_unmark_page(void *addr) -{ - struct page *page = vmalloc_to_page(addr); - - page->mapping = NULL; -} - static void rb_free_work(struct work_struct *work) { struct perf_buffer *rb; - void *base; - int i, nr; rb = container_of(work, struct perf_buffer, work); - nr = data_page_nr(rb); - - base = rb->user_page; - /* The '<=' counts in the user page. */ - for (i = 0; i <= nr; i++) - perf_mmap_unmark_page(base + (i * PAGE_SIZE)); - vfree(base); + vfree(rb->user_page); kfree(rb); }