From patchwork Wed Nov 24 19:09:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 12637519 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 B5F56C433FE for ; Wed, 24 Nov 2021 19:11:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3B2AB6B0075; Wed, 24 Nov 2021 14:10:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 361E26B007B; Wed, 24 Nov 2021 14:10:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B4F86B007D; Wed, 24 Nov 2021 14:10:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0191.hostedemail.com [216.40.44.191]) by kanga.kvack.org (Postfix) with ESMTP id 0E1676B0075 for ; Wed, 24 Nov 2021 14:10:53 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id C6C9D18464D1E for ; Wed, 24 Nov 2021 19:10:42 +0000 (UTC) X-FDA: 78844765524.08.21B4237 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf11.hostedemail.com (Postfix) with ESMTP id 06F52F0000BC for ; Wed, 24 Nov 2021 19:10:40 +0000 (UTC) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AOIFNRj000722; Wed, 24 Nov 2021 19:10:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=UeGLfalTKgxkuv18hYImqm/31GTOoGT1zdUZRd5Kn4Y=; b=lLfdfUMGy7JPCWBWyzq84YMBELDNhW67rHNb0qdqc6b0BHzBoiDR0sL8oYKltC2pKUkG jFvkq1kU6iI8DheGnDGf2z4JK8nfBeUyzvfCd+RftztIDsg2wcGkfr27BOvh4lVu6vlg N7BDGIULgHJfILpQaRimiev6d8ko3sVa5bTnLi9JxzNTWmAaMxKVca+Rqjalris66ekE +UvKATa8so6h9ACBdN9qGSw2Ic+y1mC/KD49GKGXsrJoXl2sRHtMOuvP4rwrOxBQASYd kqEvm6xRgmikmRlAegofOWb5d9Rxdfbnyw87uM3z14zW2rg8Ge5ZT4CyPL+sEahM8VuE YA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3chkfkb0bm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Nov 2021 19:10:27 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1AOJ14fq037308; Wed, 24 Nov 2021 19:10:26 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam07lp2041.outbound.protection.outlook.com [104.47.51.41]) by aserp3030.oracle.com with ESMTP id 3ceq2ghycf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Nov 2021 19:10:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BhFYVb80K3HwOyHvNe7EOdTb4C9FC6MciuoFmkkVsoLf9XmMX2aLMEPeZ47LMaPpnNRLXDvAXK/mfhwiYyv2kaWyfrmgQ7153YiiOjEizvCkqOMOB+O4dIiOFpbTR6zdflvVVukx3YjVQYTPI+Y+3ANTd9db7UYHVHNE+vVk+p3rSkF11FwuLB1lwbCDFppBPQQri2m/I6+LCbxcam1kxMXdP8B2OHj13Us+U9XIoCgjeb1pW28FaP9H/3OyGD2ZNe1i+XZg+E2PdquGKxq23MhQiyxxYfVvLAi+zbClqkeLL+739m1msPBtht9lH887umbC03oFQVelZZxv0U6AIw== 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=UeGLfalTKgxkuv18hYImqm/31GTOoGT1zdUZRd5Kn4Y=; b=JaxwNfpP4AfGxphouLfANIfLvFVrTaew+ZoaNF8YsMr/4lIJFxNXZmagv231u9tm0YjKYNuNrHspKH1eIlUplb4O1lmP/8G36QCLyN+MBtHzbF8fPmWQin6PvIuVXNLpVtnTVCnliYAeDucCPCrcBFcyafYroxoUHro5bY/6E3l2slS16NAlatV57PMfGXwO/g8+dvPlJ7hR45JPheWVA3e2tO1V5ZxoMM+rJ/o6KDFofWHiUVx37Ms8P3p2nJBpjadUVYP3PwCPzJmdaTQzDoJLA+yvcAggEJjg9Zxx/APhtVcjKldums1uKj4qNZ2UbO/kbD+vD+E8YMnRsQXV+w== 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=UeGLfalTKgxkuv18hYImqm/31GTOoGT1zdUZRd5Kn4Y=; b=EXDDk8vFhUckQFpEPS47Bpj1lWq+HQcSf7c4IdV7FXqbMowhbTFyyIUb5AB1UQciLTu1k4sOoQyJFnJzXPtf6yOHxTTz+PLjVVW5QgAQZDqscgacgYmO/1gvlUlyeW0FF+T7KKKFsnoYCnla3qkOL+lTPmrl9wXpfNCCeoarWTk= Received: from BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) by BLAPR10MB5234.namprd10.prod.outlook.com (2603:10b6:208:30c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.20; Wed, 24 Nov 2021 19:10:24 +0000 Received: from BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::d809:9016:4511:2bc6]) by BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::d809:9016:4511:2bc6%7]) with mapi id 15.20.4734.021; Wed, 24 Nov 2021 19:10:24 +0000 From: Joao Martins To: linux-mm@kvack.org Cc: Dan Williams , Vishal Verma , Dave Jiang , Naoya Horiguchi , Matthew Wilcox , Jason Gunthorpe , John Hubbard , Jane Chu , Muchun Song , Mike Kravetz , Andrew Morton , Jonathan Corbet , Christoph Hellwig , nvdimm@lists.linux.dev, linux-doc@vger.kernel.org, Joao Martins Subject: [PATCH v6 01/10] memory-failure: fetch compound_head after pgmap_pfn_valid() Date: Wed, 24 Nov 2021 19:09:56 +0000 Message-Id: <20211124191005.20783-2-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211124191005.20783-1-joao.m.martins@oracle.com> References: <20211124191005.20783-1-joao.m.martins@oracle.com> X-ClientProxiedBy: AM0PR06CA0093.eurprd06.prod.outlook.com (2603:10a6:208:fa::34) To BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) MIME-Version: 1.0 Received: from paddy.uk.oracle.com (138.3.204.47) by AM0PR06CA0093.eurprd06.prod.outlook.com (2603:10a6:208:fa::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4713.20 via Frontend Transport; Wed, 24 Nov 2021 19:10:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4127b418-f5d6-4a70-2420-08d9af7e112f X-MS-TrafficTypeDiagnostic: BLAPR10MB5234: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Dqg1VCiTzMRqULX0z9IOaHasJKKoNYqxI7/sQN6GvOr3n2qahvvREziuKsOYC0zlO8YQ9V/rhueckuQ0oBVG43ehohaRxSszmROxTb5pho6/8a2NBL3ItJjd5AnPuEcS+1ttFRG3BHv6ieIFKv9v5iDuPYz83VKqwW4bD00hSCLfH22w4d6fPvWoOgrCK0cL3FHB84Dw++EL5ZWnyefaTTguKfAARRXrjjRDmB+KUWHEkIfsB/Vr8Z6lM+5z3oKzgwU5O/nSqoMUjcJ40NZlc/pudFfWNK96s2WQ1KZtEPEDlViU7KqOO0M4p0hZ8YOjq1X8a5yYsT4TsYyGZxSN4yDekPDPqE9jyBU0ex1Vyqzk7R6VeLgQzGHAM+gx/EgnhNlyf3gG5ZGjAIsuVOB01yG/Q5cSBcHds/eDoliEvzOvML7WTvaukCDCAxHarUbvf/L9etnzdXheueDStLy/+BTm1RLswmEmufkpK3Hgjbra4RjcbpBzRhhI+4SblwTMsCnqkzpJKyiV9rZvnktljTDbrmxQGPnvMszj9SOl4hfp2WxaGDf/gmx4JgWMYC6xjdf7h7YN6KgwYm+LvC7YlXQ6UdMBLfyr5+cyDTYn9k870Uuc3K9nGtkO/IEgmN+oeXgHSWFhPX1d8bMHm7274Gd2Tmc+QcCr0iYWNm09cHTyvGaFWeoK1uJNYngXXyednrshqNepwgJSilrmf+CHtg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB4835.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(36756003)(1076003)(26005)(7696005)(83380400001)(186003)(6916009)(103116003)(316002)(52116002)(508600001)(5660300002)(38350700002)(38100700002)(107886003)(7416002)(54906003)(4326008)(86362001)(2906002)(6486002)(66476007)(8936002)(8676002)(66946007)(2616005)(66556008)(956004)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GnquEfHOeqb9LDA4MGa8O9RRQTxzUQaFgjpqWyvOuLTJvgp28ZiOq8L+XBND6A+/2wAOUBkTPCgx8QPZTQGIQgAJjg3A/BHG4VqWqdWn9cbpO0F4HzpAzJprtdNlpxpC+iKSUEwRwplG6NG5lx+tXzuxrLedMedSvjed/ZZfkxFnZl8H7uBXNuefbWfRU0R40Z+9pamZaeUDIj39szT+Hd4UPy82+4gId8nP0iND9f793Qw1CGQMncJuUO4T0JW6NaxKLd7o7GfMlbPVm+Z9D9eUB9beWaK3kF+Cr6qfaE9rzcVIj7iU9SiI5eqXU+MDsxhqDrlAJyJgk2LKrgJXiGFTpfa+yUJ5s8pOHOKV6A+mXHzLiHiwIpJ5iibnDV6q5LAI3+KITAQlMHBeiWYoE+QFFdF01PPfLvaERDDUtHexAKAu9FsEAOhTnK033mXiBg0He+MDWfz/tz/VNqN//SLYSzP2CWNnO2B0LACqaC/DEd/6ApjHVD8lH1uJXuj2tUreS9FtiFkaGX8F4oMn3MC+cZ75JmzrOfbGUNU5ZKgoVV+dXQ1qnj8MuPtOy8OYQEQiBmoRrsRnIiEzQC5gpDYmUBPrGAmVKo5uQs0/kCbEq1b3s7llWGF55l3L1ioJN2enklloGZpd0XBbGD2om6a0ZTEaUfrGVaPO0FMgTJvIrw2ypLHLO/DNb2XooFO1dy/JSLSTnuDdtuYxVzUww9luNQBzbL0u4+taYc+yAQzN9eNeGa2Ud/bc/4Ci8Oy2QdHXwqIjEyxQ4acKN+RA+rt6j6N/nD9VOQ/eyqqHajXk8qxVGT5NQfYZ0z5Nmae8IcBCQqksTvh1ovdpY2x7ujbmNmjL/uHTJNuty21durupdTz1cp7377nCldn5pVi2IR7NwN1o7QIv+mWN+NJqpim897AeRSHIgxEGKA2y6EP+FTFg4ak829u64qB2KYFHr3jqu94cDYklZpMKy3+qdIhrkE80oXqB2f0Hg6jGSH5Rjsrq3vxgg+VMjJ+UT4BpezPhegC+UQsQJgM5O7b0dTpudpy+QWBnGIJmejl7XH0MIFhtq6OwY+FxZRUocGJszYSbBmHTgAE0pZzDZAuvcj2hZg70CZQOGdEGoxX2fOJl/kOyQ19Q9+5pZF+t4Ky/+a3nOVgVAAGybC57S6VWjFfWJBg0pvN+POX8oVnB0A5XKHJA4AK3C8I/+Gnig1EJV1tpy4sGxTr/AboPyifVjPz42+fFjo1CfrmIxi4l16aO90V07N4BbEpIKUqhM0nIbN3HViBVKCRagBT78kNQb5Pt39vKyzk+HKthCcazpHnriRjXqe/RAvC69Ps6eEwkH+JGOCQtFox5qlHAqk9A/Q21noWmJJswqm5P3Ig8VZEtaMCNlIY+vNGefxcCQkNVeN2dltXVGLow4l9MZCnFisRDrd//Qptca6zeqMj/yrILuDI1z1t1SD4ej+XUsG3oqloE+IKXAZmZsO2iccwrRB3h3KHp+VqJnpUqKIVLHD1wF6GPaaXFsz92q3yJYMXb2g94tnQayhN8W9e+XYk/xoJJcpnFauRBzQthhAD9XiNY01ZD4AxeIwSSNEbYRztVriTmG2Uborwqbx+nfzGWSvR4HEmlrXCZMWWSR0QaZ+Lpex3j/qGuvXM7fpuOiK4eeGH2FzgGRhtFu2hswplSfw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4127b418-f5d6-4a70-2420-08d9af7e112f X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB4835.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2021 19:10:24.2501 (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: TY83AnqGWiT17BN/5PnWy5MpE589B2zOEKxPMFXjNsD0aanBZdVa3L9XzMIWrPDtAGmRUzUKQjNHHJODm7PzpoS9R8fTZ6ssbufIFfKapUg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5234 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10178 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 adultscore=0 spamscore=0 bulkscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111240099 X-Proofpoint-GUID: klqb-lAVVTgCajdGzt6k8L1KWIdW7gyf X-Proofpoint-ORIG-GUID: klqb-lAVVTgCajdGzt6k8L1KWIdW7gyf X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 06F52F0000BC X-Stat-Signature: kdeuudtrgck54eijow5bnw5ucxeafdzc Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=lLfdfUMG; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=EXDDk8vF; spf=none (imf11.hostedemail.com: domain of joao.m.martins@oracle.com has no SPF policy when checking 205.220.177.32) smtp.mailfrom=joao.m.martins@oracle.com; dmarc=pass (policy=none) header.from=oracle.com X-HE-Tag: 1637781040-938011 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: memory_failure_dev_pagemap() at the moment assumes base pages (e.g. dax_lock_page()). For devmap with compound pages fetch the compound_head in case a tail page memory failure is being handled. Currently this is a nop, but in the advent of compound pages in dev_pagemap it allows memory_failure_dev_pagemap() to keep working. Reported-by: Jane Chu Signed-off-by: Joao Martins Reviewed-by: Naoya Horiguchi Reviewed-by: Dan Williams Reviewed-by: Muchun Song --- mm/memory-failure.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 8f0ee5b08696..f5749db8fad3 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1600,6 +1600,12 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags, goto out; } + /* + * Pages instantiated by device-dax (not filesystem-dax) + * may be compound pages. + */ + page = compound_head(page); + /* * Prevent the inode from being freed while we are interrogating * the address_space, typically this would be handled by From patchwork Wed Nov 24 19:09:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 12637523 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 E16A7C433F5 for ; Wed, 24 Nov 2021 19:12:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E60F36B007D; Wed, 24 Nov 2021 14:10:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E104B6B007E; Wed, 24 Nov 2021 14:10:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B9FFC6B0081; Wed, 24 Nov 2021 14:10:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0248.hostedemail.com [216.40.44.248]) by kanga.kvack.org (Postfix) with ESMTP id 9E0076B007E for ; Wed, 24 Nov 2021 14:10:53 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 626A589086 for ; Wed, 24 Nov 2021 19:10:43 +0000 (UTC) X-FDA: 78844765566.06.D4C32E5 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf29.hostedemail.com (Postfix) with ESMTP id 0E1A8900066C for ; Wed, 24 Nov 2021 19:10:39 +0000 (UTC) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AOIFX8J026943; Wed, 24 Nov 2021 19:10:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=saJv+cmeXAb0i0lWCjomZjHXAEdm0lsOILVEOBAAS0Y=; b=QZ1eo1SDS5zneVwhcigw763fgsMtNDbUkTb5+CMYSwXbhMxCTkFrmG2vZ6eJ+rmkLt9A Zu8OpIqI73T9SrdaG5ybVbiNsKFvFCmMDxYQmlqvhn4CNmxDRmpcIyR1JbFP81SItiym WF6VqIMMvvCfTEt4P7pPIGlZYfTWwxIovWs5aUKW8vcOCT/s8Uii5ZrYRH98bDGYw27H 5jIzXrI+1AFa3XBNNaNFjcByl8k7O16UdPSR/h/svw8NwutuyemlsHnvFZNaw8HBtqjw coyIwKqvY03Bt7aZ8igDdYCUpPrTB6L0tMBTXSxKpUz4RV8s1FUcqXi3PdnyBSx/zTwT lA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3chk002yrn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Nov 2021 19:10:30 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1AOJ1GW3086978; Wed, 24 Nov 2021 19:10:29 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam07lp2044.outbound.protection.outlook.com [104.47.51.44]) by userp3020.oracle.com with ESMTP id 3chtx6hcm1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Nov 2021 19:10:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gzK2Aa+qHqFMjSZdeZ734GxXoo6b6AuIo31fsQlAidL0xM6CiUA8P394KSNzjwHaIaugQR7OIhR1JAIxCRTnGy65EZrdixzex8M9aq6U+7lv9rbjeqAD0mvgfVOrQ4Ig0goKKClFSqh1rcZ9afOW55vL5wCHKRIBcnEfvGfZyPGZwiqTV+/xBAZCmlNv0WsBY2PU4Afp2tOTAh3Gq4UUoICJc9q8gBCEYjay2oKcINaHgqhPsh5m/Igf03fYp7mGtq0e+uGrf2tfM4W1kX+pw1UtFfKut7iPNTTby5ehzo6k5NBJY0a5HnluvNpAUbfO+CL1SvhI5er8QXBYCJzBKQ== 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=saJv+cmeXAb0i0lWCjomZjHXAEdm0lsOILVEOBAAS0Y=; b=Jd7CQ9md7QmMwSRdrrfu0d5ZZqTSID2SRAmF4VvSoF9WF7IaaDozvuh0UKR3P0XOIh/O+n1voP2tm8Do1V3zC/ogufoeoMdUFgn8L60sxmDVF5uoHZstF9iysCbCWu6j2eJF0xE0eplQcwkYilPoTghq/HbIhJk2zsCywyPifx35GHP0c/ZcMIYItHZSeXHowGUSjiQxLAtFxSByUb7km5c9XnfCB5ki5B0bAJUyJDL1dNFrNkMmpDBjmCsOifbXaZrnTKBzfjyg6cTHeCtBnMSRP35h0Gf5o0RSp2EkXuKcrdkitEW3cFeiioVrxLX9eTteKBjbFpuH1uNfFA22wg== 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=saJv+cmeXAb0i0lWCjomZjHXAEdm0lsOILVEOBAAS0Y=; b=rpB5oNc/Y8MKUS0vgdbetLYTPYXXLjJX53K9aNod5RoHL5NAjz5iAyrIbtTwyUyhNm9uv+VTd6VBpchcU7avM/SjnJe+lvbZELF/UhlB7d1ET1Nw/aHar0nJpuhYqbF8lgvDbC0sk2NasOsqfganEp3V6JG+WHaEkiqpiNltac8= Received: from BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) by BLAPR10MB5234.namprd10.prod.outlook.com (2603:10b6:208:30c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.20; Wed, 24 Nov 2021 19:10:27 +0000 Received: from BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::d809:9016:4511:2bc6]) by BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::d809:9016:4511:2bc6%7]) with mapi id 15.20.4734.021; Wed, 24 Nov 2021 19:10:27 +0000 From: Joao Martins To: linux-mm@kvack.org Cc: Dan Williams , Vishal Verma , Dave Jiang , Naoya Horiguchi , Matthew Wilcox , Jason Gunthorpe , John Hubbard , Jane Chu , Muchun Song , Mike Kravetz , Andrew Morton , Jonathan Corbet , Christoph Hellwig , nvdimm@lists.linux.dev, linux-doc@vger.kernel.org, Joao Martins Subject: [PATCH v6 02/10] mm/page_alloc: split prep_compound_page into head and tail subparts Date: Wed, 24 Nov 2021 19:09:57 +0000 Message-Id: <20211124191005.20783-3-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211124191005.20783-1-joao.m.martins@oracle.com> References: <20211124191005.20783-1-joao.m.martins@oracle.com> X-ClientProxiedBy: AM0PR06CA0093.eurprd06.prod.outlook.com (2603:10a6:208:fa::34) To BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) MIME-Version: 1.0 Received: from paddy.uk.oracle.com (138.3.204.47) by AM0PR06CA0093.eurprd06.prod.outlook.com (2603:10a6:208:fa::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4713.20 via Frontend Transport; Wed, 24 Nov 2021 19:10:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3887b772-c393-4973-49a3-08d9af7e1315 X-MS-TrafficTypeDiagnostic: BLAPR10MB5234: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1284; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: smffKBOkvlu32MgUznUPcB9J186T194XFZi5zs8Ad134/puCvlgvHnsO+YlscQj//wsyy7KROxVv/KKRJd/Oc2NVMjamnhZXQIQy9OIJdTuYrmfqZiXSJdTtYm4uD59Kf1TxntuFm2YwN8jqZ3NQV+PeRPlHjLOO0Vyx8JYlBFu8/fadAMIbrL8BbHfhlDdG/998Vh1YM8VFKVc+3Jb9NyjS0JrjK4dtsw3ve6s+IHxWJ5twBg3pga/9embFU3fxq5LDj3NqOjF/u3K42KSaEgl7tyyHFkrInJ+5W/1kC+vKKJUZW+Z+kXGzgasY9GmKJ0+8WHbSRdUSL7s1B9ZBkBQURjTHXrAg7pgVg2CGBUDSt9z+qW7HCQ0/llHJ2pTtQp4ko+tvvtgpZ7a4Nq++B8MbJcq+GrGOc2aeDUm2vbytXLigiihrmROSkKhU7lt3n20mTnQsMGF+FRbg13UHWZd3a74vrnwBQjs3hswp+5y5t4sf1t/9WYdFQKzVg39QgrPwJXrFEEqAQMj1FZ23ynTT4JvXFGLdd2Cnf3c8Xn55C/SLupMtT8GgnyfSGT5Teo12s8HazDiKzlphClULtSY/iylAsooPRS2IVCuBul8E/RVlviHpVRSPTLmWfrK7oVcD2uI1sgR3D8HsH4ScdZxJanb2dwmlcMntX1PPR+Upx6/LCP2xNErVtxX9xZvg5KrrL5leh7vLHuGcDq0f2w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB4835.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(36756003)(1076003)(26005)(7696005)(83380400001)(186003)(6916009)(103116003)(316002)(52116002)(508600001)(5660300002)(38350700002)(38100700002)(107886003)(7416002)(54906003)(4326008)(86362001)(2906002)(6486002)(66476007)(8936002)(8676002)(66946007)(2616005)(66556008)(956004)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: evtexMtXHs12rZUgsw3bj3gSqtX4U9tQt/zu7zNNVMQjlymynKoGJqNWahvXIUDFAgDgGIESEHAZqbEBY5qYLImjLQd6m5hS2/QUEKsuNMxWr20v/eZnS8xUvwONpqu0V2FcJlyyE1LVaXNC9UC4dV3yjs0jILUCfMPpmvWcCszZGsbLPlOdDJ6ASn75ROUqiuLQR9WZn7zWc7Ui3A7Sx2hv3CgoBGvXvIUFTRCxza83yJxStFlthEyDHqPs6XVbNmR4cu5fLnC4Xaaykrcf/HU4iwsb5eJiaKYV+RfoziX7DmyGV/tFPHHW/w6AMEBqBJS/FBGptdwwPewhsfTCHEMr4QPicDTNGPvFsn9fRuT95DwBo6g61Z7wDBy4RKeZHF/93HKVVxQqYArP0BuzlnwDoxUeQDH/Ma3LnNcvAqTAOIaOBx1lCZBIMlWiKoESIgmbutae9N4AOLo5nEezS7d8Q+WxcfqjJ4zt2xeewG+VJsuabbha22qE0qUyFh91GkVCroNfdnd/M0qP/IZpvVW5wrfr/65nlDIjhyo9EEPHVv+nx/UL/83/V1r4GTmNyPx3X2hPJ3QAt0qxZFmjTlkZDOxbW/KNY69OKOsIRTrO1l3Cxdk1Gn87XHOYG/QQXj/DBk4Ti1qJm56gg7yny1h/oFmm8ikrffJt19ZYK9NkG5o0TjVvAq7Cvc92v/2Uub2nvC732idTaXsaZwmT5JVEB0USg4d7jyO8cykWrrMJ/TGLbG+6IOtk+tO/1Pan7xZhAVQMGtbFwaTPzRL+quP+8G5a4TAzogpMR2LyN1BMlnkPeCybjesMrcM+eeDpFi8roN3hYHpxlvyKepRl5GNp2I9wOHHzBtIxFc3qkRTmN/mUBzDxGYbPHz7xZiex+0Y9bLrgBDndZbOIvOs1bKGr50bTeDV6I132Vd+DmRe2wIx+JiiN6+1+Ry1XT6iXGiL64iokwCHQ/Hplbm9+2Mn0lPqCv0Ldu4s8XIM3+eWE/7BbSnSFElHOC4Tp0n3AA+cVHp1M+oR8GrbhXs7Zxekrk6WJxL7J4u+5Ru8k1rCrvDvqqI1sTIhwfagjkqQZM/d75uO2Mr7asH+M+tuVUjg8t4O8urQPqXzgiloPrbuQKik3kXOwhYj0p2R5pzYYEramijRSc7DpN/ucF5yDwCHRAPZAGMM3zO8B0qU3OdNqM/pxxfSdP3v5kIFDYsCSH413zvWT0OWxp4fyD/ocmY8kwjPZDNxAzY0BEzAxTnTfZdQ608cOMTf9FqsyFFi1yaAbuYrBRLupbuB8wEHOZDfXQ8LPIWKM4Xe7fCP+iNZmXv0PGR7D6TBW94j038ypV+vlLZW6Nu+yKk4pn2UFb6fPXCdL2c3UWW1CXQMpU+SasHHM0f73aeoz4iLjjCOIS9ASy9RrAlj5fkGN+IR0rjLKN+Vgtt/nnJV1rNkcD3o+wIGtTxw5An7zIz6+6HtmRkaFMKJSwS3xwjVvIc/5P1RQdlF1euRB4eJAFU6djZyZKJHGjASxCrPiAApKrIsm5T/UE3lLq4qPSnoLiDvlOaWyQT8jtpCv+tezFbzGTK6kXAPL3rLpQndU7NX1OF2NKBV8aAcKoP6bn7TX1fqSuplBOZcMdZB7s8QfwAvmheXqj7YKFp9bmGuckuB18l99ZbFOmpRMvCqu02VTAs8BNg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3887b772-c393-4973-49a3-08d9af7e1315 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB4835.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2021 19:10:27.3077 (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: zkIVS71ixA8Y8jCrxdMYCQaSz60W54sMJ36e7UMd/OERoiUadEtCTIL9aSLO7SBX8Wj7yswPfMmDYmbIPFt3WwGbf+ENPfSthpC6cDDMYIM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5234 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10178 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 mlxscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111240099 X-Proofpoint-ORIG-GUID: xKOlgitcew2J9gIz1o0R0S36rV4MV-lh X-Proofpoint-GUID: xKOlgitcew2J9gIz1o0R0S36rV4MV-lh X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 0E1A8900066C X-Stat-Signature: zpwqbdff7x7iepyoqmrpwyjhnyzugnu6 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=QZ1eo1SD; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="rpB5oNc/"; spf=none (imf29.hostedemail.com: domain of joao.m.martins@oracle.com has no SPF policy when checking 205.220.177.32) smtp.mailfrom=joao.m.martins@oracle.com; dmarc=pass (policy=none) header.from=oracle.com X-HE-Tag: 1637781039-622790 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: Split the utility function prep_compound_page() into head and tail counterparts, and use them accordingly. This is in preparation for sharing the storage for compound page metadata. Signed-off-by: Joao Martins Acked-by: Mike Kravetz Reviewed-by: Dan Williams Reviewed-by: Muchun Song --- mm/page_alloc.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 58490fa8948d..ba096f731e36 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -727,23 +727,33 @@ void free_compound_page(struct page *page) free_the_page(page, compound_order(page)); } +static void prep_compound_head(struct page *page, unsigned int order) +{ + set_compound_page_dtor(page, COMPOUND_PAGE_DTOR); + set_compound_order(page, order); + atomic_set(compound_mapcount_ptr(page), -1); + if (hpage_pincount_available(page)) + atomic_set(compound_pincount_ptr(page), 0); +} + +static void prep_compound_tail(struct page *head, int tail_idx) +{ + struct page *p = head + tail_idx; + + p->mapping = TAIL_MAPPING; + set_compound_head(p, head); +} + void prep_compound_page(struct page *page, unsigned int order) { int i; int nr_pages = 1 << order; __SetPageHead(page); - for (i = 1; i < nr_pages; i++) { - struct page *p = page + i; - p->mapping = TAIL_MAPPING; - set_compound_head(p, page); - } + for (i = 1; i < nr_pages; i++) + prep_compound_tail(page, i); - set_compound_page_dtor(page, COMPOUND_PAGE_DTOR); - set_compound_order(page, order); - atomic_set(compound_mapcount_ptr(page), -1); - if (hpage_pincount_available(page)) - atomic_set(compound_pincount_ptr(page), 0); + prep_compound_head(page, order); } #ifdef CONFIG_DEBUG_PAGEALLOC From patchwork Wed Nov 24 19:09:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 12637521 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 8DCB7C433F5 for ; Wed, 24 Nov 2021 19:11:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A1BAF6B007B; Wed, 24 Nov 2021 14:10:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9CA926B007D; Wed, 24 Nov 2021 14:10:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7CEC06B007E; Wed, 24 Nov 2021 14:10:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0086.hostedemail.com [216.40.44.86]) by kanga.kvack.org (Postfix) with ESMTP id 6D7F76B007B for ; Wed, 24 Nov 2021 14:10:53 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 33F9B88CF4 for ; Wed, 24 Nov 2021 19:10:43 +0000 (UTC) X-FDA: 78844765776.05.FC4477F Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf03.hostedemail.com (Postfix) with ESMTP id 5913B3000442 for ; Wed, 24 Nov 2021 19:10:39 +0000 (UTC) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AOI2slv031388; Wed, 24 Nov 2021 19:10:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=uTLYKEkYQvMOzaFUCKSxv8ku0oYdToHJNLmK7s3USEw=; b=kI44QLZYE2kocX852pd5wmIlpXkz5724UQ1Bdt0iEX0h5zGUZ6DV1piwWHTva/S5zPYG 8NGHlxABjqkKgXGPeV3c84i/fhfsbRNpVcWIXoLyWMA88+PUvD9BFraMFZk4wIsWHvnf O21YmWV7AgHkMAJWIYGqXYa8tADQnSHJH5IqZQ4bsFH87sJylSrcB3tU8jKDPuaPGRfK aa6KeN6R7+dPJMqux+SZ57yMp9/JxE7b9YsIZHMImyqn2kYZ6WErlKMmFF+PJf0kOA0s uvalWfpnjBXYfjw0WBTPloJuo9VjqprT8dBTMNHcW5oRsn3q+ZhzvzVz8snL8XiM9Nob nQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3chmfn2qsk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Nov 2021 19:10:33 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1AOJ1J4l178752; Wed, 24 Nov 2021 19:10:32 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam07lp2047.outbound.protection.outlook.com [104.47.51.47]) by aserp3020.oracle.com with ESMTP id 3ceru7j9bn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Nov 2021 19:10:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V6+0K+z/RKDwLDCKXGs1j88EptRI+PEpqP6E++nlI+D1Bt6c8JUQvdJoUbX/s403V8yypj6lN3e15E8hIzMPyCGoxcuQyK8EE2Fj70H8eklWAvcXsqzj/jv4/aKqEmiZtgBGKt+B0cnngfyMvsYgs04lPoTiX2csWndI42F2THl7kjbWPi7T7NQr31Ei8OHzLGhGQ2yv7u3wF2p0PdgbGctU0JJmmBVaAzuW0388qXVEvOEDzotmO/i9JwQ+3I8FE1UPUs26qVSzFFCy5SZ6uK/3JPAo0UgPvCfBhWA5sx000PQ2NB2ikRbqnyaX1Hxg52F7vic1aFEmuX6qDxTX+w== 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=uTLYKEkYQvMOzaFUCKSxv8ku0oYdToHJNLmK7s3USEw=; b=evNfyyCLILc+gWPSIm/Caf/laDSrxI9yAHj19LrfsinnSH1SHFmJ+rxM/ERBRJDuZbA+VyXrVWg0Qb+LxbbipMR/vdUhhILE+3ru/qF1hk28scH/Jnp3MYaO0qDYVkI7aADRDYUlTRG+J77TfmSX0CANel/cRYoHkywJezwee+TtT5Geu69eAcPPs9fblIs7nPJ+fVg20HbKby/IgxtKNCCJWkg8v9mUR8KCJbLPdRTCUXdWc++xd+59DyNqZ+8iaLnfOHyq2ps2/XfqyrGeSdTcL7KKEWiyIn4tHeJr94vCcN0ZWykenbyD/kbzR8btlzCOXwsfn73xhMdx+YB/xg== 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=uTLYKEkYQvMOzaFUCKSxv8ku0oYdToHJNLmK7s3USEw=; b=n12rnRS11F9uvwX+V+fxAs5893xatNjyuA9RGW3lQt/GBuMm4i51wSCIVN+UiCQi9ZWrHWnalGOQNDkO+15AZ7a5Dat8N7HjoNPa7vJNcZOa2ESZx+Y5r4iBlZwY96k8T1e4VAAwPzwhvIRoWqjrBEjuFoRuP952pLWGq5QNqK0= Received: from BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) by BLAPR10MB5234.namprd10.prod.outlook.com (2603:10b6:208:30c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.20; Wed, 24 Nov 2021 19:10:30 +0000 Received: from BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::d809:9016:4511:2bc6]) by BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::d809:9016:4511:2bc6%7]) with mapi id 15.20.4734.021; Wed, 24 Nov 2021 19:10:30 +0000 From: Joao Martins To: linux-mm@kvack.org Cc: Dan Williams , Vishal Verma , Dave Jiang , Naoya Horiguchi , Matthew Wilcox , Jason Gunthorpe , John Hubbard , Jane Chu , Muchun Song , Mike Kravetz , Andrew Morton , Jonathan Corbet , Christoph Hellwig , nvdimm@lists.linux.dev, linux-doc@vger.kernel.org, Joao Martins Subject: [PATCH v6 03/10] mm/page_alloc: refactor memmap_init_zone_device() page init Date: Wed, 24 Nov 2021 19:09:58 +0000 Message-Id: <20211124191005.20783-4-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211124191005.20783-1-joao.m.martins@oracle.com> References: <20211124191005.20783-1-joao.m.martins@oracle.com> X-ClientProxiedBy: AM0PR06CA0093.eurprd06.prod.outlook.com (2603:10a6:208:fa::34) To BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) MIME-Version: 1.0 Received: from paddy.uk.oracle.com (138.3.204.47) by AM0PR06CA0093.eurprd06.prod.outlook.com (2603:10a6:208:fa::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4713.20 via Frontend Transport; Wed, 24 Nov 2021 19:10:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 33f51aab-0e6d-4794-9b9c-08d9af7e14e1 X-MS-TrafficTypeDiagnostic: BLAPR10MB5234: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iCcVUSTx9tW3r+gvVp0RI0+bE+9iXbrczCx9cPWyQSk6eIj8kmROU0NJXE3jqoF6YSyEcIaF30iH70RxMzdPC/IThpM3qG30k5INoRYfI7xab/+sOBkQWGRt4NBC1b+XZtpAmVG32PY9km2b7flSCjOMxLXFXen+qW2YqYHINNh0yd45GOHBcN4YYxwJisVSHNQoCJZLPrH4nfBKy6W0zLaKSO3zkfYifb0uV841TwQqXTtyas4elN3VKcvmmf2jL6xQHYg88AZRjAR/Jz3teQfag6tWtrNx5HFTIYkoXRF7a45sHxH5+EiXwT3/hZJOimZNRafzJah1pBCCgY/2NJpeFKTJHvz6dkOTDVgj3FQhMtoeNy+o+PmSyC7aWj8GZD++6KrmRP1t6S35LT9R5kVmsDPgFL2CRrkB19f4MWKo2ir+SvXhWmAer/R7um34y5WJHgBWxiwdRwRgyXoBikEntIyq1iZNtL9BYvjQZMQJiUqZAIwXGmZ70Cg2SE/cdNvjhA3R8qaofZUo7en1awKeKuP1Q/98jsKwQaEx8jOBSvVJKMEdnvIcnHjnDP5vjVeq9N8BRfUX5pPcI2lHwHQWmOdj5A5rBSpAUaE65dYSj2B7/oJboDVg0RU7wnzB+8OYffFiLB37K1aXbinhVR9QmQWpfmC1xSmnQx+/oEBs62HbRYCEYNx07P0qkL8kfMAvmqa9vya/2Y0wEHjyBQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB4835.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(36756003)(1076003)(26005)(7696005)(83380400001)(186003)(6916009)(103116003)(316002)(52116002)(508600001)(5660300002)(38350700002)(38100700002)(107886003)(7416002)(54906003)(4326008)(86362001)(2906002)(6486002)(66476007)(8936002)(8676002)(66946007)(2616005)(66556008)(956004)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rZxlZiHPI13enpLHXXX9nMmbGlibyx74iGpyO41kQmFlzb6Ykpk6Oj8NJXRXhXmu7ft3DUw5axEh+Y7HVfOAdjuKSnnNB2wc/m1EJSTJJINs2I7nQ8DHuiBasKiA2cze0Io8c0y9lKENQQO+YiAZ/UQUehX+dX5/zOLovASlUz+iXkpPp5rxuKvZdfjLmpRS0ugChnTK6Y2QLnQMfxwUOU1t3EFMXgNeNJYefq93xbPzeZiTueODyla7eslKHaihpwxfPywsXy8xva10uDJmsuomboQFz9QqA1axtLqvWt7kbnJS7RdM6tgR2bctRTP0nofCLuAWfKGMsCoyQLg2pSIPLSxNtNqMxTRhi/pyat+q9qaFXnm0m5JvWJNym++3mI7O2MQL3eNlhVevs4BeB2WhF8y2kWXCaSFVRM3IK5/FODgUx/JF8wmn060GjRErutKMHRx4NOnUA8XQdNqkXXXd/wTT+x6Dqkas8S+u+VDAMhs+Ji5PJm124de+rv/Skt7O8ZcBdjr8+JwB7McLnz6oq8jBL00HOvEX8muhDbjTbjm3WFkYtSRXZ7fTdqTMTdZ5STB7SR0iwQ16PvuLBoIiyss7ar5OXldToBrIBzJ1ZxgenjpI0Vjmz5MvtmJSPal6M0ZgsF3dszJTYFGPk+v2DjysgcPUWBlxC8idfFulNP2mwbdpWToGQiyCeB8w+W0JNBd+Vs+ujyJVJkQ3aNY7P9Fk3SvAFQTX7WM4JvxcgaCwEUKQzuoi8AXdWHKGaKo1K0ieIVWTdGL5n8mbOGOrJQjI1OpnhjJET/4pJo8V49VgPYx7pNePpcRR8O/LD4zHwb7mZYSdw3q5V11hVWBNy4ysHYx9Vf48e3InxrMClalIchcbPZJYMgzPCoc71CnNflyM57cFduqc16XIMYQtGaTXkKEuvLLM5PD8S+0MTzb7Nzy8mlLU8TUu92bg8BORI22xtBnc/8kjJjpStUBMK5ORtvmF3nrRy4OzvvAj4tPGb1LUuBcgc65ZLKR4rRyhRpM5sHnKCFosiJaf89MSNg1mptRyu9lkjpEDbbTyLy8HcBsh0q7iJ1rUAWhv56t+LSchA2bz9lCfZQyBaGnp24ELoaI0lV7G8KzxmYVVS6eboWYSBYyKrDGxxASSxeKzKp4hGrbEBEJ4XsmHxUataZ9kAKcvrGMvM+LXmxwxXGW9nlW8o621nzB5f6XCO4SzGpmNeSFFZBI3OFC8hok8Goa8Q7+cMxxd3PRMxhvvvb9FuT6toAKOBJHoYlTZ6UagBBvgMhKk9DqUWC1ZyfT0rwBU1lgN41QEcboklWI9eG97B1+vF3f/FOQbB4vBqi3L0Zd/WihGqrYwmUIPtYmfKXjelD/7JQqCj9CD3d/hS4HES85ijlVu0AB2VlNJckLPpQvpzmfp08LKCUWKCR6u7ibs5lxRHVpEW6WOyU++hkXbKyU9z+sHCkSnLvvuvXaEsiKkKUsXZzRsXgIw5lVJEB48TdSMjHpoldWv4xEWpPdW8modIobmfklvfQRKQa0Kckfe5G5Y859XhMl/BtTl2rieihCXJUv4yc6ZgaPNrOvrbXObmum2gUh/Qyy9edz+r0yPbzpDNzb65+hji4sDx8gxn55FxlISV0vLauJN2jyyHsqO1nPpFIAUjPEd3B0//e9xcekIqVDgdC5M6w== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 33f51aab-0e6d-4794-9b9c-08d9af7e14e1 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB4835.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2021 19:10:30.2716 (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: jqDIMUkEWQK8CVBRTC7EFbxofDRVmXcjSZQk+sNaek6wLwMDwW1bXEO1AZOVxsY5U3QCaXZc5A0xOlzpzlvQTtGgMMaSGOAoshs/4nB4+68= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5234 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10178 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111240099 X-Proofpoint-ORIG-GUID: QRdmqhNLQlYB7Jcuo09HabAdRD1XSFDD X-Proofpoint-GUID: QRdmqhNLQlYB7Jcuo09HabAdRD1XSFDD X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 5913B3000442 X-Stat-Signature: asyax1uq1ujin9ji939qu18iaf8fitr9 Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=kI44QLZY; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=n12rnRS1; spf=none (imf03.hostedemail.com: domain of joao.m.martins@oracle.com has no SPF policy when checking 205.220.165.32) smtp.mailfrom=joao.m.martins@oracle.com; dmarc=pass (policy=none) header.from=oracle.com X-HE-Tag: 1637781039-906855 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: Move struct page init to an helper function __init_zone_device_page(). This is in preparation for sharing the storage for compound page metadata. Signed-off-by: Joao Martins Reviewed-by: Dan Williams --- mm/page_alloc.c | 74 +++++++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index ba096f731e36..f7f33c83222f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6565,6 +6565,46 @@ void __meminit memmap_init_range(unsigned long size, int nid, unsigned long zone } #ifdef CONFIG_ZONE_DEVICE +static void __ref __init_zone_device_page(struct page *page, unsigned long pfn, + unsigned long zone_idx, int nid, + struct dev_pagemap *pgmap) +{ + + __init_single_page(page, pfn, zone_idx, nid); + + /* + * Mark page reserved as it will need to wait for onlining + * phase for it to be fully associated with a zone. + * + * We can use the non-atomic __set_bit operation for setting + * the flag as we are still initializing the pages. + */ + __SetPageReserved(page); + + /* + * ZONE_DEVICE pages union ->lru with a ->pgmap back pointer + * and zone_device_data. It is a bug if a ZONE_DEVICE page is + * ever freed or placed on a driver-private list. + */ + page->pgmap = pgmap; + page->zone_device_data = NULL; + + /* + * Mark the block movable so that blocks are reserved for + * movable at startup. This will force kernel allocations + * to reserve their blocks rather than leaking throughout + * the address space during boot when many long-lived + * kernel allocations are made. + * + * Please note that MEMINIT_HOTPLUG path doesn't clear memmap + * because this is done early in section_activate() + */ + if (IS_ALIGNED(pfn, pageblock_nr_pages)) { + set_pageblock_migratetype(page, MIGRATE_MOVABLE); + cond_resched(); + } +} + void __ref memmap_init_zone_device(struct zone *zone, unsigned long start_pfn, unsigned long nr_pages, @@ -6593,39 +6633,7 @@ void __ref memmap_init_zone_device(struct zone *zone, for (pfn = start_pfn; pfn < end_pfn; pfn++) { struct page *page = pfn_to_page(pfn); - __init_single_page(page, pfn, zone_idx, nid); - - /* - * Mark page reserved as it will need to wait for onlining - * phase for it to be fully associated with a zone. - * - * We can use the non-atomic __set_bit operation for setting - * the flag as we are still initializing the pages. - */ - __SetPageReserved(page); - - /* - * ZONE_DEVICE pages union ->lru with a ->pgmap back pointer - * and zone_device_data. It is a bug if a ZONE_DEVICE page is - * ever freed or placed on a driver-private list. - */ - page->pgmap = pgmap; - page->zone_device_data = NULL; - - /* - * Mark the block movable so that blocks are reserved for - * movable at startup. This will force kernel allocations - * to reserve their blocks rather than leaking throughout - * the address space during boot when many long-lived - * kernel allocations are made. - * - * Please note that MEMINIT_HOTPLUG path doesn't clear memmap - * because this is done early in section_activate() - */ - if (IS_ALIGNED(pfn, pageblock_nr_pages)) { - set_pageblock_migratetype(page, MIGRATE_MOVABLE); - cond_resched(); - } + __init_zone_device_page(page, pfn, zone_idx, nid, pgmap); } pr_info("%s initialised %lu pages in %ums\n", __func__, From patchwork Wed Nov 24 19:09:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 12637525 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 BB796C433EF for ; Wed, 24 Nov 2021 19:12:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 539846B007E; Wed, 24 Nov 2021 14:10:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E8E06B0080; Wed, 24 Nov 2021 14:10:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 33B636B0081; Wed, 24 Nov 2021 14:10:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0244.hostedemail.com [216.40.44.244]) by kanga.kvack.org (Postfix) with ESMTP id 207666B007E for ; Wed, 24 Nov 2021 14:10:55 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id DDFDC8C5A5 for ; Wed, 24 Nov 2021 19:10:44 +0000 (UTC) X-FDA: 78844765608.04.7BF04CA Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf27.hostedemail.com (Postfix) with ESMTP id 0DD1070000B8 for ; Wed, 24 Nov 2021 19:10:42 +0000 (UTC) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AOIFNRr000722; Wed, 24 Nov 2021 19:10:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=h5SstNmQ1cr0H/SJe72geipxNFA/PXVszrLlkqHDrcM=; b=uPXyPTNhrBx5sTZTnLJoPTRLbQqubXsRp4aCPRE8NMkMNALZ2mlwEo7zYInf95RQMSvF 9rzl69qJhuDRzQyw9bmy++LKy5RVdvw8MtokKxT7N8ET7ofnu2iBx769DckVNqn4QXX/ LXWBY/JH/81zUNjY+glB1rDrrFoLLnJsVkf9DsXJFLCPKinhc85refGBFqHuSho+RaXC JZBIs8Jhqi5kAyubXzZn8EWnn1uGxGXY+mxqinf+C5FLDr7ja+fl/nPRuy7d2UAO2+ti VerJN+88SwMwI97lZu25E9ZfHzYWv8fYKNGau6ep/wsGGCMMxlq2EqoX1xh/T/ePaQBs cg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3chkfkb0cn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Nov 2021 19:10:38 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1AOJ0rqf192929; Wed, 24 Nov 2021 19:10:36 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2105.outbound.protection.outlook.com [104.47.58.105]) by userp3030.oracle.com with ESMTP id 3cep526txw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Nov 2021 19:10:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N78WciR/tOaublq+e+1K165/jLijI71vq+jiPSIsbj2CJrUm62OmwYCgoF7Vk8WmcDJKvrBExX4lAsbZny8mkyJULwGxD5If00fowI0HUD06PaCWP78jC+Q173w8hFv4Dr+H2uLkFEuik2irLqdfe7N2KfPe5/6VJXGMGqI4XVKBRZM1MKebwYQu0yYovuTNVT+OTksBe+vxZP/gtoyZoCxDJSrYsMz9tdmij9jPhkIi747PNzGeMJIhOoGyMolLMbCvzbQUHiOeNhyfqMVoI9cReSTWc5xM/OWgeEcDPwTI8phAgCJANZn0f9MjRtzDVk2ozcbKTMzpo4Ddyu8KGg== 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=h5SstNmQ1cr0H/SJe72geipxNFA/PXVszrLlkqHDrcM=; b=Xm6T2Y1FGOl+5e1x+V7ZiNYmqLbj4ixYjNj+5+kAq1vFVF1uRtoJywVjktGg02CjSD5mr2ccF8i98B18Tqq/s9xLMlf97Fj7AuYLxrb8O7dBkZCx6XCFbOwD8dwBFoMChEJTsnNAuCDVDEpQDe/kQdEuKJy4cN0QvBopWwSRsYrIovJ3KwFXgCg0JB6lwtwooINMjXRcyUK9egS5z0c1iQRFLlPyD2iHWIz3JJb45DsIY0PN+l4GzaYxk9fgt2tphaHF5dSZU6xq7Wxy6WtobkwxQk79k14RNtTdhOZTtmKmAPIIkr6DTQFu3RhZsr7FEmxF+jCnH+2N7TECJ/4RTQ== 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=h5SstNmQ1cr0H/SJe72geipxNFA/PXVszrLlkqHDrcM=; b=H0BzGav34mQhIpj+bAxy7ufT2pclwp5uaIJ92QCgqbhw/mp7Cq8736gZM5F4Rjrd0hNv/2glPGkoufRH8bBQvufB4+oamK7laVphH6xNibsAB3NSy/naCfFLQPhuboFiUzEp5bWdb+Lurv/V5B+ar2yhl/CN9xWpVZFimhkqjrA= Received: from BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) by BLAPR10MB5234.namprd10.prod.outlook.com (2603:10b6:208:30c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.20; Wed, 24 Nov 2021 19:10:34 +0000 Received: from BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::d809:9016:4511:2bc6]) by BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::d809:9016:4511:2bc6%7]) with mapi id 15.20.4734.021; Wed, 24 Nov 2021 19:10:34 +0000 From: Joao Martins To: linux-mm@kvack.org Cc: Dan Williams , Vishal Verma , Dave Jiang , Naoya Horiguchi , Matthew Wilcox , Jason Gunthorpe , John Hubbard , Jane Chu , Muchun Song , Mike Kravetz , Andrew Morton , Jonathan Corbet , Christoph Hellwig , nvdimm@lists.linux.dev, linux-doc@vger.kernel.org, Joao Martins Subject: [PATCH v6 04/10] mm/memremap: add ZONE_DEVICE support for compound pages Date: Wed, 24 Nov 2021 19:09:59 +0000 Message-Id: <20211124191005.20783-5-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211124191005.20783-1-joao.m.martins@oracle.com> References: <20211124191005.20783-1-joao.m.martins@oracle.com> X-ClientProxiedBy: AM0PR06CA0093.eurprd06.prod.outlook.com (2603:10a6:208:fa::34) To BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) MIME-Version: 1.0 Received: from paddy.uk.oracle.com (138.3.204.47) by AM0PR06CA0093.eurprd06.prod.outlook.com (2603:10a6:208:fa::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4713.20 via Frontend Transport; Wed, 24 Nov 2021 19:10:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ce8aa112-9e71-401b-5976-08d9af7e171e X-MS-TrafficTypeDiagnostic: BLAPR10MB5234: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:459; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ENdAy9XkSlT1QNWTD0Cibg1WH6Wn9ob0q7Z0Z5B8KluRDOPqAumgq+xmxnBQ05DyGvcPnbUKLz7i6zZJHi+ODS0hr6eSy5+dyyKOftbzFO+r8YtrDz5HQaCthBGckp53CUtPGSbHWsmCVMm4Ll9LpEYB5D0VZmP12mKM3LY5nKzSoWn/rLVi4VIeZpTjlLLfibAAOoKrg8Geh0GzVO7Lz+BCIlnn7WHQoYrzwkmVyAUikqOVm2Bl/VXHDMZ36eaKXs2sH9is+CfqhxuvqNj/iiTSvUFqVphkT0j59jzdXUlu7nakvxH3N/B7MKS+Ey8QNRr4n/wUmsA7H6I+81Q1bOfe2iJT0F9QoaDSKkvL9ZLiOQZrCrXENvlOac+oWru24wwpLLMULXBA98StH3sgYVjioj2F5kbYPwigra2FDYKO+dw1AXedvbyPJDvTX+anWpuEd63seJ5h3l4p/kKIL7lxSIe+MS9ZjLYtTwPjfIPrOkNz64oMSUz4TpHaPJoSpTkVEhOdqyFZZ8VFKKRniKBjyDXVADpE+aT1rLFdKNZ4c+UNfUtckoFHbUIphaRcnasngqi+jaJBM5pEdnlQMggNWChmSzK5iSD0M7DOw8FBNssM/UoNXvbZjDaPCXeKPhUlONoH/nvqRJTt9lXKwscOJtksdTZcaeaWCq0Y4IFVKYexE/NRVVAFA6Ak/9GMfg1ZN0a0gP4UQxHY6odPBA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB4835.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(36756003)(1076003)(26005)(7696005)(83380400001)(186003)(6916009)(103116003)(316002)(52116002)(508600001)(5660300002)(38350700002)(38100700002)(107886003)(7416002)(54906003)(4326008)(86362001)(2906002)(6486002)(66476007)(8936002)(8676002)(66946007)(2616005)(66556008)(956004)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QnjuwekRjKPL6dgexDUFr4UoA8eGDQOhRQprdD77bGioEnGv0rhdS8WLVUdHROSkuXsn6Hk0Gn6LV2HK9j8XhmsJ+NFfZz5u+huVYFP8dfCvUzDKyXZw/X0hYJxK0gmsEOkyvr86GaUM3reXH1HaYf5WD0ou9kiG7TGQhalD2ba7i2HjEcuHYDsQo6btb7i8I97icid3/898ekV37wN4D3Vj59j9e997BZKvDLd7b86XYbM6WN21x8a/SX3gzFoKNPJ28Fh8uGU2yewiIZ4SQr/3harDhB6wH1WrZ4NgZ2kZVK2qPgr/ULUoXI83V2DnoOii5/z6CV9j9QX3vRuaaJcyWY/XaTyAkFdQIMMpCVr8Zh09vxt7DFv2UONyKEPMAtq9xDDap6MSNDylUCq42/yxv728srxjIuJriElWhfe7tlVlkzyhe5QgmVS68LgfAuZucTJ4E8tBcfkkpm1MeRka0CyUTMFz5ZpqwORh9g9pTnYA1lfoUXGYM89zLQELgHmgwipzgWXoh6BFnx65YAJPiZFC1uQtAd0OFD2VnC/V6RCviz34N7I7ik125Gd0gMkCk9KeZNPOwp7D4w9pYlwlrQjk1/g+7SPO/nO1/U+c+VTABhkn21jIztq4OhrH/pUJES3gF/n4UD6eYi68QF1BxZECS5RIIBz7u2kyXr6aOrEmGqkvrpQtmObSqB9jxluDvXb44MGpLgBgMwWv+PehzqZPvdt2xvDVJnJsOD/EAYZlODWepaWxEqpP3agtiqJRqj1k8dmDEicV8k08FnHcSum2VutLEg5SR0YRMFbcL6eH2w/SlbbrCO05T7oJffOD6pP5ZPAhaRDpnRuXVtX30DxTjYBPGozPQa/Rz0lZmm9snH3PZsT7MHKe8vKiBR54MlbWPjXF3sdar8VSH2QvFWvbL5SAgprElPP8BPD5CKQhEzJgWRc+wIg0Yevo7REqn4RKS6ViWdx5/G7XzpAIQqjZWs4GN79u9tDdF0OU9FP2uLQ1FeWM+O6DNuSHmMBTSwFeStlttJcyeQDUHlPxHf3MOxgPp2wovQDGrLBwmctuFYs25Ph7mnsIPY3KsPqSk6GPuaRp55fA1hfb5xw3Ts6zMGCDJtno91ILE6rGeN8nHS3klNxmPOwayzqAG43BM+QIg2uCDH3aM0VBK+m+Hg1tfSTqIAEZ6Dsc7P+1iivOM2XQXVxgPtLZsoxfJphxRHfdlM5kNJOpXRhy8GITR4rRCwwvC2nJ+Go44zCudoBV4TMnd6fEzXDu+BLq7+0NbZJbGXa1sMDdJ/JuOkKhlXkT9Ubuq1lx1+NW8MljuVETgZHHT2NezsTOW4s8IARHCRCaqWVY01XMMZ444knNKOES/W5Qqwf8pw+EHaFiEq8bAgDnvyiy6QMLxmarvzzPBJGdYd7q0MpLiV/yOI4XMn7CLb/+W6aZ2/jMo6Rc56vD1/OXsPHo60K0W75xmhcbSIaUOCHhMaFwdkKF6IOYHNUnHVXJf85ugEm864XWY6J8BoD5LdhXttOd9mWzM932GQmmfMzTRJYtTvj3PKJOYUBdPVDdigNN1Qmg8Yzuz1cUo4PHSTxw/KJCIWdUMBkNhVy5hkYeQpriAQOtF9hHbCkF8A0y8byi17Wu7egRhACDfwFmOt0oBclwbMMl0b3WqoWr91Qb3eQPxgeirA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ce8aa112-9e71-401b-5976-08d9af7e171e X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB4835.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2021 19:10:34.0799 (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: qqwTcVaqrQ2Ve3/R+0LGpnXU/IH/V3K9b1yDwBN3H8OovPzLxKLIef4ixMqucX1kqFXk7lwYIV5XgoFnLPQOo766de+1igYSAxkvGOggsCg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5234 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10178 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111240099 X-Proofpoint-GUID: Y5OQM9nowO6W1z7h3QoH-8Fhehkn-Wah X-Proofpoint-ORIG-GUID: Y5OQM9nowO6W1z7h3QoH-8Fhehkn-Wah X-Stat-Signature: 4p7nqsdf7ozsyeuga1e6inr448aw9o5s X-Rspamd-Queue-Id: 0DD1070000B8 X-Rspamd-Server: rspam07 Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=uPXyPTNh; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=H0BzGav3; spf=none (imf27.hostedemail.com: domain of joao.m.martins@oracle.com has no SPF policy when checking 205.220.177.32) smtp.mailfrom=joao.m.martins@oracle.com; dmarc=pass (policy=none) header.from=oracle.com X-HE-Tag: 1637781042-745578 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: Add a new @vmemmap_shift property for struct dev_pagemap which specifies that a devmap is composed of a set of compound pages of order @vmemmap_shift, instead of base pages. When a compound page devmap is requested, all but the first page are initialised as tail pages instead of order-0 pages. For certain ZONE_DEVICE users like device-dax which have a fixed page size, this creates an opportunity to optimize GUP and GUP-fast walkers, treating it the same way as THP or hugetlb pages. Additionally, commit 7118fc2906e2 ("hugetlb: address ref count racing in prep_compound_gigantic_page") removed set_page_count() because the setting of page ref count to zero was redundant. devmap pages don't come from page allocator though and only head page refcount is used for compound pages, hence initialize tail page count to zero. Signed-off-by: Joao Martins Reviewed-by: Dan Williams --- include/linux/memremap.h | 11 +++++++++++ mm/memremap.c | 12 ++++++------ mm/page_alloc.c | 38 +++++++++++++++++++++++++++++++++++++- 3 files changed, 54 insertions(+), 7 deletions(-) diff --git a/include/linux/memremap.h b/include/linux/memremap.h index 119f130ef8f1..aaf85bda093b 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -99,6 +99,11 @@ struct dev_pagemap_ops { * @done: completion for @internal_ref * @type: memory type: see MEMORY_* in memory_hotplug.h * @flags: PGMAP_* flags to specify defailed behavior + * @vmemmap_shift: structural definition of how the vmemmap page metadata + * is populated, specifically the metadata page order. + * A zero value (default) uses base pages as the vmemmap metadata + * representation. A bigger value will set up compound struct pages + * of the requested order value. * @ops: method table * @owner: an opaque pointer identifying the entity that manages this * instance. Used by various helpers to make sure that no @@ -114,6 +119,7 @@ struct dev_pagemap { struct completion done; enum memory_type type; unsigned int flags; + unsigned long vmemmap_shift; const struct dev_pagemap_ops *ops; void *owner; int nr_range; @@ -130,6 +136,11 @@ static inline struct vmem_altmap *pgmap_altmap(struct dev_pagemap *pgmap) return NULL; } +static inline unsigned long pgmap_vmemmap_nr(struct dev_pagemap *pgmap) +{ + return 1 << pgmap->vmemmap_shift; +} + #ifdef CONFIG_ZONE_DEVICE bool pfn_zone_device_reserved(unsigned long pfn); void *memremap_pages(struct dev_pagemap *pgmap, int nid); diff --git a/mm/memremap.c b/mm/memremap.c index 84de22c14567..3afa246eb1ab 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -102,11 +102,11 @@ static unsigned long pfn_end(struct dev_pagemap *pgmap, int range_id) return (range->start + range_len(range)) >> PAGE_SHIFT; } -static unsigned long pfn_next(unsigned long pfn) +static unsigned long pfn_next(struct dev_pagemap *pgmap, unsigned long pfn) { - if (pfn % 1024 == 0) + if (pfn % (1024 << pgmap->vmemmap_shift)) cond_resched(); - return pfn + 1; + return pfn + pgmap_vmemmap_nr(pgmap); } /* @@ -130,7 +130,7 @@ bool pfn_zone_device_reserved(unsigned long pfn) } #define for_each_device_pfn(pfn, map, i) \ - for (pfn = pfn_first(map, i); pfn < pfn_end(map, i); pfn = pfn_next(pfn)) + for (pfn = pfn_first(map, i); pfn < pfn_end(map, i); pfn = pfn_next(map, pfn)) static void dev_pagemap_kill(struct dev_pagemap *pgmap) { @@ -315,8 +315,8 @@ static int pagemap_range(struct dev_pagemap *pgmap, struct mhp_params *params, memmap_init_zone_device(&NODE_DATA(nid)->node_zones[ZONE_DEVICE], PHYS_PFN(range->start), PHYS_PFN(range_len(range)), pgmap); - percpu_ref_get_many(pgmap->ref, pfn_end(pgmap, range_id) - - pfn_first(pgmap, range_id)); + percpu_ref_get_many(pgmap->ref, (pfn_end(pgmap, range_id) + - pfn_first(pgmap, range_id)) >> pgmap->vmemmap_shift); return 0; err_add_memory: diff --git a/mm/page_alloc.c b/mm/page_alloc.c index f7f33c83222f..ea537839816e 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6605,6 +6605,35 @@ static void __ref __init_zone_device_page(struct page *page, unsigned long pfn, } } +static void __ref memmap_init_compound(struct page *head, + unsigned long head_pfn, + unsigned long zone_idx, int nid, + struct dev_pagemap *pgmap, + unsigned long nr_pages) +{ + unsigned long pfn, end_pfn = head_pfn + nr_pages; + unsigned int order = pgmap->vmemmap_shift; + + __SetPageHead(head); + for (pfn = head_pfn + 1; pfn < end_pfn; pfn++) { + struct page *page = pfn_to_page(pfn); + + __init_zone_device_page(page, pfn, zone_idx, nid, pgmap); + prep_compound_tail(head, pfn - head_pfn); + set_page_count(page, 0); + + /* + * The first tail page stores compound_mapcount_ptr() and + * compound_order() and the second tail page stores + * compound_pincount_ptr(). Call prep_compound_head() after + * the first and second tail pages have been initialized to + * not have the data overwritten. + */ + if (pfn == head_pfn + 2) + prep_compound_head(head, order); + } +} + void __ref memmap_init_zone_device(struct zone *zone, unsigned long start_pfn, unsigned long nr_pages, @@ -6613,6 +6642,7 @@ void __ref memmap_init_zone_device(struct zone *zone, unsigned long pfn, end_pfn = start_pfn + nr_pages; struct pglist_data *pgdat = zone->zone_pgdat; struct vmem_altmap *altmap = pgmap_altmap(pgmap); + unsigned int pfns_per_compound = pgmap_vmemmap_nr(pgmap); unsigned long zone_idx = zone_idx(zone); unsigned long start = jiffies; int nid = pgdat->node_id; @@ -6630,10 +6660,16 @@ void __ref memmap_init_zone_device(struct zone *zone, nr_pages = end_pfn - start_pfn; } - for (pfn = start_pfn; pfn < end_pfn; pfn++) { + for (pfn = start_pfn; pfn < end_pfn; pfn += pfns_per_compound) { struct page *page = pfn_to_page(pfn); __init_zone_device_page(page, pfn, zone_idx, nid, pgmap); + + if (pfns_per_compound == 1) + continue; + + memmap_init_compound(page, pfn, zone_idx, nid, pgmap, + pfns_per_compound); } pr_info("%s initialised %lu pages in %ums\n", __func__, From patchwork Wed Nov 24 19:10:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 12637529 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 2F894C433EF for ; Wed, 24 Nov 2021 19:13:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2A0DD6B0081; Wed, 24 Nov 2021 14:10:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 279036B0082; Wed, 24 Nov 2021 14:10:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 042126B0085; Wed, 24 Nov 2021 14:10:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0070.hostedemail.com [216.40.44.70]) by kanga.kvack.org (Postfix) with ESMTP id D436A6B0081 for ; Wed, 24 Nov 2021 14:10:57 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 2AAEC1848B0CB for ; Wed, 24 Nov 2021 19:10:47 +0000 (UTC) X-FDA: 78844765734.08.4A66B7B Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf27.hostedemail.com (Postfix) with ESMTP id 0E04770000A2 for ; Wed, 24 Nov 2021 19:10:44 +0000 (UTC) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AOIx2bZ031509; Wed, 24 Nov 2021 19:10:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=6K3dV9kT1TePMQHNEat9vbBQo8pBmM+K6iChvFRe6Gk=; b=oMnJISYVluXbXhvBASTdBakeraweglGv3FE4o0lK8AOHho1bpWPKrfAECb+TWEN3dSy7 q3ImjjIP8nQ6yFb7yFdRdX48mcbr/8P/ggfePjrFRjKbfUDUUQvrukG4ERzRjHB6hUGf dvkpiZ5Po+ziXJyAfaPUWG/jCLOIJf9xQ2XTt0xwyG/17OQ/IKFoDaMTwN1/sOgjIBGH Gg50hLl37HVbZ5IX12MFyV08UhSZTPGSTcNUFUIvCGNh5JosBuHJf1SVKZ0C02wVKapH Pw0zQ7joD+dW+kfUG15qZWogcmV9eWSpsUJ42gQi4PdAYFw1oRdBKaErlZdtN6nt5ggz 0w== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3chpeesxm8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Nov 2021 19:10:42 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1AOJ15SZ037553; Wed, 24 Nov 2021 19:10:39 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2105.outbound.protection.outlook.com [104.47.58.105]) by aserp3030.oracle.com with ESMTP id 3ceq2ghyqj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Nov 2021 19:10:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q5mVj8koIOJZKD59sxh38eCNcThIVEkBnRD6SZdSBZ6dzp/Ycrmn/K217yazOSy+t1wWPv8Qvx/Exd3C0bVEeVYejqmXZPUKv++6R3pK6KENIj6K8cJLrWyH2EVHhioc+u3eTmf8kQVRRnOxy+7lILzaM7w5jg8aYOxUY16xwZDQ06WFNIPLliEDihd2d9d/d5kAyvhAIiySVV/ZGieDMLp6MuSyoU0eXdJWBpQ2qNCVD7yuaCgzsI2QsCbX3mOqMurJMBLrfZ5wBCWiEAnI5dacBRMCh/ExAGHuE3gdsZ3zRwK6gWLyc7JaLq4AsVuJQfY6sDAl2F2WDxD+ROWHVQ== 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=6K3dV9kT1TePMQHNEat9vbBQo8pBmM+K6iChvFRe6Gk=; b=SCh6DWtpqICNmywrTzWaGHpf6zFumKWDNhVvC6/YVAzg4fFA+bGobMjKOU5IzPNamOQIBeCyntZUBbhTOef38sUna1bgafVhQa/ZOf+VmBy+T0OoNRjmsAE42MYeRvILiLfXKK+r4k1IEU/vmaZtRRrggDKjg7ZHbjD7QJGMkHbDsZTOFmoy0zQ1uNOvvCp7f3eADgOQzfstpgABTXlALB8l17LvGyBCbUD4ylrMZvgQMzg7DEFFpv9fEo0xVeCjRG1wTClo1E4xQMFeD1Wb+tZuvOKMk441WWuWVVJOXh2AH95l4NvVN9YZv+B+3lwBsWj2y4bwuSgzieqgp8J1dQ== 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=6K3dV9kT1TePMQHNEat9vbBQo8pBmM+K6iChvFRe6Gk=; b=tfQx5X+pOOzP+f7lybo34Uu3g8qUYgyabiGaJcoVhppFqPGeVHcz/7kA39BtjD9gAOgXaw/jOR9weaQDy1oz/KapNTubj0Jp3l6NFyKvHkn0h+WNm4DdQO8u2fEHOXk3V3OQbGx+aWjGbkv3dYaG9Vf9k+iybA0ei/tosq8hPGs= Received: from BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) by BLAPR10MB5234.namprd10.prod.outlook.com (2603:10b6:208:30c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.20; Wed, 24 Nov 2021 19:10:37 +0000 Received: from BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::d809:9016:4511:2bc6]) by BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::d809:9016:4511:2bc6%7]) with mapi id 15.20.4734.021; Wed, 24 Nov 2021 19:10:37 +0000 From: Joao Martins To: linux-mm@kvack.org Cc: Dan Williams , Vishal Verma , Dave Jiang , Naoya Horiguchi , Matthew Wilcox , Jason Gunthorpe , John Hubbard , Jane Chu , Muchun Song , Mike Kravetz , Andrew Morton , Jonathan Corbet , Christoph Hellwig , nvdimm@lists.linux.dev, linux-doc@vger.kernel.org, Joao Martins Subject: [PATCH v6 05/10] device-dax: use ALIGN() for determining pgoff Date: Wed, 24 Nov 2021 19:10:00 +0000 Message-Id: <20211124191005.20783-6-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211124191005.20783-1-joao.m.martins@oracle.com> References: <20211124191005.20783-1-joao.m.martins@oracle.com> X-ClientProxiedBy: AM0PR06CA0093.eurprd06.prod.outlook.com (2603:10a6:208:fa::34) To BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) MIME-Version: 1.0 Received: from paddy.uk.oracle.com (138.3.204.47) by AM0PR06CA0093.eurprd06.prod.outlook.com (2603:10a6:208:fa::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4713.20 via Frontend Transport; Wed, 24 Nov 2021 19:10:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 51b0b42a-01ef-4062-0844-08d9af7e1923 X-MS-TrafficTypeDiagnostic: BLAPR10MB5234: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2512; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7Fhq/chqcx9PTYYm1AawQPlzC9UUeipBBP9qYllo5zD8F7mL6BNkhkpzdku/EpSMrHcdnJ4ZutTNcljDwjMpoFqHi42ZNWsJ2u3gUlbhJg+KR4WicgrVIofGPfv+Q3SIFZpk7zVD2pUEWrCIQxI+Xl5R51X++vgqKvJSI7jFwraKr3it8YcHZPx6sYqalDawOUl+7bjGcS4nW08c9gAMeIezsJ6gtvNS0SIwGG0974Prhp4xMYZ0sakiAbAotlkIstToRqkyg8p3ewO41u/R6had0njxChHDE6a38XYiTozFgU8ga/y9olhKXPeDoFs348GhjzSzLsaYFBeGpDqZ3FnMw3vTgTAQDp/zaY31ahwMM8YM0XNcfYv3sefWl1OHSuw8m95jnELrz+sAzkhF3oacgi2Ly1TYGEkA/tZnC81gafYtpMzuhncPFPhpuCjxjbOWT8cPOa0s6gtatJEvtzEJbTidmYdd+UQukp40wE8+i8zaBXM7g1+UO7OLuHIsLXPcC7xFPb3jRyJfE+w5xS4mKoJhT4Qk4r5K1bSsYWtGbHMfOqT3WRcOHn38nU5vzm8ItbY2hheAXcdxL7uIa84T0Q0JkhbozxSRVQ4c1sdKlTJKSsIVmbhPgmHIKfkXkexZGYUPdOtGOGzAacmJcwcJl9lLdcJBNBXEdj/9L8VefDxQPrahzgSLSXaO4hAQvvzti9e3Vl723+7acUrPiw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB4835.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(36756003)(1076003)(26005)(7696005)(83380400001)(186003)(6916009)(103116003)(316002)(52116002)(508600001)(5660300002)(38350700002)(38100700002)(107886003)(4744005)(7416002)(54906003)(4326008)(86362001)(2906002)(6486002)(66476007)(8936002)(8676002)(66946007)(2616005)(66556008)(956004)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 06XCv/JxSOjPNxsL1IRhlqjzO28qwZmtYOhhzukxAsZX8QdfSDmW8tfunUBvKyxIOz69a0DCjze4iG6kU1ZxHzOf9khqjFALXOuKXey7UEBvdBv6eS0cjX9gEOglFdq3ALuNR+xZBvR1wtmy/fpNGHP9LVZEn5N54/p141IUZW6hpjl1HlHHp64bgSzht+Nry9xGKoXPCZvutYoQ4qP42kJ8KkieVn/WI12C1/YY7xlnFacHw4DOuMkmXagwOGSWoBm+z8otFrC3vKMEnb6/A75LH3D24Zzq6+4GyluMAJsgRcwyRkHxdMqZ2SFGYRvoDcRlUpSfHahiWKBc/4hdyPaClRUEAUX5RFr9CksBMxmCHCWKk2SDiFQbOi6E6DdaQe7EBNR6Y9HXF39wN+BgIVWLFDi/SZn3TaMN83gzcg/wgcIiJRAdNVsdCV/qDRGKQU0gLR5LmgWnYE7Z4rm+Ecg0/Vy1UFvovqr+GdZ/F3DH1GpbVuPSQKE8Ty1ZVrqCPrUZNN0xhuS+ObjBHISFc0fUUlpb+YhI+Z5i3CXzKthEMlfwtAG1pKccXuSpUoA+8W04uZcNoWphpX1+rF7Odq2vIjeaqdXUuUV7vxpo5XAKh5X4gFQCgVYHB/UhTecORmuNtENmjeTzHa7nHeGvIGk43RXLiI9kUz7WdkbxBgHFtnS4kcGHGbU/RcPp8cczA9qhemCwJFTlR2QJIlLLtSPM21jo/KPd4UmKXez/h0X6LdUZ9pqsp9JyGOOoQtCrPtcepuLrMK2vIljm7Bftr7q1+FheTfMAwdi0Mt6Svi60mbkUPNaP99HB0kfze30aTAcIdB/eIot0+JLekQNfMc4KoqQzVVu9miaAUWYIhCjBrdNqWLCR2UqtgczcQZLLKo1/ftE2nz1ZNc5WWn5ZIxPznSuUBBTd0LzjJ5ed2Pdh/RSrFFOAAx0m5Qq2s1WOk/DnXCdxU6ECVYgTEvYkRS4N259SYReaw+sorMmjKCgbjsJXROwu2k0TY5HfxvhzD0LusgUmsSNHaoVFDVxLFkbbsh8JuGcgF5N8LQBs4ZVWMrx+mT72w4a2fa3EwlKwh56I8Pn+CkEr8V5CjoJoFRX3Ejyw4dVlYXvMjDgUet8s1Ndztkb9ZXXErmpVTipz6KlxznaBJzNFK9LycA+O+eRDkeOnsEXze1d41f4XJ/jM7dR5Bh/u0bleSpRo/i7H892fNMeyF6hYJs31QGspQ0AkRb+ANJHqiJWmlC7QB8B4C22vj3od8AHK1x5rQ1Q0ehcZBheYzclCvqN/O1RBTiEM/WVPJLu2boEMo0V18nAe1noxoQOL9fLQB22QGVtrwVAuh+Evo9rwg62OBlHwT0+sXtOYfXVZkjUxKFzrIwVHN9KHfcQzwSbpG1d/iowjU4GQSOlsGJm5TFJ95kSqvgtFSzwujljmeo0CdjGmV4qkr2QCjw3zW8tG48K0it495hxMSXopvfhROlMPLAS5tf0wOIY3Ds/06GcIugJ/Z8d9o1uFrvdyVtAMr5Z0AFV66R4hHhKgcFSYY2FNkt0898miJecr5VEflP78gDBRWO7Scf7YpqpVW2jNAhzyAx9QMygrF6arptYudixTkbPjaF8Z81Z+QNyiNgR+l5W3GwiqK2TEBxlPzDLXt6HNmOJb5UwS/cISD5V6+J/6A7h5EA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 51b0b42a-01ef-4062-0844-08d9af7e1923 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB4835.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2021 19:10:37.5357 (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: Atm7XJolu/203de3KFHIdDE9O+jwrhH+UPEQm3/9JddM/Ykps3ZiwZlfd4G2S1o3SQ0L8RQy8m24h9/hf25ffw5FzWRTuXzNZdXVPevpftE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5234 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10178 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 adultscore=0 spamscore=0 bulkscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111240099 X-Proofpoint-GUID: TYzKT6S7jKs9q7BLIOTNCXg6gXNUYk_3 X-Proofpoint-ORIG-GUID: TYzKT6S7jKs9q7BLIOTNCXg6gXNUYk_3 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 0E04770000A2 X-Stat-Signature: tgxgxfykpa79ooha9iyir6xh3rcbw94g Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=oMnJISYV; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=tfQx5X+p; dmarc=pass (policy=none) header.from=oracle.com; spf=none (imf27.hostedemail.com: domain of joao.m.martins@oracle.com has no SPF policy when checking 205.220.165.32) smtp.mailfrom=joao.m.martins@oracle.com X-HE-Tag: 1637781044-401395 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: Rather than calculating @pgoff manually, switch to ALIGN() instead. Suggested-by: Dan Williams Signed-off-by: Joao Martins Reviewed-by: Dan Williams --- drivers/dax/device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/dax/device.c b/drivers/dax/device.c index dd8222a42808..0b82159b3564 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -234,8 +234,8 @@ static vm_fault_t dev_dax_huge_fault(struct vm_fault *vmf, * mapped. No need to consider the zero page, or racing * conflicting mappings. */ - pgoff = linear_page_index(vmf->vma, vmf->address - & ~(fault_size - 1)); + pgoff = linear_page_index(vmf->vma, + ALIGN(vmf->address, fault_size)); for (i = 0; i < fault_size / PAGE_SIZE; i++) { struct page *page; From patchwork Wed Nov 24 19:10:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 12637549 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 8A377C433FE for ; Wed, 24 Nov 2021 19:15:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B79D6B0085; Wed, 24 Nov 2021 14:11:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 165F06B0087; Wed, 24 Nov 2021 14:11:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F230E6B0088; Wed, 24 Nov 2021 14:11:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0204.hostedemail.com [216.40.44.204]) by kanga.kvack.org (Postfix) with ESMTP id E240E6B0085 for ; Wed, 24 Nov 2021 14:11:07 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 956FB184D423F for ; Wed, 24 Nov 2021 19:10:57 +0000 (UTC) X-FDA: 78844766112.27.DF49B09 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf16.hostedemail.com (Postfix) with ESMTP id 25929F00008E for ; Wed, 24 Nov 2021 19:10:52 +0000 (UTC) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AOHa4Ix012792; Wed, 24 Nov 2021 19:10:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=MA4VecHh0l8AWrW9XudQugjpfPgplinZmvX3+fimGXA=; b=TYzJWhnf3DbneUpp0OLAitnf3LHIekst00HAC//6qbCf3XszCdoqkpm9cuQ5QB0W6ktL Z/LabQjh7+bYf0iVZSzAnQfN0mzNdhrvFl/vQnORAajfLqB0d777RRmXErAnHKOMjXif o7CL0jvj9h79nRxNvdTj5X7+rAtpJVOe9f96jokReKT5gxacZTQm0guSu+p1r3WohBmq PkUJFhr9Q+ZyZrTv6E2e7PYYfrZx8i6uo2z5ueZ4JWzhuDNYTYy8gIP+eSeOtvCJf+LS A2fG13/ugleWGWhKkI6D6PtIrlryMIewmrT/H4XPN1MboSs4eTqLiG2UPR1Hyc53gcFc 7A== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3chj7g3876-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Nov 2021 19:10:51 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1AOJ1KPs178822; Wed, 24 Nov 2021 19:10:43 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2175.outbound.protection.outlook.com [104.47.56.175]) by aserp3020.oracle.com with ESMTP id 3ceru7j9n7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Nov 2021 19:10:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jq0pDOhiMfwofd5leeiwZjjewgkLokMigacz+gGTqSaqcC0eAS38Uf8+SFxbgFmix3/6qRZoV46Zpm2X98sA2X06eaWW7WQqid073aGZ2jSs3RT4G/tyxJ7XsN5Si18jX/QBoCJkdZJWu4oOerMZVHELxROm29Xbo7+dio1nGmtCRMF0fcx4Xm/x06oVYJ1X5Ku2et5oT0mHloir39o+wUzEhxfjj78N+KD2Kj+hgyLhmo8tcYAErEqB7kqQ4tf7RDETGdpPbG3OboFDSFj/xxGkG7QVHGCk6MVLm3ogUf2SymZeeyLHJWbYNuIvSAlz8jEil1Ofiyiq5g2svcFqmg== 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=MA4VecHh0l8AWrW9XudQugjpfPgplinZmvX3+fimGXA=; b=bnQ0Gq9EhWfggilQCEie0di5i/6TA9F4RR1B2k6GeAVUSZniquoSyLW52IbwNnPUwKnr73keH/qrN7H6+FgLMKGZsHQJIgGBynNCUlHtgyG9x2QJPM9jRYLRNz1clmGSajGxYkPIQv5ljsoVX016++bFdeZh5a/Avjw/k0lOZAH8Ep9lqlBOTBFvBNsuh2ISgscEEZ//Glwtxujf+al0b7vFDvQ25eAnqubMNij2mXxT63IfBmufij/GBnDL51SccgbqQk3n2wji7IqkoueTGpWTDVJHTDrdKkjYqvpYIjx80NG7/2mA7CzdMBkH8hXmt7FNmJSk25BkPbBOYU0pWg== 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=MA4VecHh0l8AWrW9XudQugjpfPgplinZmvX3+fimGXA=; b=oQkTg8fb1IkuPkb3pCctfVf4hA4C1s1RNlUNKKujDVc6L3njYAAUomMjjlce0jlYu2M0FZgf641YK5gM3/XX8hhzsv5qn62fWnt5YvX3uUR6fHeVSpyoNP/H1CMDZHxTENz+wn4IYSXA+N+0t6aE6oMXZPLHaooM3Q9rsE19JDg= Received: from BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) by BL0PR10MB2916.namprd10.prod.outlook.com (2603:10b6:208:77::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.22; Wed, 24 Nov 2021 19:10:41 +0000 Received: from BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::d809:9016:4511:2bc6]) by BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::d809:9016:4511:2bc6%7]) with mapi id 15.20.4734.021; Wed, 24 Nov 2021 19:10:41 +0000 From: Joao Martins To: linux-mm@kvack.org Cc: Dan Williams , Vishal Verma , Dave Jiang , Naoya Horiguchi , Matthew Wilcox , Jason Gunthorpe , John Hubbard , Jane Chu , Muchun Song , Mike Kravetz , Andrew Morton , Jonathan Corbet , Christoph Hellwig , nvdimm@lists.linux.dev, linux-doc@vger.kernel.org, Joao Martins Subject: [PATCH v6 06/10] device-dax: use struct_size() Date: Wed, 24 Nov 2021 19:10:01 +0000 Message-Id: <20211124191005.20783-7-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211124191005.20783-1-joao.m.martins@oracle.com> References: <20211124191005.20783-1-joao.m.martins@oracle.com> X-ClientProxiedBy: AM0PR06CA0093.eurprd06.prod.outlook.com (2603:10a6:208:fa::34) To BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) MIME-Version: 1.0 Received: from paddy.uk.oracle.com (138.3.204.47) by AM0PR06CA0093.eurprd06.prod.outlook.com (2603:10a6:208:fa::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4713.20 via Frontend Transport; Wed, 24 Nov 2021 19:10:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8deb342a-9ce9-479d-83cc-08d9af7e1b37 X-MS-TrafficTypeDiagnostic: BL0PR10MB2916: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2N2p1Kxb9Jhtk+wrsu/HiLFB+jJIDWjEgzsJmwb5X6gyc9zrsamMN89AotUKLyM7KpdonM2qX/2xcKX3unEWymUWTM4q4S/tU0MgtR/wQKw00rhN3ZmETrb3J60dvPrH3QNM6BZWho+gTPXEfRWQMJLZIPXPATzhX5tdryMbB17Zn8eE0KPKsFASQ1rfDhf6gRl6shMSG7Z9s6nGIe1oZCUT3zXfEYVeoFQbR9QYkIyf9JtdH9RQ6m96QWvooYVLhC3iz/ShA9vL1KTOKWCZLtqRln5IESSZksqeTTUP73iCqaUyPPdctmgFQPE5SizsCUQlObXc2QevzTVoBqEbj7TFeL4ZXJ/PQ5UkyzwgtSHuOptRh//6dBztBhk728pCAFXiZp1Q58hsYmprbeVqwklOz9E2UNtWkQgrFHuHvz+glTRutJ8VrMoC9e758hZxUQONLKrP4FCeV933lzFxzsb8tJAYbWkUnC/R3qRZEqiXBITQOaickruAp9NJEyI7gx3cKzb88P6IogZ2q8imtpuTr9AB6vXl/Z1+P41Hn3vjQbR08e5XN55hfooAauPAaJWqY2Iog6ewHsvvrUzJkJHoZI+4XJ5L+JnBmx3LAjVmZ7xu9ESUZfbZ8fEz7CD8ypnCqlzuCAcob7j7grdAaMHX4ES+yeLqL1LJIGfH21ZbcL6c8yfvXfF5UXHJfiZz6F9O8ZGhzszS5yX97OmIv1mbPQMJOz8mefoyXmHZvx2oo8bRdy7r8aQpfebodj4d X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB4835.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(4326008)(5660300002)(103116003)(1076003)(4744005)(36756003)(107886003)(6666004)(956004)(54906003)(7416002)(38100700002)(6486002)(2616005)(86362001)(8936002)(38350700002)(7696005)(52116002)(6916009)(508600001)(26005)(8676002)(66476007)(66556008)(186003)(2906002)(66946007)(83380400001)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wMpH7R2+UN9aNtnelr5zRqezgzS7XyUkbtnX9eGCGKfU118zy/fYlua7uXAiYfVNNHhgguGmzoaCyb6GSvZhY/SVhCOe0rkoNVNnMwklsL1uFRHjUfFTnMuTmGQ8NTKyOuZeDtz32cNGFHZEU/rFYpKXEvH04BVl2IUKhAgf0MlEtgxynQzgaX5ShIeWPyUNNecsAVyZ+u6Z8idoOhaArbywq2LhhEp8mE1463ZjoeXJfs3lP38c4s5xbSa5GhllLcssz07b1Ut/0xyTsvYn9pCSfiyO3oL91U2qRjy/53O4fFgvxdVqCbDgwkgoi+oVtAGggNKbSnJ20dmLyCGFvdJk412Zdm5OhKqL+0+G3URm5ymBhI9kNeExxYpv7bXC+yQ+VSEGWeQJE7ziVOw53cW5ADxdjOyb/k/4pre/YYjG0mrxbtiFLQOPA90Ci18b0w7Eo1gh4pTfvZdRZmxXH+UXbzZLF/HMjYrhV/h2oKk+XDzRq/7RLVumJwYvlSSf7NOnd1MV5pK702XdIzRolGq1YS7lLxbpcmeDJyv0TGqDIx4pHYIB41+Hu6Xo9zZFnkWs+KZ8cu3NLprG7GnZ7P7e69uvFpK4x5hB7cm6YrUks8gFwVNXOqg/wII3I04c8MirqhU5pBqp/aEGU/Mw+KL7yV8xHeqBncy1XM2vKQIEZHNF5UViLRIxeLnVCqDfMhDBKaliJzkPftlTPnxsvYRJ0LsuzdrMBNQ7hc0hSerfEyNDYdTpgPRuxZCvhIg4cEskmRiquqncZUygUClVcE4I1a2Hnk/VBcFIRgHi70ne8dW7ByMo4zMBunU5smQSf50C1onTQHNTvYM7jvlmPMmC2BvKrZALV0z9TFjZpqFvKjhRUFjfsJQnUFaoIZNIdfj3/SzoAj3IRpJvY8K/nTXYNAik3DR8dJfWHQuHbbeDahg/HT6sOlD0XBQnOrN+/sdyNd8E+nroIikYWiikImLz3uVNNr7hc3IbD8aK6YuQkf2vCo9p5UvxhAUlkbMbUHGGWtb3BBw2RSWpLen5UX4MM0zV9P7EInc1ZOJEpuIqnhF98o+4qM3AE1fgqtAhABlIsAh9bJ3NHILII+Vv0VPzKOxxOZQHVFba6nnjDvwF7zluUATEBzUHwHGe/5vmYWDME9PwSv6uTVvkprKPdQ9fHPOJbbDG7WzTzfMP+qLX0xnMuwb7hSWmKM4sDJW4n+3COP02stDBoxDHCaK0nS5bEYXMRwXvudCZjaJCNRYErjHqkSHpL9f3LZYy2VEaZcXVVHwph+9BrGujK3v+Iot4KrzIoa6yriKvJ6nuqEGGo5AMj/KluICJ2oPC2MudHfUYSdhQvQzjKBksnOqGMTD49tLGtULE1kA5xXAnuwsnay1GSg1VaLcTCN1aXDVLW2ajQris4ilM722HX9cOclWuUguciXsh+n6c1MR8Utx1EZNVQ5A75Ypds5ZBGmp5cWNOmN+QDQIZm0MxSoUfbezHOD81ECKkIWhZ+G/RU9VQStSi7HO9qJutmVlPH+FW2l/1yiocmcU7GvAgGxIWiryKm5QtPCpYXCtj2GX90qdDKYmGZ+SHzHDAg58f+4Kej/pZirDdr1ekL5ZN7J4sNpFvYRexwfyY+rifncRNl35JEH7LYkJ/F2QAG96zyxa6RjYZJbbgSF6bYlHBB/6i8A== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8deb342a-9ce9-479d-83cc-08d9af7e1b37 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB4835.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2021 19:10:40.9697 (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: JPQj0sOng2tql2Ec0EMU4Ez+5UiHFXg7LfTbItG5BLRoWGgONNADyI/56rVOoeteDGtv5AZIHsJCDjRC85HYBsnuhMxk9go1IZTWajDR8P0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR10MB2916 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10178 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111240099 X-Proofpoint-ORIG-GUID: r4BG77tGTnqyxh9GcLR3gm_T3Nn8YkK3 X-Proofpoint-GUID: r4BG77tGTnqyxh9GcLR3gm_T3Nn8YkK3 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 25929F00008E X-Stat-Signature: 6qmscgiu1sc47no5dnsiju419qtizzxx Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=TYzJWhnf; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=oQkTg8fb; dmarc=pass (policy=none) header.from=oracle.com; spf=none (imf16.hostedemail.com: domain of joao.m.martins@oracle.com has no SPF policy when checking 205.220.165.32) smtp.mailfrom=joao.m.martins@oracle.com X-HE-Tag: 1637781052-224163 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: Use the struct_size() helper for the size of a struct with variable array member at the end, rather than manually calculating it. Suggested-by: Dan Williams Signed-off-by: Joao Martins --- drivers/dax/device.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 0b82159b3564..038816b91af6 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -404,8 +404,9 @@ int dev_dax_probe(struct dev_dax *dev_dax) return -EINVAL; if (!pgmap) { - pgmap = devm_kzalloc(dev, sizeof(*pgmap) + sizeof(struct range) - * (dev_dax->nr_range - 1), GFP_KERNEL); + pgmap = devm_kzalloc(dev, + struct_size(pgmap, ranges, dev_dax->nr_range - 1), + GFP_KERNEL); if (!pgmap) return -ENOMEM; pgmap->nr_range = dev_dax->nr_range; From patchwork Wed Nov 24 19:10:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 12637545 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 0C9BDC433EF for ; Wed, 24 Nov 2021 19:14:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B8536B0082; Wed, 24 Nov 2021 14:11:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 167566B0083; Wed, 24 Nov 2021 14:11:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EAE7D6B0085; Wed, 24 Nov 2021 14:11:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0039.hostedemail.com [216.40.44.39]) by kanga.kvack.org (Postfix) with ESMTP id D9EC16B0082 for ; Wed, 24 Nov 2021 14:11:03 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A2DBA183EC580 for ; Wed, 24 Nov 2021 19:10:53 +0000 (UTC) X-FDA: 78844765986.12.A4B76F3 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf04.hostedemail.com (Postfix) with ESMTP id 7014D5000318 for ; Wed, 24 Nov 2021 19:10:49 +0000 (UTC) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AOI2smC031388; Wed, 24 Nov 2021 19:10:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=/nhO1hp5r7T4ndz30RLhGRKUHSmXEH+wbvbCgGKJltI=; b=WJyhhANpWM9evjMWwUScPAHaQvu7LCW1rJ6bnoeerI/DdRHiHXB6IE9OPBQmtFlwslXA UzuzvNbEGDKHnG/YEkVyuRYZJkq+652Q/eWHfWRRWK6z0aqdAfsZ7Ap7EY8dkeqQ4CQJ iaqN8ArZyRCEsl5732bhmcbrdkXyzBevhFNzWxaIiOK5LarVG9FRpIHCwMJgH9sCw2wb o1F52X9DiaWCXY6slwyZK355s6pVqBRayyWfYEKg7mO3InT9DFKUC8lZyX0kySpO00CB kdXhM55fnMl6SC0wKBThZdMrP4N4ybXjVsv7pgIgEevSvYhgo2n6Cq0K49OYmqc+B4Bp gw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3chmfn2qu5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Nov 2021 19:10:48 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1AOJ13Wt037264; Wed, 24 Nov 2021 19:10:47 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2171.outbound.protection.outlook.com [104.47.56.171]) by aserp3030.oracle.com with ESMTP id 3ceq2ghywu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Nov 2021 19:10:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cxvAtHFa4mi/MOvh5/8+iX5Nn9sLI3O/xlNL4p8dCNEX6Tk7pFp8OJaGoS1hSa/p4zBGX8RV/O6z7abl/G535WNwLb1T+/Tzgxk8xMrf71WfATNMK0EC07LP4QJH4CmC2tWPbBqlJQxVHK71b/UH0b2PEaRgokzot4scaribdOXsiSCyaoLifK1g/Y7vhR1Jhe5aT06y3xf6nnTlSUd7MBVVvexN0BfABG1ZNnkSHP0boRtquaf60OzWZVV8AonXlVACbYJErxXMP+4dhI/Ua1H+dRV5rLPNnCGAwqIkatuvplF/Dwe/uxbEM2bhYruVuspc6rsNLzuNrNLt57cFrw== 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=/nhO1hp5r7T4ndz30RLhGRKUHSmXEH+wbvbCgGKJltI=; b=iCLIo+ywPU4GtTtuRtxMqFzchCn7thpA7Aes+CWT0Mo6iuYen/8qUJyxdjrzTMcmZheztT8dzSKvugjIvl/Y24wdM8d9pMm+5axeOqqttT1nVyc8E2rRp6gh8WSCKNMgvhcclYm+HyKJsOj7tN3wt2Z2xr89mtYis3ff66XLouN+WHuIR76/ncpThrzLzO/fFh8MJs6hrXVZvtLKo/mJx+UT0BQssQkd5oMgHIxn+gPbZ9ghR4YILCx9JdCdH/hhemIFbY9rTqe9q5VHazKzUcukrShRg4UbRdP+tnOsOlviHMSgbFZbIPtdjSoGVYVfaF8i3S32xGheRjqXwQioGg== 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=/nhO1hp5r7T4ndz30RLhGRKUHSmXEH+wbvbCgGKJltI=; b=B1Q2nJl7sotF0HA/32ZNEMDJWlw1eSB97DCQBIA6exLrJhXDLfOH2SLtGgE1Q/FeaSiRPpNDscDuefNnr7dhNTomoiRz+ShwA8jATL1G4yYhHx23Gtdcz06oDIgoWt81S24zmS7BKwL3T+/IrAmoW1sQ7uD1j7jytmClQxvyfFQ= Received: from BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) by BL0PR10MB2916.namprd10.prod.outlook.com (2603:10b6:208:77::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.22; Wed, 24 Nov 2021 19:10:44 +0000 Received: from BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::d809:9016:4511:2bc6]) by BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::d809:9016:4511:2bc6%7]) with mapi id 15.20.4734.021; Wed, 24 Nov 2021 19:10:44 +0000 From: Joao Martins To: linux-mm@kvack.org Cc: Dan Williams , Vishal Verma , Dave Jiang , Naoya Horiguchi , Matthew Wilcox , Jason Gunthorpe , John Hubbard , Jane Chu , Muchun Song , Mike Kravetz , Andrew Morton , Jonathan Corbet , Christoph Hellwig , nvdimm@lists.linux.dev, linux-doc@vger.kernel.org, Joao Martins Subject: [PATCH v6 07/10] device-dax: ensure dev_dax->pgmap is valid for dynamic devices Date: Wed, 24 Nov 2021 19:10:02 +0000 Message-Id: <20211124191005.20783-8-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211124191005.20783-1-joao.m.martins@oracle.com> References: <20211124191005.20783-1-joao.m.martins@oracle.com> X-ClientProxiedBy: AM0PR06CA0093.eurprd06.prod.outlook.com (2603:10a6:208:fa::34) To BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) MIME-Version: 1.0 Received: from paddy.uk.oracle.com (138.3.204.47) by AM0PR06CA0093.eurprd06.prod.outlook.com (2603:10a6:208:fa::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4713.20 via Frontend Transport; Wed, 24 Nov 2021 19:10:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4473e54b-dade-4728-6431-08d9af7e1d57 X-MS-TrafficTypeDiagnostic: BL0PR10MB2916: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zJiIVI+mS0I+moKCMSWValB9d2NeyulRBLAViiT8F2JUKyZbEwZiBSPhM0P1oawWWyFK/aLyblcB79Enz1RDPMfAsnq3js6fsV+qxq+pKZ3XiyyFBRITA7/r0cXfVNsjRZZLw3y2CSylCwJBr8H5zPMVFiPHGARLCwXiPWaNM1LiMR9COinfxrmgIF79S8rExZrJl7bTw7K0+8pAcKU1Bd9t/0tApyczrnslDf1JhniH8ii3a2vNIvEwZzcTAPdHMtBR2adJcU2rgmFpYLMZxIMDkIcFYbPs9w4fGWghECrSQxyaB4/v65pwdJl28ciAikryTMOna2VhB356nXkYxpcoKgzbyt8+60AQaLTBI3F78it9bDI/QPJCxR4dKl0tvbDMXL2mFnwQCLY4bG54+/Yn1gzTRU4c3dCBGpYHk8vfgFqfCJHaM3yxDptIOexEoo1S0mv123qnm756L5y2OEJ6YPcORiG89pyyqZPNsdyMIr2h9BpnXwLoH4y8mRfstjqTb4llI061GaiECK9PyQQjA784lSzGac82pjd8S+1hFpaLNT8K0d5zoni8lds4DRSpo7vQWFmWfq3LU8QVCOJYBYc74URP6Qd0+FzrZMeQ8YTUijfOfKOX+j45xzLkAHiHiStAx66thfWFlimTKte77c5BAnLU8oYNL2bs03lwX8nsyx5ueMLGw7NM4/RLcWbwur+dF0GH/ZVrAbW7h+VtrjiLt09dKED9fwjcnLB4n6N7Y7bqzsi6RyrlHcMa X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB4835.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(4326008)(5660300002)(103116003)(1076003)(36756003)(107886003)(6666004)(956004)(54906003)(7416002)(38100700002)(6486002)(2616005)(86362001)(8936002)(38350700002)(7696005)(52116002)(6916009)(508600001)(26005)(8676002)(66476007)(66556008)(186003)(2906002)(66946007)(83380400001)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KxT23KISPC8Xyq5/rL8CmVzCCAotvGOHjyNzzpD5A1IfnTqCxrglsVEsUmPGCg4FtJgXzaybUQYC6NoWRjLaDfTFDYc8QVng+EX2J0dQqeM5X2GNwVbpbs5e+g3lY6XmaDzQjwrrfAxJGu2H0X1GvfCndhdI9+fc9AcqDZx7rdXazKS9EegXsuVkJHumUJLV1o20JASb5Ylrdv92Xis9PlTOV05up+zDdlYsP6MgbWnj2cE7fgkHInQX2JEmmXWJ7d5ZIN960mEO5TCeEGw04iyp8bbSLO+GvVNg3F7qPjEYVQZ8XQ2UewMceNkIqze+HD6BnRuTZYoZTKhfvXSUaWLA5PLykFb51l0DoEOS1j6uSU6TcidaOXdpFEnzVAklc3vGa0sl4aFRgqHb+VXQTSJ6m38alUSfhDD4SIDbNUNnoxet29sfujCoj49Nz8Z9nRQ6t1eCDPYIsQP/+8b7XZoGk5Zzud51cpw74B6YeU+JGgvi+gZwaRE694OKdUYVgy1UGOKtLUwgT6445s9z8xUcV+LE+Q35RI04ADz7t37+53ku5y5pm6ylvTH4mN+8WkGis9QjDmQOPh5x4U0FOsDFeXJ8cbjPYiIsK8mmxn1qM8r3h7KxE8LY8oitoRHXagW1WKpn2PtXF0TibOOfLZ1ZrqQQjdbo1RL9+no8iG3vQeePPYxzWH6wkuqVMl8xQuhhxqlqXo/y53JKcWwMZJMQMxRWOJViFE1lLFZWdzt3CNZFH2QC+GjmPtGoWdTKpHqih1aaMo9mNJhNdNnfxSq0yHUHdV+3pRdFNy8+r+VSiREuHvQS/XO6Oh7xUkpWWs764Yiyt/A57Imp5InBZqAI3c1BK3rlDuU2JJFcSzhH+VPPF0QefEM5gok4hhZnCf8y1Ut/NSRaJ8wx4DgATrOW+veXhW2wUI+bNJ4TRPZFgbo1Wmk5PRJIcsVvekh4clzPsn1cW4apc2DBnuKW7f8ZKlIrSnDZOVd3HvZPjzW5XvZYofZogEQbYZgBlcbrV6y7KxACnMCI+Nhf8for2x6kC9AHm93xZjAYm8o+kYXBv3h7DfclkkBvijDwuKp2VOkal+AQ3COk3BTEaxAX8mKjzVPJJwVeJGh4kIIuWpq4EiRMycQ3kbJaMUYCKcRTJDtLIGq53qmjUZPtXEZe7cGsKA2Lufe54KKpzIIqmbJuepWhUcFGHA3V90sX3mCHVb/JXn+vHZdNIpDoCTsTln2Xd1MZcaBZRjHblSkmGzC3VwQVZB3zhFuGK8feQOB6E8/y4CS0+eI3wHExjCbnvkKX6aCdQT0OQMnOCnj5W/xqvoTYWBQjIRAbJY0jYAeQlF80S1RaWmnGqyCqb9N148BMd23+ZMRG/T4JnNeMTQ8XjsrNn7GKfBO3W8Tb0G1eUM56ZTm52gYzpUzv50FS7Bq76iLw9/0gc2NG1iXxURY1R9zRmjYLHO3ernZBllVizBNCbg+lZ3tM9WUTOpS81Q38iqbdK/Cq47U/4UfOO0wo/j1y8JR8vvHkR6wJutoSDIba0oYbXvzkOHmeQfXkfPkUOLtNSS3Gfz5qgMmGw6kIoQNs1vPYqTYCJPOMIEGUa81qDpUHPKGoG6jgbHWNB3H0xOwWG+K3273RVgCvPhdT0F7HPUk4UvuSXiXjULU7sdLeu/SxxG6UcMDN+A7wxQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4473e54b-dade-4728-6431-08d9af7e1d57 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB4835.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2021 19:10:44.5211 (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: bYSzIueGzjlnpLCU+Zj3UfOO1gC0fBu23Dhan7h55gOXbLoekAaKTU8IV9xoUqOjjPdMo7kB856qABbHEVBLrCSgaSJUe9kCTjCfnm6rI8Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR10MB2916 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10178 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 adultscore=0 spamscore=0 bulkscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111240099 X-Proofpoint-ORIG-GUID: QwhXKrp3r8Y_pON-73azZb4yQuICCg7Y X-Proofpoint-GUID: QwhXKrp3r8Y_pON-73azZb4yQuICCg7Y X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 7014D5000318 X-Stat-Signature: b5ei69cnqth3fqjmg9pwm8yjpco4hkcc Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=WJyhhANp; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=B1Q2nJl7; spf=none (imf04.hostedemail.com: domain of joao.m.martins@oracle.com has no SPF policy when checking 205.220.165.32) smtp.mailfrom=joao.m.martins@oracle.com; dmarc=pass (policy=none) header.from=oracle.com X-HE-Tag: 1637781049-243673 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: Right now, only static dax regions have a valid @pgmap pointer in its struct dev_dax. Dynamic dax case however, do not. In preparation for device-dax compound devmap support, make sure that dev_dax pgmap field is set after it has been allocated and initialized. dynamic dax device have the @pgmap is allocated at probe() and it's managed by devm (contrast to static dax region which a pgmap is provided and dax core kfrees it). So in addition to ensure a valid @pgmap, clear the pgmap when the dynamic dax device is released to avoid the same pgmap ranges to be re-requested across multiple region device reconfigs. Add a static_dev_dax() and use that helper in dev_dax_probe() to ensure the initialization differences between dynamic and static regions are more explicit. While at it, consolidate the ranges initialization when we allocate the @pgmap for the dynamic dax region case. Also take the opportunity to document the differences between static and dynamic da regions. Suggested-by: Dan Williams Signed-off-by: Joao Martins --- drivers/dax/bus.c | 32 ++++++++++++++++++++++++++++++++ drivers/dax/bus.h | 1 + drivers/dax/device.c | 29 +++++++++++++++++++++-------- 3 files changed, 54 insertions(+), 8 deletions(-) diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c index 6cc4da4c713d..a22350e822fa 100644 --- a/drivers/dax/bus.c +++ b/drivers/dax/bus.c @@ -129,11 +129,35 @@ ATTRIBUTE_GROUPS(dax_drv); static int dax_bus_match(struct device *dev, struct device_driver *drv); +/* + * Static dax regions are regions created by an external subsystem + * nvdimm where a single range is assigned. Its boundaries are by the external + * subsystem and are usually limited to one physical memory range. For example, + * for PMEM it is usually defined by NVDIMM Namespace boundaries (i.e. a + * single contiguous range) + * + * On dynamic dax regions, the assigned region can be partitioned by dax core + * into multiple subdivisions. A subdivision is represented into one + * /dev/daxN.M device composed by one or more potentially discontiguous ranges. + * + * When allocating a dax region, drivers must set whether it's static + * (IORESOURCE_DAX_STATIC). On static dax devices, the @pgmap is pre-assigned + * to dax core when calling devm_create_dev_dax(), whereas in dynamic dax + * devices it is NULL but afterwards allocated by dax core on device ->probe(). + * Care is needed to make sure that dynamic dax devices are torn down with a + * cleared @pgmap field (see kill_dev_dax()). + */ static bool is_static(struct dax_region *dax_region) { return (dax_region->res.flags & IORESOURCE_DAX_STATIC) != 0; } +bool static_dev_dax(struct dev_dax *dev_dax) +{ + return is_static(dev_dax->region); +} +EXPORT_SYMBOL_GPL(static_dev_dax); + static u64 dev_dax_size(struct dev_dax *dev_dax) { u64 size = 0; @@ -363,6 +387,14 @@ void kill_dev_dax(struct dev_dax *dev_dax) kill_dax(dax_dev); unmap_mapping_range(inode->i_mapping, 0, 0, 1); + + /* + * Dynamic dax region have the pgmap allocated via dev_kzalloc() + * and thus freed by devm. Clear the pgmap to not have stale pgmap + * ranges on probe() from previous reconfigurations of region devices. + */ + if (!static_dev_dax(dev_dax)) + dev_dax->pgmap = NULL; } EXPORT_SYMBOL_GPL(kill_dev_dax); diff --git a/drivers/dax/bus.h b/drivers/dax/bus.h index 1e946ad7780a..4acdfee7dd59 100644 --- a/drivers/dax/bus.h +++ b/drivers/dax/bus.h @@ -48,6 +48,7 @@ int __dax_driver_register(struct dax_device_driver *dax_drv, __dax_driver_register(driver, THIS_MODULE, KBUILD_MODNAME) void dax_driver_unregister(struct dax_device_driver *dax_drv); void kill_dev_dax(struct dev_dax *dev_dax); +bool static_dev_dax(struct dev_dax *dev_dax); #if IS_ENABLED(CONFIG_DEV_DAX_PMEM_COMPAT) int dev_dax_probe(struct dev_dax *dev_dax); diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 038816b91af6..630de5a795b0 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -398,18 +398,34 @@ int dev_dax_probe(struct dev_dax *dev_dax) void *addr; int rc, i; - pgmap = dev_dax->pgmap; - if (dev_WARN_ONCE(dev, pgmap && dev_dax->nr_range > 1, - "static pgmap / multi-range device conflict\n")) - return -EINVAL; + if (static_dev_dax(dev_dax)) { + if (dev_dax->nr_range > 1) { + dev_warn(dev, + "static pgmap / multi-range device conflict\n"); + return -EINVAL; + } + + pgmap = dev_dax->pgmap; + } else { + if (dev_dax->pgmap) { + dev_warn(dev, + "dynamic-dax with pre-populated page map\n"); + return -EINVAL; + } - if (!pgmap) { pgmap = devm_kzalloc(dev, struct_size(pgmap, ranges, dev_dax->nr_range - 1), GFP_KERNEL); if (!pgmap) return -ENOMEM; + pgmap->nr_range = dev_dax->nr_range; + dev_dax->pgmap = pgmap; + + for (i = 0; i < dev_dax->nr_range; i++) { + struct range *range = &dev_dax->ranges[i].range; + pgmap->ranges[i] = *range; + } } for (i = 0; i < dev_dax->nr_range; i++) { @@ -421,9 +437,6 @@ int dev_dax_probe(struct dev_dax *dev_dax) i, range->start, range->end); return -EBUSY; } - /* don't update the range for static pgmap */ - if (!dev_dax->pgmap) - pgmap->ranges[i] = *range; } pgmap->type = MEMORY_DEVICE_GENERIC; From patchwork Wed Nov 24 19:10:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 12637547 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 2086BC433F5 for ; Wed, 24 Nov 2021 19:14:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 00A5C6B0083; Wed, 24 Nov 2021 14:11:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EF9EB6B0085; Wed, 24 Nov 2021 14:11:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D749F6B0087; Wed, 24 Nov 2021 14:11:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0159.hostedemail.com [216.40.44.159]) by kanga.kvack.org (Postfix) with ESMTP id C4D5E6B0083 for ; Wed, 24 Nov 2021 14:11:06 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 84F40824C43E for ; Wed, 24 Nov 2021 19:10:56 +0000 (UTC) X-FDA: 78844766070.24.EB1FBFB Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf08.hostedemail.com (Postfix) with ESMTP id 3D985300025D for ; Wed, 24 Nov 2021 19:10:50 +0000 (UTC) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AOI2smF031388; Wed, 24 Nov 2021 19:10:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=ebePip/+Gdg9SlJTCVyJbN+5HNXO4O1rodv0cXLk5hw=; b=UloswvdT/z2X6+DpQ4naVElmVy4HW132s1QA8nxzuex76hHAeJJaOIoBJ8D2VPZ1MXQV 8nLM1kGaIdkdWUB/6edHF/My3OAeM0joWU9S7vICA0WWdHfMXFU45cVdN5i7B1WDSDQA O6Q1ynYZ3R+QQmyoOB0nEOR2HLmSj5mqEO1eL+2e37q40ssTGUAvIDhrS8tQpjuh7RVn MYB/6YVtviBVPJlhSR6abWZMiPZMUffiMLnOZQ4chO2UGmnmyMkhhke/NALyiuUS5JEk PLCvzhhJY5mRL1h7N2CEuLYCfy1ptxRyYGME9KNid2aWKiHj2B/giALrDLG00cZb4G5Z Lw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3chmfn2quf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Nov 2021 19:10:51 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1AOJ14Xa037405; Wed, 24 Nov 2021 19:10:50 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2177.outbound.protection.outlook.com [104.47.56.177]) by aserp3030.oracle.com with ESMTP id 3ceq2gj005-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Nov 2021 19:10:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j6ehOrlUrd0HaEBO7agBdB76WOT5d6I6d1uj/0sczclLgeReQkaRQhkT+nn7jULwNSqIBgSfhSEuPPSGOtvxNc+X/lN+wVEkgDWCfqxv/g+V58nuIc7RQM4M0MKYB+QXyFDabeUKWi4gYBZqutKwjxLColsi3tQK8vgxJHdw7Zhx6KPxDpDUq5+EULKY0Sas79B1bs2l6JbU4MG3oH2t9oXwTlfHZSrW/PUjs458Z3SkGIysAEUyZfOGL6Fg54HrBtDrGoBbiPZQd2DWaP7p3NbRqnAJSC85VunOD8gnGsHTdf/nFpma7fklARZrolGwI5COjp/KMM3CbSTdYn4lhA== 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=ebePip/+Gdg9SlJTCVyJbN+5HNXO4O1rodv0cXLk5hw=; b=l7N2Soaxl9GeL4OL0iRIZOPA78qJtgysfOj6qSn3xoTQ8Yu6Px9Fho6C7UZ4HmF4P0B8mUe0KnGk+B7wWNqD+Qdny+P48tU7iv0I/nuR8nfWol1XMnByfbYyKIqpleR3+sXhU7tJfaMABsErD08Gzjjr1/aT4ttKMdBR9xIYAihaAHbjOBxnBV2m67L7ApRRQ21vRcklTbZa2hoS5UZpfsW13LSTqhMmiP11cxx4pDLsrzHm8VoKmwxvmZo2bp+pbVpRdhnXhUrmnM8XYqNDUvGIR5ggeGZopDQ4vD9Q8v24I+SJS/7vmc+7d+cYvdXOv7ZKZ2WOw4nefMO5wATuIQ== 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=ebePip/+Gdg9SlJTCVyJbN+5HNXO4O1rodv0cXLk5hw=; b=hhrHAoTHkvRmEheUgMHeY5XfWTgBV/GMizojI9EcuVu8BC1v9OMjM79/s9mkMWvkk/A2DrI58hd/hfGuhfTOHvSL2N2yUatskEV8lsOIYrA8GctZvs4fv54m9zDTnCnFRhAX/gDo9hTGi9HPjpwPY9kFgTQG/Dh3xOd70DImSXE= Received: from BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) by BL0PR10MB2916.namprd10.prod.outlook.com (2603:10b6:208:77::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.22; Wed, 24 Nov 2021 19:10:48 +0000 Received: from BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::d809:9016:4511:2bc6]) by BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::d809:9016:4511:2bc6%7]) with mapi id 15.20.4734.021; Wed, 24 Nov 2021 19:10:48 +0000 From: Joao Martins To: linux-mm@kvack.org Cc: Dan Williams , Vishal Verma , Dave Jiang , Naoya Horiguchi , Matthew Wilcox , Jason Gunthorpe , John Hubbard , Jane Chu , Muchun Song , Mike Kravetz , Andrew Morton , Jonathan Corbet , Christoph Hellwig , nvdimm@lists.linux.dev, linux-doc@vger.kernel.org, Joao Martins Subject: [PATCH v6 08/10] device-dax: factor out page mapping initialization Date: Wed, 24 Nov 2021 19:10:03 +0000 Message-Id: <20211124191005.20783-9-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211124191005.20783-1-joao.m.martins@oracle.com> References: <20211124191005.20783-1-joao.m.martins@oracle.com> X-ClientProxiedBy: AM0PR06CA0093.eurprd06.prod.outlook.com (2603:10a6:208:fa::34) To BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) MIME-Version: 1.0 Received: from paddy.uk.oracle.com (138.3.204.47) by AM0PR06CA0093.eurprd06.prod.outlook.com (2603:10a6:208:fa::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4713.20 via Frontend Transport; Wed, 24 Nov 2021 19:10:44 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 85baeca7-39ea-4ba8-61b4-08d9af7e1f74 X-MS-TrafficTypeDiagnostic: BL0PR10MB2916: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t3tGOPMBTQh1zdD1KMHgjh1TLz+aejtmqvZmcrRUVhqwQJ/isQxP5hwWjuRRWdUqIdkdb99D5NsehAGAvA6tmIK57RXxCCet/PF+DUupcvbK2KISn2R3Xj+Cuk9YJ35Zv9i+6vkBSwWlZrJ6I1co3OWh/73ehUI77lfLBFqMz3NjDrMsztYWz/HDj24gnqelHE37LSBdtdsLg0zXpHAYD83gNx6Ya8BBo3T59tgpcqby5eXPJNWJpBYvGa7kpLS5QG5/VgFS0JHnHxHEhS5UitS7fJUmQv6qb0juSgpJagaugdGDZoyoWdnA76MKI+QK0VdljegUm23jh8ZjrKDXygS2vdd88VWM5J6wB5BerGx3JbOd4zEwfUsqE88uu1bV40tcmYqThAcMA9vtAzjBn+ZWBYaqqGnMPwlsCiRRZCXj6bfqvyFEB6blPtLZxwEX/5ZzMizVraUJ9gWBWhjz83PaA2Zr4bsRY/I9Hj53k5wdYY5Gvb8EW+CE6+yXdbmHhXrzIFBwiSoWSq3J2HHp4GtfMjNw7hoCzU0LbLju83TzhlavdhJWdwgRM2PQpj1a18M8uKmxzL3zi1Zce0ZrJMO7ehXkm05RRsoxyU0L4MrGIwJ2vNAJ6XK1koz6yCN2KnlIZcRLJRc4HXgH/rtHo8Fklu6Zh3xnkgTmKpuXfN5Z8LhAJr5n73OXIYqFdv4LrSb3iSqziwGDKp3YUqjUXdP3rPA32/6CyybxtccAhOCY5AYPaPP0V9huArZ55JjW X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB4835.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(4326008)(5660300002)(103116003)(1076003)(36756003)(107886003)(6666004)(956004)(54906003)(7416002)(38100700002)(6486002)(2616005)(86362001)(8936002)(38350700002)(7696005)(52116002)(6916009)(508600001)(26005)(8676002)(66476007)(66556008)(186003)(2906002)(66946007)(83380400001)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iOcogGbWNzfIq1F0tmKvOH8Y2yAmBRW9ov+f5UR9ok+ZwryhVw1urQ3k9WCUIkHO79PPV4gq/PA/vKJtuZeL+0gNNZ+qPbDMsyaKvy9cQjB6tJ5VxSLBC3RNDncuSHRU3GhQCm63pie/2V9y0zleNxXJkLg2ZCZZ3hqIYPtQ8NAzwjAmfMmQYjv1CVDMkE7LKzSQ8wqMjeq9a1cOYMKznGlHR4vhoQkGTc+XFs1KrvW5oHHG3pG7uFB/LCEwii6/u3WEdKaT4XLknrH1h99dmJEd4iS7vDHOZI4vwKMEgTX3k+qiZxbdqDZSfVkO0EmwvHTuzIvjAgxhSKCsYT4/xpy3AGvcanLvbzk5aWK9Rk7X0l4imlqY03byaj8Dtg9IBtIELpidKLsK1YCcjI5NCBU7Fx79RHDppol/oq1tpu5FeS8UT7XWA1nq8OaRhbPln/00/olJ8ItPOuJGQvIRVH6ECupBTvQU1Y/WkFPo6B9cfw10xXf5yUqRRtqXEcWPhmZ5HIu6ZSUtzA2C3Aau4uJkGxg5Z3O1bfScFKyg4pkncfEkmxfAL/P3zodQFFz3Ri9CiVAwW0M/HoMNLtTBZHNUXIVEkCN4wWwQ8LsOk4OZI33yVyT0EtEaEp2+8A7KVCS2J5Z7rd0KLrhD8cTLcKEDgoarAhuj8OU2mIdE+hfBjVQXok01Hqcp2Y1vv8WWMJOWtQZd8uuT9y1kge7K3+YjPtt7FR21+YxBrrRRvLkfn/P7+a6STFMRz0IFnNmVAPo2PGOOor8qESNbReqA/V46eQ29+zoJr/FB4AGsTwimu+QC+CkjL3DxS4MCPjtZJOJO2xkhxpsBYn8UlVHouoGXqI8H6pMp6Tpk8pQ5DIOZkk/oklt3mpCfE52PiryZI+UzQH0n+A0J13tLWStDh2TIvgupiJieXCEaH1Yo9He9Rd/b00qZFTDmaulrZeJM+Co4iR1Z0q2Z5wVekxqMX1a8X3UzI0jdRK0Yd3NHYBPmChB9RjDEwN7w/y9CBKZbTFcGgfqfvdpof9mIjhmX/ucnKMsx9IASo2rBhb98tZ5l7xLSc89oPeSdHmft6qu7EbP3YSNk6aQxsUfWscMiy/IfnuB/5ujPyz40UYsS5lI5O4ZL0DSh9OI/vLd1tfrkVDWtKS/FmjtiSKlyGhMhlLokESTlJyfejXH7jzVEcgGZIXULroS0HnWerAETMG8dBdD2/ZWo/oJFQzQfMBz02fY1RpdSou0qgrwN7nHANFFTwmnEWyZfxnOjjmrjej3VBAm6cv9ycpwB/F7Mmuyj7JmNWWGHTPrOI1mUxMKgt7cc5UJVzh84IDSoXu2AMDypr10b4xqW0gO4VyL1YCOYEQ70Af4xSBpc2/iHJR0ixI4kWItse/DEnD4mtKrbrXIPzpDyL85c/pASo2sXD5WlXXzvLSNjXcKfvF1A9F6CoTdRafr1ovq5jTDI9Td9srrmIfVf5JxijbwPMGxiVT6dbWazGo4Po/35ROtFJ4HFT2tL7s8Wyo5ocb1hV2W62/PFwaRm/jWOwVRENMRbJPh1IrCQTD8CIbBav0/cCODOJBdxx6ILWXrjkuFDIiycpMJKVdYQTLRNiOkcDaWDxnoedWbnBT0+GAO90JFG1bxb7n40ZS/opvRZXkXfYHZtKK4MEooKT2d/5I4CjOMGqKLogA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85baeca7-39ea-4ba8-61b4-08d9af7e1f74 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB4835.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2021 19:10:48.1541 (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: ub4iE0sjS47gMoD0PmrCRn3YeDoX0l6OoWw+EeUZOJaUcPlSh8IEQVo70ivUxIv1hx+4j0CF36MKRuHbTuZOGig4bmJBocY2nkYfGHf/tZs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR10MB2916 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10178 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 adultscore=0 spamscore=0 bulkscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111240099 X-Proofpoint-ORIG-GUID: 9nK7fPp0aivsUqUTUQf0DHmQIVtCnUfe X-Proofpoint-GUID: 9nK7fPp0aivsUqUTUQf0DHmQIVtCnUfe X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 3D985300025D X-Stat-Signature: ixsiagrxdbx3d9o48zad59dqbjj5z8uz Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=UloswvdT; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=hhrHAoTH; spf=none (imf08.hostedemail.com: domain of joao.m.martins@oracle.com has no SPF policy when checking 205.220.165.32) smtp.mailfrom=joao.m.martins@oracle.com; dmarc=pass (policy=none) header.from=oracle.com X-HE-Tag: 1637781050-130870 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: Move initialization of page->mapping into a separate helper. This is in preparation to move the mapping set to be prior to inserting the page table entry and also for tidying up compound page handling into one helper. Signed-off-by: Joao Martins --- drivers/dax/device.c | 45 ++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 630de5a795b0..9c87927d4bc2 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -73,6 +73,27 @@ __weak phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff, return -1; } +static void dax_set_mapping(struct vm_fault *vmf, pfn_t pfn, + unsigned long fault_size) +{ + unsigned long i, nr_pages = fault_size / PAGE_SIZE; + struct file *filp = vmf->vma->vm_file; + pgoff_t pgoff; + + pgoff = linear_page_index(vmf->vma, + ALIGN(vmf->address, fault_size)); + + for (i = 0; i < nr_pages; i++) { + struct page *page = pfn_to_page(pfn_t_to_pfn(pfn) + i); + + if (page->mapping) + continue; + + page->mapping = filp->f_mapping; + page->index = pgoff + i; + } +} + static vm_fault_t __dev_dax_pte_fault(struct dev_dax *dev_dax, struct vm_fault *vmf, pfn_t *pfn) { @@ -224,28 +245,8 @@ static vm_fault_t dev_dax_huge_fault(struct vm_fault *vmf, rc = VM_FAULT_SIGBUS; } - if (rc == VM_FAULT_NOPAGE) { - unsigned long i; - pgoff_t pgoff; - - /* - * In the device-dax case the only possibility for a - * VM_FAULT_NOPAGE result is when device-dax capacity is - * mapped. No need to consider the zero page, or racing - * conflicting mappings. - */ - pgoff = linear_page_index(vmf->vma, - ALIGN(vmf->address, fault_size)); - for (i = 0; i < fault_size / PAGE_SIZE; i++) { - struct page *page; - - page = pfn_to_page(pfn_t_to_pfn(pfn) + i); - if (page->mapping) - continue; - page->mapping = filp->f_mapping; - page->index = pgoff + i; - } - } + if (rc == VM_FAULT_NOPAGE) + dax_set_mapping(vmf, pfn, fault_size); dax_read_unlock(id); return rc; From patchwork Wed Nov 24 19:10:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 12637551 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 83927C433EF for ; Wed, 24 Nov 2021 19:15:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 168656B0087; Wed, 24 Nov 2021 14:11:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 118A86B0088; Wed, 24 Nov 2021 14:11:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EAC946B0089; Wed, 24 Nov 2021 14:11:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0056.hostedemail.com [216.40.44.56]) by kanga.kvack.org (Postfix) with ESMTP id D80086B0087 for ; Wed, 24 Nov 2021 14:11:11 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 9DAC282FF0 for ; Wed, 24 Nov 2021 19:11:01 +0000 (UTC) X-FDA: 78844766280.24.6C4023B Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf04.hostedemail.com (Postfix) with ESMTP id 822BE50000BE for ; Wed, 24 Nov 2021 19:10:57 +0000 (UTC) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AOIJEU4000716; Wed, 24 Nov 2021 19:10:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=EcYEsoxnESLwNGCqtEExBV+6TLNOK83bxuWGTwlmN54=; b=bVpMTvUUuYWAp35b0NR+2AskmfmUNYWLfszL6oTK3RYB4JFahRwmAR8/tCXI22zsu/UU lFEtVvLSZy287bNDgTwC371XE4QvdMd2GEv+o8nJDbsiEtrEbIO5A7EsHeffBYmGwcqj Ksux15fvVCC6FNpspK+3xgyQjZ1EFIeidARGpuMJ3C5HO2E/BtFKRLfCWGSCj/0CKS1q 9oOAlTt6o1QHWj7wVxj6XHpXhYqaU8MGhz2GlEkjCWDJG6wGFOn9xVowcUG9I6w50TPC 6NFyJ5b6NwVjQQuVckY5czr7mw6Y/gh11b+EDK/CdCTQSyMaVjLMt6UETlfWklPuOghr AA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3chkfkb0e2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Nov 2021 19:10:54 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1AOJ1H5n086994; Wed, 24 Nov 2021 19:10:53 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2173.outbound.protection.outlook.com [104.47.56.173]) by userp3020.oracle.com with ESMTP id 3chtx6hd38-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Nov 2021 19:10:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gIFIfBz3Au5Cdgwk82/rYLaTDtpBBxwx22K96sIfXJ+rT3ktcKTUmlR0Q+BwxDlPY90fLwXds/tmRzemrfIxGmROSjRAsBzacRIK5ylPehzR0pEZBD7xUh71LXEG73cgEZyMC6iW1PscigxJuGzzjVmvLFbGvFDC3O85emTIe4ZWn0V8UfkOi4GSlAr2ovFPmoSi4Z+KkNZretaJAc4SkvYVojPOuJg7mEaylKv4tFcoE4NrB/Vj/Kxda9BwAeRxEVR/iJjkjX+Ip9ZYZs+1n6PEsSmtFhGPDM8kQBXiw1pbAfDlTDYw9HEhfuty5FCPrn0cItr5mTBvFdU9njVp0w== 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=EcYEsoxnESLwNGCqtEExBV+6TLNOK83bxuWGTwlmN54=; b=EtK5YbR2el5uLprsKouSlqiq1fEWqfahLhDXr57PLg+3W1gfeynY7xC6WqiT0Tv9iD1QiWpsHk5Ev9lrjxrWx/+1/VhStw4YXAwhoJDT5BBgmP+GNqzFvm+SUuxJ0NmOV2tYwYRDUztz7vYBVkWSMS+CfyyuWumCZjljZ7QpwBXixezASTCEZeq1eMgo1frAafryqJa4JqXcf8YOHL1r4gTXnvdO6H3+fZeTLwiEM6GBDxueFHDBtR3sPXmW0eyzhyxMOTlnpSJtz7zQwpWiTavTTv5SW+dXwrmiNlBezGS2s+jFSt/1bGm6AxUetUBKIT6zl7esFiZHYL7GeA1bDQ== 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=EcYEsoxnESLwNGCqtEExBV+6TLNOK83bxuWGTwlmN54=; b=GOSuInYTu+DEFYlROj1Q/iBIb/ZBySddpZNQCIuDIcGFk/hB4pilFFy0sZbXs3wVWbcybGLMTYd0DSQAO4ZIQeTiLSxbDZQnThR8BxnMpcvCx2z+Tj2wdDsKf9OhwRrP930b0nZRRzYpvb5JDgmMJYEon42nPo9Xr+u5TDwRC+I= Received: from BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) by BL0PR10MB2916.namprd10.prod.outlook.com (2603:10b6:208:77::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.22; Wed, 24 Nov 2021 19:10:51 +0000 Received: from BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::d809:9016:4511:2bc6]) by BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::d809:9016:4511:2bc6%7]) with mapi id 15.20.4734.021; Wed, 24 Nov 2021 19:10:51 +0000 From: Joao Martins To: linux-mm@kvack.org Cc: Dan Williams , Vishal Verma , Dave Jiang , Naoya Horiguchi , Matthew Wilcox , Jason Gunthorpe , John Hubbard , Jane Chu , Muchun Song , Mike Kravetz , Andrew Morton , Jonathan Corbet , Christoph Hellwig , nvdimm@lists.linux.dev, linux-doc@vger.kernel.org, Joao Martins Subject: [PATCH v6 09/10] device-dax: set mapping prior to vmf_insert_pfn{,_pmd,pud}() Date: Wed, 24 Nov 2021 19:10:04 +0000 Message-Id: <20211124191005.20783-10-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211124191005.20783-1-joao.m.martins@oracle.com> References: <20211124191005.20783-1-joao.m.martins@oracle.com> X-ClientProxiedBy: AM0PR06CA0093.eurprd06.prod.outlook.com (2603:10a6:208:fa::34) To BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) MIME-Version: 1.0 Received: from paddy.uk.oracle.com (138.3.204.47) by AM0PR06CA0093.eurprd06.prod.outlook.com (2603:10a6:208:fa::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4713.20 via Frontend Transport; Wed, 24 Nov 2021 19:10:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3a0bacb4-447b-4523-3eb6-08d9af7e218f X-MS-TrafficTypeDiagnostic: BL0PR10MB2916: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hCREuq31aKyPhfix0H2s/4fuPY1UeWOApD1Kvq/ecfGG844gRux4XjqajRk0qWkzfTJLFkYOVMxoewLQQYN2jQgzXvdd0Izf4eCw6MLtft8jtb+iCUpLMlmy+pr9MKKH1PxyUYO/i6FBZ2u5xNEypAJAo+5e3IEIYJ883NRV7igpqfuDNEdU7Wjm7XMhSsPM8YsKwqJe/NPGpobZLN4hsfmnMn7MvApVMMhzz1uVNm7yplxv2jFVptmq6n34m4Oj+aei3nFfXN9M0vMGE5/XyWxr1fcD27zt7Ag1y9uCZV5MIR0Ze7TfisSJScacxfxBiAl0CgC16sPmYbl8bmajWLX0HDwcN34IISLYAFoB4278wCuNoE1sRfqrIugLo2WgTK2xivCmU4Uwv9T0S47kn4YZcud2OSCcs42bSzqw8+6cGgZGMeAytQ8KsHrT7pR3mVUEKwsDxlTBBv+jhEo1mIRjPymut6ziz6OE+0p/Jl6Z3asbCM821zK5d5zvbCxjNW/N4dQiHclOGEmE544gfYd8yxNdMvrSla597fY/G3hCrZur7a770tM7MNcWMWT1iNTEmp/NR0OK7wVghtTFgsj15pCK8htXebYUZ5MSTpIRkwA1/XhXPlBHkV6T8mzEY89sg3kSSHavFMroeLBD49MZRK/izLU2zXm3D+enACpl+LyXtx1MbSkejbjCelzmvtLNORHTX1J+rNuROa6vI06/YdDs3YIo9hthKDavB1SppQJpAwpyApVXEDW2Vcw+ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB4835.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(4326008)(5660300002)(103116003)(1076003)(36756003)(107886003)(6666004)(956004)(54906003)(7416002)(38100700002)(6486002)(2616005)(86362001)(8936002)(38350700002)(7696005)(52116002)(6916009)(508600001)(26005)(8676002)(66476007)(66556008)(186003)(2906002)(66946007)(83380400001)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BDvpVgI4DNbcYZuVJ0Y8j/RXlYNbi+ZIG/sbJntVOLXSlTcNCDzwOdP9BDZcurZqyISPmz5I9Xb1v+Ss1TGI9k+3mZp2LnqTciGo4np699BAdsP02FZy7lnuxDpbQVKFRFBaTUaxHLj/FyM3Tr4UHk8D+SNPemknh5QQMXiTeWNKtz4nLfSWCOTxD+Mtq5YAcOafZFLXIjKBZkYJpETyRlpu7jAEvbaydTg1G1wphzXxmbAlot9v4SOn+JixRX9Y2W4NFUuGMcJluuIm5VO8Iv6zyXML0nbbm7BOTvCvn0t0gGFGtll0UV7G2UF+lDVEJx/bsG2JWRwoLFVMtq/gyDEphxeiXwfwIU+XBe5mkoi2kzR2vmY4Zxq15aoZL9MOAVYJPCyw7QOPexpvR2h3JegUYxqGxpx2AvYUQybtOlEB/bOeHWe9R6Fm0V6tHc+PUQsfXhgot3ATou9DUxmciRSrOA3SEBRk4ahWOYaA7C4VHApHoIt9eSixJXJ6vo9ycZ+nPn7w2UnyLwEcGHTKFLglT4HQ0BBy4NyIlTw9Ox/E60uV3JUIPL3pgk+qP/6aWbrA4LKlaRaC2D47HMqvFjqEZCqVjrWj329WOZ/QpvkzAMeJZokfL0kZsOyMNQ4675I5PO+4t0j6zHmCfDMfq7oofyB4F/DrKFZewfEXsRbLJneA/e91yc75J8d4d+to5GsUey08i0psSD6YFNiOE06mFt3JhMX+4RM/BNi1m9bZmWMJyyVaMfSG29DEQTnu0as5M1FVs/NYj9zTO/P8Jofx5vM/3asUJfn7eRcl6NdCxLNctdCczcvyWqBbPdRGdXba5xsFP/mbjrnvpPsrdcqDchwBeOWbNxMHCZUQDBlmuETtLpt3azK8BgriQkl5C6xX13gqtlCdp/RUU+9QgDm78nMhMP2nxyjqNZP07BD1TBImVH7B5my1UTN4BCjPx3KAHU3xPp59k4enFQ2nWXcGNMdGOVXpnlDKisuHGihPQGf4L50/+ltbKz+BX9gY/E6e3wqPR7Nd0BQG4tDjRgRuRbDfS2u9w7VzULuevGtAr574gfChMPBo3xRSFMyXWWCEzeEZyRqY5cEBq+7K/zXsJJUx9vRl8IAF3lGY0OiRDlKoYSSS5xLc0mCFpDATw6AdyvyiwStWk12Ea6/hTfnIDbYdPayM5KOaz3e4drrBYEcLNw59SQcVa5gQDEOubkHUfzLbiMVLzDdb5iijeh+t2n+Zmu1BywniMm7YOZR5TIhHqR+beXQ2WpSJ9JSMO/ZeZt9vSvtCHCnBY1XJGOA9na8drvCe3yzhMKVbAeUaFlQIZPfgdlUmvrt5ha7vS/+/XYCxoQ3kweZC3lQ+K+5ZogzaN+OHK83+XkYrHwMGjHI22cARsLEW81CYdoRA2AXl2VRpz34y+RsL/t408yGndnDWFnjUFYd5eo4Y0sTKMZvr1wmY3/v3Cu8JfoPXHgp+PdfxBvVuf/lvInuOYRBuxmeJh8wpEFmGWMihAbHpK5ZANd700NLDl0WRHM+xIBoFdeZOPkR4ly4/XvQD7m8mlPeVRDoFGm64P/Q5IFSYXwC6mZZBSqcd85ceS9yVxkOabVdoIDosOMSARjCOhUffEFwK4McmIiIyzNckQKRU3zXis26Z/pwgwcFLWI+9vyzHOR8hRuYYLdYPhWJlpw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a0bacb4-447b-4523-3eb6-08d9af7e218f X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB4835.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2021 19:10:51.5462 (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: 3LnxZewutSys3fIvAQUeQZJgTgnLoXqmuP0fKHkqv8PUptsgsqxxt9U0EFMVw6cpDgP6e/xkcygN4lZhJLQdOZDdbruJYlKtkJIFBPvnJxs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR10MB2916 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10178 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 mlxscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111240099 X-Proofpoint-GUID: 9NZSxvsyjwpQPDKrx5e2dtLuL4685T_c X-Proofpoint-ORIG-GUID: 9NZSxvsyjwpQPDKrx5e2dtLuL4685T_c X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 822BE50000BE X-Stat-Signature: 8zm4dctq6psi3mg436b8y5mri9tbxwze Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=bVpMTvUU; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=GOSuInYT; spf=none (imf04.hostedemail.com: domain of joao.m.martins@oracle.com has no SPF policy when checking 205.220.177.32) smtp.mailfrom=joao.m.martins@oracle.com; dmarc=pass (policy=none) header.from=oracle.com X-HE-Tag: 1637781057-973545 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: Normally, the @page mapping is set prior to inserting the page into a page table entry. Make device-dax adhere to the same ordering, rather than setting mapping after the PTE is inserted. The address_space never changes and it is always associated with the same inode and underlying pages. So, the page mapping is set once but cleared when the struct pages are removed/freed (i.e. after {devm_}memunmap_pages()). Suggested-by: Jason Gunthorpe Signed-off-by: Joao Martins Signed-off-by: Joao Martins Signed-off-by: Joao Martins --- drivers/dax/device.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 9c87927d4bc2..0ef9fecec005 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -121,6 +121,8 @@ static vm_fault_t __dev_dax_pte_fault(struct dev_dax *dev_dax, *pfn = phys_to_pfn_t(phys, PFN_DEV|PFN_MAP); + dax_set_mapping(vmf, *pfn, fault_size); + return vmf_insert_mixed(vmf->vma, vmf->address, *pfn); } @@ -161,6 +163,8 @@ static vm_fault_t __dev_dax_pmd_fault(struct dev_dax *dev_dax, *pfn = phys_to_pfn_t(phys, PFN_DEV|PFN_MAP); + dax_set_mapping(vmf, *pfn, fault_size); + return vmf_insert_pfn_pmd(vmf, *pfn, vmf->flags & FAULT_FLAG_WRITE); } @@ -203,6 +207,8 @@ static vm_fault_t __dev_dax_pud_fault(struct dev_dax *dev_dax, *pfn = phys_to_pfn_t(phys, PFN_DEV|PFN_MAP); + dax_set_mapping(vmf, *pfn, fault_size); + return vmf_insert_pfn_pud(vmf, *pfn, vmf->flags & FAULT_FLAG_WRITE); } #else @@ -245,8 +251,6 @@ static vm_fault_t dev_dax_huge_fault(struct vm_fault *vmf, rc = VM_FAULT_SIGBUS; } - if (rc == VM_FAULT_NOPAGE) - dax_set_mapping(vmf, pfn, fault_size); dax_read_unlock(id); return rc; From patchwork Wed Nov 24 19:10:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 12637553 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 74CA3C433EF for ; Wed, 24 Nov 2021 19:16:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F23AD6B0088; Wed, 24 Nov 2021 14:11:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ED32C6B0089; Wed, 24 Nov 2021 14:11:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D26316B008A; Wed, 24 Nov 2021 14:11:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id C2A1C6B0088 for ; Wed, 24 Nov 2021 14:11:14 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 88D0A8A9CB for ; Wed, 24 Nov 2021 19:11:04 +0000 (UTC) X-FDA: 78844766448.14.F4EA636 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf23.hostedemail.com (Postfix) with ESMTP id EB81B9000093 for ; Wed, 24 Nov 2021 19:10:58 +0000 (UTC) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AOIaT6L030842; Wed, 24 Nov 2021 19:10:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=hQi3B8K98Wz3FDIAzwhNkO2hr+ugB142dpvOdHzcV/4=; b=tomSsOTHOYGZu2cX2EbTVjFtIs1R1LaijN9AXnI290pShm5VsPSXOSmSvunZFrIQLaCI caLm0/EWnEgR32x//oqbS1iBC8MXLHfnwJAwWl1Jr0YJxknarnN8s4s4RNUHt2Z6Ttiq lf2HcqBjNKKzkEvpfXiZVK4gMgaU0YZ1WP5T7Dvnxto55yo2wzcAQy/KdbduBRZgWcVq pdkoUt7qo5EevOiPJqArW7pP88wBj1eedPRyUpHzdvyWsRNQS+58o81V4eamqPTx3BHB LMHXBzJG85EwzaSZTEz3TX3BIHqYdXmWgLtC2QvJghV67c5ngPIMYIMkNoImlchyxyTR aA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3chmyyafsb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Nov 2021 19:10:59 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1AOJ0rTF192884; Wed, 24 Nov 2021 19:10:58 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam07lp2046.outbound.protection.outlook.com [104.47.51.46]) by userp3030.oracle.com with ESMTP id 3cep526udp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Nov 2021 19:10:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PP6WwpJ1fdDx7czGoo/nJvyk8AdkLooVgHZ8vnHwEdCrlCkc9VLJ3HADgs4OWKa3kNzL5UpfwOKVV+JMasxOObdzN0T1HHKqKg+BPe+/Yk5HPJCo0N/VmUW/1vU6QWjbwb62MM+s8Z8u7PMnWbcJZiY2ON72ieQXHx6gASjI0Zdx01VqzmH8y5grWH+6whjEQuUExanTZm51wNYp0tMtACJaQ4wBJJSoWL5iMxZquOOr+2MDE9h2Vev7ity7d5Bvj7H0j18Y5NmGINe6G7yGFwce4lUjWwy72SjyitpNA00Wi6J9Kb2nv7jr9Qn0PZ0MEdzZksjJbH4zBsfln4DTJg== 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=hQi3B8K98Wz3FDIAzwhNkO2hr+ugB142dpvOdHzcV/4=; b=RD2V/5lLTPWWSfgd1cfMjYZUBWsAKH3maRRlNqVks1oUWc0yGMLngAzhR9CdtcikEDn5crJSb5jU8KS3KjsYamvEw1SjPqMZSKqkat1Tx/CLd6Uf3xOagvJFhr6eIvSXsMJzbzmZUGWwtF2UiEr2n+sTX4wmgZM0mILTub+uPmlFRRndXIHPMm4FKpiicpxsBHheehPH/kBG1CMwzXh9rzOeh19aWaNvHOmw8mCuwwIcXv5l+dETxT+FMjsxA9pWbuA82nAruDnjs9ceeqyyJiOnNyZB4r25DYpUpPFFg8JXEN3oh0zF0kuv/R6NK8TTxfxaxnUvP1etTpt6bE+sTw== 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=hQi3B8K98Wz3FDIAzwhNkO2hr+ugB142dpvOdHzcV/4=; b=D4f0NfomBaSz1+O3vxkW1Ymhs3vd8TrGNjj8wLH8JsKJWpQihe8kWgdjx+sNWFDACVFjEZAWS21KUQazcMFNPxVK3t03c9rT4DA8B+0hNC4XjEMpaxynaR7YMmqcARmYjPggL8OYX+1YKa5lqLB1IPey3XitPI7SHuSzd0Jq5OE= Received: from BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) by BLAPR10MB5234.namprd10.prod.outlook.com (2603:10b6:208:30c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.20; Wed, 24 Nov 2021 19:10:55 +0000 Received: from BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::d809:9016:4511:2bc6]) by BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::d809:9016:4511:2bc6%7]) with mapi id 15.20.4734.021; Wed, 24 Nov 2021 19:10:55 +0000 From: Joao Martins To: linux-mm@kvack.org Cc: Dan Williams , Vishal Verma , Dave Jiang , Naoya Horiguchi , Matthew Wilcox , Jason Gunthorpe , John Hubbard , Jane Chu , Muchun Song , Mike Kravetz , Andrew Morton , Jonathan Corbet , Christoph Hellwig , nvdimm@lists.linux.dev, linux-doc@vger.kernel.org, Joao Martins Subject: [PATCH v6 10/10] device-dax: compound devmap support Date: Wed, 24 Nov 2021 19:10:05 +0000 Message-Id: <20211124191005.20783-11-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211124191005.20783-1-joao.m.martins@oracle.com> References: <20211124191005.20783-1-joao.m.martins@oracle.com> X-ClientProxiedBy: AM0PR06CA0093.eurprd06.prod.outlook.com (2603:10a6:208:fa::34) To BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) MIME-Version: 1.0 Received: from paddy.uk.oracle.com (138.3.204.47) by AM0PR06CA0093.eurprd06.prod.outlook.com (2603:10a6:208:fa::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4713.20 via Frontend Transport; Wed, 24 Nov 2021 19:10:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6c33dcde-ebf6-4600-8014-08d9af7e23a9 X-MS-TrafficTypeDiagnostic: BLAPR10MB5234: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:854; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: g0ZNSbe7dUDou9bzn2b8AEqBYyjxPdU98ycAKcMHW88TLFWHNb+tIsLr8bGmpylJIs3XOEdcLxMMwrlL9LYlJ18iSNUbWlwbAXWp8G7GuNwz43AIU9HOpSBbKPD8ZZih5FXeIDc6/efqQNOy1w72Rd7Ha2beAdlZN4QNhgSx+Ejbjii6x6mvKs2WaazqWCDCHUWfa81pG0IFabKbf+XGB44exOsluGN/xtXxRT52L+uL6R8s6x5nU+dbP8QDiqt+2PaWPPdrp3d5n39yqr8JgJ7CZ+XKvSDJdOedY0kQlXeV2w+tl6K8V03kY7QzQllGSAqNCKLGXde9lQFC7/SOZ0MQZUCp3NiBjJAGmXDQ7MykE5kkRVq/55uswy1qK9FjMFm4Rrpej93m70TveHt0OP5cPSMZIWbDxVKmPWIegY1JFxxjLcI4XEni4prcl5oInS7vWEALvqorPf8vBH8um6+jrnYVJ8ZvodFwYVXCyhO/42vgjnJjW9PoXW0L0MMMjTv9rH4E+Tus2tDJizg4uWeozYTg48iS7fnx/8ZMNUD4xNuFOFs/IycnlWIhpwpWXNFz1jEUfBQT2SmLFtXkO2Enj4mV//nSb3Pw01lGpABPufE0UCAoWrvvqX8RJRBepSpchOxu5W2fo7Ov+TXW2nRe3Y5/e1vAmzThKgMoyITEhRk5L/oRxueTMJrul/AWEyj7Kjd7Kvr9OLK49aA6gHoDPNcWIlJnqC91SsbC2/ttEbnzzvnCKeZsPSL+Z8wUecy8ZKGV82Bt0lp8XYv+gxMIgaab97y3aCJ9GlOrA2o= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB4835.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(36756003)(1076003)(26005)(7696005)(83380400001)(186003)(6916009)(103116003)(316002)(52116002)(508600001)(5660300002)(38350700002)(38100700002)(966005)(107886003)(7416002)(54906003)(4326008)(86362001)(2906002)(6486002)(66476007)(8936002)(8676002)(66946007)(2616005)(66556008)(956004)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VXYqXtANVm8o29x3gZz2l6VpbZa7ku5FqAWyqrpQnr9nOz9b399hGzZ/tdoMeNcUpVcPuK0IndyuV9s/M6DS3SuXOQMJLT+cT7Mwl/XI2cWhG2xXF4MwuDAoxZMOosAlCH68qe0h7Efbnh8jKCeunalvG8IOtAEuXmdyVijPM/9qj+GX1G4bbUvZcttZbFK/mY0/8KnFVblBs8OPun4VJJavDGlLxWRnq4RsUWua6reAMJM72VGBJzRd8Z/2tJl+fYGFKgJDajpPr4wKSWubTcPkAQqwfeTbTN6HFbkaH5Ac3Qc8fn7ivTrqRdFqv7wC8jIdr5ZnazYtnCLicJnR9RQpki5zu1maW7EcumDwnqDAjC8aEc0/2j3LUK7Q7IMEFt6hQshsqVbgMHKCYW2x36XkgCbjjLOdRC3MXrc9/8tjguq6e5M4NeTBQeRItmmUWNVZrtktpvGqulAk5AhX630Fy0aMOxN996VobqrYj7yt0015+2P2+HBQF7eAyVQR/BiKYE26VF1XGkCE2LKj1G0+/b+Q9aKaocG0u1x9CLm1dh7VTpIeTKKdrweWLRysFNJcX/Seo+36C3y87nlczV8g+N8wfX9/KtZCDii9gOttDTIRWdMRgYI2/+WZdff0k/jHP0JLnUvYeuDjUtgz7jJKtEQ5J97rXxrB1CMe2n8G5mbNLra+7h6JtKy7NZfZnCBDKSbnT4ykB2J/aXmANgUzKbo2Ik097vEO2RYBVWp9tLF94smxCHp0LAjO3pXDk/R21o/DXIGdRb7BhwzQUC0+DdqLVrFM0L0XZZzRd4ZTcliD/IIjTaV7cTzHkZrotPJosEqfZ031tCYuxqvgPbjG1ImfgY7g920VEAJN5LCtqJV1WU9i5M1O9omdJzV0wLC3gcUu1gdxKvKNdezylcDT+fTjVPrwN9oTLeygnb3cU36ooi8yxqhhJG2mQTUkgRt4TjspHUu9byHcTqckDD1p5Ly9GWlI8wSVTieaS9cUvJVrw0s2qskCEwDudOo6M0CPxP18dhlooJeiI084wF27hg21T0xdCMPXjk+S9Jkfhdo378wgTpA+AvGidB+kH8KAV+ib/saQdwnqoJ2Gp+ZCGlPQ7qeDqF3sHVtzW5Hvc9wqOQpSgCRYIN01sVXsP/bKHr/bvhegmD7Ue3JBVx3+EpRYgsjvK+dKxp57nfTFJ3kFkMwd9x5V6H0PePVct4fXXP+nbAFGMooQlq8lmTQoU7KMWJQKyoislLb7YN88gQD48J0J9uKz9wslShabR66bpeFmC3sdy2lkaTTw7xzfW6rXGyItomqWRYkeoTvdJLHubMP3+njVqzQlTBdkNaonZDCMB3fQ7EDBaYoH4Hat7pMb1/likUkPDc6YNSE6l54+cMJreG17m6rjfPnu3fPhT9XfzcwfOdjPOmiDseZJfgYja7d/OtYBZ6fnCUH+VFCnFEWneHcsGzGzCc+Gv5nkWvfPqGgqyi9Pbig3GsOCMSkm5HULSSHPlts8APHoS1A+JuAyJomdtDdgoLdVylLfJN+JYQq0RdfRfNKPkBhm1KIIFZ831CT1KByAyr3j6cgc8MKygfsYTdQhQ+aoVyGxzr25bpsUaTKWW1ELJ48JmsOgXa5a/is8NphhCQBhCAORja+hThAB3rAgzgdijTfR7f/eZ5qbFlJqE5KrZg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6c33dcde-ebf6-4600-8014-08d9af7e23a9 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB4835.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2021 19:10:55.1265 (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: xO9WvPGg4HpgpQrvA7IHv13NybLwr8Gkf8CgH9DMWiLyliesyDjlEAzPje+2xW8NN5sw48Sd5bZ3uXvC63VNScL1YQu1I7EAwcs+2+M25Bk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5234 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10178 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111240099 X-Proofpoint-ORIG-GUID: vYSB3fFI64C9X-D1nCAgXJ94AK-jq-3j X-Proofpoint-GUID: vYSB3fFI64C9X-D1nCAgXJ94AK-jq-3j X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: EB81B9000093 X-Stat-Signature: 6yr13wynm8aybrng6if6qhtmq4jm1nod Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=tomSsOTH; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=D4f0Nfom; spf=none (imf23.hostedemail.com: domain of joao.m.martins@oracle.com has no SPF policy when checking 205.220.177.32) smtp.mailfrom=joao.m.martins@oracle.com; dmarc=pass (policy=none) header.from=oracle.com X-HE-Tag: 1637781058-570577 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: Use the newly added compound devmap facility which maps the assigned dax ranges as compound pages at a page size of @align. dax devices are created with a fixed @align (huge page size) which is enforced through as well at mmap() of the device. Faults, consequently happen too at the specified @align specified at the creation, and those don't change throughout dax device lifetime. MCEs unmap a whole dax huge page, as well as splits occurring at the configured page size. Performance measured by gup_test improves considerably for unpin_user_pages() and altmap with NVDIMMs: $ gup_test -f /dev/dax1.0 -m 16384 -r 10 -S -a -n 512 -w (pin_user_pages_fast 2M pages) put:~71 ms -> put:~22 ms [altmap] (pin_user_pages_fast 2M pages) get:~524ms put:~525 ms -> get: ~127ms put:~71ms $ gup_test -f /dev/dax1.0 -m 129022 -r 10 -S -a -n 512 -w (pin_user_pages_fast 2M pages) put:~513 ms -> put:~188 ms [altmap with -m 127004] (pin_user_pages_fast 2M pages) get:~4.1 secs put:~4.12 secs -> get:~1sec put:~563ms .. as well as unpin_user_page_range_dirty_lock() being just as effective as THP/hugetlb[0] pages. [0] https://lore.kernel.org/linux-mm/20210212130843.13865-5-joao.m.martins@oracle.com/ Signed-off-by: Joao Martins Reviewed-by: Dan Williams --- drivers/dax/device.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 0ef9fecec005..9b51108aea91 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -78,14 +78,20 @@ static void dax_set_mapping(struct vm_fault *vmf, pfn_t pfn, { unsigned long i, nr_pages = fault_size / PAGE_SIZE; struct file *filp = vmf->vma->vm_file; + struct dev_dax *dev_dax = filp->private_data; pgoff_t pgoff; + /* mapping is only set on the head */ + if (dev_dax->pgmap->vmemmap_shift) + nr_pages = 1; + pgoff = linear_page_index(vmf->vma, ALIGN(vmf->address, fault_size)); for (i = 0; i < nr_pages; i++) { struct page *page = pfn_to_page(pfn_t_to_pfn(pfn) + i); + page = compound_head(page); if (page->mapping) continue; @@ -445,6 +451,9 @@ int dev_dax_probe(struct dev_dax *dev_dax) } pgmap->type = MEMORY_DEVICE_GENERIC; + if (dev_dax->align > PAGE_SIZE) + pgmap->vmemmap_shift = + order_base_2(dev_dax->align >> PAGE_SHIFT); addr = devm_memremap_pages(dev, pgmap); if (IS_ERR(addr)) return PTR_ERR(addr);