Skip to content

Replace kmalloc with vmalloc in seq_files

Colin Cross linux-fsdevel lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 9 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3fs: seq_file: add seq_reservefs/seq_file.c include/linux/seq_file.h+31 -02 replies
2/3sched_stats: use the new seq_reserve functionfs/proc/stat.c kernel/sched_stats.h+17 -240 replies
3/3seq_file: convert seq buffer to vmallocfs/seq_file.c+10 -134 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] Replace kmalloc with vmalloc in seq_files

When a seq_file is implemented with single_open, the show function will be called with a kmalloc'd PAGE_SIZE buffer. If the show function produces more data than can fit in the buffer, the buffer will be thrown away, and the show function will be called again with a buffer twice as large. This process repeats until the show function does not overflow the buffer, or kmalloc fails.

seq_files are often used for debugging data. When the system is under memory pressure, and dumping debugging data starts trying to allocate large physically contiguous buffers, it often makes the problem worse.

Since there is no need for a physically contiguous buffer, this patch set converts the kmalloc'd buffers into vmallocs. There are two seq_file users that kmalloc buffer and place it directly into the seq_file structure, later to be freed by seq_release. Convert those to call a new seq_reserve function that will do the correct allocation for them.