Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1233971
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | yalin wang <yalin.wang2010@gmail.com> |
| Newsgroups | linux.kernel |
| Subject | [RFC] fs: change bh_lru_install() implementation |
| Date | Mon, 28 Sep 2015 11:30:02 +0200 |
| Message-ID | <qdCUW-1DD-29@gated-at.bofh.it> (permalink) |
| X-Original-To | viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=OFeh4mCVB2KBx4wek7103+TgRj2PjSkemPsZZpS6cyw=; b=nqih5q/kFLTjVq1ayv5VOfKs+lbXcZxsHHZw4Sm4xKCCMnlvVE3Sm92/QGhml8UABE /R26P4tL5pq4J/jEEVM2pYzlA3J0YWdZTHIQ4u7lqrKQoYFLUAFllK/j+1ReD36Z1kQ9 nX31Q8A5/JzpDH2Ovm+xoQ1nAC1IplLmVxofAXvBGuQYdC/L59HqZjpvIIuote6AmTKi 4Sh9WN+m39QVZfplNiLEMv4UMR8UHerst84wUDw+HPBKE/pdBCn3oWON1lgLYBkZn6iW WaMpmJ7QVYDCch0G5IlpdOi8ac/mmIR4GO8+F+4W5xey4DF9hegkj9/aKeba/EZ2Eas/ rlhQ== |
| X-Received | by 10.68.220.132 with SMTP id pw4mr25315401pbc.149.1443432383384; Mon, 28 Sep 2015 02:26:23 -0700 (PDT) |
| X-Mailer | git-send-email 1.9.1 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 78 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | yalin wang <yalin.wang2010@gmail.com> |
| X-Original-Date | Mon, 28 Sep 2015 17:26:03 +0800 |
| X-Original-Message-ID | <1443432363-28924-1-git-send-email-yalin.wang2010@gmail.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1233971 |
Show key headers only | View raw
This patch use swap method to implement bh_lru_install,
it works like this:
swap new and [0] first, update old=[0],
then compare old and [1],
if old != new_bh && old != NULL, swap old and [1],
then start the next compare,
otherwise stop the compare.
Signed-off-by: yalin wang <yalin.wang2010@gmail.com>
---
fs/buffer.c | 33 ++++++++++++---------------------
1 file changed, 12 insertions(+), 21 deletions(-)
diff --git a/fs/buffer.c b/fs/buffer.c
index 82283ab..d6769f1 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1287,40 +1287,31 @@ static inline void check_irqs_on(void)
*/
static void bh_lru_install(struct buffer_head *bh)
{
- struct buffer_head *evictee = NULL;
+ struct buffer_head *old = NULL;
check_irqs_on();
bh_lru_lock();
if (__this_cpu_read(bh_lrus.bhs[0]) != bh) {
- struct buffer_head *bhs[BH_LRU_SIZE];
- int in;
+ struct buffer_head *temp;
int out = 0;
+ old = __this_cpu_read(bh_lrus.bhs[0]);
get_bh(bh);
- bhs[out++] = bh;
- for (in = 0; in < BH_LRU_SIZE; in++) {
- struct buffer_head *bh2 =
- __this_cpu_read(bh_lrus.bhs[in]);
-
- if (bh2 == bh) {
- __brelse(bh2);
+ __this_cpu_write(bh_lrus.bhs[out++], bh);
+ for (; out < BH_LRU_SIZE; out++) {
+ if (old == bh || old == NULL) {
+ break;
} else {
- if (out >= BH_LRU_SIZE) {
- BUG_ON(evictee != NULL);
- evictee = bh2;
- } else {
- bhs[out++] = bh2;
- }
+ temp = __this_cpu_read(bh_lrus.bhs[out]);
+ __this_cpu_write(bh_lrus.bhs[out], old);
+ old = temp;
}
}
- while (out < BH_LRU_SIZE)
- bhs[out++] = NULL;
- memcpy(this_cpu_ptr(&bh_lrus.bhs), bhs, sizeof(bhs));
}
bh_lru_unlock();
- if (evictee)
- __brelse(evictee);
+ if (old)
+ __brelse(old);
}
/*
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[RFC] fs: change bh_lru_install() implementation yalin wang <yalin.wang2010@gmail.com> - 2015-09-28 11:30 +0200
csiph-web