Skip to content

Commit 12aee27

Browse files
committed
Merge branch 'akpm' (fixes from Andrew Morton)
Merge three fixes from Andrew Morton. * emailed patches from Andrew Morton <akpm@linux-foundation.org>: memcg: use __this_cpu_sub() to dec stats to avoid incorrect subtrahend casting percpu: fix this_cpu_sub() subtrahend casting for unsigneds mm/pagewalk.c: fix walk_page_range() access of wrong PTEs
2 parents c56b097 + 5e8cfc3 commit 12aee27

4 files changed

Lines changed: 8 additions & 7 deletions

File tree

‎arch/x86/include/asm/percpu.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ do { \
128128
do { \
129129
typedef typeof(var) pao_T__; \
130130
const int pao_ID__ = (__builtin_constant_p(val) && \
131-
((val) == 1 || (val) == -1)) ? (val) : 0; \
131+
((val) == 1 || (val) == -1)) ? \
132+
(int)(val) : 0; \
132133
if (0) { \
133134
pao_T__ pao_tmp__; \
134135
pao_tmp__ = (val); \

‎include/linux/percpu.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ do { \
332332
#endif
333333

334334
#ifndef this_cpu_sub
335-
# define this_cpu_sub(pcp, val) this_cpu_add((pcp), -(val))
335+
# define this_cpu_sub(pcp, val) this_cpu_add((pcp), -(typeof(pcp))(val))
336336
#endif
337337

338338
#ifndef this_cpu_inc
@@ -418,7 +418,7 @@ do { \
418418
# define this_cpu_add_return(pcp, val) __pcpu_size_call_return2(this_cpu_add_return_, pcp, val)
419419
#endif
420420

421-
#define this_cpu_sub_return(pcp, val) this_cpu_add_return(pcp, -(val))
421+
#define this_cpu_sub_return(pcp, val) this_cpu_add_return(pcp, -(typeof(pcp))(val))
422422
#define this_cpu_inc_return(pcp) this_cpu_add_return(pcp, 1)
423423
#define this_cpu_dec_return(pcp) this_cpu_add_return(pcp, -1)
424424

@@ -586,7 +586,7 @@ do { \
586586
#endif
587587

588588
#ifndef __this_cpu_sub
589-
# define __this_cpu_sub(pcp, val) __this_cpu_add((pcp), -(val))
589+
# define __this_cpu_sub(pcp, val) __this_cpu_add((pcp), -(typeof(pcp))(val))
590590
#endif
591591

592592
#ifndef __this_cpu_inc
@@ -668,7 +668,7 @@ do { \
668668
__pcpu_size_call_return2(__this_cpu_add_return_, pcp, val)
669669
#endif
670670

671-
#define __this_cpu_sub_return(pcp, val) __this_cpu_add_return(pcp, -(val))
671+
#define __this_cpu_sub_return(pcp, val) __this_cpu_add_return(pcp, -(typeof(pcp))(val))
672672
#define __this_cpu_inc_return(pcp) __this_cpu_add_return(pcp, 1)
673673
#define __this_cpu_dec_return(pcp) __this_cpu_add_return(pcp, -1)
674674

‎mm/memcontrol.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3774,7 +3774,7 @@ void mem_cgroup_move_account_page_stat(struct mem_cgroup *from,
37743774
/* Update stat data for mem_cgroup */
37753775
preempt_disable();
37763776
WARN_ON_ONCE(from->stat->count[idx] < nr_pages);
3777-
__this_cpu_add(from->stat->count[idx], -nr_pages);
3777+
__this_cpu_sub(from->stat->count[idx], nr_pages);
37783778
__this_cpu_add(to->stat->count[idx], nr_pages);
37793779
preempt_enable();
37803780
}

‎mm/pagewalk.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ int walk_page_range(unsigned long addr, unsigned long end,
242242
if (err)
243243
break;
244244
pgd++;
245-
} while (addr = next, addr != end);
245+
} while (addr = next, addr < end);
246246

247247
return err;
248248
}

0 commit comments

Comments
 (0)