linux-stable/Documentation
Ryan Roberts 3485b88390 mm: thp: introduce multi-size THP sysfs interface
In preparation for adding support for anonymous multi-size THP, introduce
new sysfs structure that will be used to control the new behaviours.  A
new directory is added under transparent_hugepage for each supported THP
size, and contains an `enabled` file, which can be set to "inherit" (to
inherit the global setting), "always", "madvise" or "never".  For now, the
kernel still only supports PMD-sized anonymous THP, so only 1 directory is
populated.

The first half of the change converts transhuge_vma_suitable() and
hugepage_vma_check() so that they take a bitfield of orders for which the
user wants to determine support, and the functions filter out all the
orders that can't be supported, given the current sysfs configuration and
the VMA dimensions.  The resulting functions are renamed to
thp_vma_suitable_orders() and thp_vma_allowable_orders() respectively. 
Convenience functions that take a single, unencoded order and return a
boolean are also defined as thp_vma_suitable_order() and
thp_vma_allowable_order().

The second half of the change implements the new sysfs interface.  It has
been done so that each supported THP size has a `struct thpsize`, which
describes the relevant metadata and is itself a kobject.  This is pretty
minimal for now, but should make it easy to add new per-thpsize files to
the interface if needed in future (e.g.  per-size defrag).  Rather than
keep the `enabled` state directly in the struct thpsize, I've elected to
directly encode it into huge_anon_orders_[always|madvise|inherit]
bitfields since this reduces the amount of work required in
thp_vma_allowable_orders() which is called for every page fault.

See Documentation/admin-guide/mm/transhuge.rst, as modified by this
commit, for details of how the new sysfs interface works.

[ryan.roberts@arm.com: fix build warning when CONFIG_SYSFS is disabled]
  Link: https://lkml.kernel.org/r/20231211125320.3997543-1-ryan.roberts@arm.com
Link: https://lkml.kernel.org/r/20231207161211.2374093-4-ryan.roberts@arm.com
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
Reviewed-by: Barry Song <v-songbaohua@oppo.com>
Tested-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Tested-by: John Hubbard <jhubbard@nvidia.com>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: David Rientjes <rientjes@google.com>
Cc: "Huang, Ying" <ying.huang@intel.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Itaru Kitayama <itaru.kitayama@gmail.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Yang Shi <shy828301@gmail.com>
Cc: Yin Fengwei <fengwei.yin@intel.com>
Cc: Yu Zhao <yuzhao@google.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2023-12-20 14:48:12 -08:00
..
ABI Docs/ABI/damon: document DAMOS quota goals 2023-12-12 10:57:04 -08:00
PCI
RCU Merge branches 'rcu/torture', 'rcu/fixes', 'rcu/docs', 'rcu/refscale', 'rcu/tasks' and 'rcu/stall' into rcu/next 2023-10-23 15:24:11 +02:00
accel
accounting
admin-guide mm: thp: introduce multi-size THP sysfs interface 2023-12-20 14:48:12 -08:00
arch Docs/LoongArch: Update links in LoongArch introduction.rst 2023-11-21 15:03:25 +08:00
block The number of commits for documentation is not huge this time around, but 2023-11-01 17:11:41 -10:00
bpf bpf: Add __bpf_kfunc_{start,end}_defs macros 2023-11-01 22:33:53 -07:00
cdrom
core-api maple_tree: update the documentation of maple tree 2023-12-10 16:51:32 -08:00
cpu-freq
crypto crypto: ahash - remove support for nonzero alignmask 2023-10-27 18:04:29 +08:00
dev-tools Many singleton patches against the MM code. The patch series which are 2023-11-02 19:38:47 -10:00
devicetree Some pin control fixes for the v6.7 cycle: 2023-11-29 06:45:22 -08:00
doc-guide docs: doc-guide: mention 'make refcheckdocs' 2023-10-22 20:38:55 -06:00
driver-api media updates for v6.7-rc1 2023-11-06 15:06:06 -08:00
fault-injection
fb
features
filesystems mm: thp: introduce multi-size THP sysfs interface 2023-12-20 14:48:12 -08:00
firmware-guide
firmware_class
fpga
gpu Merge tag 'drm-misc-next-2023-10-27' of git://anongit.freedesktop.org/drm/drm-misc into drm-next 2023-10-31 10:47:50 +10:00
hid
hwmon hwmon: (aquacomputer_d5next) Add support for Aquacomputer High Flow USB and MPS Flow 2023-10-29 22:22:48 -07:00
i2c Documentation: i2c: add fault code for not supporting 10 bit addresses 2023-10-29 21:03:35 +01:00
iio
images
infiniband
input
isdn
kbuild Kbuild updates for v6.7 2023-11-04 08:07:19 -10:00
kernel-hacking
leds
litmus-tests
livepatch
locking
maintainer
mhi
misc-devices eeprom: remove doc and MAINTAINERS section after driver was removed 2023-10-18 10:01:34 +02:00
mm Docs/admin-guide/mm/damon/usage: document for quota goals 2023-12-12 10:57:05 -08:00
netlabel
netlink netlink: specs: devlink: add forgotten port function caps enum values 2023-11-01 22:13:43 -07:00
networking Including fixes from netfilter and bpf. 2023-11-09 17:09:35 -08:00
nvdimm
nvme
pcmcia
peci
power
process docs: netdev: try to guide people on dealing with silence 2023-11-21 14:35:43 -08:00
rust Rust changes for v6.7 2023-10-30 20:30:49 -10:00
scheduler asm-generic updates for v6.7 2023-11-01 15:28:33 -10:00
scsi
security
sound Linux 6.6-rc7 2023-10-23 19:38:22 +01:00
sphinx Documentation/sphinx: Remove the repeated word "the" in comments. 2023-10-22 20:33:38 -06:00
sphinx-static
spi
staging
target
timers
tools
trace Documentation: tracing: Add a note about argument and retval access 2023-11-10 19:59:03 +09:00
translations Docs/zh_CN/LoongArch: Update links in LoongArch introduction.rst 2023-11-21 15:03:26 +08:00
usb USB/Thunderbolt changes for 6.7-rc1 2023-11-03 16:00:42 -10:00
userspace-api drm next and fixes for 6.7-rc1 2023-11-07 17:10:02 -08:00
virt KVM/arm64 updates for 6.7 2023-10-31 16:37:07 -04:00
w1
watchdog
wmi
.gitignore
Changes
CodingStyle
Kconfig
Makefile
SubmittingPatches
atomic_bitops.txt
atomic_t.txt
conf.py
docutils.conf
dontdiff
index.rst
memory-barriers.txt
subsystem-apis.rst