lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140515090142.GB3938@dhcp22.suse.cz>
Date:	Thu, 15 May 2014 11:01:42 +0200
From:	Michal Hocko <mhocko@...e.cz>
To:	Jianyu Zhan <nasa4836@...il.com>
Cc:	akpm@...ux-foundation.org, 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 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.

> Signed-off-by: Jianyu Zhan <nasa4836@...il.com>
> ---
>  mm/hugetlb.c | 26 +++++++++++++-------------
>  1 file changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 26b1464..e81c69e 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -1246,24 +1246,17 @@ static struct page *alloc_huge_page(struct vm_area_struct *vma,
>  			return ERR_PTR(-ENOSPC);
>  
>  	ret = hugetlb_cgroup_charge_cgroup(idx, pages_per_huge_page(h), &h_cg);
> -	if (ret) {
> -		if (chg || avoid_reserve)
> -			hugepage_subpool_put_pages(spool, 1);
> -		return ERR_PTR(-ENOSPC);
> -	}
> +	if (ret)
> +		goto out_subpool_put;
> +
>  	spin_lock(&hugetlb_lock);
>  	page = dequeue_huge_page_vma(h, vma, addr, avoid_reserve, chg);
>  	if (!page) {
>  		spin_unlock(&hugetlb_lock);
>  		page = alloc_buddy_huge_page(h, NUMA_NO_NODE);
> -		if (!page) {
> -			hugetlb_cgroup_uncharge_cgroup(idx,
> -						       pages_per_huge_page(h),
> -						       h_cg);
> -			if (chg || avoid_reserve)
> -				hugepage_subpool_put_pages(spool, 1);
> -			return ERR_PTR(-ENOSPC);
> -		}
> +		if (!page)
> +			goto out_uncharge_cgroup;
> +
>  		spin_lock(&hugetlb_lock);
>  		list_move(&page->lru, &h->hugepage_activelist);
>  		/* Fall through */
> @@ -1275,6 +1268,13 @@ static struct page *alloc_huge_page(struct vm_area_struct *vma,
>  
>  	vma_commit_reservation(h, vma, addr);
>  	return page;
> +
> +out_uncharge_cgroup:
> +	hugetlb_cgroup_uncharge_cgroup(idx, pages_per_huge_page(h), h_cg);
> +out_subpool_put:
> +	if (chg || avoid_reserve)
> +		hugepage_subpool_put_pages(spool, 1);
> +	return ERR_PTR(-ENOSPC);
>  }
>  
>  /*
> -- 
> 2.0.0-rc3
> 

-- 
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ