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>] [day] [month] [year] [list]
Message-ID: <CAB4K4y62oCFphQWzeR+Cwdc+EBhp+fGFjzFXyXyjOTiyjwh_sQ@mail.gmail.com>
Date:	Tue, 27 Dec 2011 15:16:16 +0530
From:	Ajeet Yadav <ajeet.yadav.77@...il.com>
To:	Phillip Lougher <phillip@...ashfs.org.uk>,
	linux-kernel@...r.kernel.org
Subject: [PATCH] Squashfs: optimise squashfs_cache_get entry search

>From 207aafb6e1dde1bc8d7f04be5c803f30a337c188 Mon Sep 17 00:00:00 2001
From: Ajeet Yadav <ajeet.yadav.77@...il.com>
Date: Tue, 27 Dec 2011 15:10:04 +0530
Subject: [PATCH] Squashfs: optimise squashfs_cache_get entry search

squashfs_cache_get() iterates over all entries to search for
 block its looking for. Often get() / put() are called for
 same block.

If we cache the current entry index, then we can optimise the
subsequent *_get() calls.

Signed-off-by: Ajeet Yadav <ajeet.yadav.77@...il.com>
---
 fs/squashfs/cache.c          |   11 ++++++++---
 fs/squashfs/squashfs_fs_sb.h |    1 +
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/fs/squashfs/cache.c b/fs/squashfs/cache.c
index 516ce2d..fbd9670 100644
--- a/fs/squashfs/cache.c
+++ b/fs/squashfs/cache.c
@@ -70,11 +70,15 @@ struct squashfs_cache_entry
*squashfs_cache_get(struct super_block *sb,
 	spin_lock(&cache->lock);

 	while (1) {
-		for (i = 0; i < cache->entries; i++)
-			if (cache->entry[i].block == block)
+		for (i = cache->curr_blk, n = 0; n < cache->entries; n++) {
+			if (cache->entry[i].block == block) {
+				cache->curr_blk = i;
 				break;
+			}
+			i = (i + 1) % cache->entries;
+		}

-		if (i == cache->entries) {
+		if (n == cache->entries) {
 			/*
 			 * Block not in cache, if all cache entries are used
 			 * go to sleep waiting for one to become available.
@@ -240,6 +244,7 @@ struct squashfs_cache *squashfs_cache_init(char
*name, int entries,
 		goto cleanup;
 	}

+	cache->curr_blk = 0;
 	cache->next_blk = 0;
 	cache->unused = entries;
 	cache->entries = entries;
diff --git a/fs/squashfs/squashfs_fs_sb.h b/fs/squashfs/squashfs_fs_sb.h
index 651f0b3..52934a2 100644
--- a/fs/squashfs/squashfs_fs_sb.h
+++ b/fs/squashfs/squashfs_fs_sb.h
@@ -28,6 +28,7 @@
 struct squashfs_cache {
 	char			*name;
 	int			entries;
+	int			curr_blk;
 	int			next_blk;
 	int			num_waiters;
 	int			unused;
-- 
1.6.0.3
--
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