From: Michal Hocko <mhocko@suse.cz>
To: Balbir Singh <bsingharora@gmail.com>
Cc: linux-mm@kvack.org,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] memcg: change memcg_oom_mutex to spinlock
Date: Wed, 20 Jul 2011 09:00:43 +0200 [thread overview]
Message-ID: <20110720070043.GB10857@tiehlicka.suse.cz> (raw)
In-Reply-To: <CAKTCnzkiRW3aLwnCYyb9XPfTZWipqcA5Jd7d27rZpecqn3wFuQ@mail.gmail.com>
On Wed 20-07-11 12:04:17, Balbir Singh wrote:
> On Thu, Jul 14, 2011 at 8:59 PM, Michal Hocko <mhocko@suse.cz> wrote:
> > memcg_oom_mutex is used to protect memcg OOM path and eventfd interface
> > for oom_control. None of the critical sections which it protects sleep
> > (eventfd_signal works from atomic context and the rest are simple linked
> > list resp. oom_lock atomic operations).
> > Mutex is also too heavy weight for those code paths because it triggers
> > a lot of scheduling. It also makes makes convoying effects more visible
> > when we have a big number of oom killing because we take the lock
> > mutliple times during mem_cgroup_handle_oom so we have multiple places
> > where many processes can sleep.
> >
> > Signed-off-by: Michal Hocko <mhocko@suse.cz>
>
> Quick question: How long do we expect this lock to be taken?
The lock is taken in
* mem_cgroup_handle_oom at 2 places
- to protect mem_cgroup_oom_lock and mem_cgroup_oom_notify
- to protect mem_cgroup_oom_unlock and memcg_wakeup_oom
mem_cgroup_oom_{un}lock as well as mem_cgroup_oom_notify scale with the
number of groups in the hierarchy.
mem_cgroup_oom_notify scales with the number of all blocked tasks on the
memcg_oom_waitq (which is not mem_cgroup specific) and
memcg_oom_wake_function can go up the hierarchy for all of them in the
worst case.
* mem_cgroup_oom_register_event uses it to protect notifier registration
(one list_add operation) + notification in case the group is already
under oom - we can consider both operations to be constant time
* mem_cgroup_oom_unregister_event protects unregistration so it scales
with the number of notifiers. I guess this is potentially unlimitted
but I wouldn't be afraid of that as we call just list_del to every
one.
> What happens under oom?
Could you be more specific? Does the above exaplains?
> Any tests? Numbers?
I was testing with the test mentioned in the other patch and I couldn't
measure any significant difference. That is why I noted that I do not
have any hard numbers to base my argumentation on. It is just that the
mutex doesn't _feel_ right in the code paths we are using it now.
> Balbir Singh
Thanks
--
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9
Czech Republic
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2011-07-20 7:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-15 12:26 [PATCH 0/2 v2 ] memcg: oom locking updates Michal Hocko
2011-07-13 11:05 ` [PATCH 1/2 v2] memcg: make oom_lock 0 and 1 based rather than coutner Michal Hocko
2011-07-21 20:58 ` Andrew Morton
2011-07-22 0:15 ` KAMEZAWA Hiroyuki
2011-08-09 14:03 ` Johannes Weiner
2011-08-09 15:22 ` Michal Hocko
2011-08-09 15:37 ` Johannes Weiner
2011-08-09 15:43 ` Michal Hocko
2011-08-10 0:22 ` KAMEZAWA Hiroyuki
2011-07-14 15:29 ` [PATCH 2/2] memcg: change memcg_oom_mutex to spinlock Michal Hocko
2011-07-20 5:55 ` KAMEZAWA Hiroyuki
2011-07-20 7:01 ` Michal Hocko
2011-07-20 6:34 ` Balbir Singh
2011-07-20 7:00 ` Michal Hocko [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-07-13 12:44 [PATCH 0/2] memcg: oom locking updates Michal Hocko
2011-07-13 12:32 ` [PATCH 2/2] memcg: change memcg_oom_mutex to spinlock Michal Hocko
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=20110720070043.GB10857@tiehlicka.suse.cz \
--to=mhocko@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=bsingharora@gmail.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox