From patchwork Mon Aug 26 20:43:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13778398 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 1C956C5321D for ; Mon, 26 Aug 2024 20:44:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 241EC6B0093; Mon, 26 Aug 2024 16:44:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C9CC6B0095; Mon, 26 Aug 2024 16:44:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F36936B0096; Mon, 26 Aug 2024 16:44:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id CDF456B0093 for ; Mon, 26 Aug 2024 16:44:12 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 79C3D81445 for ; Mon, 26 Aug 2024 20:44:12 +0000 (UTC) X-FDA: 82495573944.09.CEB06B5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 55566180006 for ; Mon, 26 Aug 2024 20:44:09 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ANhLXbK+; spf=pass (imf16.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724704963; 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=p41Ko1t0SYR+aQ+NnkPoKcQjWVRbF5iAoso+I7QNClw=; b=flqfbxYp96EojJ6QAEhG38j2/CykRZh6zcmdxmaftR9Hw4tjzY0cZxZVrfh1oyWS26+Y3J B7aj9OEz15q34s2W9s8oTBpgqMn9hz5FdLRMfafN/FA5ecj2pOLiyvvibjtzQ/jD1bjbKs 04aVJl1fCUNcs4mIFP5DqO9tOL/U4oY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724704963; a=rsa-sha256; cv=none; b=MTqdJX0snTXl0BA7UAo4mHsW+q8XbzMHXVTApgGgskKQtnzffHymC7XF9sQR8e/foUVuXD 97HoJykLgOc+g5Jjfm6uE95FQnJ6jjJpkOGXZliJnip1YNja3fRWaUM3ATQGztJ4CiKxaA 98O6tn0RimS8JrFAKhGTm1qv3oX0N94= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ANhLXbK+; spf=pass (imf16.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724705048; h=from:from: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; bh=p41Ko1t0SYR+aQ+NnkPoKcQjWVRbF5iAoso+I7QNClw=; b=ANhLXbK+9pIbuwML79qjnFRIdr/V/LQLR07EtLdGzgb+JQj+HKRqlCGrHHGP4PnGWcbTGK hc3cM5dR61C7n4uMTmKoZgHXwBHAp58XiZu/mbOSbCwywauwVCDnYd1aw5HMi6NJCuoBvH 3wlZ2gRE58o+SDnMX2/JWji2x+tewzE= Received: from mail-oo1-f70.google.com (mail-oo1-f70.google.com [209.85.161.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-139-jnUBCwXrP-elFPqWB1fdxQ-1; Mon, 26 Aug 2024 16:44:05 -0400 X-MC-Unique: jnUBCwXrP-elFPqWB1fdxQ-1 Received: by mail-oo1-f70.google.com with SMTP id 006d021491bc7-5dcaed7de57so6506921eaf.0 for ; Mon, 26 Aug 2024 13:44:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724705044; x=1725309844; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p41Ko1t0SYR+aQ+NnkPoKcQjWVRbF5iAoso+I7QNClw=; b=ctei8GjlEQYyoW8NXAvX2mxps2Av/TTMOHBMN2AAhadk9rO7J0RH+giMzJxnqTCfOn JdFIAKlIOo9SWMHHc1Ih8LyTBdfpRDvjCHSlhzG2Uw2kA0tm39vjJoq22sDhpK69ekWX JnSuv6t98AhC8RASTqv1YMj1MmCbDICOmvQ+wPT2ipgFMkegn0YoIAW//78UTzhoPfU5 D3B/7B2ALUtKQSjOCL+xDutjX7pKIaFoH9GHoaaJ1bXY2dpFtl7rtT0COSBKiofiICYq 0EUJUoRFySRSrzp20MYqUGiEZf5zPxlVRih0/cTDBDP6KnAxcESDU7wbiVANHNBv4lDG HFQQ== X-Forwarded-Encrypted: i=1; AJvYcCVLQJ9ZYFz4lMeTVxm5ngAf8CnHsl3+5O1R60QRYF9RUocmBQ9GTroqxVOUCUAIq/Zcpgs7KDwoig==@kvack.org X-Gm-Message-State: AOJu0YxNgUBblTsLAeAETH8w0sSvlKWUGpXN27dKnkVXq8YPgfoMYbYS HgeHiocF+c5VVOS05ALHI9bYogDKC0GMUzhIDO/SKdDBzDYp1hmJp6Be1SNWWxzE0cR02StL5qr xTh9ni3N4yaomxJshQxqBB/KYJYG+itirDVUWP4e4RaEgbun5fMCdjAN+ X-Received: by 2002:a05:6358:ca5:b0:1b5:ecce:b760 with SMTP id e5c5f4694b2df-1b5ecceb805mr68655355d.21.1724705044538; Mon, 26 Aug 2024 13:44:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGqSprkmyPyKIDES0Mxu2D+0b60kqL8Leav+5Mf5w5kuR6qgHz2l36Zs0Y1NhYRXD/bnn90Fg== X-Received: by 2002:a05:6358:ca5:b0:1b5:ecce:b760 with SMTP id e5c5f4694b2df-1b5ecceb805mr68653955d.21.1724705044223; Mon, 26 Aug 2024 13:44:04 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a67f3fd6c1sm491055185a.121.2024.08.26.13.44.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 13:44:03 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Gavin Shan , Catalin Marinas , x86@kernel.org, Ingo Molnar , Andrew Morton , Paolo Bonzini , Dave Hansen , Thomas Gleixner , Alistair Popple , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sean Christopherson , peterx@redhat.com, Oscar Salvador , Jason Gunthorpe , Borislav Petkov , Zi Yan , Axel Rasmussen , David Hildenbrand , Yan Zhao , Will Deacon , Kefeng Wang , Alex Williamson , Matthew Wilcox , Ryan Roberts Subject: [PATCH v2 04/19] mm: Allow THP orders for PFNMAPs Date: Mon, 26 Aug 2024 16:43:38 -0400 Message-ID: <20240826204353.2228736-5-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240826204353.2228736-1-peterx@redhat.com> References: <20240826204353.2228736-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Stat-Signature: xatemx363oxy74u4pn9mmcnhdy9wx1mw X-Rspamd-Queue-Id: 55566180006 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1724705049-60535 X-HE-Meta: U2FsdGVkX1/4Igj2RZCM0j1znKE72Qf7L/4ysiA35uGsGDqJ0wfJoW7+7sn81JhY486FD5e7M9FOUavyQFbq9EaIBF1YWQ03ufnI/pbEv1Kn+FX1wy/5MEjyMr99do6Xz2Rz7flLdBZsRWQXtOhpzPj80Q8+za5hiAZNhFnJkH4UAZr/A4cAnYTDwmb7YgHFa22vkpzE5MCUEQMOf7nB3GhMIs9mn6/tc3Vpnksi6OHLhlbNdrSEFQwX/OsInZ5n0zLnoP6bsqKEfP7rt8chOl0Dh5CpuK1UPAs0rxEuNTDoAzTfhUqJIholnT8itQn/y891Bgrz94Zc+go2X4KUCRzCz/duqOD3gXSCXjjAbPbREcm/t9f1mb4jz7cE8eTOPC0+9OValaszGk1Pww1gNxpA2SKcNpzSu7zXASIWFsQ+ZDV+MGj1yybmLngUPilNU2iQ+zxFcKAelf9SVIRJTrzHyjM7gAlYrqE2WFIHcOiuLPT6irpYOsVzuOUOxMeuzETdCc0Nvc3HJRvu5qmYbQn25SUsWcch1M+OIhzV/RA7c/RnS1cLQybaybJckwxQqhwi8Q8lPQ8pDYpBD9Pcoti0oWT/qCz/ETpcqLUMaacyrSAFYyKlaYjRzoSETkjaL5SNpqout7YejZmPxZWoGFwYv7h+hrKInR4tovJ98vhEjkTRkdTBVXqm0jCsrKh5yd4wD3xAkJeUoVqknjmtRBP/hTZ8zHGgqSVp86AK6Qh4gn9U7kQvSd4oSH8U0RaTbrTjACGp8dpjBYeOlcm0pl/MvMMWB1lO3ma7KNQ+MR58nnxhBmpLcH3WodHebEY9AAkFNZbXJgsUUx/VvxDbcyHCUs6c7pCLbeguFVQl+D8sqYVooeLCzsLYadATAguR4UbOEXfOTftdqpqcwOL/qsudT9Q9IlAipP8A6TGssLEdyVNAyy+zz6R4Qt2dPc0ZoNwEjrlkF0lQ5CFqCmK BbJnzDP5 iWy+SUUYTofHsGB22TLQ/7Qfn7EzJ25Upvm7wULTblnmRkx9zsV/1bsMP+6+ptXKYmNWzPcrLAvgGC7u7W1wu6i0CwZw/Zf2er9TLMmy1jAURJCkiiCGQLiuD0hQD0276ROBz2+0pWrkthzXTdWGDh686o4uFE6JKl1Hc0dwHKwFybllap3y1eTmnj9M/De6vPHfMt7gKT3EVdbHptHRtKekaRiFa2BoE9ZHoNPuBpp8OmO9LLIm9dfGyt04xnBcK+cqvtfhiNGzMrtPGLVnw1QKaQMBT6u2fsCy7Rh7yA7QgAz9/W5WGkFirpwGXen7+WycB6hABD0VpQa7A9cCAJkDRecA4Q2yeD5r1JTAXiT2fl1trD0YoNQB1N6fWKuB9jj3v4JeXlVF7Q1PYJ1WVorRStMb2IdwY3Ap9+5/75gyiNqO6myNlyxF/t2nTGqNNk9pwV/B6gy4gsnB+wpkbgCD0a40HAiOXCiu4 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: List-Subscribe: List-Unsubscribe: This enables PFNMAPs to be mapped at either pmd/pud layers. Generalize the dax case into vma_is_special_huge() so as to cover both. Meanwhile, rename the macro to THP_ORDERS_ALL_SPECIAL. Cc: Matthew Wilcox Cc: Gavin Shan Cc: Ryan Roberts Cc: David Hildenbrand Cc: Zi Yan Reviewed-by: Jason Gunthorpe Signed-off-by: Peter Xu Acked-by: David Hildenbrand --- include/linux/huge_mm.h | 6 +++--- mm/huge_memory.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index b550b5a248bb..4da102b74a8c 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -76,9 +76,9 @@ extern struct kobj_attribute thpsize_shmem_enabled_attr; /* * Mask of all large folio orders supported for file THP. Folios in a DAX * file is never split and the MAX_PAGECACHE_ORDER limit does not apply to - * it. + * it. Same to PFNMAPs where there's neither page* nor pagecache. */ -#define THP_ORDERS_ALL_FILE_DAX \ +#define THP_ORDERS_ALL_SPECIAL \ (BIT(PMD_ORDER) | BIT(PUD_ORDER)) #define THP_ORDERS_ALL_FILE_DEFAULT \ ((BIT(MAX_PAGECACHE_ORDER + 1) - 1) & ~BIT(0)) @@ -87,7 +87,7 @@ extern struct kobj_attribute thpsize_shmem_enabled_attr; * Mask of all large folio orders supported for THP. */ #define THP_ORDERS_ALL \ - (THP_ORDERS_ALL_ANON | THP_ORDERS_ALL_FILE_DAX | THP_ORDERS_ALL_FILE_DEFAULT) + (THP_ORDERS_ALL_ANON | THP_ORDERS_ALL_SPECIAL | THP_ORDERS_ALL_FILE_DEFAULT) #define TVA_SMAPS (1 << 0) /* Will be used for procfs */ #define TVA_IN_PF (1 << 1) /* Page fault handler */ diff --git a/mm/huge_memory.c b/mm/huge_memory.c index dec17d09390f..e2c314f631f3 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -96,8 +96,8 @@ unsigned long __thp_vma_allowable_orders(struct vm_area_struct *vma, /* Check the intersection of requested and supported orders. */ if (vma_is_anonymous(vma)) supported_orders = THP_ORDERS_ALL_ANON; - else if (vma_is_dax(vma)) - supported_orders = THP_ORDERS_ALL_FILE_DAX; + else if (vma_is_special_huge(vma)) + supported_orders = THP_ORDERS_ALL_SPECIAL; else supported_orders = THP_ORDERS_ALL_FILE_DEFAULT;