linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: linux-mm@kvack.org
Cc: Nick Piggin <nickpiggin@yahoo.com.au>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [PATCH 08/16] mm: speculative page get for PREEMPT_RT
Date: Thu, 07 Dec 2006 17:18:08 +0100	[thread overview]
Message-ID: <20061207162735.576346000@chello.nl> (raw)
In-Reply-To: <20061207161800.426936000@chello.nl>

[-- Attachment #1: mm-lockless-preempt-rt-fixup.patch --]
[-- Type: text/plain, Size: 4403 bytes --]

Since most of the locks are sleeping locks with PREEMPT_RT provide
a sleeping implementation of wait_on_new_refs(). This also solves
the preempt livelock and thus we can remove the preempt_disable()/
preempt_enable() from the PG_nonewrefs functions.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 include/linux/pagemap.h |   51 +++++++++++++++++++++++++++++++++++++++++++++++-
 mm/filemap.c            |   17 ++--------------
 2 files changed, 53 insertions(+), 15 deletions(-)

Index: linux-2.6-rt/include/linux/pagemap.h
===================================================================
--- linux-2.6-rt.orig/include/linux/pagemap.h	2006-11-29 14:20:55.000000000 +0100
+++ linux-2.6-rt/include/linux/pagemap.h	2006-11-29 14:20:58.000000000 +0100
@@ -13,6 +13,8 @@
 #include <linux/gfp.h>
 #include <linux/page-flags.h>
 #include <linux/hardirq.h> /* for in_interrupt() */
+#include <linux/wait.h>
+#include <linux/hash.h>
 
 /*
  * Bits in mapping->flags.  The lower __GFP_BITS_SHIFT bits are the page
@@ -53,6 +55,26 @@ static inline void mapping_set_gfp_mask(
 #define page_cache_release(page)	put_page(page)
 void release_pages(struct page **pages, int nr, int cold);
 
+/*
+ * In order to wait for pages to become available there must be
+ * waitqueues associated with pages. By using a hash table of
+ * waitqueues where the bucket discipline is to maintain all
+ * waiters on the same queue and wake all when any of the pages
+ * become available, and for the woken contexts to check to be
+ * sure the appropriate page became available, this saves space
+ * at a cost of "thundering herd" phenomena during rare hash
+ * collisions.
+ */
+static inline wait_queue_head_t *page_waitqueue(struct page *page)
+{
+	const struct zone *zone = page_zone(page);
+
+	return &zone->wait_table[hash_ptr(page, zone->wait_table_bits)];
+}
+
+extern int __sleep_on_page(void *);
+
+#ifndef CONFIG_PREEMPT_RT
 static inline void set_page_no_new_refs(struct page *page)
 {
 	VM_BUG_ON(PageNoNewRefs(page));
@@ -74,6 +96,33 @@ static inline void wait_on_new_refs(stru
 	while (unlikely(PageNoNewRefs(page)))
 		cpu_relax();
 }
+#else
+static inline void set_page_no_new_refs(struct page *page)
+{
+	VM_BUG_ON(PageNoNewRefs(page));
+	SetPageNoNewRefs(page);
+	smp_wmb();
+}
+
+static inline void end_page_no_new_refs(struct page *page)
+{
+	VM_BUG_ON(!PageNoNewRefs(page));
+	smp_wmb();
+	ClearPageNoNewRefs(page);
+	smp_mb__after_clear_bit();
+	__wake_up_bit(page_waitqueue(page), &page->flags, PG_nonewrefs);
+}
+
+static inline void wait_on_new_refs(struct page *page)
+{
+	might_sleep();
+	if (unlikely(PageNoNewRefs(page))) {
+		DEFINE_WAIT_BIT(wait, &page->flags, PG_nonewrefs);
+		__wait_on_bit(page_waitqueue(page), &wait, __sleep_on_page,
+				TASK_UNINTERRUPTIBLE);
+	}
+}
+#endif
 
 /*
  * speculatively take a reference to a page.
@@ -124,7 +173,7 @@ static inline int page_cache_get_specula
 {
 	VM_BUG_ON(in_interrupt());
 
-#ifndef CONFIG_SMP
+#if !defined(CONFIG_SMP) && !defined(CONFIG_PREEMPT_RT)
 # ifdef CONFIG_PREEMPT
 	VM_BUG_ON(!in_atomic());
 # endif
Index: linux-2.6-rt/mm/filemap.c
===================================================================
--- linux-2.6-rt.orig/mm/filemap.c	2006-11-29 14:20:55.000000000 +0100
+++ linux-2.6-rt/mm/filemap.c	2006-11-29 14:20:58.000000000 +0100
@@ -486,21 +486,10 @@ static int __sleep_on_page_lock(void *wo
 	return 0;
 }
 
-/*
- * In order to wait for pages to become available there must be
- * waitqueues associated with pages. By using a hash table of
- * waitqueues where the bucket discipline is to maintain all
- * waiters on the same queue and wake all when any of the pages
- * become available, and for the woken contexts to check to be
- * sure the appropriate page became available, this saves space
- * at a cost of "thundering herd" phenomena during rare hash
- * collisions.
- */
-static wait_queue_head_t *page_waitqueue(struct page *page)
+int __sleep_on_page(void *word)
 {
-	const struct zone *zone = page_zone(page);
-
-	return &zone->wait_table[hash_ptr(page, zone->wait_table_bits)];
+	schedule();
+	return 0;
 }
 
 static inline void wake_up_page(struct page *page, int bit)

--

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2006-12-07 16:18 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-07 16:18 [PATCH 00/16] concurrent pagecache (against 2.6.19-rt) Peter Zijlstra
2006-12-07 16:18 ` [PATCH 01/16] radix-tree: RCU lockless readside Nick Piggin
2006-12-07 16:18 ` [PATCH 02/16] radix-tree: use indirect bit Nick Piggin
2006-12-07 16:18 ` [PATCH 03/16] radix-tree: gang_lookup_slot Nick Piggin
2006-12-07 16:18 ` [PATCH 04/16] radix-tree: gang_lookup_tag_slot Peter Zijlstra
2006-12-07 16:18 ` [PATCH 05/16] mm: speculative get page Nick Piggin
2006-12-07 16:18 ` [PATCH 06/16] mm: lockless pagecache lookups Nick Piggin
2006-12-07 16:18 ` [PATCH 07/16] mm: fix speculative page get preemption bug Peter Zijlstra
2006-12-07 16:18 ` Peter Zijlstra [this message]
2006-12-07 16:18 ` [PATCH 09/16] mm: speculative find_get_pages_tag Peter Zijlstra
2006-12-07 16:18 ` [PATCH 10/16] mm: remove find_tylock_page Peter Zijlstra
2006-12-07 16:18 ` [PATCH 11/16] mm: change tree_lock into a spinlock Peter Zijlstra
2006-12-07 16:18 ` [PATCH 12/16] radix-tree: concurrent write side support Peter Zijlstra
2006-12-07 16:18 ` [PATCH 13/16] atomic_ulong_t Peter Zijlstra
2006-12-07 16:18 ` [PATCH 14/16] mm/fs: abstract address_space::nrpages Peter Zijlstra
2006-12-07 16:18 ` [PATCH 15/16] mm: lock_page_ref Peter Zijlstra
2006-12-07 16:18 ` [PATCH 16/16] mm: concurrent pagecache write side Peter Zijlstra
2006-12-11 19:03 ` [PATCH 00/16] concurrent pagecache (against 2.6.19-rt) Christoph Lameter
2006-12-11 19:24   ` Peter Zijlstra

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=20061207162735.576346000@chello.nl \
    --to=a.p.zijlstra@chello.nl \
    --cc=linux-mm@kvack.org \
    --cc=nickpiggin@yahoo.com.au \
    /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