All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org
Cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [bug report] mm: memcontrol: switch to rstat
Date: Mon, 5 Jul 2021 12:40:12 +0300	[thread overview]
Message-ID: <YOLTfDNPZA1BYiok@mwanda> (raw)

Hello Johannes Weiner,

The patch 2d146aa3aa84: "mm: memcontrol: switch to rstat" from Apr
29, 2021, leads to the following static checker warning:

	kernel/cgroup/rstat.c:200 cgroup_rstat_flush()
	warn: sleeping in atomic context

mm/memcontrol.c
  3572  static unsigned long mem_cgroup_usage(struct mem_cgroup *memcg, bool swap)
  3573  {
  3574          unsigned long val;
  3575  
  3576          if (mem_cgroup_is_root(memcg)) {
  3577                  cgroup_rstat_flush(memcg->css.cgroup);
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This is from static analysis and potentially a false positive.  The
problem is that mem_cgroup_usage() is called from __mem_cgroup_threshold()
which holds an rcu_read_lock().  And the cgroup_rstat_flush() function
can sleep.

  3578                  val = memcg_page_state(memcg, NR_FILE_PAGES) +
  3579                          memcg_page_state(memcg, NR_ANON_MAPPED);
  3580                  if (swap)
  3581                          val += memcg_page_state(memcg, MEMCG_SWAP);
  3582          } else {
  3583                  if (!swap)
  3584                          val = page_counter_read(&memcg->memory);
  3585                  else
  3586                          val = page_counter_read(&memcg->memsw);
  3587          }
  3588          return val;
  3589  }

regards,
dan carpenter

                 reply	other threads:[~2021-07-05  9:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=YOLTfDNPZA1BYiok@mwanda \
    --to=dan.carpenter-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.