Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1497040

Re: [RFC PATCH] mm, compaction: allow compaction for GFP_NOFS requests

From Michal Hocko <mhocko@kernel.org>
Newsgroups linux.kernel
Subject Re: [RFC PATCH] mm, compaction: allow compaction for GFP_NOFS requests
Date 2016-10-07 09:00 +0200
Message-ID <spxip-4Mo-15@gated-at.bofh.it> (permalink)
References <sot7d-4Y-45@gated-at.bofh.it> <spvTj-3Nt-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri 07-10-16 07:27:37, Vlastimil Babka wrote:
[...]
> > diff --git a/mm/compaction.c b/mm/compaction.c
> > index badb92bf14b4..07254a73ee32 100644
> > --- a/mm/compaction.c
> > +++ b/mm/compaction.c
> > @@ -834,6 +834,13 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
> >  		    page_count(page) > page_mapcount(page))
> >  			goto isolate_fail;
> > 
> > +		/*
> > +		 * Only allow to migrate anonymous pages in GFP_NOFS context
> > +		 * because those do not depend on fs locks.
> > +		 */
> > +		if (!(cc->gfp_mask & __GFP_FS) && page_mapping(page))
> > +			goto isolate_fail;
> 
> Unless page can acquire a page_mapping between this check and migration, I
> don't see a problem with allowing this.

It can be become swapcache but I guess this should be OK. We do not
allow to get here with GFP_NOIO and migrating swapcache pages in NOFS
mode should be OK AFAICS.

> But make sure you don't break kcompactd and manual compaction from /proc, as
> they don't currently set cc->gfp_mask. Looks like until now it was only used
> to determine direct compactor's migratetype which is irrelevant in those
> contexts.

OK, I see. This is really subtle. One way to go would be to provide a
fake gfp_mask for them. How does the following look to you?
---
diff --git a/mm/compaction.c b/mm/compaction.c
index 557c165b63ad..d1d90e96ef4b 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -1779,6 +1779,7 @@ static void compact_node(int nid)
 		.mode = MIGRATE_SYNC,
 		.ignore_skip_hint = true,
 		.whole_zone = true,
+		.gfp_mask = GFP_KERNEL,
 	};
 
 
@@ -1904,6 +1905,7 @@ static void kcompactd_do_work(pg_data_t *pgdat)
 		.classzone_idx = pgdat->kcompactd_classzone_idx,
 		.mode = MIGRATE_SYNC_LIGHT,
 		.ignore_skip_hint = true,
+		.gfp_mask = GFP_KERNEL,
 
 	};
 	trace_mm_compaction_kcompactd_wake(pgdat->node_id, cc.order,
-- 
Michal Hocko
SUSE Labs

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC PATCH] mm, compaction: allow compaction for GFP_NOFS requests Michal Hocko <mhocko@kernel.org> - 2016-10-04 10:20 +0200
  Re: [RFC PATCH] mm, compaction: allow compaction for GFP_NOFS  requests Dave Chinner <david@fromorbit.com> - 2016-10-04 22:40 +0200
    Re: [RFC PATCH] mm, compaction: allow compaction for GFP_NOFS  requests Michal Hocko <mhocko@kernel.org> - 2016-10-05 13:40 +0200
      Re: [RFC PATCH] mm, compaction: allow compaction for GFP_NOFS  requests Dave Chinner <david@fromorbit.com> - 2016-10-06 04:20 +0200
        Re: [RFC PATCH] mm, compaction: allow compaction for GFP_NOFS  requests Michal Hocko <mhocko@kernel.org> - 2016-10-07 15:20 +0200
          Re: [RFC PATCH] mm, compaction: allow compaction for GFP_NOFS  requests Dave Chinner <david@fromorbit.com> - 2016-10-13 02:30 +0200
  Re: [RFC PATCH] mm, compaction: allow compaction for GFP_NOFS  requests Vlastimil Babka <vbabka@suse.cz> - 2016-10-07 07:30 +0200
    Re: [RFC PATCH] mm, compaction: allow compaction for GFP_NOFS  requests Michal Hocko <mhocko@kernel.org> - 2016-10-07 09:00 +0200
      Re: [RFC PATCH] mm, compaction: allow compaction for GFP_NOFS  requests Vlastimil Babka <vbabka@suse.cz> - 2016-10-07 10:20 +0200
        Re: [RFC PATCH] mm, compaction: allow compaction for GFP_NOFS  requests Michal Hocko <mhocko@kernel.org> - 2016-10-07 11:30 +0200
          Re: [RFC PATCH] mm, compaction: allow compaction for GFP_NOFS  requests Vlastimil Babka <vbabka@suse.cz> - 2016-10-10 08:50 +0200

csiph-web