linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: zhengqi.arch@bytedance.com
Cc: linux-mm@kvack.org
Subject: [bug report] mm: shrinker: add a secondary array for shrinker_info::{map, nr_deferred}
Date: Thu, 28 Sep 2023 16:03:59 +0300	[thread overview]
Message-ID: <f960ae49-078c-4c00-9516-da31fc1a17d6@moroto.mountain> (raw)

Hello Qi Zheng,

The patch b6884b5f15cf: "mm: shrinker: add a secondary array for
shrinker_info::{map, nr_deferred}" from Sep 11, 2023 (linux-next),
leads to the following Smatch static checker warning:

	mm/shrinker.c:100 alloc_shrinker_info()
	warn: inconsistent returns '&shrinker_mutex'.

mm/shrinker.c
    77 int alloc_shrinker_info(struct mem_cgroup *memcg)
    78 {
    79         struct shrinker_info *info;
    80         int nid, ret = 0;
    81         int array_size = 0;
    82 
    83         mutex_lock(&shrinker_mutex);
    84         array_size = shrinker_unit_size(shrinker_nr_max);
    85         for_each_node(nid) {
    86                 info = kvzalloc_node(sizeof(*info) + array_size, GFP_KERNEL, nid);
    87                 if (!info)
    88                         goto err;
                               ^^^^^^^^^

    89                 info->map_nr_max = shrinker_nr_max;
    90                 if (shrinker_unit_alloc(info, NULL, nid))
    91                         goto err;
                               ^^^^^^^^
These error paths need to unlock.  I'm not 100% positive if you want to
unlock before or after the call to free_shrinker_info().

    92                 rcu_assign_pointer(memcg->nodeinfo[nid]->shrinker_info, info);
    93         }
    94         mutex_unlock(&shrinker_mutex);
    95 
    96         return ret;
    97 
    98 err:
    99         free_shrinker_info(memcg);
-->100         return -ENOMEM;
   101 }

regards,
dan carpenter


             reply	other threads:[~2023-09-28 13:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-28 13:03 Dan Carpenter [this message]
2023-09-28 13:26 ` [External] " Qi Zheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f960ae49-078c-4c00-9516-da31fc1a17d6@moroto.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=linux-mm@kvack.org \
    --cc=zhengqi.arch@bytedance.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox