Re: [PATCH 1/4] mm/pgtable: Fix continue to preallocate pmds even if failure occurrence

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Dave,
On Thu, Aug 15, 2013 at 10:55:22AM -0700, Dave Hansen wrote:
>On 08/14/2013 05:31 PM, Wanpeng Li wrote:
>> preallocate_pmds will continue to preallocate pmds even if failure 
>> occurrence, and then free all the preallocate pmds if there is 
>> failure, this patch fix it by stop preallocate if failure occurrence
>> and go to free path.
>
>I guess there are a billion ways to do this, but I'm not sure we even
>need 'failed':
>
>--- arch/x86/mm/pgtable.c.orig	2013-08-15 10:52:15.145615027 -0700
>+++ arch/x86/mm/pgtable.c	2013-08-15 10:52:47.509614081 -0700
>@@ -196,21 +196,18 @@
> static int preallocate_pmds(pmd_t *pmds[])
> {
> 	int i;
>-	bool failed = false;
>
> 	for(i = 0; i < PREALLOCATED_PMDS; i++) {
> 		pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
> 		if (pmd == NULL)
>-			failed = true;
>+			goto err;
> 		pmds[i] = pmd;
> 	}
>
>-	if (failed) {
>-		free_pmds(pmds);
>-		return -ENOMEM;
>-	}
>-
> 	return 0;
>+err:
>+	free_pmds(pmds);
>+	return -ENOMEM;
> }
>

Thanks for your review, I will fold above to my patch. ;-)

Regards,
Wanpeng Li 

>I don't have a problem with what you have, though.  It's better than
>what was there, so:
>
>Reviewed-by: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
>
>--
>To unsubscribe, send a message with 'unsubscribe linux-mm' in
>the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
>see: http://www.linux-mm.org/ .
>Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]