[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140516075730.GA22818@dhcp22.suse.cz>
Date: Fri, 16 May 2014 09:57:30 +0200
From: Michal Hocko <mhocko@...e.cz>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Jianyu Zhan <nasa4836@...il.com>, iamjoonsoo.kim@....com,
aneesh.kumar@...ux.vnet.ibm.com, n-horiguchi@...jp.nec.com,
aarcange@...hat.com, steve.capper@...aro.org, davidlohr@...com,
kirill.shutemov@...ux.intel.com, dave.hansen@...ux.intel.com,
linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm, hugetlb: move the error handle logic out of normal
code path
On Thu 15-05-14 15:36:20, Andrew Morton wrote:
> On Thu, 15 May 2014 11:01:42 +0200 Michal Hocko <mhocko@...e.cz> wrote:
>
> > On Wed 14-05-14 15:10:59, Jianyu Zhan wrote:
> > > alloc_huge_page() now mixes normal code path with error handle logic.
> > > This patches move out the error handle logic, to make normal code
> > > path more clean and redue code duplicate.
> >
> > I don't know. Part of the function returns and cleans up on its own and
> > other part relies on clean up labels. This is not so much nicer than the
> > previous state.
>
> That's actually a common pattern:
>
> foo()
> {
> if (check which doesn't change any state)
> return -Efoo;
> if (another check which doesn't change any state)
> return -Ebar;
>
> do_something_which_changes_state()
>
> if (another check)
> goto undo_that_state_chage;
> ...
>
> undo_that_state_change:
> ...
> }
Right. I have misread the previous vma_needs_reservation and
hugepage_subpool_get_pages error path and already considered it as a
changing state one. Sorry about the confusion.
--
Michal Hocko
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists