From patchwork Fri Apr 14 13:03:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13211468 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 A5B4BC77B6E for ; Fri, 14 Apr 2023 13:04:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3B3EA280007; Fri, 14 Apr 2023 09:03:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 33C95280001; Fri, 14 Apr 2023 09:03:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B6A5280007; Fri, 14 Apr 2023 09:03:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 03818280001 for ; Fri, 14 Apr 2023 09:03:41 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C05A51C5B48 for ; Fri, 14 Apr 2023 13:03:40 +0000 (UTC) X-FDA: 80680013400.19.464C504 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf18.hostedemail.com (Postfix) with ESMTP id 07F581C0005 for ; Fri, 14 Apr 2023 13:03:38 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681477419; a=rsa-sha256; cv=none; b=EgJRaxO3DYPE5ecpCOBky5fwQWL0+fRQEGC90/YO8v4z+g48wRnYU8wnP1oPb2QeJ79rDH N6VlSN+I0lk4bXCMq8fyffYwSRCemWKd8I7Fnr1Qj4s1PKye13TL4ehjQ7ausw+6VRauth ht2D41A83gGqT+GPDNufzuUADGXI2aY= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681477419; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yLEbxn/oDvdzRpoW8AGJdEnOQjZWB+dVG7oOEDaA1Jw=; b=0oAME33ObvlzqEgk5DKdDu6LaSPwQLjYLJrCJPsfyaoJ/oA2HJZ6KOjLK0xm17ByqosLdv G4S+Qx8KdFs8X1VZn1mniL4LCfKGsSBlgtShCqH6LPGYq7z+UOQ0z7ZU66PR86JGIh47aP 8f7+t7GmIciIfmMyYhycQbhXdEw885M= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0B5541758; Fri, 14 Apr 2023 06:04:23 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 86F0B3F6C4; Fri, 14 Apr 2023 06:03:37 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , "Matthew Wilcox (Oracle)" , Yu Zhao , "Yin, Fengwei" Cc: Ryan Roberts , linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v2 PATCH 16/17] mm: mmap: Align unhinted maps to highest anon folio order Date: Fri, 14 Apr 2023 14:03:02 +0100 Message-Id: <20230414130303.2345383-17-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230414130303.2345383-1-ryan.roberts@arm.com> References: <20230414130303.2345383-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 07F581C0005 X-Rspamd-Server: rspam01 X-Stat-Signature: r8ugt3oc4pahsop65niukhzyhonkji8b X-HE-Tag: 1681477418-588092 X-HE-Meta: U2FsdGVkX1/OeR8xHrdYuWXGEOszeMgb+5KWXdViA1iRlHJyE29ohPXAINU8CYFrlQ6FxInXRQ7R49Be2yY1V7GuYH9Dm+jkJluYjSuLA5U/E1/Su6+m7WHlQm2kEHEv0WuNYrot3sHOVw4Hf0mq0272uX7dzOAP0prhBUD/k0MD3Rab8vreJUNthR4JSuwOj1IUXpF5ZI7/D2d988zJOwI0aVA9Bc3SOVDORbNhZU3WLGPCPX64+5vp2YiVTgBsfXOWfZfjtKvucvS8vnKpuldimJfuE9Uv+bU86Co8xVPbgrI4Li8lPjU0jUQMDpFaSwXCQrPTxVfGjys6AbgHkOFAZIkNJxkSOYuZV2t+Etae8wENhVpQpQQZQHZtDZyA3S9af0NXMyDayMsGQyFyLlzkBz9xuaekiies73UmT44y3bazoNcv4Jccm8VvSgptkFUadZpRaZ+mAKF48jwwYRlDHgYR/P/yZq4OiRZ4TrV+1fUjAg01aN2GT8Dd8BQOn2weUPwTfamt8TS80JnURFNEs9IoVG/q5seRlxZix/HIW0Hx8YbvtYRAqbrFcxbi3ymQxupV+7cIc/36RW/ATrbaiNS78tHz5vkYhOaxZsGio31sPAUGndCf0/vArbuZGz2nqfbEvhlVO5NwsqalOXrO6vZ/M9W2JzJRc6Ru/znkWI2Qn44HUZYrcYKgI6X3iTTDWlKlc8mqeQzDEN7Gcfxljknd8Jzz4BJak+gDzr9PMVuqZW4bVvFuV65Sn5xZ0I+e/UxiXTzUmZVDn9PfO/+1fhOfkX4oWTmXjFm9+udfHZU/0+hv/0fF/qCxNSykrvZYuzjz0uV1jWVLuX6iOA6/mk9Xi9AxQvvOyDZNRQyL/kLrPJnlpqCepzMXap8Hxk5WKuxwl4yIi/99y/PZEEs00q4cuJRK3TsRTE9dbl2CwYJdMThaTgr+o6uVF8boEIeI8GwXQc+WGzfKAc0 EB8S0JV+ ien8qW6lI0Mbt8amaDU2lYyMeeIzjsi6wzcYCQqTI1ixNxex3Arellh2d4QxSazlli91sQ9MqHtu5fNErT4eeT1x3B3Vxjo1exqSlEVJnidf3TPC2j3pMckvvatlWJSuX+rWDU3eyOCmLEx7UFeYfeQkO6Ie0g6aCVcEq6sIeMcdq3zo= 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: When allocating large anonymous folios, we want to maximize our chances of being able to use the highest order we support. Since one of the constraints is that a folio has to be mapped naturally aligned, let's have mmap default to that alignment when user space does not provide a hint. With this in place, an extra 2% of all allocated anonymous memory belongs to a folio of the highest order, when compiling the kernel. Signed-off-by: Ryan Roberts --- mm/mmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.25.1 diff --git a/mm/mmap.c b/mm/mmap.c index ff68a67a2a7c..e7652001a32e 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1627,7 +1627,7 @@ generic_get_unmapped_area(struct file *filp, unsigned long addr, info.length = len; info.low_limit = mm->mmap_base; info.high_limit = mmap_end; - info.align_mask = 0; + info.align_mask = BIT(PAGE_SHIFT + ANON_FOLIO_ORDER_MAX) - 1; info.align_offset = 0; return vm_unmapped_area(&info); } @@ -1677,7 +1677,7 @@ generic_get_unmapped_area_topdown(struct file *filp, unsigned long addr, info.length = len; info.low_limit = max(PAGE_SIZE, mmap_min_addr); info.high_limit = arch_get_mmap_base(addr, mm->mmap_base); - info.align_mask = 0; + info.align_mask = BIT(PAGE_SHIFT + ANON_FOLIO_ORDER_MAX) - 1; info.align_offset = 0; addr = vm_unmapped_area(&info);