From: Vitaly Wool <vitaly.wool@konsulko.com>
To: linux-mm@kvack.org
Cc: lkml@vger.kernel.org, linux-rt-users@vger.kernel.org,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Mike Galbraith <efault@gmx.de>,
akpm@linux-foundation.org, Vitaly Wool <vitaly.wool@konsulko.com>
Subject: [PATCH 2/3] z3fold: Remove preempt disabled sections for RT
Date: Wed, 9 Dec 2020 16:51:50 +0200 [thread overview]
Message-ID: <20201209145151.18994-3-vitaly.wool@konsulko.com> (raw)
In-Reply-To: <20201209145151.18994-1-vitaly.wool@konsulko.com>
Replace get_cpu_ptr() with migrate_disable()+this_cpu_ptr()
so RT can take spinlocks that become sleeping locks.
Signed-off-by Mike Galbraith <efault@gmx.de>
Signed-off-by: Vitaly Wool <vitaly.wool@konsulko.com>
---
mm/z3fold.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/mm/z3fold.c b/mm/z3fold.c
index 6c2325cd3fba..9fc1cc9630fe 100644
--- a/mm/z3fold.c
+++ b/mm/z3fold.c
@@ -610,14 +610,16 @@ static inline void add_to_unbuddied(struct z3fold_pool *pool,
{
if (zhdr->first_chunks == 0 || zhdr->last_chunks == 0 ||
zhdr->middle_chunks == 0) {
- struct list_head *unbuddied = get_cpu_ptr(pool->unbuddied);
-
+ struct list_head *unbuddied;
int freechunks = num_free_chunks(zhdr);
+
+ migrate_disable();
+ unbuddied = this_cpu_ptr(pool->unbuddied);
spin_lock(&pool->lock);
list_add(&zhdr->buddy, &unbuddied[freechunks]);
spin_unlock(&pool->lock);
zhdr->cpu = smp_processor_id();
- put_cpu_ptr(pool->unbuddied);
+ migrate_enable();
}
}
@@ -854,8 +856,9 @@ static inline struct z3fold_header *__z3fold_alloc(struct z3fold_pool *pool,
int chunks = size_to_chunks(size), i;
lookup:
+ migrate_disable();
/* First, try to find an unbuddied z3fold page. */
- unbuddied = get_cpu_ptr(pool->unbuddied);
+ unbuddied = this_cpu_ptr(pool->unbuddied);
for_each_unbuddied_list(i, chunks) {
struct list_head *l = &unbuddied[i];
@@ -873,7 +876,7 @@ static inline struct z3fold_header *__z3fold_alloc(struct z3fold_pool *pool,
!z3fold_page_trylock(zhdr)) {
spin_unlock(&pool->lock);
zhdr = NULL;
- put_cpu_ptr(pool->unbuddied);
+ migrate_enable();
if (can_sleep)
cond_resched();
goto lookup;
@@ -887,7 +890,7 @@ static inline struct z3fold_header *__z3fold_alloc(struct z3fold_pool *pool,
test_bit(PAGE_CLAIMED, &page->private)) {
z3fold_page_unlock(zhdr);
zhdr = NULL;
- put_cpu_ptr(pool->unbuddied);
+ migrate_enable();
if (can_sleep)
cond_resched();
goto lookup;
@@ -902,7 +905,7 @@ static inline struct z3fold_header *__z3fold_alloc(struct z3fold_pool *pool,
kref_get(&zhdr->refcount);
break;
}
- put_cpu_ptr(pool->unbuddied);
+ migrate_enable();
if (!zhdr) {
int cpu;
--
2.20.1
next prev parent reply other threads:[~2020-12-09 14:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-09 14:51 [PATCH 0/3] z3fold: stability / rt fixes Vitaly Wool
2020-12-09 14:51 ` [PATCH 1/3] z3fold: simplify freeing slots Vitaly Wool
2020-12-09 14:51 ` Vitaly Wool [this message]
2020-12-09 14:51 ` [PATCH 3/3] z3fold: stricter locking and more careful reclaim Vitaly Wool
2020-12-18 23:19 ` [PATCH 0/3] z3fold: stability / rt fixes Oleksandr Natalenko
2020-12-18 23:26 ` Vitaly Wool
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=20201209145151.18994-3-vitaly.wool@konsulko.com \
--to=vitaly.wool@konsulko.com \
--cc=akpm@linux-foundation.org \
--cc=bigeasy@linutronix.de \
--cc=efault@gmx.de \
--cc=linux-mm@kvack.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=lkml@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