Skip to content

RFC mm/vmstat: Reduce zone lock hold time when reading /proc/pagetypeinfo

Michal Hocko linux-api linux-mm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 23 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2mm, vmstat: hide /proc/pagetypeinfo from normal usersmm/vmstat.c+1 -16 replies
2/2mm, vmstat: reduce zone->lock holding time by /proc/pagetypeinfomm/vmstat.c+18 -122 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchMel GormanVlastimil BabkaWaiman LongRafael AquiniDavid Rientjes
1/2A-b A-b A-b A-b A-b
2/2A-b A-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 5 reviewers.

Read the v1 thread

Cover letter [RFC PATCH 0/2] mm/vmstat: Reduce zone lock hold time when reading /proc/pagetypeinfo
Quoted 6 lines · Mel Gorman
Quoted 3 lines · Michal Hocko

So can we go with this to address the security aspect of this and have something trivial to backport.

Yes.

Ok, patch 1 in reply to this email.

Quoted 39 lines
Quoted 29 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

There is a free_area structure associated with each page order. There is also a nr_free count within the free_area for all the different migration types combined. Tracking the number of free list entries for each migration type will probably add some overhead to the fast paths like moving pages from one migration type to another which may not be desirable.

Quoted 5 lines
Quoted 2 lines

Have you tried to measure that overhead?

I would prefer this option not be taken. It would increase the cost of watermark calculations which is a relatively fast path.

Is the change for the wmark check going to require more than

mm/page_alloc.c +0 -3
index c0b2e0306720..5d95313ba4a5 100644
@@ -3448,9 +3448,6 @@ bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark,
 		struct free_area *area = &z->free_area[o];
 		int mt;
 
-		if (!area->nr_free)
-			continue;
-
 		for (mt = 0; mt < MIGRATE_PCPTYPES; mt++) {
 			if (!free_area_empty(area, mt))
 				return true;
Quoted 5 lines

Is this really going to be visible in practice? Sure we are going to do more checks but most orders tend to have at least some memory in a reasonably balanced system and we can hardly expect an optimal allocation path on those that are not.

You also have to iterate over them all later in the same function. The the free counts are per migrate type then they would have to be iterated over every time.

Quoted 6 lines

Similarly, there would be multiple places where all the counters would have to be iterated -- find_suitable_fallback, show_free_areas, fast_isolate_freepages, fill_contig_page_info, zone_init_free_lists etc.

It'd be a small cost but given that it's aimed at fixing a problem with reading pagetypeinfo, is it really worth it? I don't think so.

Fair enough.

[...]

Quoted 8 lines
Quoted 7 lines

As pointed out in other email. The problem with this patch is that it hasn't really removed the iteration over the whole free_list which is the primary problem. So I think that we should either consider this a non-issue and make it "admin knows this is potentially expensive" or do something like Andrew was suggesting if we do not want to change the nr_free accounting.

Quoted 11 lines

Again, the cost is when reading a proc file. From what Andrew said, the lock is necessary to safely walk the list but if anything. I would be ok with limiting the length of the walk but honestly, I would also be ok with simply deleting the proc file. The utility for debugging a problem with it is limited now (it was more important when fragmentation avoidance was first introduced) and there is little an admin can do with the information. I can't remember the last time I asked for the contents of the file when trying to debug a problem. There is a possibility that someone will complain but I'm not aware of any utility that reads the information and does something useful with it. In the unlikely event something breaks, the file can be re-added with a limited walk.

I went with a bound to the pages iteratred over in the free_list. See patch 2.

Signature · 2 lines
Michal Hocko
SUSE Labs