linux/drivers
Danilo Krummrich 590b9d576c mm: kvmalloc: align kvrealloc() with krealloc()
Besides the obvious (and desired) difference between krealloc() and
kvrealloc(), there is some inconsistency in their function signatures and
behavior:

 - krealloc() frees the memory when the requested size is zero, whereas
   kvrealloc() simply returns a pointer to the existing allocation.

 - krealloc() behaves like kmalloc() if a NULL pointer is passed, whereas
   kvrealloc() does not accept a NULL pointer at all and, if passed,
   would fault instead.

 - krealloc() is self-contained, whereas kvrealloc() relies on the caller
   to provide the size of the previous allocation.

Inconsistent behavior throughout allocation APIs is error prone, hence
make kvrealloc() behave like krealloc(), which seems superior in all
mentioned aspects.

Besides that, implementing kvrealloc() by making use of krealloc() and
vrealloc() provides oppertunities to grow (and shrink) allocations more
efficiently.  For instance, vrealloc() can be optimized to allocate and
map additional pages to grow the allocation or unmap and free unused pages
to shrink the allocation.

[dakr@kernel.org: document concurrency restrictions]
  Link: https://lkml.kernel.org/r/20240725125442.4957-1-dakr@kernel.org
[dakr@kernel.org: disable KASAN when switching to vmalloc]
  Link: https://lkml.kernel.org/r/20240730185049.6244-2-dakr@kernel.org
[dakr@kernel.org: properly document __GFP_ZERO behavior]
  Link: https://lkml.kernel.org/r/20240730185049.6244-5-dakr@kernel.org
Link: https://lkml.kernel.org/r/20240722163111.4766-3-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Chandan Babu R <chandan.babu@oracle.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Christoph Lameter <cl@linux.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Kees Cook <kees@kernel.org>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Miguel Ojeda <ojeda@kernel.org>
Cc: Oliver Upton <oliver.upton@linux.dev>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Uladzislau Rezki <urezki@gmail.com>
Cc: Wedson Almeida Filho <wedsonaf@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2024-09-01 20:25:44 -07:00
..
accel
accessibility
acpi ACPI: video: Add backlight=native quirk for Dell OptiPlex 7760 AIO 2024-08-19 15:58:52 +02:00
amba
android
ata ata: pata_macio: Use WARN instead of BUG 2024-08-21 14:33:23 +09:00
atm
auxdisplay
base
bcma
block
bluetooth Bluetooth: btnxpuart: Fix random crash seen while removing driver 2024-08-23 15:56:04 -04:00
bus
cache
cdrom
cdx
char tpm: ibmvtpm: Call tpm2_sessions_init() to initialize session support 2024-08-27 21:11:44 +03:00
clk
clocksource
comedi
connector
counter
cpufreq cpufreq/amd-pstate-ut: Don't check for highest perf matching on prefcore 2024-08-23 11:07:58 -05:00
cpuidle
crypto
cxl
dax
dca
devfreq
dio
dma dmaengine: dw-edma: Do not enable watermark interrupts for HDMA 2024-08-28 18:40:17 +05:30
dma-buf
dpll
edac
eisa
extcon
firewire
firmware ARM: SoC fixes for 6.11, part 2 2024-09-01 06:42:13 +12:00
fpga
fsi
gnss
gpio
gpu mm: kvmalloc: align kvrealloc() with krealloc() 2024-09-01 20:25:44 -07:00
greybus
hid hid-for-linus-2024081901 2024-08-19 11:02:13 -07:00
hsi
hte
hv
hwmon hwmon: (pt5161l) Fix invalid temperature reading 2024-08-26 20:58:05 -07:00
hwspinlock
hwtracing
i2c
i3c
idle
iio
infiniband
input Input updates for v6.11-rc5 2024-08-31 15:32:38 +12:00
interconnect
iommu IOMMU Fixes for Linux v6.11-rc5 2024-08-31 06:11:34 +12:00
ipack
irqchip
isdn
leds
macintosh
mailbox
mcb
md block-6.11-20240824 2024-08-16 14:03:31 -07:00
media
memory
memstick
message
mfd
misc Char/Misc fixes for 6.11-rc4 2024-08-18 10:16:34 -07:00
mmc mmc: mmc_test: Fix NULL dereference on allocation failure 2024-08-20 13:47:36 +02:00
most
mtd
mux
net Regressions: 2024-08-28 16:54:45 -07:00
nfc nfc: pn533: Add poll mod list filling check 2024-08-29 12:08:44 +02:00
ntb
nubus
nvdimm
nvme nvme: Remove unused field 2024-08-22 13:28:40 -07:00
nvmem
of A revert for a previous TTM commit causing stuttering, 3 fixes for 2024-08-30 11:28:11 +10:00
opp
parisc
parport
pci pci-v6.11-fixes-2 2024-08-31 14:54:11 +12:00
pcmcia
peci
perf
phy
pinctrl pinctrl: rockchip: correct RK3328 iomux width flag for GPIO2-B pins 2024-08-24 16:39:51 +02:00
platform platform-drivers-x86 for v6.11-5 2024-08-29 07:12:02 +12:00
pmdomain
pnp
power power sequencing fixes for v6.11-rc6 2024-09-01 09:07:44 +12:00
powercap
pps
ps3
ptp
pwm
rapidio
ras
regulator
remoteproc
reset
rpmsg
rtc
s390 s390 updates for 6.11-rc5 2024-08-25 12:05:23 +12:00
sbus
scsi SCSI fixes on 20240831 2024-09-01 07:00:38 +12:00
sh
siox
slimbus
soc Qualcomm driver fixes for v6.11 2024-08-28 20:27:39 +00:00
soundwire soundwire: stream: fix programming slave ports for non-continous port maps 2024-08-17 22:55:05 +05:30
spi spi: pxa2xx: Move PM runtime handling to the glue drivers 2024-08-22 13:34:06 +01:00
spmi
ssb
staging Kbuild fixes for v6.11 (2nd) 2024-08-23 07:43:15 +08:00
target
tc
tee
thermal thermal: of: Fix OF node leak in of_thermal_zone_find() error paths 2024-08-22 20:58:49 +02:00
thunderbolt
tty
ufs scsi: ufs: qcom: Add UFSHCD_QUIRK_BROKEN_LSDBS_CAP for SM8550 SoC 2024-08-16 21:09:17 -04:00
uio
usb USB fixes for 6.11-rc6 2024-09-01 07:06:28 +12:00
vdpa
vfio
vhost
video video/aperture: optionally match the device in sysfb_disable() 2024-08-26 19:14:48 -04:00
virt
virtio
w1
watchdog
xen
zorro
Kconfig
Makefile