From patchwork Thu Dec 2 20:44:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 12653423 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 60655C433EF for ; Thu, 2 Dec 2021 20:46:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 806D36B007B; Thu, 2 Dec 2021 15:45:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7DC726B0078; Thu, 2 Dec 2021 15:45:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34E2C6B007B; Thu, 2 Dec 2021 15:45:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0073.hostedemail.com [216.40.44.73]) by kanga.kvack.org (Postfix) with ESMTP id 1F5FC6B0075 for ; Thu, 2 Dec 2021 15:45:11 -0500 (EST) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id CCF257FAAC for ; Thu, 2 Dec 2021 20:45:00 +0000 (UTC) X-FDA: 78874033560.02.256F65D Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf26.hostedemail.com (Postfix) with ESMTP id 467DC20019CD for ; Thu, 2 Dec 2021 20:45:00 +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 1B2KOCUm006869; Thu, 2 Dec 2021 20:44:44 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=0/s2VBk8c1Z11VmBU4rl4VR3Xi+ZOCq4rI2+/rSIpTY86hNnGfxMTTvdlxl7zyyN/ySP 16PmWgLCKj3KSUgqJDMf22aS0YjZQbD2Sjeppxg8n50kquxJAn2WbkMc0CtSzf8PG8kV pZHYvRQwqHSUHVuUPZp6yeneNjg7bMYxBmfwNhqZEUeiBQvExX70VhMsfHnFeLgMjwLz XhRANURsp5rvZiB88aTAWL12X44+RLmB0AXlPI6Xd0IlzQ71SLPB85Jas5N/Szpi/G7g oKcSYWoy6NRxVKkZzxuypcj7Fme/deFaaYxyrC05pWk4+fuP4glSDYN/0ONji2iCkfZj gQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3cp9gku3t3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Dec 2021 20:44:44 +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 1B2KeYlT048465; Thu, 2 Dec 2021 20:44:43 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2103.outbound.protection.outlook.com [104.47.55.103]) by userp3020.oracle.com with ESMTP id 3cke4uwyhe-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Dec 2021 20:44:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zh26CR2iXBVeKuqSnZvgAkmm2ZQ6/mc9MBDVDkyN+cqJm7Jj63eUdvnlWL1XDtGVe0JVLFrRFChKbXecRKW4HCrI6QbLN3N7bXndbvs+VLzmt9zomk497O7ikigrTmdBiVwD98HuFU43rNnzQ12F8z0mFY+v9jHhKlLxoqnJ4Y+YetzgrBNDB0unZKvwYbWXtpzV4wvhRjktOIle4/EPmYa25X27mRfroZz4hnsma8XhDAwIW6z3uLOxq56dNvlB6TjgtXaOF4ugpuKJQ0qtP2z9aRSG3mcUeMPNmouWtilQcuUfDpNeaqf2dPYs+gVW3ADdyyoKN93yCk35nKgq7g== 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=D5rv8KaFrjNp0cNfI5V0WpP3t6q5pRCu7NAm01p8K3d8qBmTC83rfI0GolBx+cStsdtgmWj7brH9L2WHhI8fHX6x5fyTv7j+c1FFzFLTgvQbfifa4X9oialqxZ3yoGzCAJ/NGdLJV1e0QPoF5hlnICFfHBONltI+4ggeUph/72gVhTJzM/HTsZclrclwxKzAfUfBe6NXASXGspkK0iw1A1fsO0RyTT+CEK8IbldH/lAPM66n7yYfkzLreXFmmhunnl4BSElQMG3MMW8QfX03GbmiQEySSZxMiChYbbSATE0h0DlHRAJ//y0cZxy9iiB5WY4FYx0p1zVBWRCxzbKguQ== 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=Ow1CVyHYu1uY0tkR7y2qwwSEO3H/dzSDN1OmBizu3Go8Aoa4iMqbBW2rZPYrJg6+ahXEj5JMywMo7th2j6lLmtOe4DoIYgmP/hiSdPMDStp9EMM5PRbf8USMrpXxOeEhiDchvAXceIgsDD0CAk4fuHrH8bofyFaGWjna4OwuLTM= Received: from BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) by MN2PR10MB4303.namprd10.prod.outlook.com (2603:10b6:208:1d8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.28; Thu, 2 Dec 2021 20:44:42 +0000 Received: from BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::693f:564:30a5:2b09]) by BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::693f:564:30a5:2b09%5]) with mapi id 15.20.4755.016; Thu, 2 Dec 2021 20:44:42 +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 v7 01/11] memory-failure: fetch compound_head after pgmap_pfn_valid() Date: Thu, 2 Dec 2021 20:44:12 +0000 Message-Id: <20211202204422.26777-2-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211202204422.26777-1-joao.m.martins@oracle.com> References: <20211202204422.26777-1-joao.m.martins@oracle.com> X-ClientProxiedBy: AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) To BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) MIME-Version: 1.0 Received: from paddy.uk.oracle.com (138.3.204.24) by AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4755.16 via Frontend Transport; Thu, 2 Dec 2021 20:44:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9cc5aacf-c416-4efe-83ed-08d9b5d490d3 X-MS-TrafficTypeDiagnostic: MN2PR10MB4303: 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: 0zGn3li5vlAuxz7+zI6XP3X6YKNofjousxUaRFaQFUsnR6kQfqir9N3PPPzwMhR8HQPAOAhqP6vMl5ZCYKOcTH4FW5T1fjeexA64rQbMvrd2TisxEGgrdX4YkaddoFB7hrnWBrhcvcRyDby0yfO1ezFbEMwt2G8pJWvzwEr6IwpTYEU3wpjyRnuoGb7ZyPr/ifnKraItodHPqKuErscKDtJshI4sjJ5GpW+OtljaXx8qBR5qCsVLknIsckL8NkFekt2esW/jzCzWSWLgmS2bUZWifWzavLlS6yaxdX8de3M02YS5qJFYFPWiFMfXFqFzzBHOM+5uOJfmP7jQHg++StjhvsQvzFaMGvQmKsoJORRPXRxb9A3tRiJFDr2UBVAJyARjGhjA51lhpi4MCoLYpgLL7H6lWhHgFHTFn3lWZAyimHusu4JKPA4rViMVqNG/A3SVYSlU4qcxickSnmr1tSJRmEjky0VmhVdKM3GXgo5CMfDqF0DA7ujcCARqBf+JzRp0/5MDOIROijvOfVnLxITX3jtnh6LcAuhtALf67rX0Vs7ZdjloKAKmZhLPOO274y/1bfIC9GqsP14cErWCCm/cS3fGO5h1eshj7Z4hxyG2ubQfW1hSUJAGrU31see9KS1Vbwgl/7f9FYQ1Yed6+eWEErNnKr1O/jmH4yNZGdNUx7pgtNj3pN63mcBGmEIUZfpJObh8ZWP74Bx6hoTG7A== 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)(6916009)(6666004)(316002)(1076003)(8676002)(103116003)(66946007)(66476007)(83380400001)(66556008)(26005)(8936002)(54906003)(956004)(4326008)(186003)(107886003)(2616005)(508600001)(7696005)(5660300002)(52116002)(6486002)(86362001)(38350700002)(38100700002)(36756003)(7416002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XJcv1ctdvS7Lzz1ttl/mlrSKACiL7BhmztPq5oPBqxTC40DN7w92wgTS91+NfotdtualNo6aaj/iaPq4CD2POscuim+qOHo6hkHTnEUuUowqnaAuBFW+YLpMZym6CAaLcp4GD0wReBvz4yH0yE7P+xAVT/PoKwrv6WzKHCCdQfN4T+hEcrAayMdEZoo3dLxuIA5MUKp0usdRZWLQrfCvURMnnR0F9tXbG1Q45r6Rbv5g/tuNfRUAE/1EeiWO7/IKkIVcZ6g8neuqty/LPyaSx2rZqu6MSnyPQWJ1U0AT6KGfCC1NWkacyCfpM1Y0b98vE/uiHmpqJ3JjM2UwabC6aoQpciqn4EYxJyt1UY8YFVldRcQ7rwSu3F9pCbXjRVb7xPRKNO5i0e+inWWKvmVw43c67rk7d/Wkqq1tFP/VVnJZssObfiT5cx3jyOMakkMlebYW2NdwcoqME7nji5C28Ql6mlC70skDmzAAp8PaAgIXoz2sZz/MyFT2CEhVVpQfZd83MChBeR+NBA3hz3n7SdYb9w9x1dTq/DLQ+HLaPUMP3kFN7i6/RNqA3gOvr+cKzFVO/mDVMwVakqTEYFhPagCm210cWH/Xegokx/AXZJDNGkOinJwjoifaPXsx9QtiUP4OTlByrCyuZMIqGcc8qedo3jsK0Gr+ushj+O+djCCDyWc3/e4ynYVSvu0yiuyhL3iQQwMtruAvJjWc8xXEBarsL7WmEu1JwebvHxvZr9Lzdb58Xl4noZ0lpodsKxWwsBvwL0x64hbYK4R3sbCOIANC4gwkjVWJdgZb+M1NCJSzwJ/z22+cJqDFHf4vNeqPeKiSx2a0MInd4S6bjnPIr1n3dbsT19abFcyl5HvRtgCYDY0cWSMJ6Ix5Z4HST0Ub0Q1AKWuQ+dKisRAX+WZiFbN5idHSDokGv3vwSJYWDYcOnglgtWoJhzx6XXJBm6IMhqV90ozygle6TwVnj2K3MjSkszz+Pq4Nn8V+d7uVYn8FYfC4fFl/uRz1oUsV/Yx9ZIUod7L9YWF7nEJtL0MxTFhrU8MqlwDhUWuXbbcyXPxgmkKn6g4faDsY0NPFZoy1bsJlN9wu48C8VrfmMkqp4tcivH5m7I9vUt058IoFzwMJi5LsZPMruz+9UPsavOrsmbW1EIdaPvQ1TD/jX5WT/uVPPijTQDHiwK5BKJPUuDtMStCTmYL+GT+t6Nd3WJ/KvG6+UYut70m6UY1UcPpT2/JmlPeUdlZO1Bxowkbzde+K7SbinICiyikO2eERDSnqWlirF8emmr27qbPouNgNrq4s+up+Q9Un0TgFhh1Fuk10fMF+fm6TPCXHcNVg6ZAoj6XDEn5lYwT00crLQxthNxwYPpG5MFMif10elIy2zrqJb/19drtsKqBzULaYnuOYSRKEcHsoodpIXXRCeSIxOYLpCz8dKKoH66LJIVWVtC96pAFLGU/OCndwd1rhgqb+ssfYwsoPOnfUv9xWdE0TJwFm3O73UPyJ8eKXXS8wI9mIEAJx3LbxYYiQDDJdGNR8PG347NfLF83UndQuUG+vA93RO32M8MrhQvdQkDjUHlU0UZMY2n30+0DtjcyqtF/blz2gcYpCV1b8HaFiQh0Ym/o9UEX640lm0X4ZDFX9ACgXOwXnM23g/PzBVfW+WCYYyNGmBZWRCs3osCXC33dEYg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9cc5aacf-c416-4efe-83ed-08d9b5d490d3 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB4835.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2021 20:44:42.0247 (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: yYTV0yE3te3K2iIXL6D+4H6IusAutnYxM187SNSTbw7AQc54s6z2agr9EUA+Ll5GZu32cVwBIeItmiCp1nGSxAZKtn3DvXzqmHNzCkXI58o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR10MB4303 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10186 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112020131 X-Proofpoint-ORIG-GUID: Z-cZMtebPIrjf9clKduK0Tco1julji1l X-Proofpoint-GUID: Z-cZMtebPIrjf9clKduK0Tco1julji1l X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 467DC20019CD X-Stat-Signature: ey1rpw8htfhwg6wmrp8z3j3qjfs1fybw Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b="0/s2VBk8"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Ow1CVyHY; spf=none (imf26.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: 1638477900-770894 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 Thu Dec 2 20:44:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 12653419 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 E3A43C433F5 for ; Thu, 2 Dec 2021 20:45:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5E4596B0072; Thu, 2 Dec 2021 15:45:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 592B56B0074; Thu, 2 Dec 2021 15:45:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 434716B0075; Thu, 2 Dec 2021 15:45:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0049.hostedemail.com [216.40.44.49]) by kanga.kvack.org (Postfix) with ESMTP id 35EE26B0072 for ; Thu, 2 Dec 2021 15:45:10 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id EA470894A3 for ; Thu, 2 Dec 2021 20:44:59 +0000 (UTC) X-FDA: 78874033518.23.B3D640E Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf10.hostedemail.com (Postfix) with ESMTP id 4EE596001982 for ; Thu, 2 Dec 2021 20:44:59 +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 1B2KOC2d006870; Thu, 2 Dec 2021 20:44:49 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=Dw1Irwkk46kBFhS7ye2lz2I7HaMMdak1ze/r9GM0TpNu1/vIpU89WadaB5kIXuB+jsuT JFRp9mcs8Ssvn3XIVyyFSASQLqF0eEEN2ykommCDGU/9EHZyTRpoh+usjnOrp8+x4yYB bHQlSETAuy1q7iYQRbynZiYMD7o/hLZiPYmzAiQR2Jf1AREZ2O23gG3MJGIzy2aCK/dq 6cGivWdiFY0iWgUS0TqCQYZAaHPRf+XbhqW9DhEyDa43Jqys1dXwQY68Vle7NjPnpA0U 2X9VKjoUR7YJeLHdebMQbHA65eysVHpnrq855zdtHzFpRiD5jDkOtDXdH54AXMWASQFP 9w== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3cp9gku3tj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Dec 2021 20:44:49 +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 1B2Ket7D121391; Thu, 2 Dec 2021 20:44:48 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2176.outbound.protection.outlook.com [104.47.57.176]) by userp3030.oracle.com with ESMTP id 3ck9t4v49j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Dec 2021 20:44:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OfMOk4VnQ+2rObphfSMD9wR/DosXA+cA34GVwfUnnMS9zhodzXly6hcfRPvd0/jgBFd3RO+WzkCUhfYpv4t1JX4IIhChA1iWp+HYWE5ZScndtZjAs52uMt4/KZq8+6A4uke17Nak1tmc7eS/xrBh3t2taksSyY0GLXyH9ocDLyrzeVlvhoN/K88yb5w36odK7NmEHC0m4uMVo1Jo1UxybI4S0U7HlkY5wmzRvj71v4dn3WAJuuNVcSImihc/Mxiw79rrVex+2y4xYyMaBZh86ati2xUFRNZBNPqFnif5seKX1BlMJIw5ex/CKeHbK41EiYJOk5GLXcN+y2NGqn7kCQ== 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=YGPN9W9+kcPLVGMHagF/jD5+Co9pMoiCHkAeKnnOXtVKR7CvFENBiCcpo4Ne63jf0XlPQ/u46eide9X3sKGa+YmdrjbCQcnqOyellLkG8bRlP0ikFkLnavFcKEfRUqJw1uUNs9rtZlXSJeyyzvFjuaBx1R90iftdWr+kefNhisFiIRrDZQ6blRjN1ONeRKybmmghw2ae1jhHjwiT4VxFE/lz9hpBt7UBduAJDamcztSxHZUPQVc12ewweJLw4oA6QKacB7mLX/DIRrJbIt0ubMRe/cRg1z289W+W9Y7nz3Qr2g//zcSgQxe8PRuXWXsEnhvvwsQArlVdjwxT0rPNDw== 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=pTJIDu1KPnawuoWteDVztDhr5euQhROB1bXwu9CLBrugfpfn4QkgIyU7nl+kz3u/0/3SWeS99YJ1EhrH+hSCV/U3JRpRLPPpAqK2sOw+QucsyF2zm88BP3wFrtiSQzPzSHtgLkL43N5Gar2Bqv8Mf+VQGwWAvQxWc/qeTcLaOFA= Received: from BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) by MN2PR10MB4303.namprd10.prod.outlook.com (2603:10b6:208:1d8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.28; Thu, 2 Dec 2021 20:44:45 +0000 Received: from BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::693f:564:30a5:2b09]) by BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::693f:564:30a5:2b09%5]) with mapi id 15.20.4755.016; Thu, 2 Dec 2021 20:44:45 +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 v7 02/11] mm/page_alloc: split prep_compound_page into head and tail subparts Date: Thu, 2 Dec 2021 20:44:13 +0000 Message-Id: <20211202204422.26777-3-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211202204422.26777-1-joao.m.martins@oracle.com> References: <20211202204422.26777-1-joao.m.martins@oracle.com> X-ClientProxiedBy: AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) To BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) MIME-Version: 1.0 Received: from paddy.uk.oracle.com (138.3.204.24) by AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4755.16 via Frontend Transport; Thu, 2 Dec 2021 20:44:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 053f0a48-6124-4560-2a06-08d9b5d492d9 X-MS-TrafficTypeDiagnostic: MN2PR10MB4303: 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: pKK47wyM8RU9ulWXVviQdiGaKP4Llb/kGcbHNdjHDIFXEUWOLm9W7gVobrIhtpuHE0E3X4w7bYjwMKvEa7CTIiOYQYjalQ9ZmbEuooLmPWtxuYCFchjpP0VrAjw8kVpGn0sh9GvqVX1dJupJF4eGSX6a62mGXZ5hg1aME/c3n6pfnxQo8tleVrC7HG1RFv94j7PeOqVhzj0RGo0ec3NtRGE6mFfOykudlAVEz0BJsOZX2jfVP667MtxyWt8jhHVbi1YM45xzpmfMozOmVAqt3c0PrgnYmF/U8kX7k90p0y18MW1mMk/VRFiI/dR9ARf++pULO1vbbAZjbrYMFPItK8oFaXLqTkBXThCNN/Yvug8OToJr9NsWOxUZ0WHSL9XRDjsY9RvQ6cOVsBrEhc93eOQwkIy6j8ze6myJLnChPubGsvCk4Oro3FgmQTQK1gcYv5j31R8ofalGkXU4z/jiq1G2VSDrQaOtzKaaHW3hZzKs8mzCraoZrDfAWPzdgOOkFIghIiRXjWcuU6qlq8LxU9gUBjid6QdG8+6B+4QExdKylOO0wBIfxAIiLS2nFLpTa0QD4W/iWLCJfFPOYGfbzf3ZStqvaGinIuHVtrAaBVU6fIdPKrbxT8T577I3dmo1Gtukmol8EEUaoWSDFKtvmA+TBqLRHZ1dmFiw+Ft3/Xt4KVV6y93T6QhNw4l76gjoE5RlXJm3R3+lvfBL2Pg0Fw== 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)(6916009)(6666004)(316002)(1076003)(8676002)(103116003)(66946007)(66476007)(83380400001)(66556008)(26005)(8936002)(54906003)(956004)(4326008)(186003)(107886003)(2616005)(508600001)(7696005)(5660300002)(52116002)(6486002)(86362001)(38350700002)(38100700002)(36756003)(7416002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tEuXO6l/gMKg4hprpknWrbWFq+q/1Aj+QSfNW7MsxL1M6vWFW5af9iB0++gM/5r4zcz5jE2egJE3Okz3QAVmtkXkmavIuRY8g6rwAaw7NClflFVcRu9tDvJhfoO5F7Iqifo9De1FwxQtsHxnURoof3omUycyLbGJiCrqbbaDFNOgWns1bD5QIcAx9V1TgRvGhq+sakpTmw7TkiOYcXtuLJp0tFA7REDXH37BKSq49TVDjcDGG+WyAHYBAvYktMgSBlplHomHrJv0Jc/TdgcIBxwy/DSLBk8fLCHgKRFE2r5LnfGCzT5ehwqVddPUMqsuVBGz+Po1Ehf+E3OPZyQLEj6cz9yeG6VogyTpJ2RVRJ75r33CQpFhns8Kq/nWOTzq2NBSkUtPErLo5NKT9lkYHHkc8BNHxP5I8icJ5060ersFklgjLv/EkkAyWNJSckUHBRHlTmmAyYHjeO5V7Gr8sjje1jsiPWIYceCdHz2xKNzLlL8vMgCRpbvLxjmj6ie/j0m1H/qDY/Wh7FoJmIw8dD8v2af8FOOpEMk0ITaObqWqG2SQW3SPVqlFVQnTYevBe2eHIfcLjRXSwwNoHHVIPzA1eT9m97c9fkyP8t48oUzdVX5izqUPHkI8xIsnmBvPS5mDZC3FI0332h6kURg0C17N16KTgUoD3LN79nUeVkbRwFCspVSJqdNwnXlKid87ybCK35OJ/ImkDzFP/pcAEEvYDhU8ipd0nmto7XazqN4P0QVqftktAHt6YIuInjBvEHa6QFbltw39l4x1RlS/lvskVbKo1nyeLTeXhX3fKgrzBDqWTZHNZ8CDOSFYC3e7pq0ealmlQ77fjSi4fqXIJHTZLV6nIeib4hG/jwLMZxIVgs4BCVhY8dVGsAyQUSREN2s/sg5kQuY1uIC+uhfD68ai4+h9uf+Yq/yKwknKOzbUEHrETnPK0Kg4ofrFUS0p+4ctQ/hxV9unA4YTJoJIH8SrK382bKYWGMBOIMHODf6AmCSmpIt5bsKajbLPxQtqyboblTjQG7aUn1AKRIkJduNDw5xf/2QJ2PGm5iWH9xhzbLE8M04yWJB7ehch8zQN0I9YCjqsa1UUdvf/W9rx4ONei993gDnmmxbBm+40B0wBzSKrMBu0HSATaro6ZOkZ+uKjrBki12TiXjQ8SRJg6f3MpHJA4+ggLp9W5/H/6QE0UPlZbQohRkN+FFid0/yHmRwMNDrAd1Iy/Ch6qNFWYFmB3wwdO+yE0fMzp2t6s9hlvyOfcJfFCQY2dyjFJN3w4g7ZYl85HPgR3Eo3uNgnlUMVWPRZM8P4VkjlIcBixhDJ6cQB+80CC9GOUc7FHK6mFVL26t19KabZ/nSjgVucAkCF7F6uLpqAXFdH43x1Jm0uzZKI5HyHxp6xM+snFshSBrdH/myd2urcalCXJ1SUBDqJ8pl/hGNR9jNhgi2OGysS2KhXqyLBCinPNk854NDOFDN738sj6EeF7JOgD/EPU2BqkUDGhOSj13I8yPztYIn5cFD8gOeX58qod7KWOHQJa4jChxB7KjSELuwXasXkXf6/kQlKDL6uF96WQG3Z2DichUvpaESVkclcvY0bSV1CU7la/Ec1LpbM5KbAcb1u50J0jzjKIMYz9ep+7gVZsc2WSL9IVi1KCnlkXchqHQ+rgT31yu9b5uqUKt5xJsg7xQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 053f0a48-6124-4560-2a06-08d9b5d492d9 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB4835.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2021 20:44:45.4617 (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: hQGjEXHf8r49q6nMiygmEFuJWVWSxUbqSnCdqyleLo2Z7VQDcNsKNBC8/wLkhXFi2nxYIxGXHvO0sJovrn8PF0GBj2OAfuM+8UAVrk9tGbk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR10MB4303 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10186 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112020130 X-Proofpoint-ORIG-GUID: O3V6_PynJqqo_jE3vLFVa5UWT31BJ4b4 X-Proofpoint-GUID: O3V6_PynJqqo_jE3vLFVa5UWT31BJ4b4 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 4EE596001982 X-Stat-Signature: oh7eaw1fbujuhzmzgrrt9poaginjf8uk Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=Dw1Irwkk; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=pTJIDu1K; dmarc=pass (policy=none) header.from=oracle.com; spf=none (imf10.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 X-HE-Tag: 1638477899-776542 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 Thu Dec 2 20:44:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 12653421 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 B614EC433EF for ; Thu, 2 Dec 2021 20:45:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F9FB6B0074; Thu, 2 Dec 2021 15:45:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4AA446B0078; Thu, 2 Dec 2021 15:45:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2ACFF6B007D; Thu, 2 Dec 2021 15:45:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0100.hostedemail.com [216.40.44.100]) by kanga.kvack.org (Postfix) with ESMTP id 1D0696B0074 for ; Thu, 2 Dec 2021 15:45:11 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id D615E183459DF for ; Thu, 2 Dec 2021 20:45:00 +0000 (UTC) X-FDA: 78874033560.29.ED75C71 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf02.hostedemail.com (Postfix) with ESMTP id 425AC80007 for ; Thu, 2 Dec 2021 20:45:00 +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 1B2KOOi7009455; Thu, 2 Dec 2021 20:44: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=uTLYKEkYQvMOzaFUCKSxv8ku0oYdToHJNLmK7s3USEw=; b=CW68oSny6EBwpdQoNmaosRy7ejywvEKqwyB9aXfgGoEUVH7PhE0hf3UIr+5iSKzfeqAk ej163PYoNjcIaenxl5wOcgGTMVc4WKzRs1vQqApYZlSZ4r/jx5z8uA0RpZ2zHsNoZIyF O+DghtFdwHaE+cqSnwx5mJNWfXjXP8avvJH2lkBtdjpO6TBbL/OBhmuDLjny6qLRSRz3 Wlfcm1jl+un2sz5xQEj5thulwfMLaUWODYnAoYQwGDbbyb6L9ScdUK23H4aI9AwFCfXe aiMIsl2ZdyknuROXK74/an3bAuBUTHTLmJ4Rc/99bgQnLlL7VLLqOAti9JzmxqZDg4hF uQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3cp9r5b1a2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Dec 2021 20:44:52 +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 1B2Kfgtc026318; Thu, 2 Dec 2021 20:44:52 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2170.outbound.protection.outlook.com [104.47.56.170]) by aserp3030.oracle.com with ESMTP id 3ckaqk6htu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Dec 2021 20:44:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QK0fpsqwAuUVVSTkGBU9pH2nXk0pXDxNrINzF24ptS/aIN/fZtDP3hRTniNvKgI0kxPeY7/SBDFeCvyU1b/U+qb0zl7WsoYTxmHFDoSviYJiB1+OTO8NBLGX5hR80LLlSPl7Wke06k8a2uEdrEgHSdADHtDix+pTw1316lBTN835s8vuJJR3mc3oM0uyY+TXvvHGy4d8ZF1nyVb1mPZHUsVNldJDWXFQ62qYVODL+QIHHLquwQ9y4WIelhKBq3k0K19IJHg5YaJrXEUgRNiexJpL3PgjjWDerTn2qWpkfzSoHREleQfnby6m3Ntz2O4fMF/KkeEa9yylMfM89lOemw== 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=Hb26mINXfKgMLS2mpfAGv0+oAArqKPpfxXqg5ZfRThqf9ELLtU8SZiqSoVoN80fLPYIdhBOymNtABafhvJ4CZLNy2idKatXQqN+SGF/jvlR6JUPp3yuU/Nh3w92+Ef9H4dfpiPStmPK3r5etlQ/fSsef4UCYCwlZaoQ98e7t4zT0dq7/RhcIXJHR4rl/En11tIhFJp5NSbUrZIOQRRPc6YsSEOY3gGiSEG5GrF9FsGDJwfiWk7w3WXQDqyOhK8BcCuVYhvcZ5/bReJ8qqQj13E33D9wmJsklEHxby+PSbB7gXlvOfqNKiQsXZgHIV+BhSpd5L0P4ZQTicdck67BNFA== 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=dID6idbMHlEfVpimX7wDO8dq6IyzWuGkYlScHoa8gS0ikXlYjL7HvQm0buQM2ieQ7x6ePCEI/Yg9bsq2QWxQ1656xDpZLWtfzX5OXKIpp5eqoNP6qRk6C2NRuDYFw+1gmt8Wu2RpujmIYpf5yeOlbHVs3pElMs7G6EPuSWV1Lto= Received: from BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) by BL0PR10MB2913.namprd10.prod.outlook.com (2603:10b6:208:31::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11; Thu, 2 Dec 2021 20:44:49 +0000 Received: from BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::693f:564:30a5:2b09]) by BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::693f:564:30a5:2b09%5]) with mapi id 15.20.4755.016; Thu, 2 Dec 2021 20:44:49 +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 v7 03/11] mm/page_alloc: refactor memmap_init_zone_device() page init Date: Thu, 2 Dec 2021 20:44:14 +0000 Message-Id: <20211202204422.26777-4-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211202204422.26777-1-joao.m.martins@oracle.com> References: <20211202204422.26777-1-joao.m.martins@oracle.com> X-ClientProxiedBy: AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) To BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) MIME-Version: 1.0 Received: from paddy.uk.oracle.com (138.3.204.24) by AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4755.16 via Frontend Transport; Thu, 2 Dec 2021 20:44:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3af51407-0693-4197-d39d-08d9b5d494fd X-MS-TrafficTypeDiagnostic: BL0PR10MB2913: 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: BwgpkjVZhIzYI8zO9gnNA+yy+r5JPGGscgHEQ7UktvlZ22UyCWslxAbI8BJCrqQsdGH1txCvpixkrtX7vERQdWQ6zdsiQ8UWSIdpEOqD6SQrtqA3YV1/SUd0J1bECilnl6bJCHhKQ6oWDjtSw10nYr4B5V0r1DnwlAVmdI3aMDtppKK9OQET3SKSz5TIM+AxeQV6wTHUvCpqALwp+x9c+CPGVgp1uwl23dcyYdlfUWEQfxwEwcRSBqL0FxvmddliKc8INi83XrjcIrLZih1duKf8BvZpZp9m66L5GExjf60KmDVZSTqmFl/I4cm7qI3uyUB2mXyt8B1Si+2RoutdgB58OCOHcRI7QaIWLOabiSMY3yZS+BF9HPt5BXyC6LSICzkezQwzmnekfUzftwTlChWC+w2P4ENoRJBY3VZKTihM4K4AT3WpmAVnrHLVq7z68BssGg7IA4wdnNTSIjfwcgzqfSfYkWQ0S1nN0iDSGIcFbKd4zfYIbay6sIrcnqQEwTHOhR9RvmMSfoSEN2TWbaEDA8W2K9al11MIFcc8ZH/+TjmFVL1GlrPGpt2OU54HHY3YlvKTfTxHhgZRMnFCcJhPNfmCJa7/G7EvOSoUMTGvsxxwu3fJ90PZaD/xk+niZbnf7fwG877dnjEKbhnTi+w0WCTwrb8BUzL/z1hv/AvWHXhduZPohkHzognvyIWY76d69U0Jhf/IeRuLAwvoBA== 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)(66556008)(38100700002)(1076003)(2616005)(956004)(83380400001)(38350700002)(66476007)(107886003)(6666004)(8936002)(66946007)(6916009)(103116003)(508600001)(7696005)(54906003)(52116002)(4326008)(186003)(7416002)(6486002)(26005)(2906002)(316002)(8676002)(86362001)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: m4LhYTfNclhs0Shk0ZtBQI0jPP9/CVfq6POzemhXoR2758nnJFjPDIF7TLwlUuKHHRc6ZmkKvJFuD31VdBHA3SI1yZxcTkS0Z+XL3CQBbvAViGpWoc/0tqDrTju7spwKFir4VWoGXmuVOBwhz1Mj+PFYQXvduo1AGecNb2JAgcdySr/EGcHJu2dSPjMfumvmby6eRLRRYKp+d25C5Scw676rtnur7JcSIGnQnQmfQ7j0uJsiE9p21AHPYikIrvTWKOmShNtE3dCiceOW6/cDWhjil4CXoVqNZHJurgnauzBK9Fh1agTvUBf7NtZetaN+RBuvbURK0MJy7CYPZm5rWWFNp6jxqJK5GtFc3wy2Qtq4aDTQPlvxkMr2aSFR7W6kTCgG7VffOjqKb1MXaLUKYKKP0byY13M6+g7LektIZM8CsLBbSSSpgL40wy+aiIIZ4DjvIo/HTpkutWexknLkWZOvV9oYPu9NmE9e+Jz84902aNXE0WCVBJF4RX2LsGuXXi2FaPhA/yH8rstZfcTN64ZkGe0qht4uVKwozX9+Ox7DKeUgrR+aWVq/r6sb9JyQpRnfXBGY/HAXrinEEWxgu49bavm2XsPQEoKFe7YQvoOEMhrGl0pRL+Cn6Y7VdJdjgjemd8ynQAlT4f8ccT+hVDHnDlMOqztb5Yrmt8FbEyVZaUEm/mqU8SfQG/03qQZehku/b26Uly1b1ZsFhZlID9I1uZXCjMkxo43lRCLOgqlxxsmJ71l/Jdt5CW8w0V3JozGJqRftxOeuZxIiREIQnZvreAMYHsbY1+bR0V++bnWTwimjYODUlpAFXYnnikiNDlQMt/b/9YQBFH0V7covkDOzoY7ZFBPN8WuVgYrG1xfbQzsvJrccg7GRhZ68mHdT1bJrNmCkYDxlz2ja5TbyxXIQLmaw3+wqmQd7K7XakkTjFiXYvo5uGPezXZ2tChqobpq3SRT0Ii+/eTBjdsGuakyr31R0PzUGLpfBwqeBaOJQGsIZjcYl4dEJqciYUlP+QTJmO0wTb47u2h0aaXvArg/Kiv6g/SrG1YO1mX/SE0ow43FWi0OrmtWVYhtTiNtV3QD3mCxn9o7zajm61/sKG00E6wiIRsiEMJwrqIbTr/Nh6HyVBxEfHUd7PuuEPn5IApTs55B5pXqaZH+gj6OWxTzbQq+SS/tNhjwe+aRHYa3X+E5TqzFKCjuXDImgq8INs5AJWaLZEbdyK3ehCOR7CZdPWxLTPDddAVMgjIjIAR7LFWMIobA7RGDud+bJbxnjGT4HhQ6E1mYtWUGYfLUtfxxAyt6Af8Z5/WdJZ7okBRHZzJ3BSfBMSoIy5X6SSQxWfgbi90dAbTMC6YZi2kdcYZd+Pm26Oaj4m/V04tAPw6M0FwUeZfm/BW0bTTVrVZ6AlEONordivTdals8LQNrNJZSUwwGD5kRrAGOqMxnC5Y7R4i9bex7cU9bNupRJ8/T9jQpwIWiGqVh4fn6+jbaXMZNKsNyzOasRJhXXku0EYpFqbZwR3FpLyT3ElJUpnLen6PLcVYhi1Dy/KB36rtiQE5mspj8CG+ZUs/VTYh76sQ7DzN+DDv2qcZTSc3tuIe58qiN94lrV1Q4slBgGc1zehRhjIGBiLR0JiIBJlpru4HH8Z0OS/sT/uKIIDm4hnZ/5mVW7ZsQwUkTPsLfIs7KtCA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3af51407-0693-4197-d39d-08d9b5d494fd X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB4835.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2021 20:44:49.3710 (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: ayTD2vA2V4VRlNZ6iXJDBSH3uaR4MEE6KPKuxjOdlzlT2nBqjWOyUXeJiwkx3Ubq9PK1lWtwEgxk5OtQTARoXRGIrT546nkKoWSUMpcX7bk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR10MB2913 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10186 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112020131 X-Proofpoint-ORIG-GUID: jNyjN9QVs1yxH-dB3s-beZ31OBH2_ynu X-Proofpoint-GUID: jNyjN9QVs1yxH-dB3s-beZ31OBH2_ynu X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 425AC80007 X-Stat-Signature: rsnacijarjk47uprw3m3rzhsw96k5fs6 Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=CW68oSny; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=dID6idbM; dmarc=pass (policy=none) header.from=oracle.com; spf=none (imf02.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 X-HE-Tag: 1638477900-125203 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 Thu Dec 2 20:44:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 12653427 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 EFA09C433F5 for ; Thu, 2 Dec 2021 20:47:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 548AF6B0078; Thu, 2 Dec 2021 15:45:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F6E26B007D; Thu, 2 Dec 2021 15:45:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 322E26B007E; Thu, 2 Dec 2021 15:45:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0218.hostedemail.com [216.40.44.218]) by kanga.kvack.org (Postfix) with ESMTP id 231C46B0078 for ; Thu, 2 Dec 2021 15:45:13 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C630A8249980 for ; Thu, 2 Dec 2021 20:45:02 +0000 (UTC) X-FDA: 78874033644.14.131E33B Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf28.hostedemail.com (Postfix) with ESMTP id 02B5990000A2 for ; Thu, 2 Dec 2021 20:45:01 +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 1B2KOU94009638; Thu, 2 Dec 2021 20:44:57 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=m/+GhgCsvmfJQIBVoJtFTMnj/Z2zM3WqTUsIWMxECS4=; b=RCkeFpTLGYkssjagZWidWmpc04zfOSdqoo9O3rd9GHkU41tAajFrQd8B1z0wwiTkR4KV 3y/VssS+NvmUYvYHqAXd6D/gKpUt/QKEKMBFmuCWn3pQnyjFGl4LyBjWpKtPfTN36ENe 80oLv4H3SWzQ8QcO+8iv99KDffuJRAU6LOHA9O0SBuOpj7vpnRqXqkRy5FnmHD3LAOKB fVvjeBIeXEsHfCJiSGVmfWngTabbQiIPPm9d0CAJ4zUqsEmgLM6p4IQX/3zFZ90H3rcn U4XUaFkP1E/KjYGHXUfEz2qUKL2ROhNhLTiuHvPoyCt23cwQlQO3itQQQ6hkS8/VEJDe 4Q== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3cpasysshj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Dec 2021 20:44:56 +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 1B2KeukF121594; Thu, 2 Dec 2021 20:44:55 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2101.outbound.protection.outlook.com [104.47.55.101]) by userp3030.oracle.com with ESMTP id 3ck9t4v4j2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Dec 2021 20:44:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iY1AQnt93LGXwEtB6RW6Or30RP3zqRsAmBJ8y/hLYtoSVckvWmpGJ5nm5TfLi5urn2n2RA9d0R+6qdkPzgZTwPeGaYqDyjjX2gzqAq0+PhdQ2y8GfpRs2/xkvWe1sLYS4viEONPhSjqMzCkPl3fOYvHlhKsfzHqO9G2OA4bzNGv4z6lJwNenG+I9TAW8Jnj8Z6dVL3M2JipJ6Joj8kV7YKkzyTCbdLaKoKIbBoDHgWoWPtTagN8VKOHdg2IEGjYUPXH5k7YR6E9vJ2nab2kQ/xXEmXeYxA01IEaIW6oVCJKCjt3sPFip2P1SaQel3WUPfssiJ1oZxloYUhyK7Z3lkw== 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=m/+GhgCsvmfJQIBVoJtFTMnj/Z2zM3WqTUsIWMxECS4=; b=DKRbS3Gj3MFx9aRINgtlL9WDZJeyHVuNE3fRhVBKevRa6CIVnkX2/fzxy/FoYLZqm+rA9CvjzYCChqwsoM1ErxGQLFOwIKKUdungi7zzIZMaAFnnkpGPZg69BE+ipNhjsnDA80qw6UgLPEnYwp1w2R3/+giYXzsTn6KHvC1z80jzyvg1LI8FaIuiziso+/xuHvzs1XR+zGsWATSNpuPqJOnktbBrORbuk4L3YY2vD15pHhbihXi3bgprEXnUiHiCa8NDZ1MttHCihCZYMLMVTS3lCSDeczXsANmarMQLyCYLCFeRiUjZGFuc4Kj8BIhsKofHviMhBJaMzaflZcWBUg== 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=m/+GhgCsvmfJQIBVoJtFTMnj/Z2zM3WqTUsIWMxECS4=; b=PisvDXdrWH7OYNL1tlSQnCivPoSpaQOQ6Qk0gNkvn0oaEnrQzT46YrmFN9WP/J1eK3jg2AhtSzCqebAiYugyVlzvglHpl5Kvi7KrpQXEnKNPFAfCGefiUCdv8Jnl49NyxOhUDORyKY6nzh50Z4hvf/0o9RY/473o0BNZViGtffE= Received: from BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) by MN2PR10MB4303.namprd10.prod.outlook.com (2603:10b6:208:1d8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.28; Thu, 2 Dec 2021 20:44:52 +0000 Received: from BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::693f:564:30a5:2b09]) by BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::693f:564:30a5:2b09%5]) with mapi id 15.20.4755.016; Thu, 2 Dec 2021 20:44:52 +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 v7 04/11] mm/memremap: add ZONE_DEVICE support for compound pages Date: Thu, 2 Dec 2021 20:44:15 +0000 Message-Id: <20211202204422.26777-5-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211202204422.26777-1-joao.m.martins@oracle.com> References: <20211202204422.26777-1-joao.m.martins@oracle.com> X-ClientProxiedBy: AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) To BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) MIME-Version: 1.0 Received: from paddy.uk.oracle.com (138.3.204.24) by AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4755.16 via Frontend Transport; Thu, 2 Dec 2021 20:44:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 81b8e165-84b5-4c11-8a19-08d9b5d4973c X-MS-TrafficTypeDiagnostic: MN2PR10MB4303: 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: nmtjDC/FOm0Cao9klSX+LjAzSNgtgVU1uVKdHPD8QR7MUDgGOw8DGKoYf5UCEg8aOyKugne/fS2mQJ9FqfS3Dtm0nP6GFSm9c8KWy4VnSVZxaugnWt8LcbdXbcCYkPow4fyDKcKVPnvEa4nM2yIslkXnwLgiOEATM47joFsAjG2O0ZKEnxrKP7One+PwkS8aVRVL/9AEHuwE/g+/aubD+9ft3dpwzjndC11WVu7KBo2e2MylougukQhOxyCC8XniyJfLB6T5zA4H7Rv2Hlo+CDcNGE8wHizr2r7Wa+rAWSxfz2vzbXMWYlg551ntsyq00ig+W73M0Y/k6GevV8Dpfh9ROoN6H5ZBnfQr/ohIS8BBYHZacT2d0WaWeAVouAUk9ZRca1h59J0NusLNsxMivIPj2v84ibOTgPQcykg6DRlFrG5txLnD7BfVFgmouqxbp+tXvDjgGuEN6JAcE+kOU0aCBbUA+GkIH0Q4iZaVhxw5CXKJOYBJb4UdWuZkzgM+syz0Kw1fSTjVrPa3PgCY4on1MoswUp+Nzzwta/GW3mLtn0hrnHblrm4pN1znWj3tDetRph2a0ASHfykmF/xN/wgdw2Ncx0IxQHgbvB++TKztvdgIDArVbTwf9KDR/oMV1v68pKQaA3xytF5WqiCkzq8SQbhWlfuBJtPuNUX3V/UiHZBYQ447W+V6c5u1VF1bHDslnp7U1P/xJ+4XN+1fdQ== 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)(6916009)(6666004)(316002)(1076003)(8676002)(103116003)(66946007)(66476007)(83380400001)(66556008)(26005)(8936002)(54906003)(956004)(4326008)(186003)(107886003)(2616005)(508600001)(7696005)(5660300002)(52116002)(6486002)(86362001)(38350700002)(38100700002)(36756003)(7416002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: w9CVjYsk9F75siLQ0UxtRqrm3LLsndvMq2HeFu33c2GnpwU0qh3LGNH1ZFiXdKUBpMSmm40xm/RLXB4l2jgrt9qFV8deQ3I6Z5ZpHWoYu9MxBEfypg/S+6zw0vXGPxSIPjZxvDIQ47qpl87+KbGklrGpA4ogFlQlPloU7Pwvb7vERyFSelMB5d/ayl5KQWcUJyuqQtjNVC5jtxZGurECtbFByRAm0pVolulg9/DZEgNezJbVnlMHQbN0Hlz34kPh8gMMwSH451SO9tLZJs2rLMA4MhrXzOvqchN8zfxGY/ZCK2LCWZ2wnC3trXqVKiIE2b/q9yEp9tA/pR6ysxjHxgfjHrPL7eXh8o2lQCcGwrjio9o3IARQpajRZ396407Ud536ybZGj2CVvKzXjllLhiD3OrsoIOgukSPnasG09erFxTE0oN5tg6mInWLtz1feJEp50vRGmU1KemtlclL8mKRZuBeyOhZI10BVF3pP0eTmB1wTR655pgwMQ1+Yo7K8HOrt7mQnzMgILIxFTmb8u3nXorigieSdkpldZPH7S8eVozQbgeG5nSUayo84PDTi+yi3WsPzyoNvATkR4OXvLs0YE63V+bkqjf+Oi1v79a+D2CNv3Q/iAl+f8xSKBIUYfQSOM2ZBXpwe4CqwdqGIzPXmy+rzVF1wWvQE8kPIW+DNL6fyAMy8kQYCQLtKhaEvkwNJQBYEIVsUZzOzAGEnOOODr1nz01P0yhKJE5FF0oqVlf5qgownJCgq1PUj3A8i3n6boVIse6p8kh9otErWilS7VsRkyhAoOOihpO/Wm7CaIBnxMD5TcTCQ2m+dGfUSOPQ+kC39IeuG06LdxvljypOIKQaF2G2XZ6E3xx2khAOa90qjC0oW+dbQ1Heg1UvcQNIRkDyHXX3dCC827KoIRNCDNDaUaaY/zvM81CIbBUlR3TSuxX1svPlyPo7rjqU5sbFNrXd29owScpGjOqHPyGvpCgfwF+n3JjsoOfa2U4tbq5BhdPVh9t2vcMvjVqsHG7d2fxVc5bOFYn5JIPRsyrNLyz3OPA/EihRX4z5ySIag7/A1SOD8NsOO8tCSvvaLV9bd8NYu2bFfmUft9BICeON+csHB8654dgGDbM4xx+7TE7twJcvoUqQ3sCBux0g7OQLJ22iMoekTPdKuhwtJMPzPYfe30d2HkGz4TkpkAPFBe1u/n5iWdEAXH57CdBIDrVCsoERoaZW5e2gn3y/JV0FS7sMqX9vTQENT4BEISU5qRUpSTHG1xqXRe4vzYKn4+rTSxzGa3KkfQGoSdwQXAVqvpDmdodTmRj+WcTNgrs3hFobZiCTvA6fMDN6i+Zode4H4RixOWSq757sKPta4+y500leh+XK6e2HncpmSExCsa42dkQS6e008EZPETd8fhhBpURsXDdXhSNpJpVIlQ91d96BULcy1n4MYrwfodcFMXDJb/JpAalgAzYntc9yyDWwM6zvUguW0bvfDB0Q4AVp923R9Fa/bri7TzGARiRN3UM2jI+ohc02ynsNwrSpHKASRVTtRU7yls1GAJH1FWooyFCX9ztYGv2fbwfBZc5qjWpSXutVOocDQjea0Q5xezg+HhF3zWudz9lWekGFVs2qhsKOngOxfiuRTmx8iyamQbVq3SlcFYNK2w3YVtj7coRJ5sByJU6Ol8J6CD63ODA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 81b8e165-84b5-4c11-8a19-08d9b5d4973c X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB4835.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2021 20:44:52.8094 (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: x/XzsVbGkyCGwgYuiLndbNf/baRAoN2yeqjniD2u/q8uZXeESXjnjmwUCcsuRQzHOuZPgZac0euGJEzp5s/hvQSV9vU9TafgWUzonpfYWz8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR10MB4303 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10186 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112020130 X-Proofpoint-GUID: nWfFup-wvAAQkyEe1aBMChNik_nLt2lZ X-Proofpoint-ORIG-GUID: nWfFup-wvAAQkyEe1aBMChNik_nLt2lZ X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 02B5990000A2 X-Stat-Signature: pupp53ntxaegfzh6gkccpxa7mswwskyr Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=RCkeFpTL; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=PisvDXdr; spf=none (imf28.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: 1638477901-262038 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 | 18 ++++++++++++------ mm/page_alloc.c | 38 +++++++++++++++++++++++++++++++++++++- 3 files changed, 60 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..d591f3aa8884 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -102,11 +102,17 @@ 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); +} + +static unsigned long pfn_len(struct dev_pagemap *pgmap, unsigned long range_id) +{ + return (pfn_end(pgmap, range_id) - + pfn_first(pgmap, range_id)) >> pgmap->vmemmap_shift; } /* @@ -130,7 +136,8 @@ 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 +322,7 @@ 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_len(pgmap, range_id)); 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 Thu Dec 2 20:44:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 12653429 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 3D9C9C433F5 for ; Thu, 2 Dec 2021 20:47:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9B59C6B007D; Thu, 2 Dec 2021 15:45:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 98BE36B007E; Thu, 2 Dec 2021 15:45:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7DD646B0080; Thu, 2 Dec 2021 15:45:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0123.hostedemail.com [216.40.44.123]) by kanga.kvack.org (Postfix) with ESMTP id 6E0806B007D for ; Thu, 2 Dec 2021 15:45:14 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 32A341827E8FF for ; Thu, 2 Dec 2021 20:45:04 +0000 (UTC) X-FDA: 78874033728.28.D1CEF13 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf01.hostedemail.com (Postfix) with ESMTP id 967D840002 for ; Thu, 2 Dec 2021 20:45:03 +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 1B2KOcDU015208; Thu, 2 Dec 2021 20:44: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=6K3dV9kT1TePMQHNEat9vbBQo8pBmM+K6iChvFRe6Gk=; b=Xi7KJNmxo1crFiDcsY8aGpK61J+x47wkOqGycsAegfgY4xWCS7eVOOwOjG9RqQQqY7Vs GnJNvftl6Jglac6cqwBVK62lpd+NUB1BbdGTeNqRvsj9JDrpkNBvwiv1puD9tSJGapQK GG0MP+4Sb/zOMNGPa1rcvRhCeODb0AY0FZGBFre77lkrvTSn7drcsR5LUt7MWCOvoVtw PLObCv/R+0kraFs72vR6NzRlE9fAcFoVAleKmv/IX7Xe57VGJkxKbaIR4Zw157jOl2cb 6KIUVsIYXy+aXXPvAEgAI0LnbLEwss/1rtWXI4YMIwwj9vGxyohoJpBykRMXkmGqMWtq Qg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3cp7t1twxf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Dec 2021 20:44:59 +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 1B2KeWtP048001; Thu, 2 Dec 2021 20:44:58 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by userp3020.oracle.com with ESMTP id 3cke4ux0au-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Dec 2021 20:44:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gSmkuPxfM5793QFxag5da/y5LkdiWFJsA2jHY+vPwjdU42Bh4kcxG8+I3jfIdNW4lF3jVYvNf0/adh1lTQe/fS96UTJbmWiqKC/mgeuhh3Xm63kQ9uqzmCYniYgv1AIpVMe+kvFnhgCBPIblSpqKirTHtp9GgNg2DKKDgIG/yqWXB9GXqSIerBzB92M+hnXBKpHw7/1urMzO0feYXpCPYS6ePj//ZPwLaxfBuTqBoy2pv7XqmTtRE/1R4VClx+yHSSo5mQcG8F40U+Pc34ebgrz97o0CsbRTf1P5V5799nApJ6FomggEjie5H5uTD7A3LtGURc99Xdz7S6i9oXu+qA== 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=gNJ3CN19RAMYb7cE21+3xLUrzMKYSplm1x5gj+S2f7v/4LyHDWXByJLXe/RnQGtwgLztt6Rsp6cd1Rgmogz2dZd6HlzCKIF1sxfsJQtRaZuEWuFpa80JvaKRC4Pz92umC857KBW1iPBNgJAwef8+I8dg6PosLws7Y+y9MgkCbszZozZclT06PYq763vqJfYa1y4Fj96yOwMYOHKV5uxMdarVoj7u89YzhBKvZ9ylg4eiL+/Ce4V4g0q527/7vvVBYpu5DnA0Il1Ei+8g8dV99Cr7NI+evRqFiOuOgiBYnrtIB/i1k48Z8I3QcQCModcens455FGT2U7/AwLcTRjZiw== 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=LJLPFt09CRR8H/a29N2Hk/ZFQ/7PT1BkJvbkVzh2UGQI1qcSXbX7fYnd3/VqCrW0tSyAhS/Y38s+o7aO5wA0u2yglVyP+C0HgRPhwc96QYJ9uHepVZIE90b9ia+glHm9QCwoKFMqLsxaNJiBz98iiRGvYpIMxR4p9jPnNY66/0o= Received: from BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) by MN2PR10MB4303.namprd10.prod.outlook.com (2603:10b6:208:1d8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.28; Thu, 2 Dec 2021 20:44:56 +0000 Received: from BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::693f:564:30a5:2b09]) by BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::693f:564:30a5:2b09%5]) with mapi id 15.20.4755.016; Thu, 2 Dec 2021 20:44:56 +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 v7 05/11] device-dax: use ALIGN() for determining pgoff Date: Thu, 2 Dec 2021 20:44:16 +0000 Message-Id: <20211202204422.26777-6-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211202204422.26777-1-joao.m.martins@oracle.com> References: <20211202204422.26777-1-joao.m.martins@oracle.com> X-ClientProxiedBy: AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) To BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) MIME-Version: 1.0 Received: from paddy.uk.oracle.com (138.3.204.24) by AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4755.16 via Frontend Transport; Thu, 2 Dec 2021 20:44:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b90bf18c-8047-4e56-f430-08d9b5d4992e X-MS-TrafficTypeDiagnostic: MN2PR10MB4303: 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: YssDo4XUxb7L4+f+ZTrgwZTxGwl1TISK8myI5MuoFn1kdxEk8oi+PvEgE4atWmWTdy0qyQNEd9+Eg4cIwjqG9ZWSgTBHo4vbYJg5UsVqEpuRZlSaWTBmIKhQKoT5zJXWKvmIffQ0o/tskqLEO/jXCS8O284m0zxuQJwx/cQNQYxDr/jYyVJglWuj97vRd8qm7r2HA62xGVtNx5gLYGmYqtro2v2RgT/97yDt3F07ZhOsARp0HP4sKbq2DjJajIHItonysnUyxYHf+XqH3itEPF9V2AwGe6FhBS5fsTZE1Dyfooe5hQtDPfsCbg8qaPxNO5omZ6NOPu2wjh0wCNLoEhuBILO+MfGuedi8xCLSjvTZWcBarSnAMiT32vV7GJCTr+r6ndk0moozbPIc86RlecUNvDLCZZtHeiCHQLhjqPePkZoeeHucovjdwxqLri57vfDZgrZ+snyx0lxhIixH3WzN9S16hK7Rqwpmms91zd3OnaxdO3U7muUX+CgZh299L+nIBCGisTz4SKXI/kxS+qd9w9HN2hN7hfx7V60RLn3uZfxvnxEBmwpNsDGYxc2O5FH5mSKugfDryZNb460h3rJzlFN0kICIv5pXwAruV2KL9WdOE8PN9mjXyCiEtfb6pdZHuX39U0E95wuQ9lecOKzJ8oDeS/oRYvBRmpevyXjvVVJ92gjZja2WpOAALAmP5Db+LK38fzVt7wHEvkzUDQ== 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)(6916009)(6666004)(316002)(1076003)(8676002)(103116003)(66946007)(66476007)(83380400001)(66556008)(26005)(8936002)(54906003)(956004)(4326008)(4744005)(186003)(107886003)(2616005)(508600001)(7696005)(5660300002)(52116002)(6486002)(86362001)(38350700002)(38100700002)(36756003)(7416002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: v3VWQa8Eun+JS8LZXyGfDTwn4RThTZElkWblrgulgwl8ItqqYMYjW1b97O11RCjE8foJHhPHxd1rfJgiG02ekYv9196ccOSBorfNubYVDZgKGDrVg2+k9gQc9pQEx5Qucsaff8l/BIXZF5o/vD75F57iGOH2NdzJREQoFBUafXLa0C1lCKHvBQBWqzOSoE7FyAZsZDNr8d61Oei73ElL+EN5RyZtFN4aKCL4KjyHcU6n2XF+3f9c6krQYn2YgtZGuK0AabjtDd+JWYtRlFq/Q68th6nZGQBnFrP5HEF2FfL4LiCfhyJ0bX07pD06vJx+E1huQB1D4jz/FjfGGPxyFRv2I0JXSIBHNa05hHbgVj2PMb7p00vLOydzsSiZuEOZGWqUUrIEZR2U6uOFXORnTjJT+Z4uo5xp19VcDKp/f8EVpSL/Ccg32/KJXpwDLBQP8pL22+91iv2V1DtouUhxECj6UQWTLbQNVVtDnLVeuE9STeg1XMmCmM2MtkN4neawz2/EwfD5wAhWs2LxHUWALLM5iGmrVWqtbJ8768zxTePK7GbzzwMPfadnwMX00DRw3Md9YUvg1zPASsQ+TZRLfjkkHgNpWUn9XcfYZpMAqKW5HA3WLceDPq28Djc4IK5KEfTlOW/DmVR9bbGaPSndaz20BgrNr+UyBu9ZZd0zwKNdt1Q+CayqMMhWjHtWXRYbInw14IBwVJWx+jZJyOBLU0ojdRZcPc9c3AsDStGGbX4RczgbstXfCGmzgqZ5sChkTXXGobcrZJDgxSfR4zW7wD8LE7/C69d3QO1Tmawca3I8uUUo6QYO+nvbC09Rd10l4nKkFdnA8ze8NfOYM7feksxaouLe5vF87xNmvbhhmTTDgTRIEbDloGQX0+vu71HnwtXytiTInl5YBK6EB4417JS+Q8xjMZ0MYifTekBCuXPiBkmCvhRFYFDdrbiA4hLOo2BwYRxuDfNLqISO9/1Ej7op8KpNJsX3+e2/jtUYy6YgV06tP2X8/2fVaUh1/WsAPF2ygm/1tpSFxlBKEby5dkFKN+XAZsUWaAN13PFqxMby/WFhOH75Rsi0KVZTxs+zqD+eUNwSWBdICZQoXVsnTZkUtJ1wR1JOmtozlH1XyXZBM17nH2P6opSralR/ghPNXL7o8woFiKqSxNvI9CGt5co7Q8OmGhN0Awgqh8RoVrSQ48PcK5Zk5a/SnizRgkELaarOIX/ffu83hOiiObI56PcJmXZQ4TX6TWOlAP0zA5Fq67+W2nDUC727AgyzGqfcFuJeoKsW2Kbz9ExDMfKwhBhvSK/xSPYCYUN4vOl08WVT4RAhITSxlGt9VsBIOgdqYnMoHet9yy5GMLM1ilUo3DG8O19kN/C4wLShbXHaFxcQZxYdVUZzcKnREwHGQ6kE3gEaWRU409kmxMihWhvmzDs6bw0It8o4La5G0CwILb9BCmrwKZQ0jyRjpo2SXb1RS2yGqi5kizX3Ca2dVPMciQJddQqX6wf4dEyWfPWcD5/tuFxC5aE9HD8s5Uk8NnNQmTT9RlE4iupxyBagWCcfGDXas6f1k5MEicJv/0G4FS4/BAuCcejbZ91uu6/Sa2hZZRc91ur3N2KS5WQQG3sQGpGvjOqiixdtgDIAo13f7XMn8cxIh2mvc9g1+hvkfQZ6lZZ4b72dbc+H+hbR4WyY2Q== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b90bf18c-8047-4e56-f430-08d9b5d4992e X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB4835.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2021 20:44:56.1082 (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: BOuyGUHi4jtgiXZOQ0Z4US65MKXqOyH5MD6fc5nPnYEJqUPjQcyeL14FS2iTVdaOVQywShd/0lxfh8xKsbpGuYT6TsKTdIAnsmJR4/hFb08= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR10MB4303 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10186 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112020131 X-Proofpoint-ORIG-GUID: TD0OPE3nQ8KJv1Ld3lSlGytrrwtVD-oM X-Proofpoint-GUID: TD0OPE3nQ8KJv1Ld3lSlGytrrwtVD-oM X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 967D840002 Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=Xi7KJNmx; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=LJLPFt09; dmarc=pass (policy=none) header.from=oracle.com; spf=none (imf01.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 X-Stat-Signature: z1xtu56yzfd7k4tja6fcpz1nugx7wi44 X-HE-Tag: 1638477903-236296 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 Thu Dec 2 20:44:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 12653431 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 4F6C2C433EF for ; Thu, 2 Dec 2021 20:48:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C25B26B007E; Thu, 2 Dec 2021 15:45:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BD4666B0080; Thu, 2 Dec 2021 15:45:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A00B36B0081; Thu, 2 Dec 2021 15:45:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0008.hostedemail.com [216.40.44.8]) by kanga.kvack.org (Postfix) with ESMTP id 90A076B007E for ; Thu, 2 Dec 2021 15:45:17 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 570A486311 for ; Thu, 2 Dec 2021 20:45:07 +0000 (UTC) X-FDA: 78874033896.10.3CC5413 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf30.hostedemail.com (Postfix) with ESMTP id DA1C0E001983 for ; Thu, 2 Dec 2021 20:45:06 +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 1B2KP5m6019810; Thu, 2 Dec 2021 20:45:02 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=B+6YfW54Kau7Ix3qTX6/WB/EqPVAvOMWnlTQaoncZadSRWOMU8wAKISg7LL3umUxSwNh Ap9MXRzmwAkQVJJpyZXX6V/kzYqvjr4bESAKAymfm7848M9DwBwDf+CopCMwGkhjJvGz uGuos46WWqinX9Hfsbbs6yIITc6KArzobrVgm9g61iaLPG9wiK0HzqM4pNZS8SHbx6XP Xlpg/6gap/yTxPWtVKWR1gdqh+5TL46clwJolvhGkvGG7NXdyWXQn1ZSjcrh321a037C CdcB45IHr7MyS7WoiuJi20FeY9OOEqTd63KOzQ6k98Gl7RUFjUdel4Rgk1v9xD6Gg+Cp rQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3cp7weud4r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Dec 2021 20:45:02 +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 1B2Kfo2K167590; Thu, 2 Dec 2021 20:45:01 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2175.outbound.protection.outlook.com [104.47.58.175]) by aserp3020.oracle.com with ESMTP id 3cnhvhc0ju-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Dec 2021 20:45:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X9UZp+uR7FGVD30Xskre6Tqgf+6/OrS3ffSMVjVwDoZym16JN05LMasDg6oLehQ54UHwZZAgjbNQM3LIxizF6kJhfIa2LOyILGdeh+48YQEwq16DFDe7cpZmeaulB4oBowfeOz66GKO2TpAp7IzC1RILZiD9l4QowN6wYoNgdUknCzuhcLpCe/w7Jvnnln71g4ti5/l6MR6DXKimbkY7UEuVYX2RBxmBFWEVcqurVizNn7jjy7iURvJ9/xtJCutM+U1ujZ7zz/+5O6DTh+uSdBOF0gf7Xgb6l0JU+gQdds1+8fupHviGyyO7GQOVStHVx1WAhvS3DJbl6orcO8w2+A== 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=A1DykunFLZSfhGCjTjR+mToDC4gFN8zf8sVRge96QD8JXbDKGmvW+GqPNnhFoajI+qXWM8Rs3sZqx4X5taKb3bAUZxPmcmMx2GHjlNi1eUlVdBQB2GUD+mlGqIw3q6aknKgV5mF0EXs4V6UqM3sYwI7JL3vk+lj0B4SlSgtwBslfuvajJQtLaFu6RxEWiMWRAd6vicy/5CcimCdVY+rMHZL1q1wpbaOruwgB9ja3VOHfFvKh/8y5OscLSjCeMRIhmJ/3isrQQ1uWq5jvXLUQSj5Zcrw8Y3yMzzVfObDP3dhjfgRVN5B5cCSvtAlCHNSr14ZS0ESK++8OMixS89kGAA== 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=tmKvyBTN+0XSwoh8jVYdTnJ+EiDsc8uIe6ovoqEfySUTpcq4V9zI7vkJp+jadr/nCk3Mq6ndmqD/s3iCNB/gp/n12IuIq9wQdOA3MtohuvvoxiZ2Pt4/2oXByjiHhMx5RAY0e1s37C68MfpnlQqVq3EPx3IqmtNFBk0MYTgyKQo= Received: from BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) by MN2PR10MB4351.namprd10.prod.outlook.com (2603:10b6:208:1d7::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.24; Thu, 2 Dec 2021 20:44:59 +0000 Received: from BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::693f:564:30a5:2b09]) by BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::693f:564:30a5:2b09%5]) with mapi id 15.20.4755.016; Thu, 2 Dec 2021 20:44:59 +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 v7 06/11] device-dax: use struct_size() Date: Thu, 2 Dec 2021 20:44:17 +0000 Message-Id: <20211202204422.26777-7-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211202204422.26777-1-joao.m.martins@oracle.com> References: <20211202204422.26777-1-joao.m.martins@oracle.com> X-ClientProxiedBy: AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) To BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) MIME-Version: 1.0 Received: from paddy.uk.oracle.com (138.3.204.24) by AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4755.16 via Frontend Transport; Thu, 2 Dec 2021 20:44:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7bc49543-6639-4ed2-12f1-08d9b5d49b43 X-MS-TrafficTypeDiagnostic: MN2PR10MB4351: 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: 4618BapZPe2IvN1NhVifYT7ysbZBbC7nSnO/56RYoHYNzNk8vwBDxYsyX1OKFm6t/2A0mGmjXBqBL+xwH0wS+5G/Ui27Ml3+ReHs7B1f+0XWQ7GUkpNWH9ep6yIaTGws1XsguGpHe0pBvdtPArVx8g9YPO7I2GmVMh5ZinPaQx4Nd36splvKSRoGJlJ5/HXo2iFUig3wTD8S+SGj4ohsAJGrwxqyGggdCaNWoqspIoGJdohGxbxPqluk88NisfhZegJN1zEHBjH9O+mbt6I0dTRULoA7WgRj9Sp7ffcToj63rSAeONWd9lId0gufKOnLtuSa49DwVbcbrqX3msm3acx2bzhzpQvnsFO0PE55v6dm6Vfi+AQZvNVzb/x2fZLX5v7gItYSOFSsfV2acfOQ1BUKHIhT8Q8kdBDGLWRRZHLW/kGh+l1VEpqYxciWKAOgj1iYOvKW3RoNpLgdUMWmHIFzYU9knXXH2LNYKZES+t02/sMliqreS8nk+dmtmLJcHQvtVRrme8wY/dHE/CmFRhakKS7agK7qdAmt6PGN6QHU0Ijilj97rSlQpTOj9OBtrGiG/6NVRtH2BBrFxpdNWxUlAZnbtC1wzuLs6b51XOh8yG3hKxx4DPtMxmHDM6YKE+vba+8TBjypDr30sxvYxbhjdTgfGRHjSHjqKc3a8u4tnid8J5aa6fdjmGgIKz72kVdELXQcJ/ViCUlkhyb8ug== 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)(66556008)(66476007)(66946007)(1076003)(7416002)(2616005)(6666004)(38350700002)(7696005)(186003)(8936002)(4744005)(956004)(4326008)(38100700002)(26005)(83380400001)(52116002)(103116003)(54906003)(107886003)(6486002)(36756003)(86362001)(316002)(8676002)(508600001)(5660300002)(2906002)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xss/65LKqzRk4DXbyVc1PDz2U8ZhRILieFG+dJbhf2Y1TH7O79yoQboeT3/OQtevEHKmMhHqxHPJlkXohsQAj1bjTaM9Jy+Hj6BQTh/GL1tXQ3f1NGQyTqwdKIGuJ1ozo/xV08E0Ch8LfPh9OhWxKmo9Ly9jMkmhqirGlRNhttS2vI1XEBDQhlJopAo5J1l3OK24GnDbmi1q09urhe9OH+4TuubKdZ9Jo+7IdrfRioMz+gCbm4GWBts7N6wbEFIucH04GBjt+SBRjsdPLSbDLHcQxr3oBQ2k8lQl+wwKle2Efmz59c4csNdVQbXJyqUcco4KJWFfX7kMojk+bbLE2jhmErnSCYmeyf6/q83ZbbabZwf5mi6NfP7Sp+aFOOWtJ0wmU8p1EygZ2n0CLcQ4nTZxwI5z5NPREko7DDY3uzKARajnbOfjppuMQ5akeOEl71vlQn0j3oGUH3bmsqE7SA1owUL9P7SlCzm6K8IRlllaL8hZeGocatDtsZ1PvGhMwbeEyOjT0FFOhQXj3oPXHgYZ7NDxLHOq1NhjLOEvqFJcnCYmKwan0ObIuclvncSKMzIxNGP4HjN6eiN1AoNH+18c7l7S0z4EkiE3ljjkSaVAkZqe4kDz6HxtkU4ndOWFOCJix1adlDJ2TlPi2jLCGpiyqFFzo/5Tz2vbP1atBz2KWm+MmHH6g36vsdd1GVHazS4pYMQN9pMvPLeKIeDxFLiR51mC0rjt+OUl0JeWwgs+BqPzUdtCRLXiyFdl2Yg28gK+ueXBtUv1D1kSUK5qUAkzsfbcNAPxoiOQbReziPyXEs8NMcKXKNfXV/FunrKKe4aPZ0ZnBZ2VK1Df+ChWunu+oNO1gLsE1donQz1M4vKzQElLu0yCd/eF+fo0kXwHnSuFUcPdsMbytf5YL2XrT03V3ndurJGcP4CShWFHN5kVekeui30Y8i6FJY2nTs5bWkWPbeeVEnuRIAmuXRT+lieYgqM5g3W618rB98vnVLJMBhxD3vRrEvekKY55o+N+VqbpBd1n6OCGXxONyPdJfgiieIEW53VikCVGKM7sh+KBQrnMmzlvi6c+DW259KTLNUikxOUFfkBsKyYH64mYS14zNXcFFm0W9pZdVvXgUuGE3G1cFEzuDZsENwHp1Q2BWLh/GwLVl68G1Yrhux8+mH4z2A3yigWclx4w7aDOKA0hgUali5TyId8sqDZNBoIXkf2EsVlMltsEPWqfRb4fUfcY+HR32RE3aLhvM+2OJyXYuAJGcOh7iB7fr4F23TiNPziin4TUOavrn1/EXtJVpJQrLRFBdgeE4PJ/DFy2umqIHm/+cGhsdoFpz0fajixr6fqmK7n25PCLuOeX10eRwKfTqM7AV4B1XiQUG4yf0Vme/IrRNvdGk2+ScUDLg/WgU4IUeusfIDO2fHeAiFxIr7J5RVQlnXxfvTqLlCdjnhMPnIzV/uEcEz/k2TAeM9RsARXCRNQeBW/K5JgZRXi5ThxwlNnJorJOKGVyQNBk/prFY4MIXxCEXl/l43NPBX8/+ZXsNEBa8j2DjH7xB1ZSzzhKFVZ6e8JEEyZLYvxiG0/W903Ng4EwTbRYuNioLyupTkMq/8VXXgtG+2h+KXrZtm71Esvg8QBDf3QNBxTkrJvdLGuxOlpvt1er9UeU5e0qNnxQfwbN+bz4NRi/iWLPvw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7bc49543-6639-4ed2-12f1-08d9b5d49b43 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB4835.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2021 20:44:59.5943 (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: VAsSx4rXbGIefmuTH9q4HqS5fK1IglMV+JcVzeSOw0P2dUbLCblbiqsrBT9r1vjwoP1WegwiGg51thEoNprYNypdm98Mz1hpCs3kagdNDkk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR10MB4351 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10186 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 adultscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112020131 X-Proofpoint-ORIG-GUID: mClAZvXMFGCiHzrtVWlWpRhDK8bcS3MJ X-Proofpoint-GUID: mClAZvXMFGCiHzrtVWlWpRhDK8bcS3MJ X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: DA1C0E001983 X-Stat-Signature: w4gk6kit7mrdpq6mzubh43a7wrr5qwcq Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=B+6YfW54; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=tmKvyBTN; spf=none (imf30.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: 1638477906-817372 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 Thu Dec 2 20:44:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 12653447 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 CB5BCC433EF for ; Thu, 2 Dec 2021 20:49:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8A4316B0080; Thu, 2 Dec 2021 15:45:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8520C6B0081; Thu, 2 Dec 2021 15:45:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A6056B0082; Thu, 2 Dec 2021 15:45:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0065.hostedemail.com [216.40.44.65]) by kanga.kvack.org (Postfix) with ESMTP id 57E256B0080 for ; Thu, 2 Dec 2021 15:45:22 -0500 (EST) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 2622118404075 for ; Thu, 2 Dec 2021 20:45:12 +0000 (UTC) X-FDA: 78874034064.31.03AAF57 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf11.hostedemail.com (Postfix) with ESMTP id 68D31F0000B0 for ; Thu, 2 Dec 2021 20:45:11 +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 1B2KODxZ006894; Thu, 2 Dec 2021 20:45:07 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=VEKOqR9X26FdohOYW92mF/UoBBQ/5QqvONjUpuMltkQ8UDHOHoOUHdi84w/cY8zgs/UM psnCIk3LJco+MLRk7YAY1Kka7KAve/TnBvlE+7HeTLk8rhBqHOTQN/jqKfNc68WKje46 OattRGnPkjoo6KM2WBKLS6A0vVHxtgAdeCVHoHmUzYzsGcc1H+5sxddMVoa89ZEQjQYL zLuK9LqYn4XcPR6j+2UOfvbPMm0HLlGFVmDX/pNfZRu1kEbG7QjyIvuX2C1jDb266PKI Emd4v+TLLZ80ActgKVTravGSWsKgS+vIqwoSkYjSqlYdjB2JUHuhO2Kmip035NdbOjRH Vw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3cp9gku3wg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Dec 2021 20:45:06 +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 1B2Kfoco167559; Thu, 2 Dec 2021 20:45:06 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by aserp3020.oracle.com with ESMTP id 3cnhvhc0qe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Dec 2021 20:45:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DRAryt1TdTEyg9JXgDC7tTInHJNphk92Hys+W+32UF2m9fpljIqR8Lp8Ot/jT8RgrKNRqD9hxN9fdFdL2p3/gIysM4WXjqwDPM+u6eUSqkPRPKmNNTpvqvL2TI/qcvNjTTM2S3j9baFwZmB1fSW+9Y73HI8coFmqn+dDsgDgh6qRrx8VYuxM8S8dVaSZtMEtQeVpQm9mQPaijxRRUkp+kxtjZ/PHfmwB0+ECkPIV/vaLg9AB4jtKq5A2JVdeV/RfSdMeRQ8CFWZ8srwUr4ZmOiVPbgkNDocOXECQ83McftiLcfBJhjXApfMF3mn/OSYv1DsLBJZWXQ7Z+HXIl6H4Wg== 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=afOkw0qSrqOC9B7F26mPvLQn6YbvkVLoLAlwfPPOSMnWPEBbwAgLPVf7uzBJecMzg6JCfMEFff9y/F1y1YuBDXSyyCw16jSolU1P+GkwRUjtoJFcVoLgiwdE38IXs5/mXwKgVSCysqsr95bMIO5Gizyh1P7hi3jlzgG+WjG7fYrKbf4Wg1+GheGeHD0pd0LVSrbBaTb0gtp1OBveeTurH24+++doF4oPNwe7aRQm0oSawEdGvDcfd20O6nNNHPEbiZXKnvwXsoRmjq6KU7ywRzIb8vSajd9dZrHr5dbF9D63Ec703jZQUm7725bovAGC6OhSFFo6FF7NqyhZU3XuOA== 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=E5sMIp7L7B5JiXqS+jPi1cx8GMIg//0bmOvjTsw3o8xf4mmaEPLivApJdA/x32/d7sDySB25zI8w2mP0JatS90376YmqUEqtmxXEn3145PT+0GHICOrDxVvDcshVaYsHuM6p5pzVkb2FKu+n0v31ZYvHGmYExPI7bj+a7ln4fEM= Received: from BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) by BLAPR10MB5186.namprd10.prod.outlook.com (2603:10b6:208:321::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11; Thu, 2 Dec 2021 20:45:03 +0000 Received: from BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::693f:564:30a5:2b09]) by BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::693f:564:30a5:2b09%5]) with mapi id 15.20.4755.016; Thu, 2 Dec 2021 20:45:03 +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 v7 07/11] device-dax: ensure dev_dax->pgmap is valid for dynamic devices Date: Thu, 2 Dec 2021 20:44:18 +0000 Message-Id: <20211202204422.26777-8-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211202204422.26777-1-joao.m.martins@oracle.com> References: <20211202204422.26777-1-joao.m.martins@oracle.com> X-ClientProxiedBy: AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) To BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) MIME-Version: 1.0 Received: from paddy.uk.oracle.com (138.3.204.24) by AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4755.16 via Frontend Transport; Thu, 2 Dec 2021 20:45:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2e6614e0-5e9d-4ff0-1351-08d9b5d49d52 X-MS-TrafficTypeDiagnostic: BLAPR10MB5186: 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: 5ce/tU01/yS16STO4xoosdYM5BZ5lufTz+gJ8XYfXdv63CpeY2MDckF+5fZoZzfkUIpIANFzSemhvkBXHfiionpYp2kSdDy9ttNusuXL9Sjk+uMIl2RJZXYKQoLimRXqOPJ7XojrfS0hh2cAw2o2HsoZagLhDN4wLl1khUShfs/4rrqJS8T9P0jUvwAR75z7z3U9cJcKicNn2lH++Uq/tj731W8qe9xkq5W3PQly9ckrCnUBmGh2LB9hTVyjMyMRpDrZ+EUWXCSD86Y9DQNakZdpN7BjieDv0uyrwdcEwqHv8KHJyqpDEUUruCnwQgN0IBN19K4d+uE100UiSRwk3ADR5ou04W4kwacSNw3mBzO/Yf9BXx+dpUxxgX7MQ3kNfKEzOM2Nn1x6MLH8SGWeed6VkhwwbRztwZ62Po3VanFQsfp/oafeK1LRv0MU4ITiYhcFtR6g3rmDHwVgHeeRvhCfiDjLjF6lxOWkqtPWqKszGAbNisD8Q8NjnF7OzoWNhNbcxAjs69LNkcvyhfVpO5ffyT6u2Dkqd/2MkpMk7w9UX/okny5y1JVHhg+M1x9F2ozGdM2nnCZq08fedOv6GUnh7Xsu/S+lOdGBWJsxXm5otgHIA8Mk4aTXuPLu20a4P2BPbPr+W0/Wqy4iVK6gR8AN8bdIPpmP9rBK/Xa4qPSWs8sIxZV7MCLBkLylYUF95ncO9PkMdeMJu38JNOZb/w== 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)(2906002)(52116002)(7696005)(186003)(66556008)(36756003)(8936002)(26005)(6666004)(1076003)(8676002)(83380400001)(6486002)(107886003)(86362001)(2616005)(38350700002)(5660300002)(6916009)(38100700002)(103116003)(4326008)(7416002)(508600001)(54906003)(66476007)(956004)(66946007)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zO4XXTOD+RSivhRcEmPVQv0fjln3PaT9Dok4CcRHH7YzF90Jy01YLHDhzPu3eHu7VgHC0B3bmEI+kAesey+Y7HIqR5umuaf615j3Tb6vZbWUWWhbbwuYso4BqgNWJV3PJuU5yEODAsu3XxEC7ly203UPNL9sbWS1OANmpnFZXx/pyEiauY8KGg98Nn04YrsdOgbWeftasd1sSXWQhobU5lsoZXqAwyox9SWZ89x4SoBImyxZuWEsLcVz2fV9IL1qVN9lJLWhZMs+/RMcP8NIx6IkaPVlTSGfYy8As6i6Sfzg7Ixukmtrrn/uMKLI0dY94kqBFZj1qozHnD6bIstPWvxccx3aVbinj7MTmKCQK4E+MSQkrwxFX0Dh9dmGXv3pUUPLTB+6/APoGurBYM8N+ZXBsk2WnmWX4FeGRdS6E7TULvNS0tIA4PcsSIDnVgNwkEyeDhLZBezp+esnxbtuiGvPPEuMUMkt4YrBaXL+jZ2jfc2rHtfvWh6p99bFoK5zjTwv4Cnd4eg/oJf4vVQvQWYe6mcUkm+sKbxGx26ooXf00IiqsllRxJY/8ZO+hdk0xfu7cQR5Ck7v3XN/AuRHjbP7byhaRXfhlGVxt0LjanX8XDzVgo3flB+6fjsItkkee9Mi8pHe/izo/qLs3EKZYoRRyCWU06Z/nbYdnhooXJUk3/2ZWGWb+0OtWN5+I+WPFtTjl6vAGhRsn/WdpKyw0mwFjiyfFj65jVRqmVcGyOagGOCDXn6SdKTmzPK5r/WhoG8Hw3Zn/32Bm/abzFwj9Dt5x3x5HqSf8x1N7LvR1JhVDY2JnsBVdXwUf9M5cgos5nbF+sW2GgLTPc/N4+MdxfZYGRhsuBQEmDw83pzLnzDFRGahdsRrfUHtKZlmSIPqWJLaMyQbb+LXB14e02ZXj3k+rU+RWxK26s03JeJE2RejaTepOYZg9peh28jOkch+iVpyVyZplypkGFNxlJrxILXDNuNbyKQtee1R/MzSeYipqwSQZbeuxYDY3HaeD9At9bZLG+0HVlfCr6t+gDWrPXnZCmSgqw/g8ylR/Ymli60VjqqsrIkxG379QBUFflYQ+Viwg6XN7kW3gjVYJcoM0Xv/93AouxP2Ad7E4M9yieWwpah7fFdICo6sLhsbI53xadhyeW+swjRjFfQSrBRKmhvSIxkPynS19zAqrwd8ayDnE6l3NwF1qjR9zltlFwrvm27wqG4GHBY3HlgUl2E80n3Gtmq/wXsSBgfcUEFV4wwXLpvcsm2z3gVCUhj9DA5mp8HNjkPABoCvCV3gGYqUcbhaIgKU8KqDrcgkcZTUXpkvghPMk3et1KKcXRkaIPHmyjSvtVK/VEOAg+yM7s5ni4wGw8ezO7tSKkpisxjuyDgRmzOmaD29oTfncIKvLCMYGl/NH5iv2vkOUY/0PJxnOFOrr6Myfb1qozYM8iso4SFdPqZdMQDkPivUgLuImt81quWBEZ4dw6Npto4TF8AOpXcDHPaJzhCEw9uOqOxsuRm1e5U1/8R+qSdDJE5PARm4YJfdI5mU6OHAA0llVQgZCNqsNkOrsdi4oQ2SKtCs1QmStfb8z0QV7zjr4NIxyrM4zhm4XZXE7T2CYGOl4hJWb3WrQ/XgQWMhmOky/oKPVxjh9eWSI69kUWgyJiHhOKq4wmLdDatTdLGLvhEwKpE+6Q== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e6614e0-5e9d-4ff0-1351-08d9b5d49d52 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB4835.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2021 20:45:03.0950 (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: QpVE3z/Bf+OPUN4aKXciPX3U0/xj9PVa9kJv2I3CVyDu0Y+o0Vb1S3cAaC3tXQu0xWS2XttSwzBHXriZV+7LuHpyc3jeHi5FDZZX2FheFSQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5186 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10186 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 adultscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112020131 X-Proofpoint-ORIG-GUID: sO-ZT9QjA_Kx5YM33a1uoO_lOgpzDxWm X-Proofpoint-GUID: sO-ZT9QjA_Kx5YM33a1uoO_lOgpzDxWm X-Rspamd-Queue-Id: 68D31F0000B0 X-Stat-Signature: kermwg3aifzwc7x1jfinh9ah378fqj1s Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=VEKOqR9X; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=E5sMIp7L; dmarc=pass (policy=none) header.from=oracle.com; 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 X-Rspamd-Server: rspam02 X-HE-Tag: 1638477911-518987 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 Thu Dec 2 20:44:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 12653449 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 34F5BC433F5 for ; Thu, 2 Dec 2021 20:49:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 399F56B0081; Thu, 2 Dec 2021 15:45:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 348B16B0082; Thu, 2 Dec 2021 15:45:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 19B926B0083; Thu, 2 Dec 2021 15:45:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0214.hostedemail.com [216.40.44.214]) by kanga.kvack.org (Postfix) with ESMTP id 09C256B0081 for ; Thu, 2 Dec 2021 15:45:24 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id CA5631838DBE4 for ; Thu, 2 Dec 2021 20:45:13 +0000 (UTC) X-FDA: 78874034106.26.7A71E6B Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf22.hostedemail.com (Postfix) with ESMTP id A30FB1902 for ; Thu, 2 Dec 2021 20:45:14 +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 1B2KODxc006894; Thu, 2 Dec 2021 20:45:09 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=veo4JShZm6zZDhJXt/HXzdyG7U9vzZhDcPq0e1iqSyp/D8HAC1U4FwmBM4u9YnkqtXbj Dkp3HE/uxhuZ7m31a8WmE02nY09PPpKf8olfZ3CuOBS2Su9wMxW/VC9xyGz6zhAgoNuS bG5rUGfugd7GM8yQeo/6fKU28br/bwGSupeeKSbVaFKtlBRs5o0eOELUc4Z+lk9nKWvM ZySUTKV3vC7Ql4sTEejURLb69LhpCFCO0XO9ynB9HMxWqMmSLyj/ouxbUDGd9q+kU5Hy IDe6DNOCX6kvE6+XDsBVvtetL2Ry1w80aU+DLZruc1tyb2pahmgbAAUenAKSJZ4ybteA 8w== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3cp9gku3x1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Dec 2021 20:45:08 +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 1B2Kfp6K167614; Thu, 2 Dec 2021 20:45:08 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2040.outbound.protection.outlook.com [104.47.66.40]) by aserp3020.oracle.com with ESMTP id 3cnhvhc0tb-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Dec 2021 20:45:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KGVjJxCeMvaxk4CcBghOp1vvLfLs170/FQzb30Xu+UiXL8lkCQVYHkG77XQW/eFvVQoSfaz8fDMBKFYZd9Dut3r24887+9VQ2MSCDavcGLFTiwcpSfoYY6TyTuAIM7OP5DVrCNUNYeXQ8YaM638Vyweatfdr7LZWroQKDOyLlvZH+Cb/NzDIga8o7yFi0L8fmg9cmAxmkXcE5UpNN1tmu2nFW5HGSNKn5k2Lppf3joYw89r3IRwevVCA4wSIeoT31bxYXwI1xVvpFHXoVZY1IDcNE0KKOrNxLGF0yCpUmeysQXkMPCb7Ti/hPPRVvAU3eZ8y5hqGnxQmE/YaCn5bFw== 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=ajQxCiVS+aiSAOY9YPQ56bFjMEpRD75Q2auVKTFPt9ls6bn65e3BZyfgciaJtvxZzVs9kberbvHqoyUjATnmwk5ou2vCwtEGg+nXMVVlp4rz3LSjVBlOi3e+Gch1+n1E1VOwstRh081f7UpedODgnXsfNKHJTkPv2SOwT5USPyR0Gtm+cbWIge/Zxn11qBYK2RGurR7nrM8v1KLh4zLa6EKoyrJXSuD/RDvo/t6bU0G6+lo5kQLnYhJukFeASfIk819fiAnL1C75alOvLfW2+4/bC1UI2ohoASAXaytXKiV/2vqI4iKyMSRWyRuxxwbaWiXyGPdl+P1zpIbMK2tErQ== 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=aYvFQOGHRjY8Y+Uxl551+K3tE6U7tKRT4NXF9YHtWrVbqgor1csAd4OGIhfOw9Tau38N4Jo58giLkaBQ/vC1/wkMt2Xanf0QdZY99Tm/ocZd3Y+3AWOQ2n/xzbJQ/XR4Q1I+eWOxT24fu1P+dGbx+3/d4Js/mnA070taFHqXXS8= Received: from BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) by MN2PR10MB4351.namprd10.prod.outlook.com (2603:10b6:208:1d7::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.24; Thu, 2 Dec 2021 20:45:06 +0000 Received: from BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::693f:564:30a5:2b09]) by BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::693f:564:30a5:2b09%5]) with mapi id 15.20.4755.016; Thu, 2 Dec 2021 20:45:06 +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 v7 08/11] device-dax: factor out page mapping initialization Date: Thu, 2 Dec 2021 20:44:19 +0000 Message-Id: <20211202204422.26777-9-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211202204422.26777-1-joao.m.martins@oracle.com> References: <20211202204422.26777-1-joao.m.martins@oracle.com> X-ClientProxiedBy: AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) To BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) MIME-Version: 1.0 Received: from paddy.uk.oracle.com (138.3.204.24) by AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4755.16 via Frontend Transport; Thu, 2 Dec 2021 20:45:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ae962f75-8d7c-4bb7-f094-08d9b5d49f3a X-MS-TrafficTypeDiagnostic: MN2PR10MB4351: 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: DarbSFsUc9STSvrg4VUtLjJSWg+sqhrqiBtiot2gereYww8aBQvDfszDKXNrAnNe8bgoIA9hwRvRbyl1rC8KLM5dbnSReBDbdabVuUjZDx+G/GbUqZdyRmNB7APH1Xv7rtT1Rhi5yRG42gvm8LhXTwvAt0UB7wtH++gLYHIztdNfDEOsTK5vV3zlzh+T8c6lIRPR9l+b6ssJMqd0pmsSxr78+cDikhU75GjR3u/Sj7N3OCs6fE0jW++zUomTe8sJWR3K/FaeRX5rK+EEZu+9q1twnLnhhWGjAoz+9UkwBuKWkdFD7dU8PeoivdJ0yO3wROCpD+6ojqXkcIjYpZy6UdlwJtn9SF32weTRZ5aRaIXFs6ygD1Jef60dMQfVydlWZwco0GCBiv/fZeJL6y93+Yd5fJfSvX3qaY57UevKNfWUE+fvhvTbQSHslHjV+toBskIFrqf9kmUIPaN9w+3FuCjT0yCU1RovaZaK0pXcnxERkf/iDr9nacAfrvUFC7uiImULtQOrR6UUmg+aBsfDC242hRztQY7kzpxmIEXPdaYsn2Dg/MuQ6jVINnuytAMXYtCx6Q4VlmMzNnCQB5YjQKM4SK13oyy11RWaPACEvq0swIqC2wj49i2fEDXM74I1M+tIFGukaqM27Bj7Xofon1k31omzAJpi+AwZoMX+ZkZWhb0iN90GJFP4ylc0GgxR8OWnxsQh6fbXpQvCvOVEvg== 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)(66556008)(66476007)(66946007)(1076003)(7416002)(2616005)(6666004)(38350700002)(7696005)(186003)(8936002)(956004)(4326008)(38100700002)(26005)(83380400001)(52116002)(103116003)(54906003)(107886003)(6486002)(36756003)(86362001)(316002)(8676002)(508600001)(5660300002)(2906002)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NaUOLZ2sEOoLhgiu7N2j6n4T2r909Nye+RmRKEmu8jIaUMGaRylW+f2Hjga6wYu5uxVn7GF17GFbkSda/lLOy4ClF+YRN0fbd98UBPg25eknVihz9MQfZSS4qz5bZfGEA7jJ7vb3fetyjDwyJz+rqlXzT01VTlklGCuROZGzzYUWuwHPNKFMnNJ+ta9M5gHd0qXaVrKwgVY3A7JiiBSU0cRMW9AlrRI6xh0MYXpk8oIuIRmOHvUhfa2G80n59Ma65MK4xJ2EguMjIEktXiztVvOUEOXYeg4TZ6PLR4SGj9heGIHrB3yp+RpkXqyYHRLkdpZzYpNmSnWwPfVPPWUgqNIpTlnMlJuddnteRx20RPJmj9YfCYzYbEcsjqoPGOUSXkPXdOaDM6MNJy3ae9GuBNlwQM2Z/9XIeLB9PZXergrufvc3RlWWOt5VaRNk7c3Cfmuxdgl6yA0NwzZa5t//wyRV/Epl5DhRAkh9lZ2ikdxI3gCHYWER/NKuB+DJGKWX631f7LaGfR0PpwTAtJwMYi31vvTLyWXMU1q0XrSGA0DWgV/F/1O51tcMWmi3xWAVQvuaPQQjMlMNaXn/0YMG9RqWDSyj+s4Hlvv3+OcZpCtKLCiOtqh+4QBR3aw+jKlu1RGt90znN/+CR3UHk5dhTrIPJZqmKJ3vsrFpyjNZuyr4go2ueFtImbhB12AhYIH+ir3j7u3sDaqHwxc3LAPWfMJMe4XjaVNSaJgTiyW2dG9Tw7kM18q/BbNYtFXsiPE5sc0yseJ7uXWz9Q/a4M9KhdoGN5oseh9Caqkrc6s4TWIv4r+EDTKK3rGjBaOTFHobRRqb4Yc7KRpyXUf28/dq4zUCSw5AfwEsQJbP1SSEQiFKQjenUSPY8gDUBQ9TqnWYvaFVn7doQw0JVb4yRqjr33CJ8l9dgNA3ciRCkkhyX4ZDAHyWa/g5cuRQ9GFd7k9Tf+iUeYZmU6/JZQW90FbxZDbvcq3uu5veSZNdgHrJDHNrvB8/5+24Ks8coLH6h3hiMabtLwaK+30Xb9pr7Orgt0ldmIEn0k1HfeElJjk+z6w+Q5aK+kPFl2JsI1H4VmhR4i0wVY9XqXD+/12jctOtKFpkfEu+eQCg/zqh3NXJvPsc2PQJPMaAXJ++6ZxwBYiwm6FtpVpbhrlnNkw9QXh0fNml2A2rMW3r9Z1Qp6KgJi4k8ieOYW/JuJPSOyEm5D434KVCkY0OdzcKVcYPjdv8RBhTRO/RRJlbPt+ukQGu+OymIMUi1S3RD9SBJOFJeKWlf2f0q7Exy6+8Fs6k32fZDSBOnxjlNgygMPAXzfcsCWCJipQ0bQxFBI66X08L/Y3PdX3ZVlmNOJsMQ/Hv5WcbvchsP9GtVhHWPYmVxzTnJ32sxqUOH1wpYRLkCwNHufffOe0RKCux4afITK/HP4skwKyYVgEvsBXPS2bdgNBDREcrL2ifuU2EUp1y7XGU9EjseoVb7hkwCT0wru0PpruR6FrxpXJI9bBU7pDBAq2DPWVw18DpYBT1Jo1GohQmSFqbGfuVI7AqPbSwwfdjvgwnTwSqHVCv3JYdyKCod+QCRk4skXHdJztH+M029AfPHMnKs1lFxvV2L5fDwdmBdIl2DkAoUbjFRSD/x/VjZ2ZuldwIXltjzSoe2XDKG+XkIW040xrPEZ6VGj94GBKg2v441g== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae962f75-8d7c-4bb7-f094-08d9b5d49f3a X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB4835.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2021 20:45:06.2062 (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: FG0qwWTq3nkZDWT+VCLPs71jhOSXWNgbcl19eI2IKcqTP6GLA/mqbT6eK9zG8uekz+mS5GrsOiOBV0qGUjoaVN78z45YnC4GUwXy/mIX1eE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR10MB4351 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10186 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 adultscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112020131 X-Proofpoint-ORIG-GUID: ngkj3N-JfzN4Kd-PEJGnqxpXpLr-YpqI X-Proofpoint-GUID: ngkj3N-JfzN4Kd-PEJGnqxpXpLr-YpqI X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: A30FB1902 X-Stat-Signature: 7rwri6dqjq5wmzekkae1kd6sm6bziug8 Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=veo4JShZ; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=aYvFQOGH; dmarc=pass (policy=none) header.from=oracle.com; spf=none (imf22.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 X-HE-Tag: 1638477914-115244 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 Thu Dec 2 20:44:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 12653451 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 DDA22C433F5 for ; Thu, 2 Dec 2021 20:50:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CC2026B0082; Thu, 2 Dec 2021 15:45:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C70AC6B0083; Thu, 2 Dec 2021 15:45:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A9DDA6B0085; Thu, 2 Dec 2021 15:45:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0062.hostedemail.com [216.40.44.62]) by kanga.kvack.org (Postfix) with ESMTP id 97C956B0082 for ; Thu, 2 Dec 2021 15:45:29 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 54B768249980 for ; Thu, 2 Dec 2021 20:45:19 +0000 (UTC) X-FDA: 78874034358.18.EB9D721 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf30.hostedemail.com (Postfix) with ESMTP id 818E5E001983 for ; Thu, 2 Dec 2021 20:45:18 +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 1B2KP5XR019803; Thu, 2 Dec 2021 20:45:14 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=Pew2mxU+sAsmKJle5Hl2pyvwyQTkMrQLauVDtE4DxlA=; b=gMVbDO6ZPO6WbZXkRQCXRau+U5tGMhz93ST2tJsdXHKnrY/+0JIV72As2hVDRajwaqjf OdID4DrV8FN7JIapYffG/OwPEuy7/ruMX2TW4+Himc/X8q9F2zwXmou+K7SBJ8wSyYUY UdXXQC7tRNLz+sVm1uuOpMZ0oflte9GGkigF9EQKhMgbheB1aTnZ5xo1jRim8dZrNJGv JI6vi7/FHdrQ/a/eNsjbUQ8kc3Dw4hBqg3JtaBdoTTvKCmyMI3c7UhSDXfg2tTEptxkH 2eV/aG/qAGA174aOwmqPVamU9oaN0q5a5u50z+Krn7QtK/F6Q2w211OyMPvKwsax2QSf VA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3cp7weud6j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Dec 2021 20:45:13 +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 1B2KeuWE121646; Thu, 2 Dec 2021 20:45:12 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2048.outbound.protection.outlook.com [104.47.66.48]) by userp3030.oracle.com with ESMTP id 3ck9t4v59a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Dec 2021 20:45:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vo+XKzoo6wiGWW6PEyFLNZ0sIs8fSkhBsqNDwrSlpQNtrR4uF3UKfkwnLnLTwlQMEB3qPJC0D01MCUJXn79JPt0hbWcAHEuZnBkEKIj/QSZFXMabma5t5N/Mz8FPnGw5FgHxloq3jVJ8+e2paHFQqM6N3Vyuzbz6S+9N9fSTYzaZYOoTiGD+BBIiOpRK3xRd//7PjW3rR8DqHL4oLqLP2oe6wAZ8NNXJ29vQRuzDBgOU5x1LaMHESC9LmBctMEprZC1fGDuLzTGDsrnDLO7o6muSxJnOKjQPVNiLb+CyNkU2KmG7TUfvb1suNjsj8VX9PWPA4VmLTazxWYjny5CxMQ== 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=Pew2mxU+sAsmKJle5Hl2pyvwyQTkMrQLauVDtE4DxlA=; b=hJInDDZKq+fVKFK9St0qNgCCFFNe1n/sJ3T/I2wjrUGk7XQcpRgp99kWvyS5k58OE3nrJ+7UF3C2fv+uwKCHv+5q4spv7tWULW0qj0R2wOWt1J+qWHfQSiqipFBT5O8Pid5rpNWhmotzvY7G8jMkILQfix838GY5kcfisXVPDiBnv+bY9Zdj2iOfuxoXb5f0RhGmZYclWkPwnWlohiSQLdTehGTDgvdJq5BBUrsrWkkp7b4UJFfHnbYdh48eoc0f4uyWSnTX29D7qmAX/mxWxsbYTKxYyRrMXLVAS0cIma5NxofqCHjd3H0MTtlzUXXsqN77BtaEhAKwTM9FHFvDuw== 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=Pew2mxU+sAsmKJle5Hl2pyvwyQTkMrQLauVDtE4DxlA=; b=ZplXFQ2Af+N0Qoj5/e/SM9FOn8KmvRIovdaisy+8EHkX4vjTYr3ny1njXc4KwjtLBn7I+JcX019gsYpAroVD0uH1zkA68oFcX6mzGr+cVBbo4UNG+MEFiAezDRqRpj5phEWIQ/DGTdeCitNyaEZKm4eCICrrVtUB93XJpaxCNvA= Received: from BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) by MN2PR10MB4351.namprd10.prod.outlook.com (2603:10b6:208:1d7::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.24; Thu, 2 Dec 2021 20:45:09 +0000 Received: from BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::693f:564:30a5:2b09]) by BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::693f:564:30a5:2b09%5]) with mapi id 15.20.4755.016; Thu, 2 Dec 2021 20:45:09 +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 v7 09/11] device-dax: set mapping prior to vmf_insert_pfn{,_pmd,pud}() Date: Thu, 2 Dec 2021 20:44:20 +0000 Message-Id: <20211202204422.26777-10-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211202204422.26777-1-joao.m.martins@oracle.com> References: <20211202204422.26777-1-joao.m.martins@oracle.com> X-ClientProxiedBy: AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) To BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) MIME-Version: 1.0 Received: from paddy.uk.oracle.com (138.3.204.24) by AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4755.16 via Frontend Transport; Thu, 2 Dec 2021 20:45:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4447e735-7b96-4f13-09e4-08d9b5d4a156 X-MS-TrafficTypeDiagnostic: MN2PR10MB4351: 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: uhxu+NY+vvEz+g+lbBHEtnr74TGufq2DWSe7iHGS5bpeZs1EoxNAGVpD82uaqLEupsHzGRYpfFj7+E+3GF3Cr+qOeoRhywQwbpgy9ErzIjcFEjD8Zj/wVnuanqCsuY8ir8fA8JF9KVN+jkQOiLGsmmHhJ1NcywTDEkACntVeJFYEk//GO7RwpDP9SItgykrzv37K0WfnUwEZs1d4seKpC0yz14jRffXcjoZkvmM3W17HSUJKsh2KUNvgt+skF2QPohjYCT6RsCEoVnjV1Zb57tS6zVRPHY/3YrYgvOGhzDTSVxhfis9ZXTHywzVy+cjXgH/Eu7Kj72lWOvNWUkDwX+v+g7UJicIQ/DDy0BjVy3SrSwcpKi2c5q/1RLPVfPrCaXe1jJyh00hYfCHx3ol1mlfhxn3cMByIExKO62/bnjIeETnf2J7U3bnk4TewQS+fRNbW62p6dI0q+V00hhb4I9u0/JzWoED6tFLKqjahAfZ08HK28/GUpr6k4mFjUvk9nulo6m78a84XGuHIJelrzmDh8kJiVmykPIa3LcYiZWWZ6hNQJD1Tq1c9Ig4Sx3prHbxBk5yg4k4EwrwZoMVhTiy76b03RWVzzW5rfWVujSW+uuf2sRV5c6IzObg70waVcm6Gy+KTqBieRigtGC5TZ3VtcVgWe/AqPCb19OzoP8YMOZi3g3lIspVF4uPxOekG/M99RiSE/U/yI5zGLk8tsQ== 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)(66556008)(66476007)(66946007)(1076003)(7416002)(2616005)(6666004)(38350700002)(7696005)(186003)(8936002)(956004)(4326008)(38100700002)(26005)(83380400001)(52116002)(103116003)(54906003)(107886003)(6486002)(36756003)(86362001)(316002)(8676002)(508600001)(5660300002)(2906002)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /2cMk5uXqcath2CI77aYHyFQspG2j+iAY2rWNngfgMPO9funjOZeMuw/yzVhJTEBoQ5l2FCWx8Rt8M3dKf5YXhExPDCum1zp0FvojNDZBdnaoLd7soaSK7xC1Y1v6TG0MLF6Tfw6N9pzco5SeC1Y6UbdbaTX18nXMHP1kGu2Z4+o9S+QxLMU2dZShozKjIdustGCMSAKaAjX2KWS+sA9eTByzuPXg3CVIj5rGataQ9vnz64k2ULOEudPZymHxZnO0U+k20q/OOvCLDTx+uEQhB9JZXKTkjfsMVsz9SBNSaqVnnuos53bDwSs0f+4NFrbCW4Q1ltm5hP7YqmsnLuk+aJrBe0QXrhUzGlgYqLmM7GaIMhTEw8DmqFwWoP/m9cvOT4GZmyMQ2kQBV6IKmfI7izIZrt3vnwlX+EodmXVF/NyAsr1XtVyQ5CiomnQs5nY+Zeg1Hg8HVZ7RdSBtLhdGwALwOWG5SLp24Cb+OcUpCZVXt43SZqNIKIueciuogbSN6esLCGY5fV74ugRv/cKWlFoswAGErjzhMzy0pYi8YtZlj13oh6rFqx+AM1zngVgjmb+9rsLlp7g8SOQf3kGYWp4ztzgTASAvTylYluaUztLOdgmvVC01z/JIA5meEhID8iHzfnBZ2/34PfQO3THwhvkL7OHdiIQ3RNGJ3Ng8iEH2sTz23pZAdMZOZcQvBJhiyvpbazFMEet/nwHYxVOFnTcqBppZWJiJmLWI/eM6SAuMAck3aa8DUjhjlD6LwmQt4JbxydSuWp5vCvj1Tpss46M99WTrX9iTFFLcHhS1PTTl7G9crgMZUd5+h84UjtsCLytW/+rrErPgaV+e7moajoh1c8uYKssUxyOZ4bmwFpJ1pbOA/QBcKwMEKYvkzCf06fRJ+OABK8yZKT2MmWzPvcKLqqPvI0eogWF90qjWawyQmqnyeJCBIIcD0x9dO9QhPS7e4baQvH4sbnxkiRPq2tDLynWcYQYv8Jta8hRiI3Qk0F3vkGUmwdS8Dp8mjHnFjEevoTV+1PpfEbR1bzOvVCIWbEx1tr59faj7MHuKrv+dyYFv1iHBXI4/Zql+dn098pEo0tPp+w2neSDd1Tp5dNKs5YIxMEEVcD5tfyNhaet6qJmruivGnQbw4bLoue2xyGxMA5IuY0Nx/O80vwLZrXPLIsDEXaL2Te/nnhWIkLnCgK9za7Q5c74mxszHvXcey83lkCKCasGRB9M6jYOYulzd9xKap4nPu5ujAIoetmQ3Hw+q6MiCo9PNFwRAH4pkJ9z8nFpby/ah6f5Ob+H+wlOQC20kIDQRDqCkLMhGBnrcw5Zh13OANx9wQ8PiZHmk5Uvy8mAB61OqZkBqIbvfqAwR6SSg+pt09RKpOtSmBVNvpnjyfq/UZQEOadOdBJdwbyOoh+/VPdBE3ZNC0/ZH2x0JdlR7RgR78OaViObpcfTf7f9ggE0vyI7aQeVYfWwwR2PP7YN534NPyZZRZZXTNTLhWazsjnQlAeP2BV0si/T51/yDmQtV45COxJ1SVH4evPYpWSf6fpuxxMRctXCAMXxtPNj791kAxvmqjjy3ANS3W71QnDTDA3faZq77QAai84md3e5nb9ijQIDyX956R43BiL9YJG13s0/G43Fy8WioXWpMHQIkOf5/1hVk0SvM5BSRvbjHm93y0mTPanfNg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4447e735-7b96-4f13-09e4-08d9b5d4a156 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB4835.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2021 20:45:09.7068 (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: 9jCh1GmIbVxglZihkOgP0l8xOqCRE4D2+R+r+Wt0RAb0sHZQm6jkVSDCmiJ+QvkOVXasHqryIAxXnXsMP7iF/ESFQqEFeY7LYE4WqLSJqhQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR10MB4351 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10186 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112020130 X-Proofpoint-ORIG-GUID: D-O77wjrGsjcRVAg0Rn8a8__Pj5iOpDg X-Proofpoint-GUID: D-O77wjrGsjcRVAg0Rn8a8__Pj5iOpDg X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 818E5E001983 X-Stat-Signature: 3txptnysz59m1f6mzd31hb8o1eioc45i Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=gMVbDO6Z; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=ZplXFQ2A; spf=none (imf30.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: 1638477918-325890 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 --- drivers/dax/device.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 9c87927d4bc2..19a6b86486ce 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 @@ -217,7 +223,6 @@ static vm_fault_t dev_dax_huge_fault(struct vm_fault *vmf, enum page_entry_size pe_size) { struct file *filp = vmf->vma->vm_file; - unsigned long fault_size; vm_fault_t rc = VM_FAULT_SIGBUS; int id; pfn_t pfn; @@ -230,23 +235,18 @@ static vm_fault_t dev_dax_huge_fault(struct vm_fault *vmf, id = dax_read_lock(); switch (pe_size) { case PE_SIZE_PTE: - fault_size = PAGE_SIZE; rc = __dev_dax_pte_fault(dev_dax, vmf, &pfn); break; case PE_SIZE_PMD: - fault_size = PMD_SIZE; rc = __dev_dax_pmd_fault(dev_dax, vmf, &pfn); break; case PE_SIZE_PUD: - fault_size = PUD_SIZE; rc = __dev_dax_pud_fault(dev_dax, vmf, &pfn); break; default: rc = VM_FAULT_SIGBUS; } - if (rc == VM_FAULT_NOPAGE) - dax_set_mapping(vmf, pfn, fault_size); dax_read_unlock(id); return rc; From patchwork Thu Dec 2 20:44:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 12653453 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 D3C5EC433F5 for ; Thu, 2 Dec 2021 20:50:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D37B76B0083; Thu, 2 Dec 2021 15:45:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CE6D46B0085; Thu, 2 Dec 2021 15:45:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B11356B0087; Thu, 2 Dec 2021 15:45:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0050.hostedemail.com [216.40.44.50]) by kanga.kvack.org (Postfix) with ESMTP id A0CD16B0083 for ; Thu, 2 Dec 2021 15:45:32 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 62B7284CF9 for ; Thu, 2 Dec 2021 20:45:22 +0000 (UTC) X-FDA: 78874034484.21.E38BA1A Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf20.hostedemail.com (Postfix) with ESMTP id 204CAD0000AF for ; Thu, 2 Dec 2021 20:45:20 +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 1B2KONJn023249; Thu, 2 Dec 2021 20:45:18 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=3q6V4tgPIyw7c/7R8KMq4uY3+XZ+wyYfe/wFopasDvk=; b=QDz7aHDCPvXP63Lhlgxs+xJnbCoqYpDBrItoaCSaKvIKEUtrTq4aLKjrA1iFED5Bi/nQ Vst67ita4IK9DilrTcz5ArtLZhFE6ZJoTJrrhrLjNWCnEoKI2zj//Lgf4QUF/T4RI56w 4xKihzvFiVdAOVGTeLTIplo4+IgY/hA+QDkPNISZehEPbH2RLSgp8ruD1ffV9nYMx/Pa eJzLw6C1Hg6LYBmW+B3wrb6vknVCPAIrWcgz7XGjWkF8A5MBNCittuhjfTLvEQD9x1Pd WSUgQUOj6JOAlhhxm61OXuNSJXV+BbXBvOuXeTlVawtGokhLKHMF38iEfX5zf35NgaET cg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3cpb70b16a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Dec 2021 20:45:17 +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 1B2KeWCK048020; Thu, 2 Dec 2021 20:45:15 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2176.outbound.protection.outlook.com [104.47.58.176]) by userp3020.oracle.com with ESMTP id 3cke4ux1ap-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Dec 2021 20:45:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gLHOeDr9YQIkPrGNuKWtKX+YpNv5ITxGbcw3NOdDr4yVhDQV5zRs0nNZnNZjGxMiqGSMykAOtSeykzuzGAS9vsECfUZjobm7tUwIs2mYv9cy2HTXl0gI5xQtK1V2HqwdAC0CWmgheS697dxYS3rpkJOu5jsG+xd8f6XjaGI0n0meWLd6WQX4yYqiNp7q8hWKr16DS8T8a/XYILMuFUJpwhsp24DPzqbAnIz+BsATZGKpIn0B0gN/6frEa4l0IIL+5NM89BGgtb+TasKjhq0MUwoK6jPiPziIwKWbgSt944ZGrpcQp2qqkAN+MdR86LdE6VRME/2CdCabMK66AE9QHg== 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=3q6V4tgPIyw7c/7R8KMq4uY3+XZ+wyYfe/wFopasDvk=; b=I5r497G1kiii7YT0Luw2TlSuSthZU9QU4GVvAFfCq+cnSeAjOD1UfI8e+NPYh1/4NJiaLlyp8mIMte+omPhOptjI6soHohW9NZyFarIwz0Y+BEZp5s2/y6N+uUVV4ERo7xQBrqSmaOmTxWwKeNfR2xGV52zbZOtipvuYl0khA1o1zJr5hLTXAaNSpWxdm+d5v8e7ceEcgWDo5ybbdPzBWdQ+ZtxpdFVc8f34p8NOfIoR+v50keJGUINmv6up4S/6U9Y1Ur5NsGLY107adZc1YmTxGBFoa/Dn5/KN7jd8z66r7UKSLtB5k4XGqKSvuR3ShhZ0NrVF/h4Y5V1ZFAAdKg== 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=3q6V4tgPIyw7c/7R8KMq4uY3+XZ+wyYfe/wFopasDvk=; b=N3E6y7B7OgU4xxEYV1DVOUXd/TdvYLwfqqjV84Pi8Ft/fENqGsgG5/cCnr3qn05MKjHMGLNIPXLW1q7VJQ4IfoXdFnSxjAXup8oovSuIvDScyYQXFG49v2Wb4kGvpjPc0Y8PIUsu5U+WCVC+l0VBdD2u7bbDVir9BFkD5pxHYHY= Received: from BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) by MN2PR10MB4351.namprd10.prod.outlook.com (2603:10b6:208:1d7::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.24; Thu, 2 Dec 2021 20:45:13 +0000 Received: from BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::693f:564:30a5:2b09]) by BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::693f:564:30a5:2b09%5]) with mapi id 15.20.4755.016; Thu, 2 Dec 2021 20:45:13 +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 v7 10/11] device-dax: remove pfn from __dev_dax_{pte,pmd,pud}_fault() Date: Thu, 2 Dec 2021 20:44:21 +0000 Message-Id: <20211202204422.26777-11-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211202204422.26777-1-joao.m.martins@oracle.com> References: <20211202204422.26777-1-joao.m.martins@oracle.com> X-ClientProxiedBy: AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) To BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) MIME-Version: 1.0 Received: from paddy.uk.oracle.com (138.3.204.24) by AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4755.16 via Frontend Transport; Thu, 2 Dec 2021 20:45:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d1e8a8b9-4e58-4221-aacf-08d9b5d4a36f X-MS-TrafficTypeDiagnostic: MN2PR10MB4351: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:813; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 66bRGzYoPEBq5N4uybUrlE6a4pKrGpVhetEQxGsqePD0+JKXyQxp+gHsLs+nCH+vSc0z7sIf2RconlF8ll+1Rrw+Ob+/87v2n8er7ozRDmj5LToDS3APY4RNIWrTGlPVWQ8Mpa6sRnVItOKEpJVpJlTmc9f9MV9OWoBhMQ/lfiwrB3TPSL81eZnZ3WFoY4u5/7mGCdBdSqiBjKkT5EsZAoiQESRGQNJ91iPslqPHfHRyHj1LjGMYMBsBwGsHPWZx8ZWfwAnYBHT1lbyJTAP0Jk1KyY8fniug0doAw0RknwgJlQCOobuYgVih6isZfiamlrq5o9iDDY3x7fWESNSEwnAedfpn2A+CYjferOR+SvOmRDnG1aXWJ8EutYz0bE/zW0nb+chZ3yITuzEbiPbAzNTfrUTthoTLSgtiNvdSWGw+lRoZtI3pRovVtv1SFcLnf38ClpVTVmk6VF1TS49tqtUsh7nwmzKmIEGWg2eH0wKxwky39K4SlGJKKipyMrsIjjL3VULNhrQXYjtPVkVeqTB1QgBgxLJbzKeguEzRWYMH2NwiVTuykG9WrakBuKE/0vCiIdiy+dxl0YBfeA18/f3ZIb+MMV4rsWQ1hTA9MESDkW6ENpIVa3Neuj8LbpHacqefcnsru6ra5DK9VCleR0x9Y7YfBWcchFkvoMXToI3d0GH7sNRiT8tEiipD4gg6nxBdbQrXXponW4OWdiNJMQ== 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)(66556008)(66476007)(66946007)(1076003)(7416002)(2616005)(6666004)(38350700002)(7696005)(186003)(8936002)(956004)(4326008)(38100700002)(26005)(83380400001)(52116002)(103116003)(54906003)(107886003)(6486002)(36756003)(86362001)(316002)(8676002)(508600001)(5660300002)(2906002)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mo/LCGQF07wCUN2rH+JQJ5LBGKpx+x3OZp3rcCOOFXsMxbzRnQUHZD89QpvWgStAgvWRGrexznKIw/YmWh+sogvzmluFjbXlhD3u/v90cNPCJZk7nzxdU6+Zqd9xsWZdhivVXjecNFLpVrlCEWp8Js1zWLO/DKzTD+gCo5D6jyl9OKm6qmu2pcYqZZ3VdosLp+rPp5HArVRQ99whXZe1NEyrfDip8s+tJhAmzQrV/u8Lo6Zf5hOfnv7O6QDd6gCsZfoaXPjIiPXLoVhiwo+i5ZiEoeSfLHAafGmSwYM5XKQ4PJk40JEKQN40cRuYvipgDOTIc8KgJF+NdUn9A/7JnZeJnmdd5kck40axagJCNrzbQx6pyqMKF6vyTfjEZB5/0uf9HNLUTvyWtVZ2Nk/A2GHSbYN2N3WrIV99NRg9YLWres+ZuCIp8Eq3Xh9wssEZto/EotPpGG9NVBF0tzRfAdY3avDiWfecH5vqyRyPZyHFAUyjKC9JAB7yWQw9LIX+TXfV8NPZpq58ZYDimevMbIfzFtFPTO4TfAUN3CnbDag5Jdg3gEjohvShPKQ3NazHP5nW1kK2sSwyO6HF90JWQOWkDIrzIoCRWHOe9jV61KTBH3/1+YQ7xf8B3EohCxOVw/FSD7p4ydyn2cQNBmzii7WiPmpT6prtusXlnno5DgQhU+iVRBD+EK5sPdnaFO3mVfLvyhheS+noqwYwBOT387am29stgQBuoIH14EPDH8PIfEjSztalHJaG3hU6dw49kUfkk40sGccKOGqY2nIU886hbsB5WJ4n0uDuoeHRK8uSordSrw9obo20TUkivxgSUCYM+7oABP528cXiEa+tmOUutpq2JSNLgUnMGr5b9z/1FdoeO4+WB3hpoCEGCjuWKXCDLU/rJr07p9WgX2hW2q8TVPQXOdmVfGD4MUM+odvQ76WkTmBALGT8b7O50yn2Y4vejMSxnCyGvjKAbNrhDm1FqDxNF/lIJJ4+L8Lbl0NxvWFlt2KxPchKAqEhwtTWxfBhMhN+sJoFq9PXWEB6fbC+jgjteFp/NIwi08WNTGKsQG7y1aVGRl26VdLC0axIDijrEXv4nRthqLRbBl5XKTz5kV5TecrRJEfPEt/2NNZx4dsdO4xvmsYxxzIHuBeOj7mk9EpwrmGoeezdw4lKgQnBQUXuybT2dvkX/grc8fbQf5ND0bfyd5qo3q57imWKeMxdrWjdsEsseHG6zMx4ZMfQT3YIyxCvcxiql7FjXegcacPi2kdqDhr3j31Fa4ArS7X2WTnpZTyME09RxWRTaPOIPqLumWujPDCWtggcf3yT2mT++RsN21m94LiUW2b/Z54VjMmSt1pj+5tS9pIU7mQjm7HOGjAuoyglshrREt9i+p4XFd5Q9epy8ASXC4F4nWIRZqcZa7btWy2un1ZzuqCnTb9Pi1wXLFKMgMK5HoIK0glu4iUs7to4uXRiJY8MosGaSdSz8wFdAhYCTLdQMApoNDD5vqY6RB0tRovgKqLg2cU8zg1wT4sztMh8MfwnrCEjEe2P6633tvMeRa6xwwhw0Mqa1C9a5jipV24eN05xj/m6jGvIZvL8FwvnHwM3Aejbrnq7IVLqINOCGeQoBu8RmvOUapyDE1pqnyXZ/fr2nKghwn3JQiLhV4uHXDGMUwKuTdcbq5C0YCIqyEhP/Q== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d1e8a8b9-4e58-4221-aacf-08d9b5d4a36f X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB4835.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2021 20:45:13.6208 (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: 83+6BzongsbTwAGY+p8Y7S4YjrkQ4iqxq9HF/+uPkRXTSI0tHBG6yWXugH1I2qsIZFO8GpvQXaM9G02Mx1ZG0fkcTVaXSlz9Qgn/jsqtn7U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR10MB4351 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10186 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112020131 X-Proofpoint-ORIG-GUID: 8h73Prh6ppfjbKDouM5bVDZVnqNkcAz9 X-Proofpoint-GUID: 8h73Prh6ppfjbKDouM5bVDZVnqNkcAz9 X-Stat-Signature: k44cumxy9h6sij3eoeekohrnqo9ucw9e Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=QDz7aHDC; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=N3E6y7B7; dmarc=pass (policy=none) header.from=oracle.com; spf=none (imf20.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-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 204CAD0000AF X-HE-Tag: 1638477920-742687 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: After moving the page mapping to be set prior to pte insertion, the pfn in dev_dax_huge_fault() no longer is necessary. Remove it, as well as the @pfn argument passed to the internal fault handler helpers. Suggested-by: Christoph Hellwig Signed-off-by: Joao Martins Reported-by: kernel test robot --- drivers/dax/device.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 19a6b86486ce..914368164e05 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -95,10 +95,11 @@ static void dax_set_mapping(struct vm_fault *vmf, pfn_t pfn, } static vm_fault_t __dev_dax_pte_fault(struct dev_dax *dev_dax, - struct vm_fault *vmf, pfn_t *pfn) + struct vm_fault *vmf) { struct device *dev = &dev_dax->dev; phys_addr_t phys; + pfn_t pfn; unsigned int fault_size = PAGE_SIZE; if (check_vma(dev_dax, vmf->vma, __func__)) @@ -119,20 +120,21 @@ static vm_fault_t __dev_dax_pte_fault(struct dev_dax *dev_dax, return VM_FAULT_SIGBUS; } - *pfn = phys_to_pfn_t(phys, PFN_DEV|PFN_MAP); + pfn = phys_to_pfn_t(phys, PFN_DEV|PFN_MAP); - dax_set_mapping(vmf, *pfn, fault_size); + dax_set_mapping(vmf, pfn, fault_size); - return vmf_insert_mixed(vmf->vma, vmf->address, *pfn); + return vmf_insert_mixed(vmf->vma, vmf->address, pfn); } static vm_fault_t __dev_dax_pmd_fault(struct dev_dax *dev_dax, - struct vm_fault *vmf, pfn_t *pfn) + struct vm_fault *vmf) { unsigned long pmd_addr = vmf->address & PMD_MASK; struct device *dev = &dev_dax->dev; phys_addr_t phys; pgoff_t pgoff; + pfn_t pfn; unsigned int fault_size = PMD_SIZE; if (check_vma(dev_dax, vmf->vma, __func__)) @@ -161,21 +163,22 @@ static vm_fault_t __dev_dax_pmd_fault(struct dev_dax *dev_dax, return VM_FAULT_SIGBUS; } - *pfn = phys_to_pfn_t(phys, PFN_DEV|PFN_MAP); + pfn = phys_to_pfn_t(phys, PFN_DEV|PFN_MAP); - dax_set_mapping(vmf, *pfn, fault_size); + dax_set_mapping(vmf, pfn, fault_size); - return vmf_insert_pfn_pmd(vmf, *pfn, vmf->flags & FAULT_FLAG_WRITE); + return vmf_insert_pfn_pmd(vmf, pfn, vmf->flags & FAULT_FLAG_WRITE); } #ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD static vm_fault_t __dev_dax_pud_fault(struct dev_dax *dev_dax, - struct vm_fault *vmf, pfn_t *pfn) + struct vm_fault *vmf) { unsigned long pud_addr = vmf->address & PUD_MASK; struct device *dev = &dev_dax->dev; phys_addr_t phys; pgoff_t pgoff; + pfn_t pfn; unsigned int fault_size = PUD_SIZE; @@ -205,11 +208,11 @@ static vm_fault_t __dev_dax_pud_fault(struct dev_dax *dev_dax, return VM_FAULT_SIGBUS; } - *pfn = phys_to_pfn_t(phys, PFN_DEV|PFN_MAP); + pfn = phys_to_pfn_t(phys, PFN_DEV|PFN_MAP); - dax_set_mapping(vmf, *pfn, fault_size); + dax_set_mapping(vmf, pfn, fault_size); - return vmf_insert_pfn_pud(vmf, *pfn, vmf->flags & FAULT_FLAG_WRITE); + return vmf_insert_pfn_pud(vmf, pfn, vmf->flags & FAULT_FLAG_WRITE); } #else static vm_fault_t __dev_dax_pud_fault(struct dev_dax *dev_dax, @@ -225,7 +228,6 @@ static vm_fault_t dev_dax_huge_fault(struct vm_fault *vmf, struct file *filp = vmf->vma->vm_file; vm_fault_t rc = VM_FAULT_SIGBUS; int id; - pfn_t pfn; struct dev_dax *dev_dax = filp->private_data; dev_dbg(&dev_dax->dev, "%s: %s (%#lx - %#lx) size = %d\n", current->comm, @@ -235,13 +237,13 @@ static vm_fault_t dev_dax_huge_fault(struct vm_fault *vmf, id = dax_read_lock(); switch (pe_size) { case PE_SIZE_PTE: - rc = __dev_dax_pte_fault(dev_dax, vmf, &pfn); + rc = __dev_dax_pte_fault(dev_dax, vmf); break; case PE_SIZE_PMD: - rc = __dev_dax_pmd_fault(dev_dax, vmf, &pfn); + rc = __dev_dax_pmd_fault(dev_dax, vmf); break; case PE_SIZE_PUD: - rc = __dev_dax_pud_fault(dev_dax, vmf, &pfn); + rc = __dev_dax_pud_fault(dev_dax, vmf); break; default: rc = VM_FAULT_SIGBUS; From patchwork Thu Dec 2 20:44:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 12653455 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 A461FC433EF for ; Thu, 2 Dec 2021 20:51:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D5CC6B0085; Thu, 2 Dec 2021 15:45:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 285A86B0087; Thu, 2 Dec 2021 15:45:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B3BB6B0088; Thu, 2 Dec 2021 15:45:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0187.hostedemail.com [216.40.44.187]) by kanga.kvack.org (Postfix) with ESMTP id F05416B0085 for ; Thu, 2 Dec 2021 15:45:45 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id B897D1838F857 for ; Thu, 2 Dec 2021 20:45:35 +0000 (UTC) X-FDA: 78874035030.06.66CDBC8 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf21.hostedemail.com (Postfix) with ESMTP id E17A8D0369C8 for ; Thu, 2 Dec 2021 20:45:34 +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 1B2KP5ZN019804; Thu, 2 Dec 2021 20:45: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=ulJEg/Kgpzv/I7StoVL/4+pHE3ZMH5euZvNJ/aod2+A=; b=CrAH1JXhf/ZDQCelbuOqIAriLbxJsowyBOv6fxOQYfSYmIv4I8qBXcl+T3OsXLC6S9E8 hC+S25dZbrGz21Lu+r49yVK/Zy6BSIVXt65tl3HFdxq6dHAx8IoWSsKxbnFLNOCuu4Kk ie1tpdeBcQGluauywpd6gdV3Jao1YDI/ut1OWW9aGVGiKZ1a2FrAwDU8SQI8jvusuQbC sXy3OUljti06NHzt1QZiYjZB0EYnavgmNCH7YKTnmtxpV/F51L5xaJNG/EN+JYCM4NvM D8T1xGb3fQhEJQdw1a8+yiqm/xUU73/m7/upaNkNinAsRD+oIGw2Y3VpdWvSaAz++y7+ Zw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3cp7weud9a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Dec 2021 20:45:29 +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 1B2KesvB121355; Thu, 2 Dec 2021 20:45:19 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by userp3030.oracle.com with ESMTP id 3ck9t4v5jc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Dec 2021 20:45:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GWohP7aKEexWutgh8qfcsEp3ZjYidKZvqOnmDqmILwDKLS7nB7Lsbc3ktaPAfc7ktgSTNXX55WHpz7FFLlhIVbpQ6jK3Xtmpk81PSVKLO2HSXpT2X0TiRUSgWI64HUR6uv35vsAJdh8jjPK2px3CMnZ7pKz0hCdGQpDd/N9aGbf5HZECrWAYBz74+B+2cl+DS3yXLa6cVr03HIHcyj5In914PFP8IlfGz3ky9xruWh98boo53Gs7EUWid1B7tEfi0MTwVRFU+2iPXrr4DH8nBsZe20THO0yLaHcpXaFvznp0wZsfJEr3vYIPirXY0MzUr8pg6FLE6pdPBIkOPrMSIw== 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=ulJEg/Kgpzv/I7StoVL/4+pHE3ZMH5euZvNJ/aod2+A=; b=U7umRJ8Yg7qo6y4ONO+XttU+YjcNDwOE3TxGq/B2xvnnIGjvac2aEz6g5ap5K41L0fOzFsEcVOpe7/tMKkLEv5ffA4yaL1jnUcjPwKbUH3ndW/nUz8ZmJkTkFuJ2Nmzyb2GLOzp7VCuaWEh2rORf9JTWF2tysIYtuFXleDhLmTv3GPCjFrJ8usPAiVK7M6yWGDwj+8rHISz5XJkFG4azomGux2Z2+2VwZ+kNU3hp9MOJ2sWdF/3At1x8NNnhmGvi7SAv2ddS8CbkSTrfmoXYNLLeRFkD46IiqRtalHdp382h1jhJ7tK0Z3//8GMfoqBWLqiTLHngSUrEtghFZddtrA== 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=ulJEg/Kgpzv/I7StoVL/4+pHE3ZMH5euZvNJ/aod2+A=; b=bLhbf6yXn17ps9Hg4lEppqWGMH9imPeB3L5eezrIeJISXXc8PSSmvgKe0219CjfswSFLPRKPtTc6KCMeMlTgCcSvGmDmSfhn0IFLRvdBjlHZ75TGQbnukIcosrzuamwI6YDiTHVsMUzU6Mh4pdOXbuc28k+1R6fuyS0L6NOd+0o= Received: from BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) by BLAPR10MB5186.namprd10.prod.outlook.com (2603:10b6:208:321::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11; Thu, 2 Dec 2021 20:45:17 +0000 Received: from BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::693f:564:30a5:2b09]) by BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::693f:564:30a5:2b09%5]) with mapi id 15.20.4755.016; Thu, 2 Dec 2021 20:45:17 +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 v7 11/11] device-dax: compound devmap support Date: Thu, 2 Dec 2021 20:44:22 +0000 Message-Id: <20211202204422.26777-12-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211202204422.26777-1-joao.m.martins@oracle.com> References: <20211202204422.26777-1-joao.m.martins@oracle.com> X-ClientProxiedBy: AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) To BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) MIME-Version: 1.0 Received: from paddy.uk.oracle.com (138.3.204.24) by AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4755.16 via Frontend Transport; Thu, 2 Dec 2021 20:45:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 066451ab-5df8-43b0-06f3-08d9b5d4a5a6 X-MS-TrafficTypeDiagnostic: BLAPR10MB5186: 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: UHO65K3fsCc9KRaXjLQbyq1RF0sxDc3Gj6ZTYsDUiyQioVceefVWDHu79e/bImE85VrDMtd9EOWhMJermcqQYahfFTzAMfhYgi4PqpA8fgz3EARfttJXHVzgqKvvrpOpHffWPru/Nf7+Bdwyvm8zaaTxuxQOKxwHLrikVF3YcB7clUhGaTDvdbc4yiOcSmIOhN2I3wi0vCf73/3r+T6xYth+DVpai+904ej6g5PF0lUbYPxrAzPRD5WcU5WrBma3pIUrvqlOJfa0BWkeYO3qDFpJgBM1Ll/OgrGVIKJD9+X2oawlkip6TTdAKUdpnuzNEsOSXIfOKBCtyVnanWjnrNCedikWyCJlQO5dm3y0+NKQjmulnoxge0FhPh76hl8JHgGu2OhO4iy+d4hrwuHx5RSBZtcY1Ya3mPKzC0vM+5nsPvWozOTyFU8hZV1XFsTOJgwQadyJYS7E4L87G1hGGmeG6H2VXTPIDPYv6slTs7xbG1filJ9SFQNFYRv6dIXVbtwYtH3IM2eDGMpj96IwQJSugwSx6LUdzKQXIbLN+sgSyzjh2fSNgiYQcIJfSwapBVu2wbWL0BEcmvkxewhFrHWaySPA56vETilJB7w2cUTI9H05VJuIzidUaCNDXFor523f/P0N2Y/WBPgQ5K+5b3LEQeRZifx3p+NJKwutZ6BkvhwEDybbsz9BNKdj1SuLGyU9Y5Y339IlcjB4boNefD0CmN8QDiiBJHLxCiQfFc+hlaGO5hDOSbrz206bP+frcHTDj+mOL9RiJ4CG8NMBAFHmpPGxCGm49wHMj9ry7Ng= 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)(2906002)(52116002)(7696005)(186003)(66556008)(36756003)(8936002)(26005)(6666004)(1076003)(8676002)(83380400001)(6486002)(107886003)(86362001)(2616005)(38350700002)(5660300002)(966005)(6916009)(38100700002)(103116003)(4326008)(7416002)(508600001)(54906003)(66476007)(956004)(66946007)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 960MwqIPE3LnP33F2GFwxUdTqkzamQvefCDx7S9Tn44MNnBulx5xkb6QZWQAzuLXV/kal9LbfkYErh/grHIzvxYEpJniqwKo23F8k0/SjVF7yNXx6+o/kusO8mQKfOEGCqHUWjCDddDSAYnMtdxgku5FEY2fWsaPrJy8iBZKFkilnZvr1g7SXq0XyfmOjE0X1DACT7QXfDiWrmZkYTDdF4HamQsELw7QaRtq4z6xfUABBC/d6RTYpfdwmlg39hloB8Rj+63T55NcCG21bnRtQsdvhoGWs2gZEzjPUlgjbALhuupXO4Ul9X0CQ2d/oSjyOvLxXPalnZIaaVgjHDDyvlkChJxPwfLc9Lr/8F3p35aD83eMOwB4l3empXJ680KYohagJi3wTNkhen0O3XVsikil24FBjzsy3dIB3SYDWo/LKcyXbQqUZtyqc/GZSlrfypd7hnJmdjRzchByu+NTqFMyi5I3HchgflbntcklnYAUlO3UFl11aQOSxoDnjAEqYZRLaYegw4jhhD5thOMQFLT1jhI8wr9vkW/SlfWs8QIR68hDqc4OtrnyCZ7daidmdTgU5orhDqHq4RMERSy6T/cvgYfM3zGFJDw57X3aaCKu/tCECsZb8gHxpZLya9Y6TquHyCswCPlJZIYNHscLza165S+7FzZd6JWMtIN/WUdU6uHtf/jD5+St+i1QBCcnELmEoMEQLaf7lCz8kc/mS29gMR0CKTQOkUi1Zob8DtsEygagxxHGHDaARKwjMVz6E1q8Dlkl5O0qGSP530spZMNSmNuEaFnpewmGaqQI2ltbx/WoV4kmLYNVFMjx9Z92dNE99dNg5uNPG6UmDjAcqo+QTjHHNI+Y+KQ7iElhySrNx6hYFVI+hfGhiu/WPwKYeJMzfPuS/oC9VdTo0eNiMgeYLIt9NoNhDT7Got+v4+cMn53mzzOCUoSDYqybch23VmATBlj+75r1JZ7wSFippY2PKnYPsPx+xQwtFPnYXMsDfrAWWszk6fd6DX5wswrY/IPhT1N+Co/jBNk2SalZVjidAz+Ur6pXhOZwWbdaf6ZFnwR9IwYXt0Q74BvZSfHFNuPxsmGoCssj7FJkww6eOfOoqNR51gZD36g+OK/nVaAvx/HDDH6Ad6fvkctLlnp1lpGwkYwm9ZxwfKgZlnARmRuD4/QpldbIwVC/jE0wT6XyPs59Clc6QLdionwQaQInmlNvdHyL6oTCJ+2lIpJ5WNMq7nezn5ZS2R+tfyyNWepyp3fuXHzHmsjoVjIeA927c2igaWWkBMa0fKorbrQXvNbl3jN1sEPGEEtmLjQ68+elgokGNyyK7+WgsteiDomnFULFWRqi3sstlXmEp2JQJW3R709Q3rSZRgky82Lg7q4faRWW3Y4xmr77+huYpQinyaCYiKy+D/FGhzMgqYP3whBmYDxwr0NBIN3vKK19CaKwglpS43OWtpZFyOgan9uYoYhER3L1ZTAST+mpxA8Qe5acpTVe86i1RJTRWoDvn+hlvRfGrH3OzwjQ3ePlXgNN1Bi0m/koQQ8W7hp+o622h2FHcT6YcdnY1zZRnIevQ71dMirSdsDZMCz7Fxa/U8yjwklZwci2ETXfvdxMsE+tddUyU0M+hRmWu4KXXv865fL1Ezyqdmw0JveKL37gsxUK3GpEtrEka9r1WyVHq9CN6A== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 066451ab-5df8-43b0-06f3-08d9b5d4a5a6 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB4835.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2021 20:45:16.9732 (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: 1VSc3A7Ah8TIURDfu8b/T7monYmaheVErHBJJfTev5bgXG/NIlfhIMfAvFO4VOn1QvxUmpKyJYEBUPUb2+qRX9jZkhrGm7Kt99ASC3jFPTw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5186 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10186 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112020130 X-Proofpoint-ORIG-GUID: -Kzt_InKDDa1VFU6LtEImSOEriiSRSLr X-Proofpoint-GUID: -Kzt_InKDDa1VFU6LtEImSOEriiSRSLr X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: E17A8D0369C8 X-Stat-Signature: tim4awwx7g5xaia5kg53fd8pjp7bxn1r Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=CrAH1JXh; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=bLhbf6yX; dmarc=pass (policy=none) header.from=oracle.com; spf=none (imf21.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: 1638477934-109768 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 914368164e05..6ef8f374e27b 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; @@ -443,6 +449,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);