On Fri, 2013-04-19 at 08:33 +0900, Yasuaki Ishimatsu wrote: : > > > >> +static struct resource *get_resource(gfp_t flags) > >> +{ > >> + struct resource *res = NULL; > >> + > >> + spin_lock(&bootmem_resource_lock); > >> + if (bootmem_resource.sibling) { > >> + res = bootmem_resource.sibling; > >> + bootmem_resource.sibling = res->sibling; > >> + memset(res, 0, sizeof(struct resource)); > >> + } > >> + spin_unlock(&bootmem_resource_lock); > > > > > I prefer to keep memset() outside of the spin lock. > > > > spin_lock(&bootmem_resource_lock); > > if (..) { > > : > > spin_unlock(&bootmem_resource_lock); > > memset(res, 0, sizeof(struct resource)); > > } else { > > spin_unlock(&bootmem_resource_lock); > > res = kzalloc(sizeof(struct resource), flags); > > } > > Hmm. It is a little ugly. How about it? > > spin_lock(&bootmem_resource_lock); > if (bootmem_resource.sibling) { > res = bootmem_resource.sibling; > bootmem_resource.sibling = res->sibling; > } > spin_unlock(&bootmem_resource_lock); > > if (res) > memset(res, 0, sizeof(struct resource)); > else > res = kzalloc(sizeof(struct resource), flags); Sounds good to me. Thanks, -Toshi -- 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>