linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yafang Shao <laoar.shao@gmail.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@kernel.org>,
	 Vladimir Davydov <vdavydov.dev@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	 Linux MM <linux-mm@kvack.org>
Subject: Re: [PATCH v2] mm, memcg: fix error return value of mem_cgroup_css_alloc()
Date: Tue, 7 Apr 2020 00:51:16 +0800	[thread overview]
Message-ID: <CALOAHbCR_KRm5XeAFNZX+iJp_bvC6A57rkgRKob=Opq_gM51ig@mail.gmail.com> (raw)
In-Reply-To: <20200406164251.GE21484@bombadil.infradead.org>

On Tue, Apr 7, 2020 at 12:42 AM Matthew Wilcox <willy@infradead.org> wrote:
>
> On Mon, Apr 06, 2020 at 11:48:54PM +0800, Yafang Shao wrote:
> > @@ -2717,8 +2717,12 @@ static int memcg_alloc_cache_id(void)
> >
> >       id = ida_simple_get(&memcg_cache_ida,
> >                           0, MEMCG_CACHES_MAX_SIZE, GFP_KERNEL);
> > -     if (id < 0)
> > +     if (id < 0) {
> > +             if (id == -ENOSPC)
> > +                     id = -EBUSY;
> > +
> >               return id;
> > +     }
>
> This seems more complex than my original suggestion?
>

I thought the (id < 0) is an unlikely case, writing it like this only
checks id once for the most common case, while your original
suggestion will check id twice if the compiler is not good enough.
But that is not a big problem, I can change it as you suggestion. Your
suggestion is more readable.


Thanks
Yafang


  reply	other threads:[~2020-04-06 16:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-06 15:48 Yafang Shao
2020-04-06 16:42 ` Matthew Wilcox
2020-04-06 16:51   ` Yafang Shao [this message]
2020-04-07  6:36 ` Michal Hocko
2020-04-07  6:44   ` 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='CALOAHbCR_KRm5XeAFNZX+iJp_bvC6A57rkgRKob=Opq_gM51ig@mail.gmail.com' \
    --to=laoar.shao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=vdavydov.dev@gmail.com \
    --cc=willy@infradead.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