From patchwork Wed Aug 24 17:57:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 12953869 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 F1515C32796 for ; Wed, 24 Aug 2022 17:58:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D66296B0075; Wed, 24 Aug 2022 13:58:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CEFC5940009; Wed, 24 Aug 2022 13:58:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF3946B0078; Wed, 24 Aug 2022 13:58:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 98A20940009 for ; Wed, 24 Aug 2022 13:58:30 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 60AD080287 for ; Wed, 24 Aug 2022 17:58:30 +0000 (UTC) X-FDA: 79835245980.12.3BB3D50 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf27.hostedemail.com (Postfix) with ESMTP id CF85D40057 for ; Wed, 24 Aug 2022 17:58:29 +0000 (UTC) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27OHkK8W019890; Wed, 24 Aug 2022 17:58:21 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-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=Glb9IFLJyvvc/v2Fwk4BwqIMnxr1gMo/DaP60kaegfQ=; b=bmVaLAVsW/TsvUOm3KdbOpYIT0F/gYzMrOruoLDqg/oiw4sKgJULugoDzltDwJ9et3qV U3C7iuNjBP0qPOOGboRqBHG7Ve1x7WtyEeXLGc5jw46W3Qqi0KmdN0iRuzcxcqTTu2fP iEO2zDfRCuTyt/8lDz33nsBod/wwHmHaDXTu83bISJFTp9feuSbRwHGANqqOBaLgyEVi 8dozkY51wqX1gwtgwRwKRe+M6RQ4vYi7OfPV9IpHaMecRlBFcwwrn1tDU7j/u0L6zvzK UAFPd3y1lqXV72CBvC5806EzYhRWlWkpNUz+YAVd6b/XAkdea6JFZR7xmwwP1zD7yzEk Ug== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3j4w23vbvb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Aug 2022 17:58:21 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 27OHCw6v021777; Wed, 24 Aug 2022 17:58:20 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1anam02lp2041.outbound.protection.outlook.com [104.47.57.41]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3j5n5nbgf4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Aug 2022 17:58:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MxXRYhDCvuU4quXzMs2VY1fFAOE+Cxu0Eu2mBH8ZNbOaURpA3LvaBTK/3glckdrZ7mUYjpuHNsmkOTctRFBVssnlnA3326uE7AM1CnTLz5Y5OcDpDGpbNId1y0n25VsbScRFhrRREpHZdIaJSkpZbgI3pZCHrQ+3btjsqA7s54Oh3UwkumW6MkyB+RQiQnjrq6+krzG6Utebo+Wrrw/ZxNxRCbrTmAZwWwYhNQcNnHUAJYcuoJQgIy9goaRZoYZV1F3aOjmhCb3a+bZEeM/oEnyqebpD5GZzFNbcX087qqzF33pAs7FygKkqp4tqeUqCvRfVtKtWZWkcPhaV156c6w== 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=Glb9IFLJyvvc/v2Fwk4BwqIMnxr1gMo/DaP60kaegfQ=; b=YR5M4iS9/qU15OF1gw0NkNfMDhqejH87L7ZpqL/sNcdOkdmFsVRop2oHZO6RwiCG9bS7V282fCQHGBSVWb9joazcC4PsjtoE6qrKatssMsG4R5XOcYMklEohqvskrf+7LGak/CDJVNFPltWIiuXjZeplVz+EJ1xtS2nDeuVMfvF0f/xdt4uNe3fQXo5pojhLfQv3ULIAtRWo54aigpRwNf2cY1omJzbtiiTyjY39ROTLxBS0XUS6i6IWVUA9Nq7rLDqbU+BneQGaXap2eX2t099sYr2QYHVjjO0KJ2n/QEACidO1Bk7d5exE+5cKgZSebNzEpq5CTNhQHMu2iWBh8A== 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=Glb9IFLJyvvc/v2Fwk4BwqIMnxr1gMo/DaP60kaegfQ=; b=UKMRsviVb/VUlxhzeHESG7aqCQ2ec7SOoZj1zP9Ua/U3EGyPYkN14nxR8UgkMxgeFU++L4w2cyFlkx+PtMgk94H07GX6E4mifuzQ8MAWCGkY4ls6W3mY+b9W+efIJ1pfvgbpPsklvC+2yqf0i4KCovsJqY5tNL9BVh8A8yMo1i4= Received: from DM6PR10MB4201.namprd10.prod.outlook.com (2603:10b6:5:216::10) by PH0PR10MB4520.namprd10.prod.outlook.com (2603:10b6:510:43::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.19; Wed, 24 Aug 2022 17:58:18 +0000 Received: from DM6PR10MB4201.namprd10.prod.outlook.com ([fe80::11b6:7a8a:1432:bec]) by DM6PR10MB4201.namprd10.prod.outlook.com ([fe80::11b6:7a8a:1432:bec%6]) with mapi id 15.20.5546.022; Wed, 24 Aug 2022 17:58:18 +0000 From: Mike Kravetz To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Muchun Song , Miaohe Lin , David Hildenbrand , Michal Hocko , Peter Xu , Naoya Horiguchi , "Aneesh Kumar K . V" , Andrea Arcangeli , "Kirill A . Shutemov" , Davidlohr Bueso , Prakash Sangappa , James Houghton , Mina Almasry , Pasha Tatashin , Axel Rasmussen , Ray Fucillo , Andrew Morton , Mike Kravetz Subject: [PATCH 5/8] hugetlb: rename vma_shareable() and refactor code Date: Wed, 24 Aug 2022 10:57:54 -0700 Message-Id: <20220824175757.20590-6-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220824175757.20590-1-mike.kravetz@oracle.com> References: <20220824175757.20590-1-mike.kravetz@oracle.com> X-ClientProxiedBy: MW2PR16CA0063.namprd16.prod.outlook.com (2603:10b6:907:1::40) To DM6PR10MB4201.namprd10.prod.outlook.com (2603:10b6:5:216::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f22e230a-f671-41ab-5e8d-08da85fa39cf X-MS-TrafficTypeDiagnostic: PH0PR10MB4520:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 40g0J68DKbepl0hxQDrS3oxXeVge9wCg0+e25UkkgR+ylGkW1zljHV5Bzk1mZp5brUbzMaln7EGCn7geF3dwNJ2gllBSAR/ouW9Hgo3e1jcibP0qPo1M+nBDbv0hWCrxmb09HZb8LFAhd6wNGioo9QHfzhNRH3LvCsso3tepYK2+siDGEZ8QwvXJx6vun0PX0hqDhRJy3W/9yce6KU8mxFU1Wsa/s39T1u4ZfTdzd5KQryOsnjI73Oxh28ZP4OelTSdLJ1cJtw6zE9ZBz/WC6CPRcCh0qaZqF7M6OAnLB2YTj0B/kt9Ldf/GYdZaTBJZMGgYsqYCt9eUB4uj97LqbAJyZe+bA/Er/lF8CgxqUf9eTPv5R3BrMBsAgF+enNcLIqDQEjK4yB/ppWEFmTnkZNTuAaT6YWJV0yuh/Fxe12yqfILKx4o0L6OHR2Tb/l2hCyREsnY2JEF7p4u81lOkkl6dLxDlkVhttppKGZH7jMgb9vLP8E2qFh3UfvgDFTNyM3/CaFiJVP4ferlDAjacdo/0BkdS6uKFTxAle5N+/SBZnZnbFO8Uy7eAFFo5Hy8sXcq2Mdtq8Ga4wgN5y4DriHqRx0W8U+AE3kbCr6pRlfhpvIa0XCbMynkUsJ5AbwK8Eh5gKUK4QCmr/q4JupLpu6yR3gfKCONUTBlt2cF7oj4OBwg7JMGf/zUqhsPhCb8vGSfbit6xA6Ma+ucs94B1TA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4201.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(39860400002)(396003)(136003)(376002)(346002)(366004)(7416002)(1076003)(6512007)(6666004)(8936002)(26005)(186003)(107886003)(2616005)(6506007)(44832011)(86362001)(36756003)(41300700001)(316002)(5660300002)(54906003)(478600001)(66556008)(8676002)(4326008)(6486002)(83380400001)(38100700002)(66946007)(2906002)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sJiBa6wsm6KJ5zBz66XkDs1Rve96iA3fq1XW9wm15QKkUhOt0TTzi6oyvVaWqRQzZNrv4e4E1BQGOYLEUwhrgHcYdXD/2a9KugqLRylFTZ7dulHRDoBjKMkdjR/S8qos5wfrvNhoSJlceLxOYgqBQGKsNWtJHwwf7AihrsxKUq7yHTVLZ6/sm3TCi60YXV3oywlRa6KTmW/qr3frA3tMOmt0QRoEtXPutCgadAYF7b28S2TuqepNAFcwDp+3bhiCxoEH/jdC3hY2CMe7k1wxPlG7D15XoGd7ZpM/OMAd4dTrhSkqzevEwtXRb7K9/ckQa5sDN5chyCmMq3q9/ayRAUxx+cdyY3MfIzzHlPpCDJHQ6l6vJfYre/HsWmhAulO13gKG7hcxkt8OKl+dTdxjx5+mgOm9Pj555AtzhOZfrNnxejZhiWgRI3QDArT2T7PcnBNjnbaeewla+VYezxvAHRb7z798iSIIHxWH8Xgbh5qYKuIh/xGSbJRYmQw6A2V3Ywmq2BKiD76ikzgCOy2dJPNSPbh9KwNCSaBPNBErB0Mfe9y492/6SlY6+/fkEPl/7pm4pDI+75rT5UqKve9IIfFBPGXOXivf6GnY0sR4ioHQCzgogjupBJN1Ud0H3Gzigd9+DJFB8u+JemB8RMssnYz5jmIYRCiZas+uSa6spkNNUUwbdA4YQ2Mg26Spv3MUm2nouuLehEohzgJdEhA8J/JBeZF7ZoWgid0kKx6Dgn4qOHpiK4L9aTzqeoFyb9YWjDmgPQY4Zrbdrf/G/SzrD2FDWB6fvZb1jQpMY6VLpjSZKv1UZtxbDk72kwEvtTf1Ozg02EiIfIxPQk1GggyJKmI5f90Nmw66w1nOUBE3FFMBs0KDuULxoF7+QVE4cIc0Yfap44Of5fAV3IS3pT3yCsuWlREW6on0rnnUL5Ji+/tjiQ8vCKqT8xJ/22/22OgAR1XuxFKljiJ1qSyrYsiNZgsOlnpwnGQrdE3/gXKqx61V8eqjdGUsJDq/fd4JBKRKQxYbY4LD+RmBtNMzWzUZx1WweXh+6+TF9EBdY9EJD3YSgputO3lzZDEUXNs/A4d8Ro7mO9lAaO8GurfSRvjMZhOW467K4Baeh3UTc1p0mr60BaCHo7pf9M4vE3Z9XQwTAYnbDgKrfmtPQXl5xELLzO3WxK7Q/uqeLRGo9RFYXV8CclVw1mgb76okHOuJuIvzebFrzGTZCIk68ikAlbfVKlG7T3yl8mfs3ETLHvtkIL/Zmz+Q5CauzT1iXX/NhB7gQwDrumBP/uMnXHFSUM3cndjrXhPLio205Hxwv5aC8p+rVveBDzhHGg+m8q4Xclrco22gmVx4ya4B32Z2kWFHBWHkpIT0yCJOv0c7IAA4lttd4vsd1QKZwTDKgt0ptf1hLFRrmNTLgn10uukSx2TiVogUGim2GqkhD+Y5Vww8qDZlsB+gd2tSL82x9ZG6OFE38gycWQzAR8SVzY2OxuowdkY9IJ15M3jBq5cNFCmiKpKNxAqV7P+fVSLRIQLpdwnyf/9wfYlcuaAazCUu3crlRCVzgzFHRy2BM14X9G0jliHFG9UB10pkyMvZL5Ol7khyGgMmvq7Y5ILHbXwqJsviAw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f22e230a-f671-41ab-5e8d-08da85fa39cf X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4201.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2022 17:58:18.5337 (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: tB2OYvFd2x1ZpbFcBLkqPUBVSGgcjG6EjQwuXpXeMFJPYqM2mFpvsw1LTGLC+nUJHsHoJDUEfpH5BCLzxuY4mA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4520 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-24_11,2022-08-22_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 phishscore=0 adultscore=0 mlxscore=0 bulkscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208240066 X-Proofpoint-ORIG-GUID: qzDGbdXMLe7l5D7Nxr2hAGVfcXHJslbp X-Proofpoint-GUID: qzDGbdXMLe7l5D7Nxr2hAGVfcXHJslbp ARC-Authentication-Results: i=2; imf27.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=bmVaLAVs; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=UKMRsviV; spf=pass (imf27.hostedemail.com: domain of mike.kravetz@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1661363909; a=rsa-sha256; cv=pass; b=sq+WLb5x7QqSgJ3w8BMiG6vfTvmpUyI5j+BnqHjgnu+aKpD2kYa+/Z3W2rKUKLF11WZqZy 63q6LzcyBt9j7qT1l5d7WUDeKEJqFeGXRNNpXoTKD9Q0cnETQeZbbbwVwk2HNKfCi3Uwsw gZvADkie236KvngiItGcimVKd0IOaMA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661363909; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Glb9IFLJyvvc/v2Fwk4BwqIMnxr1gMo/DaP60kaegfQ=; b=N/v8Zl69KvthM5ViMxhkDGMX45FrGaZbE0Jvl4hU8mjDjf2kTqP08qw+N4ulQfMMWrpWmD NZtE7qdTM5ACdcBuhGWgZ/HEPfdpntzmYcPJXtArlM49wOxN0nKcV3b2/SY3p7BYO5FYPL 7R1xbRe/0K4L+foShbqVeytDedc4Vqo= Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=bmVaLAVs; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=UKMRsviV; spf=pass (imf27.hostedemail.com: domain of mike.kravetz@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: CF85D40057 X-Stat-Signature: yh1b7gedfue6rxgme46xsfq4rmqjmp7k X-HE-Tag: 1661363909-119438 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: Rename the routine vma_shareable to vma_addr_pmd_shareable as it is checking a specific address within the vma. Refactor code to check if an aligned range is shareable as this will be needed in a subsequent patch. Signed-off-by: Mike Kravetz Reviewed-by: Miaohe Lin --- mm/hugetlb.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index a6eb46c64baf..758b6844d566 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -6648,26 +6648,33 @@ static unsigned long page_table_shareable(struct vm_area_struct *svma, return saddr; } -static bool vma_shareable(struct vm_area_struct *vma, unsigned long addr) +static bool __vma_aligned_range_pmd_shareable(struct vm_area_struct *vma, + unsigned long start, unsigned long end) { - unsigned long base = addr & PUD_MASK; - unsigned long end = base + PUD_SIZE; - /* * check on proper vm_flags and page table alignment */ - if (vma->vm_flags & VM_MAYSHARE && range_in_vma(vma, base, end)) + if (vma->vm_flags & VM_MAYSHARE && range_in_vma(vma, start, end)) return true; return false; } +static bool vma_addr_pmd_shareable(struct vm_area_struct *vma, + unsigned long addr) +{ + unsigned long start = addr & PUD_MASK; + unsigned long end = start + PUD_SIZE; + + return __vma_aligned_range_pmd_shareable(vma, start, end); +} + bool want_pmd_share(struct vm_area_struct *vma, unsigned long addr) { #ifdef CONFIG_USERFAULTFD if (uffd_disable_huge_pmd_share(vma)) return false; #endif - return vma_shareable(vma, addr); + return vma_addr_pmd_shareable(vma, addr); } /*