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-next>] [day] [month] [year] [list]
Message-ID: <ac8f92701003220735h76b4a51dib1a9b311f9cf6d99@mail.gmail.com>
Date:	Mon, 22 Mar 2010 22:35:54 +0800
From:	jing zhang <zj.barak@...il.com>
To:	linux-ext4 <linux-ext4@...r.kernel.org>
Cc:	"Theodore Ts'o" <tytso@....edu>, Andreas Dilger <adilger@....com>,
	Dave Kleikamp <shaggy@...ux.vnet.ibm.com>
Subject: [PATCH] ext4: remove unnecessary operation in ext4_mb_regular_allocator()

From: Jing Zhang <zj.barak@...il.com>

Date: Mon Mar 22 22:20:38     2010

1, In one of the hot functions in mballoc.c, unnecessary operation on
       struct ext4_group_desc *desc;
    is removed.

2, Unlike spin_lock() and spin_unlock(), ext4_mb_load_buddy() is
companied by ext4_mb_release_desc. And it is hard, at least for me, to
get sure that ext4_mb_release_desc has little to do with struct
ext4_group_desc, and for those readers as well, whose native language
is not English. It seems the choice includes
     ext4_mb_release_buddy
     ext4_mb_put_buddy
     ext4_mb_unload_buddy
and I like the last one.

Cc: Theodore Ts'o <tytso@....edu>
Cc: Andreas Dilger <adilger@....com>
Cc: Dave Kleikamp <shaggy@...ux.vnet.ibm.com>
Signed-off-by: Jing Zhang <zj.barak@...il.com>

---

--- linux-2.6.32/fs/ext4/mballoc.c	2009-12-03 11:51:22.000000000 +0800
+++ ext4_mm_leak/mballoc4.c	2010-03-22 22:08:56.000000000 +0800
@@ -1150,7 +1150,7 @@ err:
 	return ret;
 }

-static void ext4_mb_release_desc(struct ext4_buddy *e4b)
+static void ext4_mb_unload_buddy(struct ext4_buddy *e4b)
 {
 	if (e4b->bd_bitmap_page)
 		page_cache_release(e4b->bd_bitmap_page);
@@ -1618,7 +1618,7 @@ int ext4_mb_try_best_found(struct ext4_a
 	}

 	ext4_unlock_group(ac->ac_sb, group);
-	ext4_mb_release_desc(e4b);
+	ext4_mb_unload_buddy(e4b);

 	return 0;
 }
@@ -1674,7 +1674,7 @@ int ext4_mb_find_by_goal(struct ext4_all
 		ext4_mb_use_best_found(ac, e4b);
 	}
 	ext4_unlock_group(ac->ac_sb, group);
-	ext4_mb_release_desc(e4b);
+	ext4_mb_unload_buddy(e4b);

 	return 0;
 }
@@ -2027,7 +2027,7 @@ repeat:

 		for (i = 0; i < ngroups; group++, i++) {
 			struct ext4_group_info *grp;
-			struct ext4_group_desc *desc;
+			/* struct ext4_group_desc *desc; */

 			if (group == ngroups)
 				group = 0;
@@ -2045,12 +2045,12 @@ repeat:
 			if (!ext4_mb_good_group(ac, group, cr)) {
 				/* someone did allocation from this group */
 				ext4_unlock_group(sb, group);
-				ext4_mb_release_desc(&e4b);
+				ext4_mb_unload_buddy(&e4b);
 				continue;
 			}

 			ac->ac_groups_scanned++;
-			desc = ext4_get_group_desc(sb, group, NULL);
+			/* desc = ext4_get_group_desc(sb, group, NULL); */
 			if (cr == 0)
 				ext4_mb_simple_scan_group(ac, &e4b);
 			else if (cr == 1 &&
@@ -2060,7 +2060,7 @@ repeat:
 				ext4_mb_complex_scan_group(ac, &e4b);

 			ext4_unlock_group(sb, group);
-			ext4_mb_release_desc(&e4b);
+			ext4_mb_unload_buddy(&e4b);

 			if (ac->ac_status != AC_STATUS_CONTINUE)
 				break;
@@ -2150,7 +2150,7 @@ static int ext4_mb_seq_groups_show(struc
 	ext4_lock_group(sb, group);
 	memcpy(&sg, ext4_get_group_info(sb, group), i);
 	ext4_unlock_group(sb, group);
-	ext4_mb_release_desc(&e4b);
+	ext4_mb_unload_buddy(&e4b);

 	seq_printf(seq, "#%-5u: %-5u %-5u %-5u [", group, sg.info.bb_free,
 			sg.info.bb_fragments, sg.info.bb_first_free);
@@ -2567,7 +2567,7 @@ static void release_blocks_on_commit(jou
 		sb_issue_discard(sb, discard_block, entry->count);

 		kmem_cache_free(ext4_free_ext_cachep, entry);
-		ext4_mb_release_desc(&e4b);
+		ext4_mb_unload_buddy(&e4b);
 	}

 	mb_debug(1, "freed %u blocks in %u structures\n", count, count2);
@@ -3692,7 +3692,7 @@ out:
 	ext4_unlock_group(sb, group);
 	if (ac)
 		kmem_cache_free(ext4_ac_cachep, ac);
-	ext4_mb_release_desc(&e4b);
+	ext4_mb_unload_buddy(&e4b);
 	put_bh(bitmap_bh);
 	return free;
 }
@@ -3796,7 +3796,7 @@ repeat:
 		if (bitmap_bh == NULL) {
 			ext4_error(sb, __func__, "Error in reading block "
 					"bitmap for %u", group);
-			ext4_mb_release_desc(&e4b);
+			ext4_mb_unload_buddy(&e4b);
 			continue;
 		}

@@ -3805,7 +3805,7 @@ repeat:
 		ext4_mb_release_inode_pa(&e4b, bitmap_bh, pa, ac);
 		ext4_unlock_group(sb, group);

-		ext4_mb_release_desc(&e4b);
+		ext4_mb_unload_buddy(&e4b);
 		put_bh(bitmap_bh);

 		list_del(&pa->u.pa_tmp_list);
@@ -4069,7 +4069,7 @@ ext4_mb_discard_lg_preallocations(struct
 		ext4_mb_release_group_pa(&e4b, pa, ac);
 		ext4_unlock_group(sb, group);

-		ext4_mb_release_desc(&e4b);
+		ext4_mb_unload_buddy(&e4b);
 		list_del(&pa->u.pa_tmp_list);
 		call_rcu(&(pa)->u.pa_rcu, ext4_mb_pa_callback);
 	}
@@ -4570,7 +4570,7 @@ do_more:
 		atomic_add(count, &sbi->s_flex_groups[flex_group].free_blocks);
 	}

-	ext4_mb_release_desc(&e4b);
+	ext4_mb_unload_buddy(&e4b);

 	*freed += count;
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ