linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Baoquan He <bhe@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org, akpm@linux-foundation.org,
	stephen.s.brennan@oracle.com, urezki@gmail.com,
	hch@infradead.org, Baoquan He <bhe@redhat.com>
Subject: [PATCH RFC 0/3] mm/vmalloc.c: allow vread() to read out vm_map_ram areas
Date: Wed,  9 Nov 2022 11:35:31 +0800	[thread overview]
Message-ID: <20221109033535.269229-1-bhe@redhat.com> (raw)

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



             reply	other threads:[~2022-11-09  3:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09  3:35 Baoquan He [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221109033535.269229-1-bhe@redhat.com \
    --to=bhe@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=stephen.s.brennan@oracle.com \
    --cc=urezki@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).