linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH] fs/buffer.c: Revoke LRU when trying to drop buffers
@ 2012-09-11 17:28 Laura Abbott
  2012-09-15  1:41 ` Hugh Dickins
  0 siblings, 1 reply; 4+ messages in thread
From: Laura Abbott @ 2012-09-11 17:28 UTC (permalink / raw)
  To: Alexander Viro
  Cc: linux-fsdevel, linux-kernel, Marek Szyprowski, linaro-mm-sig,
	linux-arm-msm, Laura Abbott

When a buffer is added to the LRU list, a reference is taken which is
not dropped until the buffer is evicted from the LRU list. This is the
correct behavior, however this LRU reference will prevent the buffer
from being dropped. This means that the buffer can't actually be dropped
until it is selected for eviction. There's no bound on the time spent
on the LRU list, which means that the buffer may be undroppable for
very long periods of time. Given that migration involves dropping
buffers, the associated page is now unmigratible for long periods of
time as well. CMA relies on being able to migrate a specific range
of pages, so these these types of failures make CMA significantly
less reliable, especially under high filesystem usage.

Rather than waiting for the LRU algorithm to eventually kick out
the buffer, explicitly remove the buffer from the LRU list when trying
to drop it. There is still the possibility that the buffer
could be added back on the list, but that indicates the buffer is
still in use and would probably have other 'in use' indicates to
prevent dropping.

Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
---
 fs/buffer.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/fs/buffer.c b/fs/buffer.c
index ad5938c..daa0c3d 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1399,12 +1399,49 @@ static bool has_bh_in_lru(int cpu, void *dummy)
 	return 0;
 }
 
+static void __evict_bh_lru(void *arg)
+{
+	struct bh_lru *b = &get_cpu_var(bh_lrus);
+	struct buffer_head *bh = arg;
+	int i;
+
+	for (i = 0; i < BH_LRU_SIZE; i++) {
+		if (b->bhs[i] == bh) {
+			brelse(b->bhs[i]);
+			b->bhs[i] = NULL;
+			goto out;
+		}
+	}
+out:
+	put_cpu_var(bh_lrus);
+}
+
+static bool bh_exists_in_lru(int cpu, void *arg)
+{
+	struct bh_lru *b = per_cpu_ptr(&bh_lrus, cpu);
+	struct buffer_head *bh = arg;
+	int i;
+
+	for (i = 0; i < BH_LRU_SIZE; i++) {
+		if (b->bhs[i] == bh)
+			return 1;
+	}
+
+	return 0;
+
+}
 void invalidate_bh_lrus(void)
 {
 	on_each_cpu_cond(has_bh_in_lru, invalidate_bh_lru, NULL, 1, GFP_KERNEL);
 }
 EXPORT_SYMBOL_GPL(invalidate_bh_lrus);
 
+void evict_bh_lrus(struct buffer_head *bh)
+{
+	on_each_cpu_cond(bh_exists_in_lru, __evict_bh_lru, bh, 1, GFP_ATOMIC);
+}
+EXPORT_SYMBOL_GPL(evict_bh_lrus);
+
 void set_bh_page(struct buffer_head *bh,
 		struct page *page, unsigned long offset)
 {
@@ -3052,6 +3089,7 @@ drop_buffers(struct page *page, struct buffer_head **buffers_to_free)
 
 	bh = head;
 	do {
+		evict_bh_lrus(bh);
 		if (buffer_write_io_error(bh) && page->mapping)
 			set_bit(AS_EIO, &page->mapping->flags);
 		if (buffer_busy(bh))
-- 
1.7.11.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread
* Re: [RFC][PATCH] fs/buffer.c: Revoke LRU when trying to drop buffers
@ 2013-07-05  2:01 Damian Hobson-Garcia
  0 siblings, 0 replies; 4+ messages in thread
From: Damian Hobson-Garcia @ 2013-07-05  2:01 UTC (permalink / raw)
  To: lauraa; +Cc: Marek Szyprowski, viro, linux-fsdevel, linux-kernel

Hi,

I've come across a problem allocating chunks of CMA memory on a system
under heavy disk access load which seems very similar to the situation
described as the rationale for this patch:

https://lkml.org/lkml/2012/9/11/335

Basically buffer headers sitting on the LRU list preventing them from
being dropped during page migration.

I've tried the patch and it seems to solve my problems, so I'm wondering
if it is worth resubmitting. The discussion on the original thread seems
to have faded out. Does anyone know if it was continued somewhere else?

Thank you,
Damian
-- 
Damian Hobson-Garcia
IGEL Co.,Ltd
http://www.igel.co.jp

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-07-05  2:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-11 17:28 [RFC][PATCH] fs/buffer.c: Revoke LRU when trying to drop buffers Laura Abbott
2012-09-15  1:41 ` Hugh Dickins
2012-09-17 17:57   ` Laura Abbott
2013-07-05  2:01 Damian Hobson-Garcia

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).