From: "David S. Miller" <davem@redhat.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: bh_lru_install
Date: Tue, 27 Jul 2004 17:15:48 -0700 [thread overview]
Message-ID: <20040727171548.75c3b14c.davem@redhat.com> (raw)
In-Reply-To: <20040727160617.321ce504.akpm@osdl.org>
On Tue, 27 Jul 2004 16:06:17 -0700
Andrew Morton <akpm@osdl.org> wrote:
> > It shouldn't be too hard to make the code just work without
> > an on-stack copy, shuffling the lru->bh[] array entries
> > directly.
>
> Yup, that plus making it a ringbuffer maybe.
It seems implementable using two roving indexes, one for
reading and one for writing. So it's just like the existing
code sans the on-stack+memcpy stuff :-)
Do you see any logic errors in this new code below?
static void bh_lru_install(struct buffer_head *bh)
{
struct buffer_head *e = NULL;
struct bh_lru *lru;
check_irqs_on();
bh_lru_lock();
lru = &__get_cpu_var(bh_lrus);
if ((e = lru->bhs[0]) != bh) {
int rd_idx, wr_idx;
wr_idx = 0;
get_bh(bh);
lru->bhs[wr_idx++] = bh;
for (rd_idx = 1; rd_idx < BH_LRU_SIZE; rd_idx++) {
struct buffer_head *nxt = lru->bhs[rd_idx];
if (e != NULL)
lru->bhs[wr_idx++] = e;
e = nxt;
if (e == bh) {
__brelse(e);
e = NULL;
} else if (e == NULL)
break;
}
while (wr_idx < BH_LRU_SIZE)
lru->bhs[wr_idx++] = NULL;
}
bh_lru_unlock();
if (e)
__brelse(e);
}
prev parent reply other threads:[~2004-07-28 0:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-24 0:03 bh_lru_install David S. Miller
2004-07-27 23:06 ` bh_lru_install Andrew Morton
2004-07-27 23:41 ` bh_lru_install David S. Miller
2004-07-28 0:15 ` David S. Miller [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=20040727171548.75c3b14c.davem@redhat.com \
--to=davem@redhat.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®