Commit f2f43e56 authored by Nick Desaulniers's avatar Nick Desaulniers Committed by Linus Torvalds

mm/vmscan.c: fix unsequenced modification and access warning

Clang and its -Wunsequenced emits a warning

  mm/vmscan.c:2961:25: error: unsequenced modification and access to 'gfp_mask' [-Wunsequenced]
                  .gfp_mask = (gfp_mask = current_gfp_context(gfp_mask)),
                                        ^

While it is not clear to me whether the initialization code violates the
specification (6.7.8 par 19 (ISO/IEC 9899) looks like it disagrees) the
code is quite confusing and worth cleaning up anyway.  Fix this by
reusing sc.gfp_mask rather than the updated input gfp_mask parameter.

Link: http://lkml.kernel.org/r/20170510154030.10720-1-nick.desaulniers@gmail.comSigned-off-by: default avatarNick Desaulniers <nick.desaulniers@gmail.com>
Acked-by: default avatarMichal Hocko <mhocko@suse.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ac34ceaf
...@@ -2967,7 +2967,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order, ...@@ -2967,7 +2967,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
unsigned long nr_reclaimed; unsigned long nr_reclaimed;
struct scan_control sc = { struct scan_control sc = {
.nr_to_reclaim = SWAP_CLUSTER_MAX, .nr_to_reclaim = SWAP_CLUSTER_MAX,
.gfp_mask = (gfp_mask = current_gfp_context(gfp_mask)), .gfp_mask = current_gfp_context(gfp_mask),
.reclaim_idx = gfp_zone(gfp_mask), .reclaim_idx = gfp_zone(gfp_mask),
.order = order, .order = order,
.nodemask = nodemask, .nodemask = nodemask,
...@@ -2982,12 +2982,12 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order, ...@@ -2982,12 +2982,12 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
* 1 is returned so that the page allocator does not OOM kill at this * 1 is returned so that the page allocator does not OOM kill at this
* point. * point.
*/ */
if (throttle_direct_reclaim(gfp_mask, zonelist, nodemask)) if (throttle_direct_reclaim(sc.gfp_mask, zonelist, nodemask))
return 1; return 1;
trace_mm_vmscan_direct_reclaim_begin(order, trace_mm_vmscan_direct_reclaim_begin(order,
sc.may_writepage, sc.may_writepage,
gfp_mask, sc.gfp_mask,
sc.reclaim_idx); sc.reclaim_idx);
nr_reclaimed = do_try_to_free_pages(zonelist, &sc); nr_reclaimed = do_try_to_free_pages(zonelist, &sc);
...@@ -3774,17 +3774,16 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in ...@@ -3774,17 +3774,16 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in
const unsigned long nr_pages = 1 << order; const unsigned long nr_pages = 1 << order;
struct task_struct *p = current; struct task_struct *p = current;
struct reclaim_state reclaim_state; struct reclaim_state reclaim_state;
int classzone_idx = gfp_zone(gfp_mask);
unsigned int noreclaim_flag; unsigned int noreclaim_flag;
struct scan_control sc = { struct scan_control sc = {
.nr_to_reclaim = max(nr_pages, SWAP_CLUSTER_MAX), .nr_to_reclaim = max(nr_pages, SWAP_CLUSTER_MAX),
.gfp_mask = (gfp_mask = current_gfp_context(gfp_mask)), .gfp_mask = current_gfp_context(gfp_mask),
.order = order, .order = order,
.priority = NODE_RECLAIM_PRIORITY, .priority = NODE_RECLAIM_PRIORITY,
.may_writepage = !!(node_reclaim_mode & RECLAIM_WRITE), .may_writepage = !!(node_reclaim_mode & RECLAIM_WRITE),
.may_unmap = !!(node_reclaim_mode & RECLAIM_UNMAP), .may_unmap = !!(node_reclaim_mode & RECLAIM_UNMAP),
.may_swap = 1, .may_swap = 1,
.reclaim_idx = classzone_idx, .reclaim_idx = gfp_zone(gfp_mask),
}; };
cond_resched(); cond_resched();
...@@ -3795,7 +3794,7 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in ...@@ -3795,7 +3794,7 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in
*/ */
noreclaim_flag = memalloc_noreclaim_save(); noreclaim_flag = memalloc_noreclaim_save();
p->flags |= PF_SWAPWRITE; p->flags |= PF_SWAPWRITE;
lockdep_set_current_reclaim_state(gfp_mask); lockdep_set_current_reclaim_state(sc.gfp_mask);
reclaim_state.reclaimed_slab = 0; reclaim_state.reclaimed_slab = 0;
p->reclaim_state = &reclaim_state; p->reclaim_state = &reclaim_state;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment