From: Uladzislau Rezki <urezki@gmail.com>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Christoph Lameter <cl@linux.com>,
David Rientjes <rientjes@google.com>,
"Paul E. McKenney" <paulmck@kernel.org>,
Joel Fernandes <joel@joelfernandes.org>,
Josh Triplett <josh@joshtriplett.org>,
Boqun Feng <boqun.feng@gmail.com>,
Uladzislau Rezki <urezki@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Hyeonggon Yoo <42.hyeyoo@gmail.com>,
linux-mm@kvack.org, Steven Rostedt <rostedt@goodmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Lai Jiangshan <jiangshanlai@gmail.com>,
Zqiang <qiang.zhang1211@gmail.com>,
rcu@vger.kernel.org
Subject: Re: [PATCH RFC 1/4] slab, rcu: move TINY_RCU variant of kvfree_rcu() to SLAB
Date: Fri, 24 Jan 2025 13:56:32 +0100 [thread overview]
Message-ID: <Z5OOAPQcoIP_HwYS@pc636> (raw)
In-Reply-To: <20250123-slub-tiny-kfree_rcu-v1-1-0e386ef1541a@suse.cz>
On Thu, Jan 23, 2025 at 11:37:18AM +0100, Vlastimil Babka wrote:
> Following the move of TREE_RCU implementation, let's move also the
> TINY_RCU one for consistency and subsequent refactoring.
>
> For simplicity, remove the separate inline __kvfree_call_rcu() as
> TINY_RCU is not meant for high-performance hardware anyway.
>
> Declare kvfree_call_rcu() in rcupdate.h to avoid header dependency
> issues.
>
> Also move the kvfree_rcu_barrier() declaration to slab.h
>
> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
> ---
> include/linux/rcupdate.h | 5 +++++
> include/linux/rcutiny.h | 36 ------------------------------------
> include/linux/rcutree.h | 3 ---
> include/linux/slab.h | 14 ++++++++++++++
> kernel/rcu/tiny.c | 11 -----------
> mm/slab_common.c | 20 ++++++++++++++++++--
> 6 files changed, 37 insertions(+), 52 deletions(-)
>
> diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> index 48e5c03df1dd83c246a61d0fcc8aa638adcd7654..3f70d1c8144426f40553c8c589f07097ece8a706 100644
> --- a/include/linux/rcupdate.h
> +++ b/include/linux/rcupdate.h
> @@ -1082,6 +1082,11 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)
> #define kfree_rcu_mightsleep(ptr) kvfree_rcu_arg_1(ptr)
> #define kvfree_rcu_mightsleep(ptr) kvfree_rcu_arg_1(ptr)
>
> +/*
> + * In mm/slab_common.c, no suitable header to include here.
> + */
> +void kvfree_call_rcu(struct rcu_head *head, void *ptr);
> +
> #define kvfree_rcu_arg_2(ptr, rhf) \
> do { \
> typeof (ptr) ___p = (ptr); \
> diff --git a/include/linux/rcutiny.h b/include/linux/rcutiny.h
> index fe42315f667fc5be7f2ed8eae6ea0c7193030846..f519cd6802286710bdd56588b5ff3d07bcd30b92 100644
> --- a/include/linux/rcutiny.h
> +++ b/include/linux/rcutiny.h
> @@ -90,41 +90,6 @@ static inline void synchronize_rcu_expedited(void)
> synchronize_rcu();
> }
>
> -/*
> - * Add one more declaration of kvfree() here. It is
> - * not so straight forward to just include <linux/mm.h>
> - * where it is defined due to getting many compile
> - * errors caused by that include.
> - */
> -extern void kvfree(const void *addr);
> -
> -static inline void __kvfree_call_rcu(struct rcu_head *head, void *ptr)
> -{
> - if (head) {
> - call_rcu(head, (rcu_callback_t) ((void *) head - ptr));
> - return;
> - }
> -
> - // kvfree_rcu(one_arg) call.
> - might_sleep();
> - synchronize_rcu();
> - kvfree(ptr);
> -}
> -
> -static inline void kvfree_rcu_barrier(void)
> -{
> - rcu_barrier();
> -}
> -
> -#ifdef CONFIG_KASAN_GENERIC
> -void kvfree_call_rcu(struct rcu_head *head, void *ptr);
> -#else
> -static inline void kvfree_call_rcu(struct rcu_head *head, void *ptr)
> -{
> - __kvfree_call_rcu(head, ptr);
> -}
> -#endif
> -
> void rcu_qs(void);
>
> static inline void rcu_softirq_qs(void)
> @@ -164,7 +129,6 @@ static inline void rcu_end_inkernel_boot(void) { }
> static inline bool rcu_inkernel_boot_has_ended(void) { return true; }
> static inline bool rcu_is_watching(void) { return true; }
> static inline void rcu_momentary_eqs(void) { }
> -static inline void kfree_rcu_scheduler_running(void) { }
>
> /* Avoid RCU read-side critical sections leaking across. */
> static inline void rcu_all_qs(void) { barrier(); }
> diff --git a/include/linux/rcutree.h b/include/linux/rcutree.h
> index 27d86d9127817e50f8d4dd79e1990d70a02435bb..dbe77b5fe06ec89a393b5444d6c479ced346a37b 100644
> --- a/include/linux/rcutree.h
> +++ b/include/linux/rcutree.h
> @@ -34,12 +34,9 @@ static inline void rcu_virt_note_context_switch(void)
> }
>
> void synchronize_rcu_expedited(void);
> -void kvfree_call_rcu(struct rcu_head *head, void *ptr);
> -void kvfree_rcu_barrier(void);
>
> void rcu_barrier(void);
> void rcu_momentary_eqs(void);
> -void kfree_rcu_scheduler_running(void);
>
> struct rcu_gp_oldstate {
> unsigned long rgos_norm;
> diff --git a/include/linux/slab.h b/include/linux/slab.h
> index 09eedaecf1205672bb2e7c8cd57ae8fccebc2737..bcc62e5656c35c6a3f4caf26fb33d7447dead39a 100644
> --- a/include/linux/slab.h
> +++ b/include/linux/slab.h
> @@ -16,6 +16,7 @@
> #include <linux/gfp.h>
> #include <linux/overflow.h>
> #include <linux/types.h>
> +#include <linux/rcupdate.h>
> #include <linux/workqueue.h>
> #include <linux/percpu-refcount.h>
> #include <linux/cleanup.h>
> @@ -1082,6 +1083,19 @@ extern void kvfree_sensitive(const void *addr, size_t len);
>
> unsigned int kmem_cache_size(struct kmem_cache *s);
>
> +#ifdef CONFIG_TINY_RCU
> +static inline void kvfree_rcu_barrier(void)
> +{
> + rcu_barrier();
> +}
> +
> +static inline void kfree_rcu_scheduler_running(void) { }
> +#else
> +void kvfree_rcu_barrier(void);
> +
> +void kfree_rcu_scheduler_running(void);
> +#endif
> +
> /**
> * kmalloc_size_roundup - Report allocation bucket size for the given size
> *
> diff --git a/kernel/rcu/tiny.c b/kernel/rcu/tiny.c
> index b3b3ce34df6310f7bddba40b2be1bdf6c9f00232..0ec27093d0e14a4b1060ea08932c4ac13f9b0f26 100644
> --- a/kernel/rcu/tiny.c
> +++ b/kernel/rcu/tiny.c
> @@ -246,17 +246,6 @@ bool poll_state_synchronize_rcu(unsigned long oldstate)
> }
> EXPORT_SYMBOL_GPL(poll_state_synchronize_rcu);
>
> -#ifdef CONFIG_KASAN_GENERIC
> -void kvfree_call_rcu(struct rcu_head *head, void *ptr)
> -{
> - if (head)
> - kasan_record_aux_stack_noalloc(ptr);
> -
> - __kvfree_call_rcu(head, ptr);
> -}
> -EXPORT_SYMBOL_GPL(kvfree_call_rcu);
> -#endif
> -
> void __init rcu_init(void)
> {
> open_softirq(RCU_SOFTIRQ, rcu_process_callbacks);
> diff --git a/mm/slab_common.c b/mm/slab_common.c
> index 69f2d19010dedaa3e5b303ab9803c8cdd40152fa..330cdd8ebc5380090ee784c58e8ca1d1a52b3758 100644
> --- a/mm/slab_common.c
> +++ b/mm/slab_common.c
> @@ -1861,7 +1861,23 @@ add_ptr_to_bulk_krc_lock(struct kfree_rcu_cpu **krcp,
> return true;
> }
>
> -#if !defined(CONFIG_TINY_RCU)
> +#ifdef CONFIG_TINY_RCU
> +
> +void kvfree_call_rcu(struct rcu_head *head, void *ptr)
> +{
> + if (head) {
> + kasan_record_aux_stack_noalloc(ptr);
> + call_rcu(head, (rcu_callback_t) ((void *) head - ptr));
> + return;
> + }
> +
> + // kvfree_rcu(one_arg) call.
> + might_sleep();
> + synchronize_rcu();
> + kvfree(ptr);
> +}
> +
> +#else /* !CONFIG_TINY_RCU */
>
> static enum hrtimer_restart
> schedule_page_work_fn(struct hrtimer *t)
> @@ -2071,7 +2087,7 @@ void kvfree_rcu_barrier(void)
> }
> EXPORT_SYMBOL_GPL(kvfree_rcu_barrier);
>
> -#endif /* #if !defined(CONFIG_TINY_RCU) */
> +#endif /* !CONFIG_TINY_RCU */
>
> static unsigned long
> kfree_rcu_shrink_count(struct shrinker *shrink, struct shrink_control *sc)
>
> --
> 2.48.1
>
Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
--
Uladzislau Rezki
next prev parent reply other threads:[~2025-01-24 12:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-23 10:37 [PATCH RFC 0/4] slab, rcu: move and consolidate TINY_RCU kvfree_rcu() to SLAB Vlastimil Babka
2025-01-23 10:37 ` [PATCH RFC 1/4] slab, rcu: move TINY_RCU variant of " Vlastimil Babka
2025-01-24 12:56 ` Uladzislau Rezki [this message]
2025-01-23 10:37 ` [PATCH RFC 2/4] rcu: remove trace_rcu_kvfree_callback Vlastimil Babka
2025-01-23 10:37 ` [PATCH RFC 3/4] rcu, slab: use a regular callback function for kvfree_rcu Vlastimil Babka
2025-01-24 12:47 ` Uladzislau Rezki
2025-01-24 14:16 ` Vlastimil Babka
2025-01-24 14:19 ` Uladzislau Rezki
2025-01-23 10:37 ` [PATCH RFC 4/4] slab: don't batch kvfree_rcu() with SLUB_TINY Vlastimil Babka
2025-01-24 2:43 ` kernel test robot
2025-01-24 12:11 ` Uladzislau Rezki
2025-01-23 19:37 ` [PATCH RFC 0/4] slab, rcu: move and consolidate TINY_RCU kvfree_rcu() to SLAB Joel Fernandes
2025-01-23 20:26 ` Paul E. McKenney
2025-01-24 14:25 ` Vlastimil Babka
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=Z5OOAPQcoIP_HwYS@pc636 \
--to=urezki@gmail.com \
--cc=42.hyeyoo@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=boqun.feng@gmail.com \
--cc=cl@linux.com \
--cc=jiangshanlai@gmail.com \
--cc=joel@joelfernandes.org \
--cc=josh@joshtriplett.org \
--cc=linux-mm@kvack.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=paulmck@kernel.org \
--cc=qiang.zhang1211@gmail.com \
--cc=rcu@vger.kernel.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=rostedt@goodmis.org \
--cc=vbabka@suse.cz \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.