Skip to contentSkip to conversation

rcu: Release per-cpu krcp page cache when CPU going offline

PATCH In review [email protected] 3 participants 10 messages Jan 21, 2021 – Jan 27, 2021 RCU

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rcu: Release per-cpu krcp page cache when CPU going offline

From: Zqiang <[email protected]>

If CPUs go offline, the corresponding krcp's page cache can not be use util the CPU come back online, or maybe the CPU will never go online again, this commit therefore free krcp's page cache when CPUs go offline.

---
 kernel/rcu/tree.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)
kernel/rcu/tree.c +46 -1
index e04e336bee42..2eaf6f287483 100644
@@ -158,6 +158,9 @@ static void sync_sched_exp_online_cleanup(int cpu);
 static void check_cb_ovld_locked(struct rcu_data *rdp, struct rcu_node *rnp);
 static bool rcu_rdp_is_offloaded(struct rcu_data *rdp);
 
+static void krc_offline(unsigned int cpu, bool off);
+static void free_krc_page_cache(int cpu);
+
 /* rcuc/rcub kthread realtime priority */
 static int kthread_prio = IS_ENABLED(CONFIG_RCU_BOOST) ? 1 : 0;
 module_param(kthread_prio, int, 0444);
@@ -2457,6 +2460,9 @@ int rcutree_dead_cpu(unsigned int cpu)
 
 	// Stop-machine done, so allow nohz_full to disable tick.
 	tick_dep_clear(TICK_DEP_BIT_RCU);
+
+	krc_offline(cpu, true);
+	free_krc_page_cache(cpu);
 	return 0;
 }
 
@@ -3169,6 +3175,7 @@ struct kfree_rcu_cpu {
 
 	struct llist_head bkvcache;
 	int nr_bkv_objs;
+	bool offline;
 };
 
 static DEFINE_PER_CPU(struct kfree_rcu_cpu, krc) = {
@@ -3220,6 +3227,8 @@ static inline bool
 put_cached_bnode(struct kfree_rcu_cpu *krcp,
 	struct kvfree_rcu_bulk_data *bnode)
 {
+	if (krcp->offline)
+		return false;
 	// Check the limit.
 	if (krcp->nr_bkv_objs >= rcu_min_cached_objs)
 		return false;
@@ -3230,6 +3239,39 @@ put_cached_bnode(struct kfree_rcu_cpu *krcp,
 
 }
 
+static void krc_offline(unsigned int cpu, bool off)
+{
+	unsigned long flags;
+	struct kfree_rcu_cpu *krcp;
+
+	krcp = per_cpu_ptr(&krc, cpu);
+	raw_spin_lock_irqsave(&krcp->lock, flags);
+	if (off)
+		krcp->offline = true;
+	else
+		krcp->offline = false;
+	raw_spin_unlock_irqrestore(&krcp->lock, flags);
+}
+
+static void free_krc_page_cache(int cpu)
+{
+	unsigned long flags;
+	struct kfree_rcu_cpu *krcp;
+	int i;
+	struct kvfree_rcu_bulk_data *bnode;
+
+	krcp = per_cpu_ptr(&krc, cpu);
+
+	for (i = 0; i < rcu_min_cached_objs; i++) {
+		raw_spin_lock_irqsave(&krcp->lock, flags);
+		bnode = get_cached_bnode(krcp);
+		raw_spin_unlock_irqrestore(&krcp->lock, flags);
+		if (!bnode)
+			break;
+		free_page((unsigned long)bnode);
+	}
+}
+
 /*
  * This function is invoked in workqueue context after a grace period.
  * It frees all the objects queued on ->bhead_free or ->head_free.
@@ -3549,7 +3591,8 @@ void kvfree_call_rcu(struct rcu_head *head, rcu_callback_t func)
 	kasan_record_aux_stack(ptr);
 	success = kvfree_call_rcu_add_ptr_to_bulk(krcp, ptr);
 	if (!success) {
-		run_page_cache_worker(krcp);
+		if (!krcp->offline)
+			run_page_cache_worker(krcp);
 
 		if (head == NULL)
 			// Inline if kvfree_rcu(one_arg) call.
@@ -4086,6 +4129,7 @@ int rcutree_prepare_cpu(unsigned int cpu)
 	rcu_spawn_cpu_nocb_kthread(cpu);
 	WRITE_ONCE(rcu_state.n_online_cpus, rcu_state.n_online_cpus + 1);
 
+	krc_offline(cpu, false);
 	return 0;
 }
 
@@ -4591,6 +4635,7 @@ static void __init kfree_rcu_batch_init(void)
 		INIT_DELAYED_WORK(&krcp->monitor_work, kfree_rcu_monitor);
 		INIT_WORK(&krcp->page_cache_work, fill_page_cache_func);
 		krcp->initialized = true;
+		krcp->offline = true;
 	}
 	if (register_shrinker(&kfree_rcu_shrinker))
 		pr_err("Failed to register kfree_rcu() shrinker!\n");
Signature · 1 line
2.29.2
maintainer
#1 lore raw
Quoted 8 lines · On Thu, Jan 21, 2021 at 02:49:49PM +0800, [email protected] wrote:

From: Zqiang <[email protected]>

If CPUs go offline, the corresponding krcp's page cache can not be use util the CPU come back online, or maybe the CPU will never go online again, this commit therefore free krcp's page cache when CPUs go offline.

Adding Uladzislau on CC for his thoughts.

Thanx, Paul

Quoted 114 lines
---
 kernel/rcu/tree.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)
kernel/rcu/tree.c +46 -1
index e04e336bee42..2eaf6f287483 100644
@@ -158,6 +158,9 @@ static void sync_sched_exp_online_cleanup(int cpu);
 static void check_cb_ovld_locked(struct rcu_data *rdp, struct rcu_node *rnp);
 static bool rcu_rdp_is_offloaded(struct rcu_data *rdp);
 
+static void krc_offline(unsigned int cpu, bool off);
+static void free_krc_page_cache(int cpu);
+
 /* rcuc/rcub kthread realtime priority */
 static int kthread_prio = IS_ENABLED(CONFIG_RCU_BOOST) ? 1 : 0;
 module_param(kthread_prio, int, 0444);
@@ -2457,6 +2460,9 @@ int rcutree_dead_cpu(unsigned int cpu)
 
 	// Stop-machine done, so allow nohz_full to disable tick.
 	tick_dep_clear(TICK_DEP_BIT_RCU);
+
+	krc_offline(cpu, true);
+	free_krc_page_cache(cpu);
 	return 0;
 }
 
@@ -3169,6 +3175,7 @@ struct kfree_rcu_cpu {
 
 	struct llist_head bkvcache;
 	int nr_bkv_objs;
+	bool offline;
 };
 
 static DEFINE_PER_CPU(struct kfree_rcu_cpu, krc) = {
@@ -3220,6 +3227,8 @@ static inline bool
 put_cached_bnode(struct kfree_rcu_cpu *krcp,
 	struct kvfree_rcu_bulk_data *bnode)
 {
+	if (krcp->offline)
+		return false;
 	// Check the limit.
 	if (krcp->nr_bkv_objs >= rcu_min_cached_objs)
 		return false;
@@ -3230,6 +3239,39 @@ put_cached_bnode(struct kfree_rcu_cpu *krcp,
 
 }
 
+static void krc_offline(unsigned int cpu, bool off)
+{
+	unsigned long flags;
+	struct kfree_rcu_cpu *krcp;
+
+	krcp = per_cpu_ptr(&krc, cpu);
+	raw_spin_lock_irqsave(&krcp->lock, flags);
+	if (off)
+		krcp->offline = true;
+	else
+		krcp->offline = false;
+	raw_spin_unlock_irqrestore(&krcp->lock, flags);
+}
+
+static void free_krc_page_cache(int cpu)
+{
+	unsigned long flags;
+	struct kfree_rcu_cpu *krcp;
+	int i;
+	struct kvfree_rcu_bulk_data *bnode;
+
+	krcp = per_cpu_ptr(&krc, cpu);
+
+	for (i = 0; i < rcu_min_cached_objs; i++) {
+		raw_spin_lock_irqsave(&krcp->lock, flags);
+		bnode = get_cached_bnode(krcp);
+		raw_spin_unlock_irqrestore(&krcp->lock, flags);
+		if (!bnode)
+			break;
+		free_page((unsigned long)bnode);
+	}
+}
+
 /*
  * This function is invoked in workqueue context after a grace period.
  * It frees all the objects queued on ->bhead_free or ->head_free.
@@ -3549,7 +3591,8 @@ void kvfree_call_rcu(struct rcu_head *head, rcu_callback_t func)
 	kasan_record_aux_stack(ptr);
 	success = kvfree_call_rcu_add_ptr_to_bulk(krcp, ptr);
 	if (!success) {
-		run_page_cache_worker(krcp);
+		if (!krcp->offline)
+			run_page_cache_worker(krcp);
 
 		if (head == NULL)
 			// Inline if kvfree_rcu(one_arg) call.
@@ -4086,6 +4129,7 @@ int rcutree_prepare_cpu(unsigned int cpu)
 	rcu_spawn_cpu_nocb_kthread(cpu);
 	WRITE_ONCE(rcu_state.n_online_cpus, rcu_state.n_online_cpus + 1);
 
+	krc_offline(cpu, false);
 	return 0;
 }
 
@@ -4591,6 +4635,7 @@ static void __init kfree_rcu_batch_init(void)
 		INIT_DELAYED_WORK(&krcp->monitor_work, kfree_rcu_monitor);
 		INIT_WORK(&krcp->page_cache_work, fill_page_cache_func);
 		krcp->initialized = true;
+		krcp->offline = true;
 	}
 	if (register_shrinker(&kfree_rcu_shrinker))
 		pr_err("Failed to register kfree_rcu() shrinker!\n");
Signature · 1 line
2.29.2
maintainer
#2 lore raw

Hello, Qiang,

Quoted 10 lines · On Thu, Jan 21, 2021 at 02:49:49PM +0800, [email protected] wrote:
Quoted 8 lines

From: Zqiang <[email protected]>

If CPUs go offline, the corresponding krcp's page cache can not be use util the CPU come back online, or maybe the CPU will never go online again, this commit therefore free krcp's page cache when CPUs go offline.

Do you consider it as an issue? We have 5 pages per CPU, that is 20480 bytes.

--
Vlad Rezki

#3 lore raw

________________________________________
发件人: Uladzislau Rezki <[email protected]>
发送时间: 2021年1月22日 4:26
收件人: Zhang, Qiang
抄送: Paul E. McKenney; [email protected]; [email protected]; [email protected] 主题: Re: [PATCH] rcu: Release per-cpu krcp page cache when CPU going offline

Quoted 5 lines

Hello, Qiang,

Quoted 2 lines · On Thu, Jan 21, 2021 at 02:49:49PM +0800, [email protected] wrote:

From: Zqiang <[email protected]>

Quoted 9 lines
Quoted 6 lines

If CPUs go offline, the corresponding krcp's page cache can not be use util the CPU come back online, or maybe the CPU will never go online again, this commit therefore free krcp's page cache when CPUs go offline.

Do you consider it as an issue? We have 5 pages per CPU, that is 20480 bytes.

Hello Rezki

In a multi CPUs system, more than one CPUs may be offline, there are more than 5 pages, and these offline CPUs may never go online again or in the process of CPUs online, there are errors, which lead to the failure of online, these scenarios will lead to the per-cpu krc page cache will never be released.

Thanks
Qiang

Quoted 2 lines

--
Vlad Rezki

maintainer
#4 lore raw
Quoted 18 lines · Qiang

________________________________________
发件人: Uladzislau Rezki <[email protected]>
发送时间: 2021年1月22日 4:26
收件人: Zhang, Qiang
抄送: Paul E. McKenney; [email protected]; [email protected]; [email protected] 主题: Re: [PATCH] rcu: Release per-cpu krcp page cache when CPU going offline

Quoted 10 lines

Hello, Qiang,

Quoted 7 lines · On Thu, Jan 21, 2021 at 02:49:49PM +0800, [email protected] wrote:

From: Zqiang <[email protected]>

If CPUs go offline, the corresponding krcp's page cache can not be use util the CPU come back online, or maybe the CPU will never go online again, this commit therefore free krcp's page cache when CPUs go offline.

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

Do you consider it as an issue? We have 5 pages per CPU, that is 20480 bytes.

Hello Rezki

In a multi CPUs system, more than one CPUs may be offline, there are more than 5 pages, and these offline CPUs may never go online again or in the process of CPUs online, there are errors, which lead to the failure of online, these scenarios will lead to the per-cpu krc page cache will never be released.

Thanks for your answer. I was thinking more about if you knew some platforms which suffer from such extra page usage when CPU goes offline. Any issues your platforms or devices run into because of that.

So i understand that if CPU goes offline the 5 pages associated with it are unused until it goes online back.

--
Vlad Rezki

#5 lore raw

________________________________________
发件人: Uladzislau Rezki <[email protected]>
发送时间: 2021年1月22日 22:31
收件人: Zhang, Qiang
抄送: Uladzislau Rezki; Paul E. McKenney; [email protected]; [email protected] 主题: Re: 回复: [PATCH] rcu: Release per-cpu krcp page cache when CPU going offline

Quoted 25 lines · Qiang

________________________________________
发件人: Uladzislau Rezki <[email protected]>
发送时间: 2021年1月22日 4:26
收件人: Zhang, Qiang
抄送: Paul E. McKenney; [email protected]; [email protected]; [email protected] 主题: Re: [PATCH] rcu: Release per-cpu krcp page cache when CPU going offline

Quoted 5 lines

Hello, Qiang,

Quoted 2 lines · On Thu, Jan 21, 2021 at 02:49:49PM +0800, [email protected] wrote:

From: Zqiang <[email protected]>

Quoted 9 lines
Quoted 6 lines

If CPUs go offline, the corresponding krcp's page cache can not be use util the CPU come back online, or maybe the CPU will never go online again, this commit therefore free krcp's page cache when CPUs go offline.

Do you consider it as an issue? We have 5 pages per CPU, that is 20480 bytes.

Hello Rezki

Quoted 8 lines

In a multi CPUs system, more than one CPUs may be offline, there are more than 5 pages, and these offline CPUs may never go online again or in the process of CPUs online, there are errors, which lead to the failure of online, these scenarios will lead to the per-cpu krc page cache will never be released.

Thanks for your answer. I was thinking more about if you knew some >platforms which suffer from such extra page usage when CPU goes offline. Any >issues your platforms or devices run into because of that.

So i understand that if CPU goes offline the 5 pages associated with it >are unused until it goes online back.

I agree with you, But I still want to talk about what I think

My understanding is that when the CPU is offline, the pages is not accessible, beacuse we don't know when this CPU will
go online again, so we best to return these page to the buddy system, when the CPU goes online again, we can allocate page from the buddy system to fill krcp's page cache. maybe you may think that this memory is small and don't need to.

Thanks
Qiang

Quoted 3 lines

--
Vlad Rezki

maintainer
#6 lore raw
Quoted 44 lines · Qiang

________________________________________
发件人: Uladzislau Rezki <[email protected]>
发送时间: 2021年1月22日 22:31
收件人: Zhang, Qiang
抄送: Uladzislau Rezki; Paul E. McKenney; [email protected]; [email protected] 主题: Re: 回复: [PATCH] rcu: Release per-cpu krcp page cache when CPU going offline

Quoted 25 lines · Qiang

________________________________________
发件人: Uladzislau Rezki <[email protected]>
发送时间: 2021年1月22日 4:26
收件人: Zhang, Qiang
抄送: Paul E. McKenney; [email protected]; [email protected]; [email protected] 主题: Re: [PATCH] rcu: Release per-cpu krcp page cache when CPU going offline

Quoted 5 lines

Hello, Qiang,

Quoted 2 lines · On Thu, Jan 21, 2021 at 02:49:49PM +0800, [email protected] wrote:

From: Zqiang <[email protected]>

Quoted 9 lines
Quoted 6 lines

If CPUs go offline, the corresponding krcp's page cache can not be use util the CPU come back online, or maybe the CPU will never go online again, this commit therefore free krcp's page cache when CPUs go offline.

Do you consider it as an issue? We have 5 pages per CPU, that is 20480 bytes.

Hello Rezki

Quoted 8 lines

In a multi CPUs system, more than one CPUs may be offline, there are more than 5 pages, and these offline CPUs may never go online again or in the process of CPUs online, there are errors, which lead to the failure of online, these scenarios will lead to the per-cpu krc page cache will never be released.

Thanks for your answer. I was thinking more about if you knew some >platforms which suffer from such extra page usage when CPU goes offline. Any >issues your platforms or devices run into because of that.

So i understand that if CPU goes offline the 5 pages associated with it >are unused until it goes online back.

Quoted 9 lines

I agree with you, But I still want to talk about what I think

My understanding is that when the CPU is offline, the pages is not accessible, beacuse we don't know when this CPU will
go online again, so we best to return these page to the buddy system, when the CPU goes online again, we can allocate page from the buddy system to fill krcp's page cache. maybe you may think that this memory is small and don't need to.

Exactly. I think that 5 pages are not that important(small amount of memory), so it is not worth to build the logic around it in order to return them back to the page allocator when CPU goes offline, even forever. This is how i see it.

If you are aware about some specific systems where it is critical, please let's as know.

--
Vlad Rezki

maintainer
#7 lore raw
In reply to Zhang, Qiang
Quoted 42 lines

________________________________________
发件人: Uladzislau Rezki <[email protected]>
发送时间: 2021年1月22日 22:31
收件人: Zhang, Qiang
抄送: Uladzislau Rezki; Paul E. McKenney; [email protected]; [email protected] 主题: Re: 回复: [PATCH] rcu: Release per-cpu krcp page cache when CPU going offline

Quoted 25 lines · Qiang

________________________________________
发件人: Uladzislau Rezki <[email protected]>
发送时间: 2021年1月22日 4:26
收件人: Zhang, Qiang
抄送: Paul E. McKenney; [email protected]; [email protected]; [email protected] 主题: Re: [PATCH] rcu: Release per-cpu krcp page cache when CPU going offline

Quoted 5 lines

Hello, Qiang,

Quoted 2 lines · On Thu, Jan 21, 2021 at 02:49:49PM +0800, [email protected] wrote:

From: Zqiang <[email protected]>

Quoted 9 lines
Quoted 6 lines

If CPUs go offline, the corresponding krcp's page cache can not be use util the CPU come back online, or maybe the CPU will never go online again, this commit therefore free krcp's page cache when CPUs go offline.

Do you consider it as an issue? We have 5 pages per CPU, that is 20480 bytes.

Hello Rezki

Quoted 8 lines

In a multi CPUs system, more than one CPUs may be offline, there are more than 5 pages, and these offline CPUs may never go online again or in the process of CPUs online, there are errors, which lead to the failure of online, these scenarios will lead to the per-cpu krc page cache will never be released.

Thanks for your answer. I was thinking more about if you knew some >platforms which suffer from such extra page usage when CPU goes offline. Any >issues your platforms or devices run into because of that.

So i understand that if CPU goes offline the 5 pages associated with it >are unused until it goes online back.

Quoted 9 lines

I agree with you, But I still want to talk about what I think

My understanding is that when the CPU is offline, the pages is not accessible, beacuse we don't know when this CPU will
go online again, so we best to return these page to the buddy system, when the CPU goes online again, we can allocate page from the buddy system to fill krcp's page cache. maybe you may think that this memory is small and don't need to.

BTW, we can release the caches via shrinker path instead, what is more makes sense to me. We already have a callback, that frees pages when a page allocator asks for it. I think in that case it would be fair to return it to the buddy system. It happens under low memory condition or can be done manually to flush system caches:

echo 3 > /proc/sys/vm/drop_caches

What do you think?

--
Vlad Rezki

#8 lore raw

________________________________________
发件人: Uladzislau Rezki <[email protected]>
发送时间: 2021年1月26日 22:07
收件人: Zhang, Qiang
抄送: Uladzislau Rezki; Paul E. McKenney; [email protected]; [email protected] 主题: Re: 回复: 回复: [PATCH] rcu: Release per-cpu krcp page cache when CPU going offline

Quoted 45 lines · Qiang
Quoted 25 lines

________________________________________
发件人: Uladzislau Rezki <[email protected]>
发送时间: 2021年1月22日 4:26
收件人: Zhang, Qiang
抄送: Paul E. McKenney; [email protected]; [email protected]; [email protected] 主题: Re: [PATCH] rcu: Release per-cpu krcp page cache when CPU going offline

Quoted 5 lines

Hello, Qiang,

Quoted 2 lines · On Thu, Jan 21, 2021 at 02:49:49PM +0800, [email protected] wrote:

From: Zqiang <[email protected]>

Quoted 9 lines
Quoted 6 lines

If CPUs go offline, the corresponding krcp's page cache can not be use util the CPU come back online, or maybe the CPU will never go online again, this commit therefore free krcp's page cache when CPUs go offline.

Do you consider it as an issue? We have 5 pages per CPU, that is 20480 bytes.

Hello Rezki

Quoted 8 lines

In a multi CPUs system, more than one CPUs may be offline, there are more than 5 pages, and these offline CPUs may never go online again or in the process of CPUs online, there are errors, which lead to the failure of online, these scenarios will lead to the per-cpu krc page cache will never be released.

Thanks for your answer. I was thinking more about if you knew some >platforms which suffer from such extra page usage when CPU goes offline. Any >issues your platforms or devices run into because of that.

So i understand that if CPU goes offline the 5 pages associated with it >are unused until it goes online back.

I agree with you, But I still want to talk about what I think

My understanding is that when the CPU is offline, the pages is not accessible, beacuse we don't know when this CPU will
go online again, so we best to return these page to the buddy system, when the CPU goes online again, we can allocate page from the buddy system to fill krcp's page cache. maybe you may think that this memory is small and don't need to.

Quoted 4 lines

BTW, we can release the caches via shrinker path instead, what is more makes sense to me. We already have a callback, that frees pages when a page allocator asks for it. I think in that case it would be fair to return it to the buddy system. It happens under low memory condition

I agree. it can be done in shrink callback, can release the currently existing per-cpu page cache.

Thanks
Qiang

Quoted 9 lines

or can be done manually to flush
system caches:

echo 3 > /proc/sys/vm/drop_caches

What do you think?

--
Vlad Rezki

maintainer
#9 lore raw
Quoted 54 lines · Qiang

________________________________________
发件人: Uladzislau Rezki <[email protected]>
发送时间: 2021年1月26日 22:07
收件人: Zhang, Qiang
抄送: Uladzislau Rezki; Paul E. McKenney; [email protected]; [email protected] 主题: Re: 回复: 回复: [PATCH] rcu: Release per-cpu krcp page cache when CPU going offline

Quoted 45 lines · Qiang
Quoted 25 lines

________________________________________
发件人: Uladzislau Rezki <[email protected]>
发送时间: 2021年1月22日 4:26
收件人: Zhang, Qiang
抄送: Paul E. McKenney; [email protected]; [email protected]; [email protected] 主题: Re: [PATCH] rcu: Release per-cpu krcp page cache when CPU going offline

Quoted 5 lines

Hello, Qiang,

Quoted 2 lines · On Thu, Jan 21, 2021 at 02:49:49PM +0800, [email protected] wrote:

From: Zqiang <[email protected]>

Quoted 9 lines
Quoted 6 lines

If CPUs go offline, the corresponding krcp's page cache can not be use util the CPU come back online, or maybe the CPU will never go online again, this commit therefore free krcp's page cache when CPUs go offline.

Do you consider it as an issue? We have 5 pages per CPU, that is 20480 bytes.

Hello Rezki

Quoted 8 lines

In a multi CPUs system, more than one CPUs may be offline, there are more than 5 pages, and these offline CPUs may never go online again or in the process of CPUs online, there are errors, which lead to the failure of online, these scenarios will lead to the per-cpu krc page cache will never be released.

Thanks for your answer. I was thinking more about if you knew some >platforms which suffer from such extra page usage when CPU goes offline. Any >issues your platforms or devices run into because of that.

So i understand that if CPU goes offline the 5 pages associated with it >are unused until it goes online back.

I agree with you, But I still want to talk about what I think

My understanding is that when the CPU is offline, the pages is not accessible, beacuse we don't know when this CPU will
go online again, so we best to return these page to the buddy system, when the CPU goes online again, we can allocate page from the buddy system to fill krcp's page cache. maybe you may think that this memory is small and don't need to.

Quoted 8 lines
Quoted 4 lines

BTW, we can release the caches via shrinker path instead, what is more makes sense to me. We already have a callback, that frees pages when a page allocator asks for it. I think in that case it would be fair to return it to the buddy system. It happens under low memory condition

I agree. it can be done in shrink callback, can release the currently existing per-cpu page cache.

Would not you mind to send a patch? If you need some input, i am happy to participate.

Thanks!

--
Vlad Rezki