From patchwork Fri Apr 21 13:55:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13220082 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 DF11CC7618E for ; Fri, 21 Apr 2023 13:56:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 729446B0078; Fri, 21 Apr 2023 09:56:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B08B6B007B; Fri, 21 Apr 2023 09:56:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48DE66B007D; Fri, 21 Apr 2023 09:56:53 -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 2D3296B0078 for ; Fri, 21 Apr 2023 09:56:53 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 1386BA0402 for ; Fri, 21 Apr 2023 13:56:52 +0000 (UTC) X-FDA: 80705549064.17.7B534E5 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf09.hostedemail.com (Postfix) with ESMTP id BB3BA140003 for ; Fri, 21 Apr 2023 13:56:48 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=gNR78VCF; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=uGsxpXly; dmarc=pass (policy=none) header.from=oracle.com; spf=pass (imf09.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682085408; 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=4dop6dLB8MYyf4g70fGvheMGvbOaLIxIGFq/jpCiG4o=; b=rITaXURgbF8eYPHHXMgHwHLu0FctdkJUcfI3t6PWaBDvolDrBnpSXI5mW0FJUOD1SMC1lX yyYjP1F5xXChHIeRVxlPs8pOn/CZ94W7kNEJX5VYov2wlfdoGEu2MR9BpjodEjhDpnNYg4 MPWei3IAmzJxSMweTqUUXqLTWJQ+FqE= ARC-Authentication-Results: i=2; imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=gNR78VCF; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=uGsxpXly; dmarc=pass (policy=none) header.from=oracle.com; spf=pass (imf09.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1682085408; a=rsa-sha256; cv=pass; b=5aHll8EmW+QKMAV4Tcn1HvEQSz8EE2N2ZrvdEIhSPFMO5Rh2a+heDIK5kEB2ICe1D5fJED AVUKE9goicZ4/4PMHA0mSPtNrc9+TQD16Oi6FOlpyBuBuD9QEx8hWb7W76M36CkYJ11qMK 3hUjH1KLyLdSnwXr5/MEhJbXmrHrP/k= Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33LCYa7w020032; Fri, 21 Apr 2023 13:56:32 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-2023-03-30; bh=4dop6dLB8MYyf4g70fGvheMGvbOaLIxIGFq/jpCiG4o=; b=gNR78VCFUDTX0OeN69aV7mcYIYoQaRbwqP88Vz/EJr3t0qY1EmhE5uFiXm81YCHd7SKA hzVgkSXa4V3MRZcBz67ITiYic1z5GjhrQLkZ8jBdWe4CMsRA49noOtCSvJ5g9DNqOy5N bEwDhyvPEUe4VZYzy2PKaT8OIJlWdtdLUywWawXSpRJ3fLdbOzCrJxQMcRhUOzccG6a5 q7i50neae2P4TAs3qb37YpWdPRlESRZxkVceFv1hyGLX8oJvTbF8nwy4+TOFzzdCZrjg x29Djglga+LdZzSYlIbIFZLmVMuObNquo7NkfL4Y6ld3hUDyO3evIaKd2MoBIA7OaCV6 Zg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3q07694b6n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Apr 2023 13:56:32 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 33LD1gQR011183; Fri, 21 Apr 2023 13:56:31 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2105.outbound.protection.outlook.com [104.47.58.105]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3pyjc95yyv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Apr 2023 13:56:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fHIQYEKdDQnxPTYruqI1J/WOUwJZhG6iKvD91W3Cblwvpkxi04UTQKFxtaJ2mKL9fd1hTNzdRfHYovl4lbfCkYGr8oBinrwqyPeraFv3qWCFOTLiYPqwcpPacl8E1mEb7rMu/SPX/n3ge0lMUw2/FHPaEwS3crw22IB2zHsNMxJq78M1eCR56SBlPZ/tTbfXLRmixYUhxlgHGOjyQK8dzeWRDCjEmjCE9L1RhAZDPPaECZHOZ8wC1mE1tVPvM6veA+/Lf7+w8x+qju2spK77Cs+z56Ba4HWj+aGcdRVBUE+BTJJaFEgLFk1nE1P9UyqIRdgGK6QmiDOuINNNeDNWlA== 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=4dop6dLB8MYyf4g70fGvheMGvbOaLIxIGFq/jpCiG4o=; b=EII0hIeePQQnbPWXwf9MZbE0eHMc12nBfffAtTJH/2edsUZ0Ijxsvn97b27bJWJ8JlDdzbe4yqC2uEq2mSU4y7xxWriYpMMv/xGEnY0vRI4ObYksluUNDpUBg02JhJ/CX/leURY1SwzPhe25QUbSmXvmqThfk88Mesy9VCsFfAyisAgYGZIZg/lVMNAGJ9h7cnh8M//mQ4f8x/ytmNDlqOxn1p374CwVxrKgdEu6jMelgrcB4D6egjY0P8vGabVxIu3lrRiRXaX64UAjNZXGkUhIzlVByajXL2s4wj76+4p83zvy+pV9zI8nXumKvX7IyX7bUZFtGzGn4aS95sobfA== 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=4dop6dLB8MYyf4g70fGvheMGvbOaLIxIGFq/jpCiG4o=; b=uGsxpXlyYASWhEySlxJPe276DbWwNG9OB684MPohBRtUPk4zrzjr2oXMSMpFftn+WIY/2jm73edY8B38581D0nIhWWhhbYxZWzIQi9sbIRTr5gCzNEv+d8O3sI4xn84E/sHXNekUXxb+U4+xfnqGjVURBocjbogbPo/eviRGXss= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by IA1PR10MB7540.namprd10.prod.outlook.com (2603:10b6:208:445::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.22; Fri, 21 Apr 2023 13:56:29 +0000 Received: from SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::8bb9:2bb7:3930:b5da]) by SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::8bb9:2bb7:3930:b5da%7]) with mapi id 15.20.6319.022; Fri, 21 Apr 2023 13:56:29 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, maple-tree@lists.infradead.org, Rick Edgecombe , Peng Zhang , "Liam R. Howlett" Subject: [PATCH v3 4/4] mm/mmap: Regression fix for unmapped_area{_topdown} Date: Fri, 21 Apr 2023 09:55:59 -0400 Message-Id: <20230421135559.2163923-5-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230421135559.2163923-1-Liam.Howlett@oracle.com> References: <20230421135559.2163923-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0027.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:fe::6) To SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR10MB3022:EE_|IA1PR10MB7540:EE_ X-MS-Office365-Filtering-Correlation-Id: 8d41b251-c89b-4664-8e3f-08db427034bb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SbelP2/xAScKNfyCJL/cTEHLD/j6FeLCPHZ1Vt5NOwnK6vgR8JK5DDXpjmj2yxrDm3tGMG2OQpvairm7ksUihCs/fyFYYz17iimbPEhdU9V80qrNXUkG46D/+jCdMFRJgYTnXShtv5y8gZ0ad/Uf/rK9oWMTf5JlHaYJqkKzg3H1eH0zOFYVcMvXoPAVnjWF/hNYHm3I/gepmL2MKSVBr7x45ltZ5rg1Fp5ix4uPDdqRTt/Ug4EkGqP1UOm1t3xisSyFEM3zgj2IJA5XRGI7aGjxMm+hSmPuJXP+aqem9AU41XYL3eQkoSDXmbY2qe/LLL4UxmuzLf804I7F5bzQ9kdHnt0ubOWGkraPPrFqksnwnIfsbWhfbTfeYYJ9m+uDJap/Nhg2R9aF0QAFQsLAj0rzhyzkfWrKI1FYjEHO+By+vStLFKq3W2xFJViuKf9kGj9vLz0ZGryYy5g7FZt4Mc0GT7UhfkoB2PhgsAoUphhGvrZQRM6PSYEJKOv+iop7NuaDGyY8ZZMOycdKVavlNhVoup5v6lkgEOtzId/J2APJZI6NLjYKJNdzvzRzIzfT X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR10MB3022.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(366004)(39860400002)(376002)(346002)(136003)(451199021)(8676002)(8936002)(38100700002)(6916009)(4326008)(66556008)(66946007)(66476007)(41300700001)(316002)(2906002)(5660300002)(186003)(107886003)(86362001)(1076003)(6506007)(26005)(6512007)(36756003)(83380400001)(2616005)(54906003)(6666004)(478600001)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiS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cp+nMNV7AcDLnZYQWRvqJXLT0GJ3x9IwUTzAFis92gSO50AGvN3uithWsv4oFoAgs6Kp88Vi+xNU2dmK0gQNcwIPilQL7/h32B20+1qSEzDUsuBw5LgP9941OPsl6IKNxkdjokL2vMh0Dv4lpPfcHuhw/efwX0JvZ/dVswmJbDNfrNSgLvXg1GIKhQObSxUjxqUP0gQ0j8GFw9Q5Js1s+dJ5CN154XhPYTAInt8Bmnat4oKfB+LwVbJHPDBWz1K9KCR2nBftLXSuVLuN75KwFLjO7BVkQW9D0JfIPHKDZMk85W7dh5G5VjU9MccgXcreNXaVnLgG2gIOBHhmM/sSPDuTIm/87hslduk0Z16oFqY8EerNN8/VAOw0AWiqh3a5pF5dbVAvNfyyTMLuteks+UhQLKQtD5mTwi56XA57N7MRT3qwz+7uBQsoHpcW5A2228ZgUQLhamqCS/fmL8ml5S3UDy+ILaCrMsCbhB1vVZIW7Y8TnYfqoaMqtOQaMh2bnFJFOd/4bpdVjJHH0oWgZlq0Z6B+uGkEvQEpihguc0D0zwUgRDGglIOx2+6cBGRgUQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d41b251-c89b-4664-8e3f-08db427034bb X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3022.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2023 13:56:29.3576 (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: ccnuV/UOcaj9DJwG6WZn4YbFHka1OQWFmsU6UgeSXyQH3mjBvxDm0PHxR6WjXzVXDRjSz4akjjEIh8O4+XS5Kg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB7540 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-21_06,2023-04-21_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304210121 X-Proofpoint-ORIG-GUID: IjrZg72Bv0EJyEfyIsajhwMHlzOWjOZj X-Proofpoint-GUID: IjrZg72Bv0EJyEfyIsajhwMHlzOWjOZj X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: BB3BA140003 X-Stat-Signature: kmmofjzcp5847p9mjqmini96myj4xuxp X-HE-Tag: 1682085408-199260 X-HE-Meta: U2FsdGVkX1+dY8FD3BULdNdiq+0Ak7pPNXlZ4snEgCa+ul7gYIboPDIVW/YrysMx+WTpwiUuQ1RqvfYHz6mqZ0IV0i30BczhON4m4nn+gN4t+A8xPjbFoPKgzpn/emxTe7PzvbusoBvAK8J2pCIbmK36QxwX4AnN3A4pROcgad5UfzTED57Nq8Ib98BV5SEHsko5M3Rc4i9vDataw09Ke4Nwfe9IMpP63eT2RI0S3wvymgiZw/ugCH2CR9XUR+bydrOqiQ0RsBFj5rCCHkQcyeYVvtqluAhfE2o2CZ9bBo5pYZU0hFyhTDIkZHPPgBTgnKUqI70u0QPpvtRJBP+rIEezIJ95SBO8I1NwhoTeh3FfstuO0EqwUbmIMPgdaqYGNoeFF+M8t87+blU9Mmv5oGskR9alE+kyo/F5X+bfsmdbjuuiMBJsM3d1exYGWilbUr2smppLm2ltnyRD+FRmo5cDpFtyCpusr+zK41P+D91xMdYv+4uX5D3YgrAlyqolR54i7iecdfnB2Lw1EOEYqTnU98Fe6gIo6Y05eCcF5UZJTii3wliFKpYw4fN+srpK0+b9P3ngTE9PVSdx6Dp2+noTgKLN4HLOlVKxITeCwKOzvXXvV6FQa6yy127VAJAlWiTufDfw5u0cTT5KSTTwwL9EoC6MbLwOaNEBgruBEE0etBnHzYU2lV9F70nBj9zXoeA7ytp5+4YNcMK04LswtM839SenH+4gbJ/D3M61BlGVlfD0HbH/UwUat2NBNzWTeBNZg3Dxm9gej7XzN+QckBZwfJVqLHlSuEIUh1VDPY0ywx9lppVtXa8Z6kBvUBnocpODpM2Cm+PhxEWsPxmHpGOe9x8SzFTaME7+yWBhTXf/M8w6QgIinGtvZRZP453qxTtvs2XWDiboUleOM36PI8dTCr7GhqsPdVYdMgq8L97P68xPctNuNAyryM1hO+z6zAMnnGKzTR8qUxLWJD3 2yeyP2B4 BQfXVONZN118I0+IzLgZlfh6n8fNZlPwNHX/lbo/dDNiGHu145vtmP07mzFEaz9wA6twKB3mYoZKZ/oV0GXL7KaWi8blA7e7133y4MqUhbuy4xmXupZYQGm0O9f1gaRR21aJ/4sNoM2Ea0GnM/4gSjnFSEcnIOQnltsAhHfWLAwTCqemzWkcxEZ4czyIJo3bkNSpSyQwOSUWVNPQQWg1MUSsI/lbY9MgYK9IKG9mP83hjXb/ilgFE+f4VR4H2ymluPLZxieXpUA0Wa3Wyrrn+fiue7qmOk4HlUSbyPQCDyHIFSjcIMzFpYPvI7ez9SIUoJGrfp8MS1W7RGQQwG2tFw/ayJ1IdyXqxRn63IBk7KdJVI3WRkzyNhO4qaBjgrxNYt1RI+nyPgCIuMbUrns0FyqndMwD1pCcwkZMvz9OsR4myBjyfsPo5gpmZF3wn/5Ar/yN8 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: The maple tree limits the gap returned to a window that specifically fits what was asked. This may not be optimal in the case of switching search directions or a gap that does not satisfy the requested space for other reasons. Fix the search by retrying the operation and limiting the search window in the rare occasion that a conflict occurs. Reported-by: Rick Edgecombe Fixes: 3499a13168da ("mm/mmap: use maple tree for unmapped_area{_topdown}") Signed-off-by: Liam R. Howlett --- mm/mmap.c | 48 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 055fbd5ed762f..6b9116f1c3049 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1548,7 +1548,8 @@ static inline int accountable_mapping(struct file *file, vm_flags_t vm_flags) */ static unsigned long unmapped_area(struct vm_unmapped_area_info *info) { - unsigned long length, gap; + unsigned long length, gap, low_limit; + struct vm_area_struct *tmp; MA_STATE(mas, ¤t->mm->mm_mt, 0, 0); @@ -1557,12 +1558,29 @@ static unsigned long unmapped_area(struct vm_unmapped_area_info *info) if (length < info->length) return -ENOMEM; - if (mas_empty_area(&mas, info->low_limit, info->high_limit - 1, - length)) + low_limit = info->low_limit; +retry: + if (mas_empty_area(&mas, low_limit, info->high_limit - 1, length)) return -ENOMEM; gap = mas.index; gap += (info->align_offset - gap) & info->align_mask; + tmp = mas_next(&mas, ULONG_MAX); + if (tmp && (tmp->vm_flags & VM_GROWSDOWN)) { /* Avoid prev check if possible */ + if (vm_start_gap(tmp) < gap + length - 1) { + low_limit = tmp->vm_end; + mas_reset(&mas); + goto retry; + } + } else { + tmp = mas_prev(&mas, 0); + if (tmp && vm_end_gap(tmp) > gap) { + low_limit = vm_end_gap(tmp); + mas_reset(&mas); + goto retry; + } + } + return gap; } @@ -1578,7 +1596,8 @@ static unsigned long unmapped_area(struct vm_unmapped_area_info *info) */ static unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info) { - unsigned long length, gap; + unsigned long length, gap, high_limit, gap_end; + struct vm_area_struct *tmp; MA_STATE(mas, ¤t->mm->mm_mt, 0, 0); /* Adjust search length to account for worst case alignment overhead */ @@ -1586,12 +1605,31 @@ static unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info) if (length < info->length) return -ENOMEM; - if (mas_empty_area_rev(&mas, info->low_limit, info->high_limit - 1, + high_limit = info->high_limit; +retry: + if (mas_empty_area_rev(&mas, info->low_limit, high_limit - 1, length)) return -ENOMEM; gap = mas.last + 1 - info->length; gap -= (gap - info->align_offset) & info->align_mask; + gap_end = mas.last; + tmp = mas_next(&mas, ULONG_MAX); + if (tmp && (tmp->vm_flags & VM_GROWSDOWN)) { /* Avoid prev check if possible */ + if (vm_start_gap(tmp) <= gap_end) { + high_limit = vm_start_gap(tmp); + mas_reset(&mas); + goto retry; + } + } else { + tmp = mas_prev(&mas, 0); + if (tmp && vm_end_gap(tmp) > gap) { + high_limit = tmp->vm_start; + mas_reset(&mas); + goto retry; + } + } + return gap; }