From patchwork Fri Apr 14 13:02:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13211457 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 D7C63C77B72 for ; Fri, 14 Apr 2023 13:03:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 169E96B007E; Fri, 14 Apr 2023 09:03:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F2F86B0080; Fri, 14 Apr 2023 09:03:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E63786B0081; Fri, 14 Apr 2023 09:03:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id D46336B007E for ; Fri, 14 Apr 2023 09:03:27 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id ADEA2AB191 for ; Fri, 14 Apr 2023 13:03:27 +0000 (UTC) X-FDA: 80680012854.16.A2C96F4 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf21.hostedemail.com (Postfix) with ESMTP id DF2C21C0011 for ; Fri, 14 Apr 2023 13:03:25 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; spf=pass (imf21.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=1681477406; 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=68Fb6So7DE+raDH8PM2qT2Sxx3ozWiuljRjCiDhnZ+o=; b=5EhLr6M9PH9fxyk5+MSt4BzVFuEkZvVwT39LJfVXQVIY+QeeYQge/QEBputYil/nq7MHVT t4H5+O1+3yhWIvN41sVHbEZGqyOXUiIbkUyi9I1Qq7H7SqVj1Drv7FzWjlV3+cKblr9PKM RDCBUc67uxL1rNznewHyOKlnVA2G/Fs= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; spf=pass (imf21.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=1681477406; a=rsa-sha256; cv=none; b=x6sDFJZ1/eiCVxf2gX9zBUGJP0ycx0BKon258RFXAMKsEKg7mWE9EtEvleTWWFKJJsxBbE J/jSWCoAls8eogqVs8p2MNuRlZ58U6Xt5bEbRLU4brV+fbmJOsuHau8wI59IdmJGUw9HDK 4BX0LsBu3IqWgz28hvSMlh3RQZAfWv8= 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 A585D1758; Fri, 14 Apr 2023 06:04:09 -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 2CD9F3F6C4; Fri, 14 Apr 2023 06:03:24 -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 05/17] mm: Routines to determine max anon folio allocation order Date: Fri, 14 Apr 2023 14:02:51 +0100 Message-Id: <20230414130303.2345383-6-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-Server: rspam03 X-Stat-Signature: 5remrwijsyatpy9id41fmbrk85q8npo7 X-Rspamd-Queue-Id: DF2C21C0011 X-HE-Tag: 1681477405-68088 X-HE-Meta: U2FsdGVkX19u4fHGWemD6ULnLQPPJmED8MiV0lcgUtzKrLuO77Fy7CIRK9D1FZiE+xm0Vyuj9Q/bAxpa9sROV7KjycLD4CvqfJBpnGIp/9sYUTK9Es7/2eNYeSj9DG9bEx/R0ySCJiE4mdk9fmt4uBengnJ3AQE9XZYG9cDSoYoEbnKb/SwOCDGjGzrJ4b/SxF0gRTT/1/Tv2aFAqJeLX4kViV7FWh+poUpYH/BuqHxnEzPMuKvtDNMNtHzNGHEGZx0r5xd251DP3sQ3rV08NIYKRyNy8CsoWW6+1HNZUYlhbM1AYnl2jww35Zv0K0MHSASbLHNhfJgNEDjdJEDLVm4MWTRoDvYik6eBfi6WTv4RJKy+S8C5Ery5ukfpNBoRa9yNkanSJJBCVIEY1Dht4cHQhzbQHDsLb3o8KqOoUhcGKTEl1QDjlrz2QVHezHOYC5VsTD2TczvssvtDaUPNENaGDAkLhTI0gZPmvBlJm9sQItgLJpJv4n1n7MjuwkfmTKHlbvod3ECjypQukczCN+cLHRPqiKUNy3uERg9pWppwVurMNA7v9B88ucdpkPQRaYwru71l8JqOVc3tk9nY96bXoyFp1on0sVBBthHguibCBBoZFXT2MiEzz9Pgre+BBCu14A5Z8d7iJIYKdbmuAKn38qPkn53Xmevh2Sa7tyZzdQwqgWfHBxCnZhbwKUBDmVSqbH3wlomMEnq1XfYXxm91FSzJGtUJB8CmpcU9vpufVjWZBRufogym6ZE4he+hZw6s5OhQ6QOo/36E9p7WL91YLeTYkdddzjpMBCaDqQNRBJjxL9y0NEKmet1TJCGZw2Guaq9hQE2moNYnRywZF4ks1+NW/IK3fvcluoMfSis3n0MNbGVMO+Y5hdVDHOp4VSqckvrSFi8VhA29U2/ZyEPw7Ni66WoIFzccDpt23mJTBzzyPGvTdkdhQZMNZ7cwLC2H/GnxpAkoB9xCBlN Wn9b/GG3 ORH8Lhex63CMzCpzLP78QbaY8fqtnjiobjx4JIj54E2q0t9YoX7oqn8bopCs/inRrd7VlussKWN7eJp6IVVHerBWhd6ngxspb4mNDa5KTKPR221xE0mDF7hBLj0Ek7UIoTm5xi3vOb3jfesZhfEIm1tMQnSFksqSM6wWG9VY72EJec+Y= 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: For variable-order anonymous folios, we want to tune the order that we prefer to allocate based on the vma. Add the routines to manage that heuristic. TODO: Currently we always use the global maximum. Add per-vma logic! Signed-off-by: Ryan Roberts --- include/linux/mm.h | 5 +++++ mm/memory.c | 8 ++++++++ 2 files changed, 13 insertions(+) -- 2.25.1 diff --git a/include/linux/mm.h b/include/linux/mm.h index cdb8c6031d0f..cc8d0b239116 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3674,4 +3674,9 @@ madvise_set_anon_name(struct mm_struct *mm, unsigned long start, } #endif +/* + * TODO: Should this be set per-architecture? + */ +#define ANON_FOLIO_ORDER_MAX 4 + #endif /* _LINUX_MM_H */ diff --git a/mm/memory.c b/mm/memory.c index ca32f59acef2..d7e34a8c46aa 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3022,6 +3022,14 @@ static struct folio *try_vma_alloc_movable_folio(struct vm_area_struct *vma, return vma_alloc_movable_folio(vma, vaddr, 0, zeroed); } +static inline int max_anon_folio_order(struct vm_area_struct *vma) +{ + /* + * TODO: Policy for maximum folio order should likely be per-vma. + */ + return ANON_FOLIO_ORDER_MAX; +} + /* * Handle write page faults for pages that can be reused in the current vma *