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: 13211484 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4A84AC77B6E for ; Fri, 14 Apr 2023 13:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9LNsaLx/NxrS4Sr0uxWgBpRLXdlaoBHHAPiaU9pRtZM=; b=ig7l1pnXjsxPK4 f7lHsJgzwMcn0neul57U7QIZA7EMsfnXpAYs3dOeqqjWurAG4oFul7zS5+BKiR9jeLnz/F7VoAtDX E2By/V9VBdv1AvRoe2EJTL4A5MB0MYZjfN+SbOJuYpNMy6Dq4jYmYXJQAnX6bmrLsm84lfOmPf1wC SkYCZNllVpIZi9Gbw+9Ls0RtnJiLWjeo9Iw02SMvUtADCe7vmWIbLvqWQQXKkvt1kY9VP8myHsmDa agNcSzdUjiTUYRhBAXny61UHY3F9gck1NKY2tvMiwKfQQFkTy1+A1WKv8CgJHND+aS55wpPcUGjf2 ONFG8cOkFgEtZpBfcGYQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pnJ68-009bqP-2H; Fri, 14 Apr 2023 13:04:17 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pnJ5W-009bQ5-2v for linux-arm-kernel@lists.infradead.org; Fri, 14 Apr 2023 13:03:43 +0000 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230414_060339_450615_C8A60FA0 X-CRM114-Status: GOOD ( 11.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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);