linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC 0/3] mm/vmalloc.c: allow vread() to read out vm_map_ram areas
@ 2022-11-09  3:35 Baoquan He
  2022-11-09  3:35 ` [PATCH RFC 1/3] mm/vmalloc.c: add used_map into vmap_block to track space of vmap_block Baoquan He
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Baoquan He @ 2022-11-09  3:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-mm, akpm, stephen.s.brennan, urezki, hch, Baoquan He

Problem:
***
Stephen reported vread() will skip vm_map_ram areas when reading out
/proc/kcore with drgn utility. Please see below link to get more about
it:

  /proc/kcore reads 0's for vmap_block
  https://lore.kernel.org/all/87ilk6gos2.fsf@oracle.com/T/#u

Root cause:
***
The normal vmalloc API uses struct vmap_area to manage the virtual
kernel area allocated and associate a vm_struct to store more information
and passed out. However, area reserved through vm_map_ram() interface
doesn't allocate vm_struct to bind with. So the current code in vread()
will skip the vm_map_ram area by 'if (!va->vm)' conditional checking.

Solution:
***
There are two types of vm_map_ram area. One is the whole vmap_area being
reserved and mapped at one time; the other is the whole vmap_area with
VMAP_BLOCK_SIZE size being reserved at one time, while mapped into split
regions with smaller size several times.

In patch 1 and 2, add flags into struct vmap_area to mark these two types
of vm_map_ram area, meanwhile add bitmap field used_map into struct
vmap_block to mark those regions being used to differentiate with dirty
and free regions.

With the help of above vmap_area->flags and vmap_block->used_map, we can
recognize them in vread() and handle them respectively.

Test:
***
I don't know what system has vm_map_ram() area. So just pass compiling
test and execute "makedumpfile --mem-usage /proc/kcore" to guarantee it
won't impact the old kcore reading.

	[root@ibm-x3950x6-01 ~]# free -h
	               total        used        free      shared  buff/cache   available
	Mem:           3.9Ti       3.6Gi       3.9Ti       7.0Mi       497Mi       3.9Ti
	Swap:          8.0Gi          0B       8.0Gi
	[root@ibm-x3950x6-01 ~]# makedumpfile --mem-usage /proc/kcore
	The kernel version is not supported.
	The makedumpfile operation may be incomplete.
	
	TYPE		PAGES			EXCLUDABLE	DESCRIPTION
	----------------------------------------------------------------------
	ZERO		327309          	yes		Pages filled with zero
	NON_PRI_CACHE	81750           	yes		Cache pages without private flag
	PRI_CACHE	83981           	yes		Cache pages with private flag
	USER		12735           	yes		User process pages
	FREE		1055688908      	yes		Free pages
	KERN_DATA	17464385        	no		Dumpable kernel data 
	
	page size:		4096            
	Total pages on system:	1073659068      
	Total size on system:	4397707542528    Byte


Baoquan He (3):
  mm/vmalloc.c: add used_map into vmap_block to track space of
    vmap_block
  mm/vmalloc.c: add flags to mark vm_map_ram area
  mm/vmalloc.c: allow vread() to read out vm_map_ram areas

 include/linux/vmalloc.h |  1 +
 mm/vmalloc.c            | 81 +++++++++++++++++++++++++++++++++++++----
 2 files changed, 75 insertions(+), 7 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-12-01  4:47 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-09  3:35 [PATCH RFC 0/3] mm/vmalloc.c: allow vread() to read out vm_map_ram areas Baoquan He
2022-11-09  3:35 ` [PATCH RFC 1/3] mm/vmalloc.c: add used_map into vmap_block to track space of vmap_block Baoquan He
2022-11-09  3:35 ` [PATCH RFC 2/3] mm/vmalloc.c: add flags to mark vm_map_ram area Baoquan He
2022-11-09  3:35 ` [PATCH RFC 3/3] mm/vmalloc.c: allow vread() to read out vm_map_ram areas Baoquan He
2022-11-10  0:59   ` Stephen Brennan
2022-11-10 10:23     ` Baoquan He
2022-11-10 18:48       ` Stephen Brennan
2022-11-14 10:06         ` Baoquan He
2022-11-18  8:01   ` Matthew Wilcox
2022-11-23  3:38     ` Baoquan He
2022-11-23 13:24       ` Matthew Wilcox
2022-11-24  9:52         ` Baoquan He
2022-11-30 13:06           ` Uladzislau Rezki
2022-12-01  4:46             ` Baoquan He

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).