From: Michal Hocko <mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Yu Zhao <yuzhao-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Cc: Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>,
Vladimir Davydov
<vdavydov.dev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
n.borisov.lkml-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Subject: Re: [PATCH v3] memcg: refactor mem_cgroup_resize_limit()
Date: Tue, 13 Jun 2017 13:35:45 +0200 [thread overview]
Message-ID: <20170613113545.GH10819@dhcp22.suse.cz> (raw)
In-Reply-To: <20170604211807.32685-1-yuzhao-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
[Sorry for a late reponse]
On Sun 04-06-17 14:18:07, Yu Zhao wrote:
> mem_cgroup_resize_limit() and mem_cgroup_resize_memsw_limit() have
> identical logics. Refactor code so we don't need to keep two pieces
> of code that does same thing.
>
> Signed-off-by: Yu Zhao <yuzhao-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
> Acked-by: Vladimir Davydov <vdavydov.dev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
It is nice to see removal of the code duplication. I have one comment
though
[...]
> @@ -2498,22 +2449,24 @@ static int mem_cgroup_resize_memsw_limit(struct mem_cgroup *memcg,
> }
>
> mutex_lock(&memcg_limit_mutex);
> - if (limit < memcg->memory.limit) {
> + inverted = memsw ? limit < memcg->memory.limit :
> + limit > memcg->memsw.limit;
> + if (inverted) {
> mutex_unlock(&memcg_limit_mutex);
> ret = -EINVAL;
> break;
> }
This is just too ugly and hard to understand. inverted just doesn't give
you a good clue what is going on. What do you think about something like
/*
* Make sure that the new limit (memsw or hard limit) doesn't
* break our basic invariant that memory.limit <= memsw.limit
*/
limits_invariant = memsw ? limit >= memcg->memory.limit :
limit <= mmecg->memsw.limit;
if (!limits_invariant) {
mutex_unlock(&memcg_limit_mutex);
ret = -EINVAL;
break;
}
with that feel free to add
Acked-by: Michal Hocko <mhocko-IBi9RG/b67k@public.gmane.org>
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2017-06-13 11:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-01 23:02 [PATCH] memcg: refactor mem_cgroup_resize_limit() Yu Zhao
2017-06-02 7:32 ` Nikolay Borisov
2017-06-04 19:44 ` Yu Zhao
2017-06-03 15:15 ` Vladimir Davydov
2017-06-04 20:04 ` [PATCH v2] " Yu Zhao
2017-06-04 20:09 ` Vladimir Davydov
2017-06-04 20:31 ` Yu Zhao
2017-06-04 21:00 ` kbuild test robot
[not found] ` <20170604200437.17815-1-yuzhao-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2017-06-04 21:12 ` kbuild test robot
[not found] ` <20170601230212.30578-1-yuzhao-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2017-06-04 21:18 ` [PATCH v3] " Yu Zhao
[not found] ` <20170604211807.32685-1-yuzhao-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2017-06-13 11:35 ` Michal Hocko [this message]
2017-06-14 21:20 ` [PATCH v4] " Yu Zhao
2018-01-08 22:42 ` Yu Zhao
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=20170613113545.GH10819@dhcp22.suse.cz \
--to=mhocko-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
--cc=n.borisov.lkml-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=vdavydov.dev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=yuzhao-hpIqsD4AKlfQT0dZR+AlfA@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox