LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Evgeniy Polyakov <zbr@ioremap.net>
To: Phillip Lougher <phillip@lougher.demon.co.uk>
Cc: akpm@linux-foundation.org, linux-embedded@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	tim.bird@am.sony.com
Subject: Re: [PATCH V2 10/16] Squashfs: cache operations
Date: Mon, 3 Nov 2008 17:11:02 +0300	[thread overview]
Message-ID: <20081103141102.GA27263@ioremap.net> (raw)
In-Reply-To: <E1Kv0C4-0006HO-BC@dylan>

Hi.

Couple comments below.

On Wed, Oct 29, 2008 at 01:49:56AM +0000, Phillip Lougher (phillip@lougher.demon.co.uk) wrote:
> +struct squashfs_cache_entry *squashfs_cache_get(struct super_block *sb,
> +	struct squashfs_cache *cache, long long block, int length)
> +{
> +	int i, n;
> +	struct squashfs_cache_entry *entry;
> +
> +	spin_lock(&cache->lock);
> +
> +	while (1) {
> +		for (i = 0; i < cache->entries; i++)
> +			if (cache->entry[i].block == block)
> +				break;
> +
> +		if (i == cache->entries) {
> +			/*
> +			 * Block not in cache, if all cache entries are locked
> +			 * go to sleep waiting for one to become available.
> +			 */
> +			if (cache->unused == 0) {
> +				cache->waiting++;
> +				spin_unlock(&cache->lock);
> +				wait_event(cache->wait_queue, cache->unused);
> +				spin_lock(&cache->lock);
> +				cache->waiting--;
> +				continue;
> +			}
> +
> +			/*
> +			 * At least one unlocked cache entry.  A simple
> +			 * round-robin strategy is used to choose the entry to
> +			 * be evicted from the cache.
> +			 */
> +			i = cache->next_blk;
> +			for (n = 0; n < cache->entries; n++) {
> +				if (cache->entry[i].locked == 0)
> +					break;
> +				i = (i + 1) % cache->entries;
> +			}
> +
> +			cache->next_blk = (i + 1) % cache->entries;
> +			entry = &cache->entry[i];

This is invoked for every read when cache is filled, if I understood
correctly, and having a modulo in this path is an additional overhead.
This may be hidden on behalf of compression overhead, but stil.

Also what happens when there are no unlocked entries? I.e. you will try
to work with existing one, while it is already locked and processed by
another thread?


-- 
	Evgeniy Polyakov

      parent reply	other threads:[~2008-11-03 14:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-29  1:49 Phillip Lougher
2008-10-29  9:32 ` Jörn Engel
2008-10-31  4:43   ` Phillip Lougher
2008-10-31  7:29     ` Jörn Engel
2008-10-31 15:03       ` Phillip Lougher
2008-11-03 14:11 ` Evgeniy Polyakov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081103141102.GA27263@ioremap.net \
    --to=zbr@ioremap.net \
    --cc=akpm@linux-foundation.org \
    --cc=linux-embedded@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=phillip@lougher.demon.co.uk \
    --cc=tim.bird@am.sony.com \
    --subject='Re: [PATCH V2 10/16] Squashfs: cache operations' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).