From patchwork Mon Aug 8 20:46:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rik van Riel X-Patchwork-Id: 12939125 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 B0103C00140 for ; Mon, 8 Aug 2022 20:47:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A43558E0001; Mon, 8 Aug 2022 16:47:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9F2936B0073; Mon, 8 Aug 2022 16:47:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8BA718E0001; Mon, 8 Aug 2022 16:47:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 7800A6B0071 for ; Mon, 8 Aug 2022 16:47:10 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 245D14022F for ; Mon, 8 Aug 2022 20:47:10 +0000 (UTC) X-FDA: 79777610220.31.9973B64 Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) by imf22.hostedemail.com (Postfix) with ESMTP id 2365DC005A for ; Mon, 8 Aug 2022 20:47:07 +0000 (UTC) Received: from [2603:3005:d05:2b00:6e0b:84ff:fee2:98bb] (helo=imladris.surriel.com) by shelob.surriel.com with esmtpsa (TLS1.2) tls TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1oL9eM-0006om-U7; Mon, 08 Aug 2022 16:46:58 -0400 Date: Mon, 8 Aug 2022 16:46:58 -0400 From: Rik van Riel To: Andrew Morton Cc: linux-mm@kvack.org, kernel-team@fb.com, Matthew Wilcox Subject: [PATCH] mm: align larger anonymous mappings on THP boundaries Message-ID: <20220808164658.5079a9a0@imladris.surriel.com> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.31; x86_64-redhat-linux-gnu) MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659991629; h=from:from:sender: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: references; bh=7RvPtnKeqm14GLIRahgg962jVwEpbLdxthJjgrcDD5c=; b=pdQCyxDWplyCN/UeiXfxQyjKy1/zbXyId5jAC3Ut4sY3E0pkotJJ80J/0hr2eFL/nmOdz7 brXZ7hX1fn/wp/oLNygPAB2N8deFHjAKUdsKRv7xofrktQ4fQ27ISqirbJlDL8aLndSOrG MagO3qiPpFEzr+BzwsH+KNK5tqvELlo= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; dmarc=none; spf=none (imf22.hostedemail.com: domain of riel@shelob.surriel.com has no SPF policy when checking 96.67.55.147) smtp.mailfrom=riel@shelob.surriel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659991629; a=rsa-sha256; cv=none; b=mvIixwo4m5OMoY8hhrxsmtepDJNMbJq5Tw+VLlCzEX+5So91blIJlWj5TKUo6WkZAqgH/y M90dY2b+0NN77n6QfliESFoOUn9lz5NLP6CALZRD5p+Y/7lr5IqPGXXnkMtgLwcxdgbqi2 PJhy410XnRzXeEtaycsH290t9IhkDNY= X-Rspamd-Queue-Id: 2365DC005A X-Rspamd-Server: rspam03 X-Rspam-User: Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=none; spf=none (imf22.hostedemail.com: domain of riel@shelob.surriel.com has no SPF policy when checking 96.67.55.147) smtp.mailfrom=riel@shelob.surriel.com X-Stat-Signature: jrwor5s3ob6a3365bazj5qn3obdd9wf7 X-HE-Tag: 1659991627-821381 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: Align larger anonymous memory mappings on THP boundaries by going through thp_get_unmapped_area if THPs are enabled for the current process. With this patch, larger anonymous mappings are now THP aligned when checking in /proc/PID/maps, but only when THP is enabled for that process. Signed-off-by: Rik van Riel --- mm/mmap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/mmap.c b/mm/mmap.c index c035020d0c89..3a9d19cec690 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2229,6 +2229,9 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, */ pgoff = 0; get_area = shmem_get_unmapped_area; + } else if (test_bit(MMF_VM_HUGEPAGE, ¤t->mm->flags)) { + /* Ensures that larger anonymous mappings are THP aligned. */ + get_area = thp_get_unmapped_area; } addr = get_area(file, addr, len, pgoff, flags);