Re: [Bug fix PATCH v4] Reusing a resource structure allocated by bootmem

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

 



2013/04/18 22:42, Johannes Weiner wrote:
On Thu, Apr 18, 2013 at 05:36:12PM +0900, Yasuaki Ishimatsu wrote:
@@ -151,6 +162,39 @@ __initcall(ioresources_init);

  #endif /* CONFIG_PROC_FS */

+static void free_resource(struct resource *res)
+{
+	if (!res)
+		return;
+
+	if (PageSlab(virt_to_head_page(res))) {
+		spin_lock(&bootmem_resource_lock);
+		res->sibling = bootmem_resource.sibling;
+		bootmem_resource.sibling = res;
+		spin_unlock(&bootmem_resource_lock);
+	} else {
+		kfree(res);
+	}


The branch is mixed up, you are collecting slab objects in
bootmem_resource and kfreeing bootmem.

Ah. I'm wrong. I'll update soon.

Thanks,
Yasuaki Ishimatsu


+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);
+
+	if (!res)
+		res = kzalloc(sizeof(struct resource), flags);
+
+	return res;
+}
+
  /* Return the conflict entry if you can't request it */
  static struct resource * __request_resource(struct resource *root, struct resource *new)
  {


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