[PATCH] Let list grow
From: Joel Fernandes (Google)
Date: Thu Aug 08 2019 - 16:29:58 EST
Signed-off-by: Joel Fernandes (Google) <joel@xxxxxxxxxxxxxxxxx>
---
kernel/rcu/rcuperf.c | 2 +-
kernel/rcu/tree.c | 52 +++++++++++++++++++-------------------------
2 files changed, 23 insertions(+), 31 deletions(-)
diff --git a/kernel/rcu/rcuperf.c b/kernel/rcu/rcuperf.c
index 34658760da5e..7dc831db89ae 100644
--- a/kernel/rcu/rcuperf.c
+++ b/kernel/rcu/rcuperf.c
@@ -654,7 +654,7 @@ kfree_perf_thread(void *arg)
}
}
- schedule_timeout_uninterruptible(2);
+ cond_resched();
} while (!torture_must_stop() && ++l < kfree_loops);
kfree(alloc_ptrs);
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index bdbd483606ce..bab77220d8ac 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -2595,7 +2595,7 @@ EXPORT_SYMBOL_GPL(call_rcu);
/* Maximum number of jiffies to wait before draining batch */
-#define KFREE_DRAIN_JIFFIES 50
+#define KFREE_DRAIN_JIFFIES (HZ / 20)
/*
* Maximum number of kfree(s) to batch, if limit is hit
@@ -2684,27 +2684,19 @@ static void kfree_rcu_drain_unlock(struct kfree_rcu_cpu *krc,
{
struct rcu_head *head, *next;
- /* It is time to do bulk reclaim after grace period */
- krc->monitor_todo = false;
+ /* It is time to do bulk reclaim after grace period. */
if (queue_kfree_rcu_work(krc)) {
spin_unlock_irqrestore(&krc->lock, flags);
return;
}
- /*
- * Use non-batch regular call_rcu for kfree_rcu in case things are too
- * busy and batching of kfree_rcu could not be used.
- */
- head = krc->head;
- krc->head = NULL;
- krc->kfree_batch_len = 0;
- spin_unlock_irqrestore(&krc->lock, flags);
-
- for (; head; head = next) {
- next = head->next;
- head->next = NULL;
- __call_rcu(head, head->func, -1, 1);
+ /* Previous batch did not get free yet, let us try again soon. */
+ if (krc->monitor_todo == false) {
+ schedule_delayed_work_on(smp_processor_id(),
+ &krc->monitor_work, KFREE_DRAIN_JIFFIES/4);
+ krc->monitor_todo = true;
}
+ spin_unlock_irqrestore(&krc->lock, flags);
}
/*
--
2.23.0.rc1.153.gdeed80330f-goog