2014-12-06 16:43:19

by Rickard Strandqvist

[permalink] [raw]
Subject: [PATCH] mm: memcontrol.c: Cleaning up function that are not used anywhere

Remove function mem_cgroup_lru_names_not_uptodate() that is not used anywhere.
And move BUILD_BUG_ON() to the beginning of memcg_stat_show() instead.

This was partially found by using a static code analysis program called cppcheck.

Signed-off-by: Rickard Strandqvist <[email protected]>
---
mm/memcontrol.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index d6ac0e3..5e2f0f3 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4379,17 +4379,14 @@ static int memcg_numa_stat_show(struct seq_file *m, void *v)
}
#endif /* CONFIG_NUMA */

-static inline void mem_cgroup_lru_names_not_uptodate(void)
-{
- BUILD_BUG_ON(ARRAY_SIZE(mem_cgroup_lru_names) != NR_LRU_LISTS);
-}
-
static int memcg_stat_show(struct seq_file *m, void *v)
{
struct mem_cgroup *memcg = mem_cgroup_from_css(seq_css(m));
struct mem_cgroup *mi;
unsigned int i;

+ BUILD_BUG_ON(ARRAY_SIZE(mem_cgroup_lru_names) != NR_LRU_LISTS);
+
for (i = 0; i < MEM_CGROUP_STAT_NSTATS; i++) {
if (i == MEM_CGROUP_STAT_SWAP && !do_swap_account)
continue;
--
1.7.10.4


2014-12-07 10:31:12

by Michal Hocko

[permalink] [raw]
Subject: Re: [PATCH] mm: memcontrol.c: Cleaning up function that are not used anywhere

On Sat 06-12-14 17:45:56, Rickard Strandqvist wrote:
> Remove function mem_cgroup_lru_names_not_uptodate() that is not used anywhere.
> And move BUILD_BUG_ON() to the beginning of memcg_stat_show() instead.
>
> This was partially found by using a static code analysis program called cppcheck.
>
> Signed-off-by: Rickard Strandqvist <[email protected]>

Acked-by: Michal Hocko <[email protected]>

> ---
> mm/memcontrol.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index d6ac0e3..5e2f0f3 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -4379,17 +4379,14 @@ static int memcg_numa_stat_show(struct seq_file *m, void *v)
> }
> #endif /* CONFIG_NUMA */
>
> -static inline void mem_cgroup_lru_names_not_uptodate(void)
> -{
> - BUILD_BUG_ON(ARRAY_SIZE(mem_cgroup_lru_names) != NR_LRU_LISTS);
> -}
> -
> static int memcg_stat_show(struct seq_file *m, void *v)
> {
> struct mem_cgroup *memcg = mem_cgroup_from_css(seq_css(m));
> struct mem_cgroup *mi;
> unsigned int i;
>
> + BUILD_BUG_ON(ARRAY_SIZE(mem_cgroup_lru_names) != NR_LRU_LISTS);
> +
> for (i = 0; i < MEM_CGROUP_STAT_NSTATS; i++) {
> if (i == MEM_CGROUP_STAT_SWAP && !do_swap_account)
> continue;
> --
> 1.7.10.4
>

--
Michal Hocko
SUSE Labs

2014-12-08 16:02:50

by Johannes Weiner

[permalink] [raw]
Subject: Re: [PATCH] mm: memcontrol.c: Cleaning up function that are not used anywhere

On Sat, Dec 06, 2014 at 05:45:56PM +0100, Rickard Strandqvist wrote:
> Remove function mem_cgroup_lru_names_not_uptodate() that is not used anywhere.
> And move BUILD_BUG_ON() to the beginning of memcg_stat_show() instead.
>
> This was partially found by using a static code analysis program called cppcheck.
>
> Signed-off-by: Rickard Strandqvist <[email protected]>

Looks good, thanks for following up.

Acked-by: Johannes Weiner <[email protected]>