Implement call_rcu_lazy() and miscellaneous fixes
Subsystems (6)
v3 cover Implement call_rcu_lazy() and miscellaneous fixes
Just a refresh of v3 with one additional debug patch. v3's cover letter is here:
https://lore.kernel.org/all/[email protected]/
I just started working on this again while I have some time during paternity leave ;-) So I thought I'll just send it out again. No other changes other than that 1 debug patch I added on the top.
Next I am going to go refine the power results as mentioned in Paul's comments on the last cover letter.
Joel Fernandes (Google) (5):
rcu: Introduce call_rcu_lazy() API implementation
rcuscale: Add laziness and kfree tests
fs: Move call_rcu() to call_rcu_lazy() in some paths
rcutorture: Add test code for call_rcu_lazy()
debug: Toggle lazy at runtime and change flush jiffies
Vineeth Pillai (1):
rcu: shrinker for lazy rcu
fs/dcache.c | 4 +- fs/eventpoll.c | 2 +- fs/file_table.c | 2 +- fs/inode.c | 2 +- include/linux/rcu_segcblist.h | 1 + include/linux/rcupdate.h | 6 + include/linux/sched/sysctl.h | 3 + kernel/rcu/Kconfig | 8 + kernel/rcu/rcu.h | 12 + kernel/rcu/rcu_segcblist.c | 15 +- kernel/rcu/rcu_segcblist.h | 20 +- kernel/rcu/rcuscale.c | 74 +++++- kernel/rcu/rcutorture.c | 60 ++++- kernel/rcu/tree.c | 131 ++++++---- kernel/rcu/tree.h | 10 +- kernel/rcu/tree_nocb.h | 246 +++++++++++++++--- kernel/sysctl.c | 17 ++ .../selftests/rcutorture/configs/rcu/CFLIST | 1 + .../selftests/rcutorture/configs/rcu/TREE11 | 18 ++ .../rcutorture/configs/rcu/TREE11.boot | 8 + 20 files changed, 536 insertions(+), 104 deletions(-)
create mode 100644 tools/testing/selftests/rcutorture/configs/rcu/TREE11 create mode 100644 tools/testing/selftests/rcutorture/configs/rcu/TREE11.boot
--
2.37.1.559.g78731f0fdb-goog
PATCH RESEND v3 1/6 rcu: Introduce call_rcu_lazy() API implementation
Implement timer-based RCU lazy callback batching. The batch is flushed whenever a certain amount of time has passed, or the batch on a particular CPU grows too big. Also memory pressure will flush it in a future patch.
To handle several corner cases automagically (such as rcu_barrier() and hotplug), we re-use bypass lists to handle lazy CBs. The bypass list length has the lazy CB length included in it. A separate lazy CB length counter is also introduced to keep track of the number of lazy CBs.
--- include/linux/rcu_segcblist.h | 1 + include/linux/rcupdate.h | 6 ++ kernel/rcu/Kconfig | 8 ++ kernel/rcu/rcu.h | 11 ++ kernel/rcu/rcu_segcblist.c | 15 ++- kernel/rcu/rcu_segcblist.h | 20 +++- kernel/rcu/tree.c | 130 +++++++++++++++--------- kernel/rcu/tree.h | 10 +- kernel/rcu/tree_nocb.h | 185 ++++++++++++++++++++++++++-------- 9 files changed, 289 insertions(+), 97 deletions(-)
include/linux/rcu_segcblist.h +1 -0
@@ -22,6 +22,7 @@ struct rcu_cblist {struct rcu_head *head;struct rcu_head **tail;long len; +long lazy_len; };#define RCU_CBLIST_INITIALIZER (n) { .head = NULL, .tail = &n.head }
include/linux/rcupdate.h +6 -0
@@ -82,6 +82,12 @@ static inline int rcu_preempt_depth(void)#endif /* #else #ifdef CONFIG_PREEMPT_RCU */ +#ifdef CONFIG_RCU_LAZY +void call_rcu_lazy (struct rcu_head *head,rcu_callback_t func); +#else +#define call_rcu_lazy (head, func) call_rcu(head, func) +#endif +/* Internal to kernel */ void rcu_init (void );extern int rcu_scheduler_active;
kernel/rcu/Kconfig +8 -0
@@ -293,4 +293,12 @@ config TASKS_TRACE_RCU_READ_MB Say N here if you hate read-side memory barriers. Take the default if you are unsure. +config RCU_LAZY + bool "RCU callback lazy invocation functionality" + depends on RCU_NOCB_CPU + default n + help + To save power, batch RCU callbacks and flush after delay, memory + pressure or callback list growing too big. + endmenu # "RCU Subsystem"
kernel/rcu/rcu.h +11 -0
@@ -463,6 +463,14 @@ enum rcutorture_type { INVALID_RCU_FLAVOR }; +#if defined(CONFIG_RCU_LAZY ) +unsigned long rcu_lazy_get_jiffies_till_flush (void ); +void rcu_lazy_set_jiffies_till_flush (unsigned long j); +#else +static inline unsigned long rcu_lazy_get_jiffies_till_flush (void ) {return 0 ; } +static inline void rcu_lazy_set_jiffies_till_flush (unsigned long j) { } +#endif +#if defined(CONFIG_TREE_RCU )void rcutorture_get_gp_data (enum rcutorture_type test_type,int *flags,unsigned long *gp_seq);
@@ -472,6 +480,8 @@ void do_trace_rcu_torture_read(const char *rcutorturename,unsigned long c_old, unsigned long c);void rcu_gp_set_torture_wait (int duration); +void rcu_force_call_rcu_to_lazy (bool force); +#else static inline void rcutorture_get_gp_data (enum rcutorture_type test_type,int *flags,unsigned long *gp_seq)
@@ -490,6 +500,7 @@ void do_trace_rcu_torture_read(const char *rcutorturename, do { } while (0)#endif static inline void rcu_gp_set_torture_wait (int duration) { } +static inline void rcu_force_call_rcu_to_lazy (bool force) { }#endif #if IS_ENABLED (CONFIG_RCU_TORTURE_TEST ) ||IS_MODULE (CONFIG_RCU_TORTURE_TEST )
kernel/rcu/rcu_segcblist.c +12 -3
@@ -20,16 +20,21 @@ void rcu_cblist_init(struct rcu_cblist *rclp) rclp->head =NULL ; rclp->tail = &rclp->head; rclp->len =0 ; + rclp->lazy_len =0 ; }/* * Enqueue an rcu_head structure onto the specified callback list. */ -void rcu_cblist_enqueue (struct rcu_cblist *rclp,struct rcu_head *rhp) +void rcu_cblist_enqueue (struct rcu_cblist *rclp,struct rcu_head *rhp, +bool lazy) { *rclp->tail = rhp; rclp->tail = &rhp->next;WRITE_ONCE (rclp->len, rclp->len +1 ); + +if (IS_ENABLED (CONFIG_RCU_LAZY ) && lazy) +WRITE_ONCE (rclp->lazy_len, rclp->lazy_len +1 ); }/*
@@ -38,11 +43,12 @@ void rcu_cblist_enqueue(struct rcu_cblist *rclp, struct rcu_head *rhp)* element of the second rcu_cblist structure, but ensuring that the second * rcu_cblist structure, if initially non-empty, always appears non-empty * throughout the process. If rdp is NULL, the second rcu_cblist structure -* is instead initialized to empty. +* is instead initialized to empty. Also account for lazy_len for lazy CBs. */ void rcu_cblist_flush_enqueue (struct rcu_cblist *drclp,struct rcu_cblist *srclp, -struct rcu_head *rhp) +struct rcu_head *rhp, +bool lazy) { drclp->head = srclp->head;if (drclp->head)
@@ -58,6 +64,9 @@ void rcu_cblist_flush_enqueue(struct rcu_cblist *drclp, srclp->tail = &rhp->next;WRITE_ONCE (srclp->len,1 ); } + +if (IS_ENABLED (CONFIG_RCU_LAZY ) && rhp && lazy) +WRITE_ONCE (srclp->lazy_len,1 ); }/*
kernel/rcu/rcu_segcblist.h +18 -2
@@ -15,14 +15,30 @@ static inline long rcu_cblist_n_cbs(struct rcu_cblist *rclp)return READ_ONCE (rclp->len); } +/* Return number of callbacks in the specified callback list. */ +static inline long rcu_cblist_n_lazy_cbs (struct rcu_cblist *rclp) +{ +if (IS_ENABLED (CONFIG_RCU_LAZY )) +return READ_ONCE (rclp->lazy_len); +return 0 ; +} + +static inline void rcu_cblist_reset_lazy_len (struct rcu_cblist *rclp) +{ +if (IS_ENABLED (CONFIG_RCU_LAZY )) +WRITE_ONCE (rclp->lazy_len,0 ); +} +/* Return number of callbacks in segmented callback list by summing seglen. */ long rcu_segcblist_n_segment_cbs (struct rcu_segcblist *rsclp);void rcu_cblist_init (struct rcu_cblist *rclp); -void rcu_cblist_enqueue (struct rcu_cblist *rclp,struct rcu_head *rhp); +void rcu_cblist_enqueue (struct rcu_cblist *rclp,struct rcu_head *rhp, +bool lazy);void rcu_cblist_flush_enqueue (struct rcu_cblist *drclp,struct rcu_cblist *srclp, -struct rcu_head *rhp); +struct rcu_head *rhp, +bool lazy);struct rcu_head *rcu_cblist_dequeue (struct rcu_cblist *rclp);/*
kernel/rcu/tree.c +85 -45
161 lines not on this page · raw message
kernel/rcu/tree.h +6 -4
@@ -267,8 +267,9 @@ struct rcu_data {/* Values for nocb_defer_wakeup field in struct rcu_data. */ #define RCU_NOCB_WAKE_NOT 0#define RCU_NOCB_WAKE_BYPASS 1 -#define RCU_NOCB_WAKE 2 -#define RCU_NOCB_WAKE_FORCE 3 +#define RCU_NOCB_WAKE_LAZY 2 +#define RCU_NOCB_WAKE 3 +#define RCU_NOCB_WAKE_FORCE 4#define RCU_JIFFIES_TILL_FORCE_QS (1 + (HZ > 250) + (HZ > 500))/* For jiffies_till_first_fqs and */
@@ -436,9 +437,10 @@ static struct swait_queue_head *rcu_nocb_gp_get(struct rcu_node *rnp);static void rcu_nocb_gp_cleanup (struct swait_queue_head *sq);static void rcu_init_one_nocb (struct rcu_node *rnp);static bool rcu_nocb_flush_bypass (struct rcu_data *rdp,struct rcu_head *rhp, -unsigned long j); +unsigned long j,bool lazy,bool wakegp);static bool rcu_nocb_try_bypass (struct rcu_data *rdp,struct rcu_head *rhp, -bool *was_alldone,unsigned long flags); +bool *was_alldone,unsigned long flags, +bool lazy);static void __call_rcu_nocb_wake (struct rcu_data *rdp,bool was_empty,unsigned long flags);static int rcu_nocb_need_deferred_wakeup (struct rcu_data *rdp,int level);
kernel/rcu/tree_nocb.h +142 -43
342 lines not on this page · raw message
Signature · 1 line
2.37.1.559.g78731f0fdb-goog
PATCH RESEND v3 2/6 rcu: shrinker for lazy rcu
In reply to Joel Fernandes (Google)From: Vineeth Pillai <[email protected]>
The shrinker is used to speed up the free'ing of memory potentially held by RCU lazy callbacks. RCU kernel module test cases show this to be effective. Test is introduced in a later patch.
--- kernel/rcu/tree_nocb.h | 52 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
kernel/rcu/tree_nocb.h +52 -0
@@ -1249,6 +1249,55 @@ int rcu_nocb_cpu_offload(int cpu) }EXPORT_SYMBOL_GPL (rcu_nocb_cpu_offload); +static unsigned long +lazy_rcu_shrink_count (struct shrinker *shrink,struct shrink_control *sc) +{ +int cpu; +unsigned long count =0 ; + +/* Snapshot count of all CPUs */ +for_each_possible_cpu (cpu) { +struct rcu_data *rdp =per_cpu_ptr (&rcu_data, cpu); + + count +=rcu_cblist_n_lazy_cbs (&rdp->nocb_bypass); + } + +return count ? count :SHRINK_EMPTY ; +} + +static unsigned long +lazy_rcu_shrink_scan (struct shrinker *shrink,struct shrink_control *sc) +{ +int cpu; +unsigned long flags; +unsigned long count =0 ; + +/* Snapshot count of all CPUs */ +for_each_possible_cpu (cpu) { +struct rcu_data *rdp =per_cpu_ptr (&rcu_data, cpu); +int _count =rcu_cblist_n_lazy_cbs (&rdp->nocb_bypass); + +if (_count ==0 ) +continue ; +rcu_nocb_lock_irqsave (rdp, flags); +rcu_cblist_reset_lazy_len (&rdp->nocb_bypass); +rcu_nocb_unlock_irqrestore (rdp, flags); +wake_nocb_gp (rdp, false); + sc->nr_to_scan -= _count; + count += _count; +if (sc->nr_to_scan <=0 ) +break ; + } +return count ? count :SHRINK_STOP ; +} + +static struct shrinker lazy_rcu_shrinker = { + .count_objects = lazy_rcu_shrink_count, + .scan_objects = lazy_rcu_shrink_scan, + .batch =0 , + .seeks =DEFAULT_SEEKS , +}; +void __init rcu_init_nohz (void ) {int cpu;
@@ -1286,6 +1335,9 @@ void __init rcu_init_nohz(void)if (!rcu_state.nocb_is_setup)return ; +if (register_shrinker (&lazy_rcu_shrinker)) +pr_err ("Failed to register lazy_rcu shrinker!\n" ); +#if defined(CONFIG_NO_HZ_FULL )if (tick_nohz_full_running)cpumask_or (rcu_nocb_mask, rcu_nocb_mask, tick_nohz_full_mask);
Signature · 1 line
2.37.1.559.g78731f0fdb-goog
PATCH RESEND v3 3/6 rcuscale: Add laziness and kfree tests
In reply to Joel Fernandes (Google)We had 2 tests to rcuscale, one is a startup test to check whether we are not too lazy or too hard working. Two, emulate kfree_rcu() itself to use call_rcu_lazy() and check memory pressure. In my testing, call_rcu_lazy() does well to keep memory pressure under control, similar to kfree_rcu().
--- kernel/rcu/rcuscale.c | 74 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-)
kernel/rcu/rcuscale.c +73 -1
@@ -95,6 +95,7 @@ torture_param(int, verbose, 1, "Enable verbose debugging printk()s");torture_param (int, writer_holdoff,0 ,"Holdoff (us) between GPs, zero to disable" );torture_param (int, kfree_rcu_test,0 ,"Do we run a kfree_rcu() scale test?" );torture_param (int, kfree_mult,1 ,"Multiple of kfree_obj size to allocate." ); +torture_param (int, kfree_rcu_by_lazy,0 ,"Use call_rcu_lazy() to emulate kfree_rcu()?" );static char *scale_type ="rcu" ;module_param (scale_type, charp,0444 );
@@ -658,6 +659,14 @@ struct kfree_obj {struct rcu_head rh; }; +/* Used if doing RCU-kfree'ing via call_rcu_lazy(). */ +static void kfree_rcu_lazy (struct rcu_head *rh) +{ + struct kfree_obj *obj = container_of(rh, struct kfree_obj, rh); + +kfree (obj); +} +static int kfree_scale_thread (void *arg) {
@@ -695,6 +704,11 @@ kfree_scale_thread(void *arg)if (!alloc_ptr)return -ENOMEM ; +if (kfree_rcu_by_lazy) { +call_rcu_lazy (&(alloc_ptr->rh), kfree_rcu_lazy); +continue ; + } +// By default kfree_rcu_test_single and kfree_rcu_test_double are // initialized to false. If both have the same value (false or true) // both are randomly tested, otherwise only the one with value true
@@ -737,6 +751,9 @@ kfree_scale_cleanup(void) {int i; +if (kfree_rcu_by_lazy) +rcu_force_call_rcu_to_lazy (false); +if (torture_cleanup_begin ())return ;
@@ -766,11 +783,64 @@ kfree_scale_shutdown(void *arg)return -EINVAL ; } +// Used if doing RCU-kfree'ing via call_rcu_lazy(). +static unsigned long jiffies_at_lazy_cb; +static struct rcu_head lazy_test1_rh; +static int rcu_lazy_test1_cb_called; +static void call_rcu_lazy_test1 (struct rcu_head *rh) +{ + jiffies_at_lazy_cb = jiffies; +WRITE_ONCE (rcu_lazy_test1_cb_called,1 ); +} +static int __init kfree_scale_init (void ) {long i;int firsterr =0 ; +unsigned long orig_jif, jif_start; + +// If lazy-rcu based kfree'ing is requested, then for kernels that +// support it, force all call_rcu() to call_rcu_lazy() so that non-lazy +// CBs do not remove laziness of the lazy ones (since the test tries to +// stress call_rcu_lazy() for OOM). +// +// Also, do a quick self-test to ensure laziness is as much as +// expected. +if (kfree_rcu_by_lazy && !IS_ENABLED (CONFIG_RCU_LAZY )) { +pr_alert ("CONFIG_RCU_LAZY is disabled, falling back to kfree_rcu() " +"for delayed RCU kfree'ing\n" ); + kfree_rcu_by_lazy =0 ; + } + +if (kfree_rcu_by_lazy) { +/* do a test to check the timeout. */ + orig_jif =rcu_lazy_get_jiffies_till_flush (); + +rcu_force_call_rcu_to_lazy (true); +rcu_lazy_set_jiffies_till_flush (2 *HZ ); +rcu_barrier (); + + jif_start = jiffies; + jiffies_at_lazy_cb =0 ; +call_rcu_lazy (&lazy_test1_rh, call_rcu_lazy_test1); + +smp_cond_load_relaxed (&rcu_lazy_test1_cb_called,VAL ==1 ); + +rcu_lazy_set_jiffies_till_flush (orig_jif); + +if (WARN_ON_ONCE (jiffies_at_lazy_cb - jif_start <2 *HZ )) { +pr_alert ("ERROR: Lazy CBs are not being lazy as expected!\n" ); +WARN_ON_ONCE (1 ); +return -1 ; + } + +if (WARN_ON_ONCE (jiffies_at_lazy_cb - jif_start >3 *HZ )) { +pr_alert ("ERROR: Lazy CBs are being too lazy!\n" ); +WARN_ON_ONCE (1 ); +return -1 ; + } + } kfree_nrealthreads =compute_real (kfree_nthreads);/* Start up the kthreads. */
@@ -783,7 +853,9 @@ kfree_scale_init(void)schedule_timeout_uninterruptible (1 ); } -pr_alert ("kfree object size=%zu\n" , kfree_mult *sizeof (struct kfree_obj )); +pr_alert ("kfree object size=%zu, kfree_rcu_by_lazy=%d\n" , + kfree_mult *sizeof (struct kfree_obj ), + kfree_rcu_by_lazy); kfree_reader_tasks =kcalloc (kfree_nrealthreads,sizeof (kfree_reader_tasks[0 ]),GFP_KERNEL );
Signature · 1 line
2.37.1.559.g78731f0fdb-goog
PATCH RESEND v3 4/6 fs: Move call_rcu() to call_rcu_lazy() in some paths
In reply to Joel Fernandes (Google)This is required to prevent callbacks triggering RCU machinery too quickly and too often, which adds more power to the system.
When testing, we found that these paths were invoked often when the system is not doing anything (screen is ON but otherwise idle).
--- fs/dcache.c | 4 ++-- fs/eventpoll.c | 2 +- fs/file_table.c | 2 +- fs/inode.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)
fs/dcache.c +2 -2
@@ -366,7 +366,7 @@ static void dentry_free(struct dentry *dentry)if (unlikely (dname_external (dentry))) {struct external_name *p =external_name (dentry);if (likely (atomic_dec_and_test (&p->u.count))) { -call_rcu (&dentry->d_u.d_rcu, __d_free_external); +call_rcu_lazy (&dentry->d_u.d_rcu, __d_free_external);return ; } }
@@ -374,7 +374,7 @@ static void dentry_free(struct dentry *dentry)if (dentry->d_flags &DCACHE_NORCU )__d_free (&dentry->d_u.d_rcu);else -call_rcu (&dentry->d_u.d_rcu, __d_free); +call_rcu_lazy (&dentry->d_u.d_rcu, __d_free); }/*
fs/eventpoll.c +1 -1
@@ -729,7 +729,7 @@ static int ep_remove(struct eventpoll *ep, struct epitem *epi)* ep->mtx. The rcu read side, reverse_path_check_proc(), does not make * use of the rbn field. */ -call_rcu (&epi->rcu, epi_rcu_free); +call_rcu_lazy (&epi->rcu, epi_rcu_free);percpu_counter_dec (&ep->user->epoll_watches);
fs/file_table.c +1 -1
@@ -56,7 +56,7 @@ static inline void file_free(struct file *f)security_file_free (f);if (!(f->f_mode &FMODE_NOACCOUNT ))percpu_counter_dec (&nr_files); -call_rcu (&f->f_u.fu_rcuhead, file_free_rcu); +call_rcu_lazy (&f->f_u.fu_rcuhead, file_free_rcu); }/*
fs/inode.c +1 -1
@@ -312,7 +312,7 @@ static void destroy_inode(struct inode *inode)return ; } inode->free_inode = ops->free_inode; -call_rcu (&inode->i_rcu, i_callback); +call_rcu_lazy (&inode->i_rcu, i_callback); }/**
Signature · 1 line
2.37.1.559.g78731f0fdb-goog
Re: [PATCH v3 resend 4/6] fs: Move call_rcu() to call_rcu_lazy() in some paths
Quoted 6 lines · Joel Fernandes (Google)
This is required to prevent callbacks triggering RCU machinery too quickly and too often, which adds more power to the system.
When testing, we found that these paths were invoked often when the system is not doing anything (screen is ON but otherwise idle).
Unfortunately, I am seeing a slow down in ChromeOS boot performance after applying this particular patch. It is the first time I could test ChromeOS boot times with the series since it was hard to find a ChromeOS device that runs the upstream kernel.
Anyway, Vlad, Neeraj, do you guys also see slower boot times with this patch? I wonder if the issue is with wake up interaction with the nocb GP threads.
We ought to disable lazy RCU during boot since it would have little benefit anyway. But I am also concerned about some deeper problem I did not catch before.
I'll look into tracing the fs paths to see if I can narrow down what's causing it. Will also try a newer kernel, I am currently testing on 5.19-rc4.
Thanks,
- Joel
Quoted 73 lines
Signed-off-by Joel Fernandes (Google) <[email protected]>--- fs/dcache.c | 4 ++-- fs/eventpoll.c | 2 +- fs/file_table.c | 2 +- fs/inode.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)fs/dcache.c +2
-2@@ -366,7 +366,7 @@ static void dentry_free(struct dentry *dentry)if (unlikely (dname_external (dentry))) {struct external_name *p =external_name (dentry);if (likely (atomic_dec_and_test (&p->u.count))) { -call_rcu (&dentry->d_u.d_rcu, __d_free_external); +call_rcu_lazy (&dentry->d_u.d_rcu, __d_free_external);return ; } }@@ -374,7 +374,7 @@ static void dentry_free(struct dentry *dentry)if (dentry->d_flags &DCACHE_NORCU )__d_free (&dentry->d_u.d_rcu);else -call_rcu (&dentry->d_u.d_rcu, __d_free); +call_rcu_lazy (&dentry->d_u.d_rcu, __d_free); }/* fs/eventpoll.c +1
-1@@ -729,7 +729,7 @@ static int ep_remove(struct eventpoll *ep, struct epitem *epi)* ep->mtx. The rcu read side, reverse_path_check_proc(), does not make * use of the rbn field. */ -call_rcu (&epi->rcu, epi_rcu_free); +call_rcu_lazy (&epi->rcu, epi_rcu_free);percpu_counter_dec (&ep->user->epoll_watches);fs/file_table.c +1
-1@@ -56,7 +56,7 @@ static inline void file_free(struct file *f)security_file_free (f);if (!(f->f_mode &FMODE_NOACCOUNT ))percpu_counter_dec (&nr_files); -call_rcu (&f->f_u.fu_rcuhead, file_free_rcu); +call_rcu_lazy (&f->f_u.fu_rcuhead, file_free_rcu); }/* fs/inode.c +1
-2@@ -312,7 +312,7 @@ static void destroy_inode(struct inode *inode)return ; } inode->free_inode = ops->free_inode; -call_rcu (&inode->i_rcu, i_callback); +call_rcu_lazy (&inode->i_rcu, i_callback); }/** -- 2.37.1.559.g78731f0fdb-goog
Re: [PATCH v3 resend 4/6] fs: Move call_rcu() to call_rcu_lazy() in some paths
In reply to Joel Fernandes (Google)[Sorry, adding back the CC list]
Quoted 6 lines · Joel Fernandes (Google)
This is required to prevent callbacks triggering RCU machinery too quickly and too often, which adds more power to the system.
When testing, we found that these paths were invoked often when the system is not doing anything (screen is ON but otherwise idle).
Unfortunately, I am seeing a slow down in ChromeOS boot performance after applying this particular patch. It is the first time I could test ChromeOS boot times with the series since it was hard to find a ChromeOS device that runs the upstream kernel.
Anyway, Vlad, Neeraj, do you guys also see slower boot times with this patch? I wonder if the issue is with wake up interaction with the nocb GP threads.
We ought to disable lazy RCU during boot since it would have little benefit anyway. But I am also concerned about some deeper problem I did not catch before.
I'll look into tracing the fs paths to see if I can narrow down what's causing it. Will also try a newer kernel, I am currently testing on 5.19-rc4.
Thanks,
- Joel
Re: [PATCH v3 resend 4/6] fs: Move call_rcu() to call_rcu_lazy() in some paths
Quoted 21 lines · Joel Fernandes
[Sorry, adding back the CC list]
Quoted 6 lines · Joel Fernandes (Google)
This is required to prevent callbacks triggering RCU machinery too quickly and too often, which adds more power to the system.
When testing, we found that these paths were invoked often when the system is not doing anything (screen is ON but otherwise idle).
Unfortunately, I am seeing a slow down in ChromeOS boot performance after applying this particular patch. It is the first time I could test ChromeOS boot times with the series since it was hard to find a ChromeOS device that runs the upstream kernel.
Anyway, Vlad, Neeraj, do you guys also see slower boot times with this patch? I wonder if the issue is with wake up interaction with the nocb GP threads.
Quoted 7 lines
We ought to disable lazy RCU during boot since it would have little benefit anyway. But I am also concerned about some deeper problem I did not catch before.
I'll look into tracing the fs paths to see if I can narrow down what's causing it. Will also try a newer kernel, I am currently testing on 5.19-rc4.
I got somewhere with this. It looks like queuing CBs as lazy CBs instead of normal CBs, are triggering expedited stalls during the boot process:
39.949198] rcu: INFO: rcu_preempt detected expedited stalls on
CPUs/tasks: { } 28 jiffies s: 69 root: 0x0/.
No idea how/why lazy RCU CBs would be related to expedited GP issues, but maybe something hangs and causes that side-effect.
initcall_debug did not help, as it seems initcalls all work fine, and then 8 seconds after the boot, it starts slowing down a lot, followed by the RCU stall messages. As a next step I'll enable ftrace during the boot to see if I can get more insight. But I believe, its not the FS layer, the FS layer just triggers lazy CBs, but there is something wrong with the core lazy-RCU work itself.
This kernel is 5.19-rc4. I'll also try to rebase ChromeOS on more recent kernels and debug.
Thanks,
- Joel
Re: [PATCH v3 resend 4/6] fs: Move call_rcu() to call_rcu_lazy() in some paths
Quoted 48 lines · Joel Fernandes
Quoted 21 lines · Joel Fernandes
[Sorry, adding back the CC list]
Quoted 6 lines · Joel Fernandes (Google)
This is required to prevent callbacks triggering RCU machinery too quickly and too often, which adds more power to the system.
When testing, we found that these paths were invoked often when the system is not doing anything (screen is ON but otherwise idle).
Unfortunately, I am seeing a slow down in ChromeOS boot performance after applying this particular patch. It is the first time I could test ChromeOS boot times with the series since it was hard to find a ChromeOS device that runs the upstream kernel.
Anyway, Vlad, Neeraj, do you guys also see slower boot times with this patch? I wonder if the issue is with wake up interaction with the nocb GP threads.
Quoted 7 lines
We ought to disable lazy RCU during boot since it would have little benefit anyway. But I am also concerned about some deeper problem I did not catch before.
I'll look into tracing the fs paths to see if I can narrow down what's causing it. Will also try a newer kernel, I am currently testing on 5.19-rc4.
I got somewhere with this. It looks like queuing CBs as lazy CBs instead of normal CBs, are triggering expedited stalls during the boot process:
39.949198] rcu: INFO:
rcu_preemptdetected expedited stalls on
CPUs/tasks: { } 28 jiffies s: 69 root: 0x0/.No idea how/why lazy RCU CBs would be related to expedited GP issues, but maybe something hangs and causes that side-effect.
initcall_debugdid not help, as it seems initcalls all work fine, and then 8 seconds after the boot, it starts slowing down a lot, followed by the RCU stall messages. As a next step I'll enable ftrace during the boot to see if I can get more insight. But I believe, its not the FS layer, the FS layer just triggers lazy CBs, but there is something wrong with the core lazy-RCU work itself.
Quoted 2 lines
This kernel is 5.19-rc4. I'll also try to rebase ChromeOS on more recent kernels and debug.
More digging, thanks to trace_event= boot option , I find that the boot process does have some synchronous waits, and though these are "non-lazy", for some reason the lazy CBs that were previously queued are making them wait for the *full* lazy duration. Which points to a likely bug in the lazy RCU logic. These synchronous CBs should never be waiting like the lazy ones:
[ 17.715904] => trace_dump_stack [ 17.715904] => __wait_rcu_gp [ 17.715904] => synchronize_rcu [ 17.715904] => selinux_netcache_avc_callback [ 17.715904] => avc_ss_reset [ 17.715904] => sel_write_enforce [ 17.715904] => vfs_write [ 17.715904] => ksys_write [ 17.715904] => do_syscall_64 [ 17.715904] => entry_SYSCALL_64_after_hwframe
I'm tired so I'll resume the debug later.
Re: [PATCH v3 resend 4/6] fs: Move call_rcu() to call_rcu_lazy() in some paths
Quoted 53 lines · Joel Fernandes
Quoted 48 lines · Joel Fernandes
Quoted 21 lines · Joel Fernandes
[Sorry, adding back the CC list]
Quoted 6 lines · Joel Fernandes (Google)
This is required to prevent callbacks triggering RCU machinery too quickly and too often, which adds more power to the system.
When testing, we found that these paths were invoked often when the system is not doing anything (screen is ON but otherwise idle).
Unfortunately, I am seeing a slow down in ChromeOS boot performance after applying this particular patch. It is the first time I could test ChromeOS boot times with the series since it was hard to find a ChromeOS device that runs the upstream kernel.
Anyway, Vlad, Neeraj, do you guys also see slower boot times with this patch? I wonder if the issue is with wake up interaction with the nocb GP threads.
Quoted 7 lines
We ought to disable lazy RCU during boot since it would have little benefit anyway. But I am also concerned about some deeper problem I did not catch before.
I'll look into tracing the fs paths to see if I can narrow down what's causing it. Will also try a newer kernel, I am currently testing on 5.19-rc4.
I got somewhere with this. It looks like queuing CBs as lazy CBs instead of normal CBs, are triggering expedited stalls during the boot process:
39.949198] rcu: INFO:
rcu_preemptdetected expedited stalls on
CPUs/tasks: { } 28 jiffies s: 69 root: 0x0/.No idea how/why lazy RCU CBs would be related to expedited GP issues, but maybe something hangs and causes that side-effect.
initcall_debugdid not help, as it seems initcalls all work fine, and then 8 seconds after the boot, it starts slowing down a lot, followed by the RCU stall messages. As a next step I'll enable ftrace during the boot to see if I can get more insight. But I believe, its not the FS layer, the FS layer just triggers lazy CBs, but there is something wrong with the core lazy-RCU work itself.Quoted 2 lines
This kernel is 5.19-rc4. I'll also try to rebase ChromeOS on more recent kernels and debug.
Quoted 7 lines
More digging, thanks to trace_event= boot option , I find that the boot process does have some synchronous waits, and though these are "non-lazy", for some reason the lazy CBs that were previously queued are making them wait for the *full* lazy duration. Which points to a likely bug in the lazy RCU logic. These synchronous CBs should never be waiting like the lazy ones:
[ 17.715904] init-1 2..... 8917039us : <stack trace>
Quoted 11 lines
[ 17.715904] => trace_dump_stack [ 17.715904] => __wait_rcu_gp [ 17.715904] => synchronize_rcu [ 17.715904] => selinux_netcache_avc_callback [ 17.715904] => avc_ss_reset [ 17.715904] => sel_write_enforce [ 17.715904] => vfs_write [ 17.715904] => ksys_write [ 17.715904] => do_syscall_64 [ 17.715904] => entry_SYSCALL_64_after_hwframe
Quoted 1 line
I'm tired so I'll resume the debug later.
Rushikesh, btw do note that using jiffies_till_first_fqs would also likely slow these synchronous waits down, and thus slow down the boot process for ChromeOS. This could be what you're seeing with the jiffies option. No idea why you were not seeing this in earlier experiments, maybe there was a change in ChromeOS with how selinux enforce option was being written out, or something. This write syscall is being done by the init process. I'll add this to the slides as well as another call_rcu_lazy() selling point (vs using jiffies) :)
- Joel
Paul E. McKenney
maintainerRe: [PATCH v3 resend 4/6] fs: Move call_rcu() to call_rcu_lazy() in some paths
In reply to Joel FernandesQuoted 70 lines · Joel Fernandes
Quoted 48 lines · Joel Fernandes
Quoted 21 lines · Joel Fernandes
[Sorry, adding back the CC list]
Quoted 6 lines · Joel Fernandes (Google)
This is required to prevent callbacks triggering RCU machinery too quickly and too often, which adds more power to the system.
When testing, we found that these paths were invoked often when the system is not doing anything (screen is ON but otherwise idle).
Unfortunately, I am seeing a slow down in ChromeOS boot performance after applying this particular patch. It is the first time I could test ChromeOS boot times with the series since it was hard to find a ChromeOS device that runs the upstream kernel.
Anyway, Vlad, Neeraj, do you guys also see slower boot times with this patch? I wonder if the issue is with wake up interaction with the nocb GP threads.
Quoted 7 lines
We ought to disable lazy RCU during boot since it would have little benefit anyway. But I am also concerned about some deeper problem I did not catch before.
I'll look into tracing the fs paths to see if I can narrow down what's causing it. Will also try a newer kernel, I am currently testing on 5.19-rc4.
I got somewhere with this. It looks like queuing CBs as lazy CBs instead of normal CBs, are triggering expedited stalls during the boot process:
39.949198] rcu: INFO:
rcu_preemptdetected expedited stalls on
CPUs/tasks: { } 28 jiffies s: 69 root: 0x0/.No idea how/why lazy RCU CBs would be related to expedited GP issues, but maybe something hangs and causes that side-effect.
initcall_debugdid not help, as it seems initcalls all work fine, and then 8 seconds after the boot, it starts slowing down a lot, followed by the RCU stall messages. As a next step I'll enable ftrace during the boot to see if I can get more insight. But I believe, its not the FS layer, the FS layer just triggers lazy CBs, but there is something wrong with the core lazy-RCU work itself.Quoted 2 lines
This kernel is 5.19-rc4. I'll also try to rebase ChromeOS on more recent kernels and debug.
More digging, thanks to trace_event= boot option , I find that the boot process does have some synchronous waits, and though these are "non-lazy", for some reason the lazy CBs that were previously queued are making them wait for the *full* lazy duration. Which points to a likely bug in the lazy RCU logic. These synchronous CBs should never be waiting like the lazy ones:
[ 17.715904] => trace_dump_stack [ 17.715904] => __wait_rcu_gp [ 17.715904] => synchronize_rcu [ 17.715904] => selinux_netcache_avc_callback [ 17.715904] => avc_ss_reset [ 17.715904] => sel_write_enforce [ 17.715904] => vfs_write [ 17.715904] => ksys_write [ 17.715904] => do_syscall_64 [ 17.715904] => entry_SYSCALL_64_after_hwframe
Quoted 1 line
I'm tired so I'll resume the debug later.
At times like this, I often pull the suspect code into userspace and run it through its paces. In this case, a bunch of call_rcu_lazy() invocations into an empty bypass list, followed by a call_rcu() invocation, then a check to make sure that the bypass list is no longer lazy.
Thanx, Paul
Re: [PATCH v3 resend 4/6] fs: Move call_rcu() to call_rcu_lazy() in some paths
Quoted 71 lines · Paul E. McKenney
Quoted 70 lines · Joel Fernandes
Quoted 48 lines · Joel Fernandes
Quoted 21 lines · Joel Fernandes
[Sorry, adding back the CC list]
Quoted 6 lines · Joel Fernandes (Google)
This is required to prevent callbacks triggering RCU machinery too quickly and too often, which adds more power to the system.
When testing, we found that these paths were invoked often when the system is not doing anything (screen is ON but otherwise idle).
Unfortunately, I am seeing a slow down in ChromeOS boot performance after applying this particular patch. It is the first time I could test ChromeOS boot times with the series since it was hard to find a ChromeOS device that runs the upstream kernel.
Anyway, Vlad, Neeraj, do you guys also see slower boot times with this patch? I wonder if the issue is with wake up interaction with the nocb GP threads.
Quoted 7 lines
We ought to disable lazy RCU during boot since it would have little benefit anyway. But I am also concerned about some deeper problem I did not catch before.
I'll look into tracing the fs paths to see if I can narrow down what's causing it. Will also try a newer kernel, I am currently testing on 5.19-rc4.
I got somewhere with this. It looks like queuing CBs as lazy CBs instead of normal CBs, are triggering expedited stalls during the boot process:
39.949198] rcu: INFO:
rcu_preemptdetected expedited stalls on
CPUs/tasks: { } 28 jiffies s: 69 root: 0x0/.No idea how/why lazy RCU CBs would be related to expedited GP issues, but maybe something hangs and causes that side-effect.
initcall_debugdid not help, as it seems initcalls all work fine, and then 8 seconds after the boot, it starts slowing down a lot, followed by the RCU stall messages. As a next step I'll enable ftrace during the boot to see if I can get more insight. But I believe, its not the FS layer, the FS layer just triggers lazy CBs, but there is something wrong with the core lazy-RCU work itself.Quoted 2 lines
This kernel is 5.19-rc4. I'll also try to rebase ChromeOS on more recent kernels and debug.
More digging, thanks to trace_event= boot option , I find that the boot process does have some synchronous waits, and though these are "non-lazy", for some reason the lazy CBs that were previously queued are making them wait for the *full* lazy duration. Which points to a likely bug in the lazy RCU logic. These synchronous CBs should never be waiting like the lazy ones:
[ 17.715904] => trace_dump_stack [ 17.715904] => __wait_rcu_gp [ 17.715904] => synchronize_rcu [ 17.715904] => selinux_netcache_avc_callback [ 17.715904] => avc_ss_reset [ 17.715904] => sel_write_enforce [ 17.715904] => vfs_write [ 17.715904] => ksys_write [ 17.715904] => do_syscall_64 [ 17.715904] => entry_SYSCALL_64_after_hwframe
Quoted 7 lines
Quoted 1 line
I'm tired so I'll resume the debug later.
At times like this, I often pull the suspect code into userspace and run it through its paces. In this case, a bunch of
call_rcu_lazy()invocations into an empty bypass list, followed by acall_rcu()invocation, then a check to make sure that the bypass list is no longer lazy.
Thanks a lot for this great debug idea, I will look into it.
Thanks,
- Joel
Re: [PATCH v3 resend 4/6] fs: Move call_rcu() to call_rcu_lazy() in some paths
Quoted 76 lines · Joel Fernandes
Quoted 73 lines · Paul E. McKenney
Quoted 71 lines · Joel Fernandes
Quoted 48 lines · Joel Fernandes
Quoted 21 lines · Joel Fernandes
[Sorry, adding back the CC list]
Quoted 6 lines · Joel Fernandes (Google)
This is required to prevent callbacks triggering RCU machinery too quickly and too often, which adds more power to the system.
When testing, we found that these paths were invoked often when the system is not doing anything (screen is ON but otherwise idle).
Unfortunately, I am seeing a slow down in ChromeOS boot performance after applying this particular patch. It is the first time I could test ChromeOS boot times with the series since it was hard to find a ChromeOS device that runs the upstream kernel.
Anyway, Vlad, Neeraj, do you guys also see slower boot times with this patch? I wonder if the issue is with wake up interaction with the nocb GP threads.
Quoted 7 lines
We ought to disable lazy RCU during boot since it would have little benefit anyway. But I am also concerned about some deeper problem I did not catch before.
I'll look into tracing the fs paths to see if I can narrow down what's causing it. Will also try a newer kernel, I am currently testing on 5.19-rc4.
I got somewhere with this. It looks like queuing CBs as lazy CBs instead of normal CBs, are triggering expedited stalls during the boot process:
39.949198] rcu: INFO:
rcu_preemptdetected expedited stalls on
CPUs/tasks: { } 28 jiffies s: 69 root: 0x0/.No idea how/why lazy RCU CBs would be related to expedited GP issues, but maybe something hangs and causes that side-effect.
initcall_debugdid not help, as it seems initcalls all work fine, and then 8 seconds after the boot, it starts slowing down a lot, followed by the RCU stall messages. As a next step I'll enable ftrace during the boot to see if I can get more insight. But I believe, its not the FS layer, the FS layer just triggers lazy CBs, but there is something wrong with the core lazy-RCU work itself.Quoted 2 lines
This kernel is 5.19-rc4. I'll also try to rebase ChromeOS on more recent kernels and debug.
More digging, thanks to trace_event= boot option , I find that the boot process does have some synchronous waits, and though these are "non-lazy", for some reason the lazy CBs that were previously queued are making them wait for the *full* lazy duration. Which points to a likely bug in the lazy RCU logic. These synchronous CBs should never be waiting like the lazy ones:
[ 17.715904] => trace_dump_stack [ 17.715904] => __wait_rcu_gp [ 17.715904] => synchronize_rcu [ 17.715904] => selinux_netcache_avc_callback [ 17.715904] => avc_ss_reset [ 17.715904] => sel_write_enforce [ 17.715904] => vfs_write [ 17.715904] => ksys_write [ 17.715904] => do_syscall_64 [ 17.715904] => entry_SYSCALL_64_after_hwframeI'm tired so I'll resume the debug later.
Quoted 7 lines
Quoted 5 lines
At times like this, I often pull the suspect code into userspace and run it through its paces. In this case, a bunch of
call_rcu_lazy()invocations into an empty bypass list, followed by acall_rcu()invocation, then a check to make sure that the bypass list is no longer lazy.Thanks a lot for this great debug idea, I will look into it.
It seems to be a subtle issue when a large number of callbacks are queued trigging the lock-contention code, which happens at boot. It appears the non-lazy ones and lazy ones collide, so you have the lazy timer which wins, and then the regular bypass lock-contention timer is not allowed to do its thing. Due to this, the rcuog thread wakes up much later than a jiffie.
Things are much better with the following change. However, this brings me to a question about lock-contention based or any deferring and boot time.
If you have a path like selinux doing a synchronize_rcu(), shouldn't we skip the jiffie waiting for the bypass timer? Otherwise things synchronously waiting will slow down more than usual. Maybe bypassing should not be done for any case until boot up is done. I'm curious to see if that improves boot time.
@@ -580,7 +585,11 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
len = rcu_segcblist_n_cbs(&rdp->cblist);
bypass_len = rcu_cblist_n_cbs(&rdp->nocb_bypass);
lazy_len = rcu_cblist_n_lazy_cbs(&rdp->nocb_bypass);
- if (was_alldone) {
+
+ // If we are in lazy-mode, we still need to do a wake up even if
+ // all CBs were previously done. Otherwise the GP thread will
+ // wait for the full lazy duration.
+ if (was_alldone || (READ_ONCE(rdp->nocb_defer_wakeup) ==
RCU_NOCB_WAKE_LAZY)) {
rdp->qlen_last_fqs_check = len;
// Only lazy CBs in bypass list
if (lazy_len && bypass_len == lazy_len) {---
Thanks,
- Joel
Paul E. McKenney
maintainerRe: [PATCH v3 resend 4/6] fs: Move call_rcu() to call_rcu_lazy() in some paths
Quoted 81 lines · Joel Fernandes
Quoted 80 lines · Joel Fernandes
Quoted 78 lines · Paul E. McKenney
Quoted 70 lines · Joel Fernandes
Quoted 48 lines · Joel Fernandes
Quoted 21 lines · Joel Fernandes
[Sorry, adding back the CC list]
Quoted 6 lines · Joel Fernandes (Google)
This is required to prevent callbacks triggering RCU machinery too quickly and too often, which adds more power to the system.
When testing, we found that these paths were invoked often when the system is not doing anything (screen is ON but otherwise idle).
Unfortunately, I am seeing a slow down in ChromeOS boot performance after applying this particular patch. It is the first time I could test ChromeOS boot times with the series since it was hard to find a ChromeOS device that runs the upstream kernel.
Anyway, Vlad, Neeraj, do you guys also see slower boot times with this patch? I wonder if the issue is with wake up interaction with the nocb GP threads.
Quoted 7 lines
We ought to disable lazy RCU during boot since it would have little benefit anyway. But I am also concerned about some deeper problem I did not catch before.
I'll look into tracing the fs paths to see if I can narrow down what's causing it. Will also try a newer kernel, I am currently testing on 5.19-rc4.
I got somewhere with this. It looks like queuing CBs as lazy CBs instead of normal CBs, are triggering expedited stalls during the boot process:
39.949198] rcu: INFO:
rcu_preemptdetected expedited stalls on
CPUs/tasks: { } 28 jiffies s: 69 root: 0x0/.No idea how/why lazy RCU CBs would be related to expedited GP issues, but maybe something hangs and causes that side-effect.
initcall_debugdid not help, as it seems initcalls all work fine, and then 8 seconds after the boot, it starts slowing down a lot, followed by the RCU stall messages. As a next step I'll enable ftrace during the boot to see if I can get more insight. But I believe, its not the FS layer, the FS layer just triggers lazy CBs, but there is something wrong with the core lazy-RCU work itself.Quoted 2 lines
This kernel is 5.19-rc4. I'll also try to rebase ChromeOS on more recent kernels and debug.
More digging, thanks to trace_event= boot option , I find that the boot process does have some synchronous waits, and though these are "non-lazy", for some reason the lazy CBs that were previously queued are making them wait for the *full* lazy duration. Which points to a likely bug in the lazy RCU logic. These synchronous CBs should never be waiting like the lazy ones:
[ 17.715904] => trace_dump_stack [ 17.715904] => __wait_rcu_gp [ 17.715904] => synchronize_rcu [ 17.715904] => selinux_netcache_avc_callback [ 17.715904] => avc_ss_reset [ 17.715904] => sel_write_enforce [ 17.715904] => vfs_write [ 17.715904] => ksys_write [ 17.715904] => do_syscall_64 [ 17.715904] => entry_SYSCALL_64_after_hwframeQuoted 1 line
I'm tired so I'll resume the debug later.
At times like this, I often pull the suspect code into userspace and run it through its paces. In this case, a bunch of
call_rcu_lazy()invocations into an empty bypass list, followed by acall_rcu()invocation, then a check to make sure that the bypass list is no longer lazy.
Quoted 8 lines
Quoted 1 line
Thanks a lot for this great debug idea, I will look into it.
It seems to be a subtle issue when a large number of callbacks are queued trigging the lock-contention code, which happens at boot. It appears the non-lazy ones and lazy ones collide, so you have the lazy timer which wins, and then the regular bypass lock-contention timer is not allowed to do its thing. Due to this, the rcuog thread wakes up much later than a jiffie.
Good show, and glad you found it!
Quoted 8 lines
Things are much better with the following change. However, this brings me to a question about lock-contention based or any deferring and boot time.
If you have a path like selinux doing a
synchronize_rcu(), shouldn't we skip the jiffie waiting for the bypass timer? Otherwise things synchronously waiting will slow down more than usual. Maybe bypassing should not be done for any case until boot up is done. I'm curious to see if that improves boot time.
Why not simply disable laziness at boot time and enable it only after booting is complete? The exiting rcupdate.rcu_normal_after_boot kernel boot parameter uses a similar scheme.
Quoted 13 lines
(quoted diff) +5
-1@@ -580,7 +585,11 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone, len = rcu_segcblist_n_cbs(&rdp->cblist); bypass_len = rcu_cblist_n_cbs(&rdp->nocb_bypass); lazy_len = rcu_cblist_n_lazy_cbs(&rdp->nocb_bypass); - if (was_alldone) { + + // If we are in lazy-mode, we still need to do a wake up even if + // all CBs were previously done. Otherwise the GP thread will + // wait for the full lazy duration. + if (was_alldone || (READ_ONCE(rdp->nocb_defer_wakeup) == RCU_NOCB_WAKE_LAZY)) { rdp->qlen_last_fqs_check = len;
Quoted 2 lines
// Only lazy CBs in bypass list
if (lazy_len && bypass_len == lazy_len) {And this change looks plausible, though as always, the system's opinion carries much more weight than does mine.
Thanx, Paul
Re: [PATCH v3 resend 4/6] fs: Move call_rcu() to call_rcu_lazy() in some paths
Quoted 84 lines · Paul E. McKenney
Quoted 83 lines · Joel Fernandes
Quoted 81 lines · Joel Fernandes
Quoted 71 lines · Paul E. McKenney
Quoted 70 lines · Joel Fernandes
Quoted 48 lines · Joel Fernandes
Quoted 21 lines · Joel Fernandes
[Sorry, adding back the CC list]
Quoted 6 lines · Joel Fernandes (Google)
This is required to prevent callbacks triggering RCU machinery too quickly and too often, which adds more power to the system.
When testing, we found that these paths were invoked often when the system is not doing anything (screen is ON but otherwise idle).
Unfortunately, I am seeing a slow down in ChromeOS boot performance after applying this particular patch. It is the first time I could test ChromeOS boot times with the series since it was hard to find a ChromeOS device that runs the upstream kernel.
Anyway, Vlad, Neeraj, do you guys also see slower boot times with this patch? I wonder if the issue is with wake up interaction with the nocb GP threads.
Quoted 7 lines
We ought to disable lazy RCU during boot since it would have little benefit anyway. But I am also concerned about some deeper problem I did not catch before.
I'll look into tracing the fs paths to see if I can narrow down what's causing it. Will also try a newer kernel, I am currently testing on 5.19-rc4.
I got somewhere with this. It looks like queuing CBs as lazy CBs instead of normal CBs, are triggering expedited stalls during the boot process:
39.949198] rcu: INFO:
rcu_preemptdetected expedited stalls on
CPUs/tasks: { } 28 jiffies s: 69 root: 0x0/.No idea how/why lazy RCU CBs would be related to expedited GP issues, but maybe something hangs and causes that side-effect.
initcall_debugdid not help, as it seems initcalls all work fine, and then 8 seconds after the boot, it starts slowing down a lot, followed by the RCU stall messages. As a next step I'll enable ftrace during the boot to see if I can get more insight. But I believe, its not the FS layer, the FS layer just triggers lazy CBs, but there is something wrong with the core lazy-RCU work itself.Quoted 2 lines
This kernel is 5.19-rc4. I'll also try to rebase ChromeOS on more recent kernels and debug.
More digging, thanks to trace_event= boot option , I find that the boot process does have some synchronous waits, and though these are "non-lazy", for some reason the lazy CBs that were previously queued are making them wait for the *full* lazy duration. Which points to a likely bug in the lazy RCU logic. These synchronous CBs should never be waiting like the lazy ones:
[ 17.715904] => trace_dump_stack [ 17.715904] => __wait_rcu_gp [ 17.715904] => synchronize_rcu [ 17.715904] => selinux_netcache_avc_callback [ 17.715904] => avc_ss_reset [ 17.715904] => sel_write_enforce [ 17.715904] => vfs_write [ 17.715904] => ksys_write [ 17.715904] => do_syscall_64 [ 17.715904] => entry_SYSCALL_64_after_hwframeQuoted 7 lines
Quoted 1 line
I'm tired so I'll resume the debug later.
At times like this, I often pull the suspect code into userspace and run it through its paces. In this case, a bunch of
call_rcu_lazy()invocations into an empty bypass list, followed by acall_rcu()invocation, then a check to make sure that the bypass list is no longer lazy.Thanks a lot for this great debug idea, I will look into it.
Quoted 8 lines
Quoted 6 lines
It seems to be a subtle issue when a large number of callbacks are queued trigging the lock-contention code, which happens at boot. It appears the non-lazy ones and lazy ones collide, so you have the lazy timer which wins, and then the regular bypass lock-contention timer is not allowed to do its thing. Due to this, the rcuog thread wakes up much later than a jiffie.
Good show, and glad you found it!
Thanks!
Quoted 9 lines
Quoted 8 lines
Things are much better with the following change. However, this brings me to a question about lock-contention based or any deferring and boot time.
If you have a path like selinux doing a
synchronize_rcu(), shouldn't we skip the jiffie waiting for the bypass timer? Otherwise things synchronously waiting will slow down more than usual. Maybe bypassing should not be done for any case until boot up is done. I'm curious to see if that improves boot time.
Quoted 3 lines
Why not simply disable laziness at boot time and enable it only after booting is complete? The exiting rcupdate.rcu_normal_after_boot kernel boot parameter uses a similar scheme.
That sounds like the right thing to good, but unfortunately it wont help this problem. The boot time issue happens after init has started. So the OS is still "booting" even though the kernel has.
Also the problem can happen after boot as well, like if RCU lazy/non-lazy callbacks come back to back quickly, or so.
But yes nonetheless, I can see the value of disabling it till the in-kernel boot completets.
Quoted 10 lines
Quoted 10 lines
(quoted diff) +4
-1@@ -580,7 +585,11 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone, len = rcu_segcblist_n_cbs(&rdp->cblist); bypass_len = rcu_cblist_n_cbs(&rdp->nocb_bypass); lazy_len = rcu_cblist_n_lazy_cbs(&rdp->nocb_bypass); - if (was_alldone) { + + // If we are in lazy-mode, we still need to do a wake up even if + // all CBs were previously done. Otherwise the GP thread will + // wait for the full lazy duration.
Quoted 8 lines
Quoted 5 lines
(quoted diff) +1
-0+ if (was_alldone || (READ_ONCE(rdp->nocb_defer_wakeup) == RCU_NOCB_WAKE_LAZY)) { rdp->qlen_last_fqs_check = len;// Only lazy CBs in bypass list if (lazy_len && bypass_len == lazy_len) {And this change looks plausible, though as always, the system's opinion carries much more weight than does mine.
Sounds good, thanks, I am testing it more. Will update it for v4.
Thanks,
- Joel
Re: [PATCH v3 resend 4/6] fs: Move call_rcu() to call_rcu_lazy() in some paths
On Fri, Aug 19, 2022 at 2:14 PM Joel Fernandes <[email protected]> wrote:
[..]
Quoted 17 lines
Quoted 9 lines
Quoted 8 lines
Things are much better with the following change. However, this brings me to a question about lock-contention based or any deferring and boot time.
If you have a path like selinux doing a
synchronize_rcu(), shouldn't we skip the jiffie waiting for the bypass timer? Otherwise things synchronously waiting will slow down more than usual. Maybe bypassing should not be done for any case until boot up is done. I'm curious to see if that improves boot time.Quoted 3 lines
Why not simply disable laziness at boot time and enable it only after booting is complete? The exiting rcupdate.rcu_normal_after_boot kernel boot parameter uses a similar scheme.
That sounds like the right thing to good, but unfortunately it wont help this problem. The boot time issue happens after init has started. So the OS is still "booting" even though the kernel has.
Quoted 5 lines
Also the problem can happen after boot as well, like if RCU lazy/non-lazy callbacks come back to back quickly, or so.
But yes nonetheless, I can see the value of disabling it till the in-kernel boot completets.
My mail client is acting weird. I meant to add to this, I wonder if there is a way other subsystems detect when userspace boots using some heuristic?
Thanks,
- Joel
Paul E. McKenney
maintainerRe: [PATCH v3 resend 4/6] fs: Move call_rcu() to call_rcu_lazy() in some paths
Quoted 22 lines · Joel Fernandes
On Fri, Aug 19, 2022 at 2:14 PM Joel Fernandes <[email protected]> wrote:
[..]Quoted 20 lines
Quoted 9 lines
Quoted 8 lines
Things are much better with the following change. However, this brings me to a question about lock-contention based or any deferring and boot time.
If you have a path like selinux doing a
synchronize_rcu(), shouldn't we skip the jiffie waiting for the bypass timer? Otherwise things synchronously waiting will slow down more than usual. Maybe bypassing should not be done for any case until boot up is done. I'm curious to see if that improves boot time.Quoted 3 lines
Why not simply disable laziness at boot time and enable it only after booting is complete? The exiting rcupdate.rcu_normal_after_boot kernel boot parameter uses a similar scheme.
That sounds like the right thing to good, but unfortunately it wont help this problem. The boot time issue happens after init has started. So the OS is still "booting" even though the kernel has.
Also the problem can happen after boot as well, like if RCU lazy/non-lazy callbacks come back to back quickly, or so.
Quoted 6 lines
Quoted 2 lines
But yes nonetheless, I can see the value of disabling it till the in-kernel boot completets.
My mail client is acting weird. I meant to add to this, I wonder if there is a way other subsystems detect when userspace boots using some heuristic?
I don't know of one, but I bet that ChromeOS has ways. If nothing else, might you add a sysfs write to one of the boot-up phases?
Thanx, Paul
Re: [PATCH v3 resend 4/6] fs: Move call_rcu() to call_rcu_lazy() in some paths
Quoted 27 lines · Paul E. McKenney
Quoted 25 lines · Joel Fernandes
On Fri, Aug 19, 2022 at 2:14 PM Joel Fernandes <[email protected]> wrote:
[..]Quoted 22 lines
Quoted 9 lines
Quoted 8 lines
Things are much better with the following change. However, this brings me to a question about lock-contention based or any deferring and boot time.
If you have a path like selinux doing a
synchronize_rcu(), shouldn't we skip the jiffie waiting for the bypass timer? Otherwise things synchronously waiting will slow down more than usual. Maybe bypassing should not be done for any case until boot up is done. I'm curious to see if that improves boot time.Quoted 3 lines
Why not simply disable laziness at boot time and enable it only after booting is complete? The exiting rcupdate.rcu_normal_after_boot kernel boot parameter uses a similar scheme.
That sounds like the right thing to good, but unfortunately it wont help this problem. The boot time issue happens after init has started. So the OS is still "booting" even though the kernel has.
Also the problem can happen after boot as well, like if RCU lazy/non-lazy callbacks come back to back quickly, or so.
But yes nonetheless, I can see the value of disabling it till the in-kernel boot completets.
Quoted 6 lines
Quoted 3 lines
My mail client is acting weird. I meant to add to this, I wonder if there is a way other subsystems detect when userspace boots using some heuristic?
I don't know of one, but I bet that ChromeOS has ways. If nothing else, might you add a sysfs write to one of the boot-up phases?
Yes, that's possible :) Thanks, I will consider this idea.
Thanks,
- Joel
Re: [PATCH v3 resend 4/6] fs: Move call_rcu() to call_rcu_lazy() in some paths
In reply to Joel FernandesQuoted 140 lines · Joel Fernandes
Quoted 84 lines · Paul E. McKenney
Quoted 83 lines · Joel Fernandes
Quoted 81 lines · Joel Fernandes
Quoted 71 lines · Paul E. McKenney
Quoted 70 lines · Joel Fernandes
Quoted 48 lines · Joel Fernandes
Quoted 21 lines · Joel Fernandes
[Sorry, adding back the CC list]
Quoted 6 lines · Joel Fernandes (Google)
This is required to prevent callbacks triggering RCU machinery too quickly and too often, which adds more power to the system.
When testing, we found that these paths were invoked often when the system is not doing anything (screen is ON but otherwise idle).
Unfortunately, I am seeing a slow down in ChromeOS boot performance after applying this particular patch. It is the first time I could test ChromeOS boot times with the series since it was hard to find a ChromeOS device that runs the upstream kernel.
Anyway, Vlad, Neeraj, do you guys also see slower boot times with this patch? I wonder if the issue is with wake up interaction with the nocb GP threads.
Quoted 7 lines
We ought to disable lazy RCU during boot since it would have little benefit anyway. But I am also concerned about some deeper problem I did not catch before.
I'll look into tracing the fs paths to see if I can narrow down what's causing it. Will also try a newer kernel, I am currently testing on 5.19-rc4.
I got somewhere with this. It looks like queuing CBs as lazy CBs instead of normal CBs, are triggering expedited stalls during the boot process:
39.949198] rcu: INFO:
rcu_preemptdetected expedited stalls on
CPUs/tasks: { } 28 jiffies s: 69 root: 0x0/.No idea how/why lazy RCU CBs would be related to expedited GP issues, but maybe something hangs and causes that side-effect.
initcall_debugdid not help, as it seems initcalls all work fine, and then 8 seconds after the boot, it starts slowing down a lot, followed by the RCU stall messages. As a next step I'll enable ftrace during the boot to see if I can get more insight. But I believe, its not the FS layer, the FS layer just triggers lazy CBs, but there is something wrong with the core lazy-RCU work itself.Quoted 2 lines
This kernel is 5.19-rc4. I'll also try to rebase ChromeOS on more recent kernels and debug.
More digging, thanks to trace_event= boot option , I find that the boot process does have some synchronous waits, and though these are "non-lazy", for some reason the lazy CBs that were previously queued are making them wait for the *full* lazy duration. Which points to a likely bug in the lazy RCU logic. These synchronous CBs should never be waiting like the lazy ones:
[ 17.715904] => trace_dump_stack [ 17.715904] => __wait_rcu_gp [ 17.715904] => synchronize_rcu [ 17.715904] => selinux_netcache_avc_callback [ 17.715904] => avc_ss_reset [ 17.715904] => sel_write_enforce [ 17.715904] => vfs_write [ 17.715904] => ksys_write [ 17.715904] => do_syscall_64 [ 17.715904] => entry_SYSCALL_64_after_hwframeQuoted 7 lines
Quoted 1 line
I'm tired so I'll resume the debug later.
At times like this, I often pull the suspect code into userspace and run it through its paces. In this case, a bunch of
call_rcu_lazy()invocations into an empty bypass list, followed by acall_rcu()invocation, then a check to make sure that the bypass list is no longer lazy.Thanks a lot for this great debug idea, I will look into it.
Quoted 8 lines
Quoted 6 lines
It seems to be a subtle issue when a large number of callbacks are queued trigging the lock-contention code, which happens at boot. It appears the non-lazy ones and lazy ones collide, so you have the lazy timer which wins, and then the regular bypass lock-contention timer is not allowed to do its thing. Due to this, the rcuog thread wakes up much later than a jiffie.
Good show, and glad you found it!
Thanks!
Quoted 9 lines
Quoted 8 lines
Things are much better with the following change. However, this brings me to a question about lock-contention based or any deferring and boot time.
If you have a path like selinux doing a
synchronize_rcu(), shouldn't we skip the jiffie waiting for the bypass timer? Otherwise things synchronously waiting will slow down more than usual. Maybe bypassing should not be done for any case until boot up is done. I'm curious to see if that improves boot time.Quoted 3 lines
Why not simply disable laziness at boot time and enable it only after booting is complete? The exiting rcupdate.rcu_normal_after_boot kernel boot parameter uses a similar scheme.
That sounds like the right thing to good, but unfortunately it wont help this problem. The boot time issue happens after init has started. So the OS is still "booting" even though the kernel has.
Also the problem can happen after boot as well, like if RCU lazy/non-lazy callbacks come back to back quickly, or so.
But yes nonetheless, I can see the value of disabling it till the in-kernel boot completets.
Quoted 10 lines
Quoted 10 lines
(quoted diff) +4
-1@@ -580,7 +585,11 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone, len = rcu_segcblist_n_cbs(&rdp->cblist); bypass_len = rcu_cblist_n_cbs(&rdp->nocb_bypass); lazy_len = rcu_cblist_n_lazy_cbs(&rdp->nocb_bypass); - if (was_alldone) { + + // If we are in lazy-mode, we still need to do a wake up even if + // all CBs were previously done. Otherwise the GP thread will + // wait for the full lazy duration.Quoted 8 lines
Quoted 5 lines
(quoted diff) +1
-0+ if (was_alldone || (READ_ONCE(rdp->nocb_defer_wakeup) == RCU_NOCB_WAKE_LAZY)) { rdp->qlen_last_fqs_check = len;// Only lazy CBs in bypass list if (lazy_len && bypass_len == lazy_len) {And this change looks plausible, though as always, the system's opinion carries much more weight than does mine.
Quoted 1 line
Sounds good, thanks, I am testing it more. Will update it for v4.
We could also do the following, I tested it and it fixes it. It seems more maintainable and less fragile, but it comes at a slightly higher (but likely negligible) cost. If there are lazy CBs queued, and any non-lazy one comes, then the first non-lazy one is not considered to be added to the bypass list but hopefully that's Ok with you. Later non-lazy ones will be added to the bypass.
@@ -484,9 +490,17 @@ static bool rcu_nocb_try_bypass(struct rcu_data *rdp, struct rcu_head *rhp,
// since we are kick-starting RCU GP processing anyway for the non-lazy
// one, we can just reuse that GP for the already queued-up lazy ones.
if ((rdp->nocb_nobypass_count < nocb_nobypass_lim_per_jiffy && !lazy) ||
- (lazy && n_lazy_cbs >= qhimark)) {
+ (!lazy && n_lazy_cbs) ||
+ (lazy && n_lazy_cbs >= qhimark)) {
rcu_nocb_lock(rdp);
- *was_alldone = !rcu_segcblist_pend_cbs(&rdp->cblist);
+
+ // This variable helps decide if a wakeup of the rcuog thread
+ // is needed. It is passed to __call_rcu_nocb_wake() by the
+ // caller. If only lazy CBs were previously queued and this one
+ // is non-lazy, make sure the caller does a wake up.
+ *was_alldone = !rcu_segcblist_pend_cbs(&rdp->cblist) ||
+ (!lazy && n_lazy_cbs);
+
if (*was_alldone)
trace_rcu_nocb_wake(rcu_state.name, rdp->cpu,
lazy ? TPS("FirstLazyQ") : TPS("FirstQ"));
@@ -500,7 +514,8 @@ static bool rcu_nocb_try_bypass(struct rcu_data *rdp, struct rcu_head
*rhp,
if ((ncbs && j != READ_ONCE(rdp->nocb_bypass_first)) || ncbs >= qhimark) {
rcu_nocb_lock(rdp);
if (!rcu_nocb_flush_bypass(rdp, rhp, j, lazy, false)) {
- *was_alldone = !rcu_segcblist_pend_cbs(&rdp->cblist);
+ *was_alldone = !rcu_segcblist_pend_cbs(&rdp->cblist) ||
+ (!lazy && n_lazy_cbs);
if (*was_alldone)
trace_rcu_nocb_wake(rcu_state.name, rdp->cpu,
lazy ? TPS("FirstLazyQ") : TPS("FirstQ"));Paul E. McKenney
maintainerRe: [PATCH v3 resend 4/6] fs: Move call_rcu() to call_rcu_lazy() in some paths
Quoted 139 lines · Joel Fernandes
Quoted 138 lines · Joel Fernandes
Quoted 84 lines · Paul E. McKenney
Quoted 83 lines · Joel Fernandes
Quoted 81 lines · Joel Fernandes
Quoted 71 lines · Paul E. McKenney
Quoted 70 lines · Joel Fernandes
Quoted 48 lines · Joel Fernandes
Quoted 21 lines · Joel Fernandes
[Sorry, adding back the CC list]
Quoted 6 lines · Joel Fernandes (Google)
This is required to prevent callbacks triggering RCU machinery too quickly and too often, which adds more power to the system.
When testing, we found that these paths were invoked often when the system is not doing anything (screen is ON but otherwise idle).
Unfortunately, I am seeing a slow down in ChromeOS boot performance after applying this particular patch. It is the first time I could test ChromeOS boot times with the series since it was hard to find a ChromeOS device that runs the upstream kernel.
Anyway, Vlad, Neeraj, do you guys also see slower boot times with this patch? I wonder if the issue is with wake up interaction with the nocb GP threads.
Quoted 7 lines
We ought to disable lazy RCU during boot since it would have little benefit anyway. But I am also concerned about some deeper problem I did not catch before.
I'll look into tracing the fs paths to see if I can narrow down what's causing it. Will also try a newer kernel, I am currently testing on 5.19-rc4.
I got somewhere with this. It looks like queuing CBs as lazy CBs instead of normal CBs, are triggering expedited stalls during the boot process:
39.949198] rcu: INFO:
rcu_preemptdetected expedited stalls on
CPUs/tasks: { } 28 jiffies s: 69 root: 0x0/.No idea how/why lazy RCU CBs would be related to expedited GP issues, but maybe something hangs and causes that side-effect.
initcall_debugdid not help, as it seems initcalls all work fine, and then 8 seconds after the boot, it starts slowing down a lot, followed by the RCU stall messages. As a next step I'll enable ftrace during the boot to see if I can get more insight. But I believe, its not the FS layer, the FS layer just triggers lazy CBs, but there is something wrong with the core lazy-RCU work itself.Quoted 2 lines
This kernel is 5.19-rc4. I'll also try to rebase ChromeOS on more recent kernels and debug.
More digging, thanks to trace_event= boot option , I find that the boot process does have some synchronous waits, and though these are "non-lazy", for some reason the lazy CBs that were previously queued are making them wait for the *full* lazy duration. Which points to a likely bug in the lazy RCU logic. These synchronous CBs should never be waiting like the lazy ones:
[ 17.715904] => trace_dump_stack [ 17.715904] => __wait_rcu_gp [ 17.715904] => synchronize_rcu [ 17.715904] => selinux_netcache_avc_callback [ 17.715904] => avc_ss_reset [ 17.715904] => sel_write_enforce [ 17.715904] => vfs_write [ 17.715904] => ksys_write [ 17.715904] => do_syscall_64 [ 17.715904] => entry_SYSCALL_64_after_hwframeQuoted 7 lines
Quoted 1 line
I'm tired so I'll resume the debug later.
At times like this, I often pull the suspect code into userspace and run it through its paces. In this case, a bunch of
call_rcu_lazy()invocations into an empty bypass list, followed by acall_rcu()invocation, then a check to make sure that the bypass list is no longer lazy.Thanks a lot for this great debug idea, I will look into it.
Quoted 8 lines
Quoted 6 lines
It seems to be a subtle issue when a large number of callbacks are queued trigging the lock-contention code, which happens at boot. It appears the non-lazy ones and lazy ones collide, so you have the lazy timer which wins, and then the regular bypass lock-contention timer is not allowed to do its thing. Due to this, the rcuog thread wakes up much later than a jiffie.
Good show, and glad you found it!
Thanks!
Quoted 9 lines
Quoted 8 lines
Things are much better with the following change. However, this brings me to a question about lock-contention based or any deferring and boot time.
If you have a path like selinux doing a
synchronize_rcu(), shouldn't we skip the jiffie waiting for the bypass timer? Otherwise things synchronously waiting will slow down more than usual. Maybe bypassing should not be done for any case until boot up is done. I'm curious to see if that improves boot time.Quoted 3 lines
Why not simply disable laziness at boot time and enable it only after booting is complete? The exiting rcupdate.rcu_normal_after_boot kernel boot parameter uses a similar scheme.
That sounds like the right thing to good, but unfortunately it wont help this problem. The boot time issue happens after init has started. So the OS is still "booting" even though the kernel has.
Also the problem can happen after boot as well, like if RCU lazy/non-lazy callbacks come back to back quickly, or so.
But yes nonetheless, I can see the value of disabling it till the in-kernel boot completets.
Quoted 18 lines
Quoted 13 lines
(quoted diff) +5
-1@@ -580,7 +585,11 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone, len = rcu_segcblist_n_cbs(&rdp->cblist); bypass_len = rcu_cblist_n_cbs(&rdp->nocb_bypass); lazy_len = rcu_cblist_n_lazy_cbs(&rdp->nocb_bypass); - if (was_alldone) { + + // If we are in lazy-mode, we still need to do a wake up even if + // all CBs were previously done. Otherwise the GP thread will + // wait for the full lazy duration. + if (was_alldone || (READ_ONCE(rdp->nocb_defer_wakeup) == RCU_NOCB_WAKE_LAZY)) { rdp->qlen_last_fqs_check = len;Quoted 2 lines
// Only lazy CBs in bypass list if (lazy_len && bypass_len == lazy_len) {And this change looks plausible, though as always, the system's opinion carries much more weight than does mine.
Quoted 7 lines
Quoted 1 line
Sounds good, thanks, I am testing it more. Will update it for v4.
We could also do the following, I tested it and it fixes it. It seems more maintainable and less fragile, but it comes at a slightly higher (but likely negligible) cost. If there are lazy CBs queued, and any non-lazy one comes, then the first non-lazy one is not considered to be added to the bypass list but hopefully that's Ok with you. Later non-lazy ones will be added to the bypass.
At first I was concerned that you intended to reorder the callbacks, but fortunately that is not what the patch below does. ;-)
But don't you also need to clear the "lazy" flag at some point in this execution path? After all, once a non-lazy callback arrives, all the callbacks are treated as if they are non-lazy, correct?
Thanx, Paul
Quoted 32 lines
(quoted diff) +10
-2@@ -484,9 +490,17 @@ static bool rcu_nocb_try_bypass(struct rcu_data *rdp, struct rcu_head *rhp, // since we are kick-starting RCU GP processing anyway for the non-lazy // one, we can just reuse that GP for the already queued-up lazy ones. if ((rdp->nocb_nobypass_count < nocb_nobypass_lim_per_jiffy && !lazy) || - (lazy && n_lazy_cbs >= qhimark)) { + (!lazy && n_lazy_cbs) || + (lazy && n_lazy_cbs >= qhimark)) { rcu_nocb_lock(rdp); - *was_alldone = !rcu_segcblist_pend_cbs(&rdp->cblist); + + // This variable helps decide if a wakeup of the rcuog thread + // is needed. It is passed to __call_rcu_nocb_wake() by the + // caller. If only lazy CBs were previously queued and this one + // is non-lazy, make sure the caller does a wake up. + *was_alldone = !rcu_segcblist_pend_cbs(&rdp->cblist) || + (!lazy && n_lazy_cbs); + if (*was_alldone) trace_rcu_nocb_wake(rcu_state.name, rdp->cpu,lazy ? TPS("FirstLazyQ") : TPS("FirstQ"));(quoted diff) +2
-1@@ -500,7 +514,8 @@ static bool rcu_nocb_try_bypass(struct rcu_data *rdp, struct rcu_head *rhp, if ((ncbs && j != READ_ONCE(rdp->nocb_bypass_first)) || ncbs >= qhimark) { rcu_nocb_lock(rdp); if (!rcu_nocb_flush_bypass(rdp, rhp, j, lazy, false)) { - *was_alldone = !rcu_segcblist_pend_cbs(&rdp->cblist); + *was_alldone = !rcu_segcblist_pend_cbs(&rdp->cblist) || + (!lazy && n_lazy_cbs); if (*was_alldone) trace_rcu_nocb_wake(rcu_state.name, rdp->cpu,lazy ? TPS("FirstLazyQ") : TPS("FirstQ"));
Re: [PATCH v3 resend 4/6] fs: Move call_rcu() to call_rcu_lazy() in some paths
Quoted 148 lines · Paul E. McKenney
Quoted 139 lines · Joel Fernandes
Quoted 138 lines · Joel Fernandes
Quoted 84 lines · Paul E. McKenney
Quoted 83 lines · Joel Fernandes
Quoted 81 lines · Joel Fernandes
Quoted 71 lines · Paul E. McKenney
Quoted 70 lines · Joel Fernandes
Quoted 48 lines · Joel Fernandes
Quoted 21 lines · Joel Fernandes
[Sorry, adding back the CC list]
Quoted 6 lines · Joel Fernandes (Google)
This is required to prevent callbacks triggering RCU machinery too quickly and too often, which adds more power to the system.
When testing, we found that these paths were invoked often when the system is not doing anything (screen is ON but otherwise idle).
Unfortunately, I am seeing a slow down in ChromeOS boot performance after applying this particular patch. It is the first time I could test ChromeOS boot times with the series since it was hard to find a ChromeOS device that runs the upstream kernel.
Anyway, Vlad, Neeraj, do you guys also see slower boot times with this patch? I wonder if the issue is with wake up interaction with the nocb GP threads.
Quoted 7 lines
We ought to disable lazy RCU during boot since it would have little benefit anyway. But I am also concerned about some deeper problem I did not catch before.
I'll look into tracing the fs paths to see if I can narrow down what's causing it. Will also try a newer kernel, I am currently testing on 5.19-rc4.
I got somewhere with this. It looks like queuing CBs as lazy CBs instead of normal CBs, are triggering expedited stalls during the boot process:
39.949198] rcu: INFO:
rcu_preemptdetected expedited stalls on
CPUs/tasks: { } 28 jiffies s: 69 root: 0x0/.No idea how/why lazy RCU CBs would be related to expedited GP issues, but maybe something hangs and causes that side-effect.
initcall_debugdid not help, as it seems initcalls all work fine, and then 8 seconds after the boot, it starts slowing down a lot, followed by the RCU stall messages. As a next step I'll enable ftrace during the boot to see if I can get more insight. But I believe, its not the FS layer, the FS layer just triggers lazy CBs, but there is something wrong with the core lazy-RCU work itself.Quoted 2 lines
This kernel is 5.19-rc4. I'll also try to rebase ChromeOS on more recent kernels and debug.
More digging, thanks to trace_event= boot option , I find that the boot process does have some synchronous waits, and though these are "non-lazy", for some reason the lazy CBs that were previously queued are making them wait for the *full* lazy duration. Which points to a likely bug in the lazy RCU logic. These synchronous CBs should never be waiting like the lazy ones:
[ 17.715904] => trace_dump_stack [ 17.715904] => __wait_rcu_gp [ 17.715904] => synchronize_rcu [ 17.715904] => selinux_netcache_avc_callback [ 17.715904] => avc_ss_reset [ 17.715904] => sel_write_enforce [ 17.715904] => vfs_write [ 17.715904] => ksys_write [ 17.715904] => do_syscall_64 [ 17.715904] => entry_SYSCALL_64_after_hwframeQuoted 7 lines
Quoted 1 line
I'm tired so I'll resume the debug later.
At times like this, I often pull the suspect code into userspace and run it through its paces. In this case, a bunch of
call_rcu_lazy()invocations into an empty bypass list, followed by acall_rcu()invocation, then a check to make sure that the bypass list is no longer lazy.Thanks a lot for this great debug idea, I will look into it.
Quoted 8 lines
Quoted 6 lines
It seems to be a subtle issue when a large number of callbacks are queued trigging the lock-contention code, which happens at boot. It appears the non-lazy ones and lazy ones collide, so you have the lazy timer which wins, and then the regular bypass lock-contention timer is not allowed to do its thing. Due to this, the rcuog thread wakes up much later than a jiffie.
Good show, and glad you found it!
Thanks!
Quoted 9 lines
Quoted 8 lines
Things are much better with the following change. However, this brings me to a question about lock-contention based or any deferring and boot time.
If you have a path like selinux doing a
synchronize_rcu(), shouldn't we skip the jiffie waiting for the bypass timer? Otherwise things synchronously waiting will slow down more than usual. Maybe bypassing should not be done for any case until boot up is done. I'm curious to see if that improves boot time.Quoted 3 lines
Why not simply disable laziness at boot time and enable it only after booting is complete? The exiting rcupdate.rcu_normal_after_boot kernel boot parameter uses a similar scheme.
That sounds like the right thing to good, but unfortunately it wont help this problem. The boot time issue happens after init has started. So the OS is still "booting" even though the kernel has.
Also the problem can happen after boot as well, like if RCU lazy/non-lazy callbacks come back to back quickly, or so.
But yes nonetheless, I can see the value of disabling it till the in-kernel boot completets.
Quoted 18 lines
Quoted 13 lines
(quoted diff) +5
-1@@ -580,7 +585,11 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone, len = rcu_segcblist_n_cbs(&rdp->cblist); bypass_len = rcu_cblist_n_cbs(&rdp->nocb_bypass); lazy_len = rcu_cblist_n_lazy_cbs(&rdp->nocb_bypass); - if (was_alldone) { + + // If we are in lazy-mode, we still need to do a wake up even if + // all CBs were previously done. Otherwise the GP thread will + // wait for the full lazy duration. + if (was_alldone || (READ_ONCE(rdp->nocb_defer_wakeup) == RCU_NOCB_WAKE_LAZY)) { rdp->qlen_last_fqs_check = len;Quoted 2 lines
// Only lazy CBs in bypass list if (lazy_len && bypass_len == lazy_len) {And this change looks plausible, though as always, the system's opinion carries much more weight than does mine.
Quoted 7 lines
Quoted 1 line
Sounds good, thanks, I am testing it more. Will update it for v4.
We could also do the following, I tested it and it fixes it. It seems more maintainable and less fragile, but it comes at a slightly higher (but likely negligible) cost. If there are lazy CBs queued, and any non-lazy one comes, then the first non-lazy one is not considered to be added to the bypass list but hopefully that's Ok with you. Later non-lazy ones will be added to the bypass.
Quoted 6 lines
At first I was concerned that you intended to reorder the callbacks, but fortunately that is not what the patch below does. ;-)
But don't you also need to clear the "lazy" flag at some point in this execution path? After all, once a non-lazy callback arrives, all the callbacks are treated as if they are non-lazy, correct?
Oh, I did not see a need to clear this flag, I did not want to modify the flag because it is set by the caller and is more to signal what the caller intended than what its treated as.
IMO it should not effect the treatment of the lazy CB as a non-lazy one, because the effect is the same as if something was queued into the bypass list. The bypass list is flushed first before the "non-bypass" (which could be non-lazy) CB is requested to be queued by the caller, so we're doing the same thing as the existing bypass logic.
Basically these comments:
// If there hasn't yet been all that many ->cblist enqueues
// this jiffy, tell the caller to enqueue onto ->cblist. But flush
// ->nocb_bypass first.
WARN_ON_ONCE(!rcu_nocb_flush_bypass(rdp, NULL, j, lazy, false));Also the issue that the below diff fixed is more about the non-lazy one being treated as a lazy one than the other way.
Let me know if I missed something. Thanks,
- Joel
Quoted 34 lines
Thanx, Paul
Quoted 32 lines
(quoted diff) +10
-2@@ -484,9 +490,17 @@ static bool rcu_nocb_try_bypass(struct rcu_data *rdp, struct rcu_head *rhp, // since we are kick-starting RCU GP processing anyway for the non-lazy // one, we can just reuse that GP for the already queued-up lazy ones. if ((rdp->nocb_nobypass_count < nocb_nobypass_lim_per_jiffy && !lazy) || - (lazy && n_lazy_cbs >= qhimark)) { + (!lazy && n_lazy_cbs) || + (lazy && n_lazy_cbs >= qhimark)) { rcu_nocb_lock(rdp); - *was_alldone = !rcu_segcblist_pend_cbs(&rdp->cblist); + + // This variable helps decide if a wakeup of the rcuog thread + // is needed. It is passed to __call_rcu_nocb_wake() by the + // caller. If only lazy CBs were previously queued and this one + // is non-lazy, make sure the caller does a wake up. + *was_alldone = !rcu_segcblist_pend_cbs(&rdp->cblist) || + (!lazy && n_lazy_cbs); + if (*was_alldone) trace_rcu_nocb_wake(rcu_state.name, rdp->cpu,lazy ? TPS("FirstLazyQ") : TPS("FirstQ"));(quoted diff) +2
-1@@ -500,7 +514,8 @@ static bool rcu_nocb_try_bypass(struct rcu_data *rdp, struct rcu_head *rhp, if ((ncbs && j != READ_ONCE(rdp->nocb_bypass_first)) || ncbs >= qhimark) { rcu_nocb_lock(rdp); if (!rcu_nocb_flush_bypass(rdp, rhp, j, lazy, false)) { - *was_alldone = !rcu_segcblist_pend_cbs(&rdp->cblist); + *was_alldone = !rcu_segcblist_pend_cbs(&rdp->cblist) || + (!lazy && n_lazy_cbs); if (*was_alldone) trace_rcu_nocb_wake(rcu_state.name, rdp->cpu,lazy ? TPS("FirstLazyQ") : TPS("FirstQ"));
PATCH RESEND v3 5/6 rcutorture: Add test code for call_rcu_lazy()
In reply to Joel Fernandes (Google)We add a new RCU type to test call_rcu_lazy(). This allows us to just override the '.call' callback. To compensate for the laziness, we force the laziness to a small number of jiffies. The idea of this test is to stress the new code paths for stability and ensure it at least is providing behavior in parity with, or similar to, call_rcu(). The actual check for amount of laziness is in another test (rcuscale).
--- kernel/rcu/rcu.h | 1 + kernel/rcu/rcutorture.c | 60 ++++++++++++++++++- kernel/rcu/tree.c | 1 + .../selftests/rcutorture/configs/rcu/CFLIST | 1 + .../selftests/rcutorture/configs/rcu/TREE11 | 18 ++++++ .../rcutorture/configs/rcu/TREE11.boot | 8 +++ 6 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/rcutorture/configs/rcu/TREE11 create mode 100644 tools/testing/selftests/rcutorture/configs/rcu/TREE11.boot
kernel/rcu/rcu.h +1 -0
@@ -460,6 +460,7 @@ enum rcutorture_type {RCU_TASKS_TRACING_FLAVOR ,RCU_TRIVIAL_FLAVOR ,SRCU_FLAVOR , +RCU_LAZY_FLAVOR , INVALID_RCU_FLAVOR };
kernel/rcu/rcutorture.c +59 -1
72 lines not on this page · raw message
kernel/rcu/tree.c +1 -0
@@ -600,6 +600,7 @@ void rcutorture_get_gp_data(enum rcutorture_type test_type, int *flags, {switch (test_type) {case RCU_FLAVOR : +case RCU_LAZY_FLAVOR : *flags =READ_ONCE (rcu_state.gp_flags); *gp_seq =rcu_seq_current (&rcu_state.gp_seq);break ;
tools/testing/selftests/rcutorture/configs/rcu/CFLIST +1 -0
@@ -5,6 +5,7 @@ TREE04 TREE05 TREE07 TREE09 +TREE11 SRCU-N SRCU-P SRCU-T
tools/testing/selftests/rcutorture/configs/rcu/TREE11 new file +18 -0
@@ -0,0 +1,18 @@ +CONFIG_SMP=y +CONFIG_PREEMPT_NONE=n +CONFIG_PREEMPT_VOLUNTARY=n +CONFIG_PREEMPT=y +#CHECK#CONFIG_PREEMPT_RCU=y +CONFIG_HZ_PERIODIC=n +CONFIG_NO_HZ_IDLE=y +CONFIG_NO_HZ_FULL=n +CONFIG_RCU_TRACE=y +CONFIG_HOTPLUG_CPU=y +CONFIG_MAXSMP=y +CONFIG_CPUMASK_OFFSTACK=y +CONFIG_RCU_NOCB_CPU=y +CONFIG_DEBUG_LOCK_ALLOC=n +CONFIG_RCU_BOOST=n +CONFIG_DEBUG_OBJECTS_RCU_HEAD=n +CONFIG_RCU_EXPERT=y +CONFIG_RCU_LAZY=y
tools/testing/selftests/rcutorture/configs/rcu/TREE11.boot new file +8 -0
@@ -0,0 +1,8 @@ +maxcpus=8 nr_cpus=43 +rcutree.gp_preinit_delay=3 +rcutree.gp_init_delay=3 +rcutree.gp_cleanup_delay=3 +rcu_nocbs=0-7 +rcutorture.torture_type=rcu_lazy +rcutorture.nocbs_nthreads=8 +rcutorture.fwd_progress=0
Signature · 1 line
2.37.1.559.g78731f0fdb-goog
PATCH RESEND v3 6/6 debug: Toggle lazy at runtime and change flush jiffies
In reply to Joel Fernandes (Google)Enable/Disable this feature by writing 1 or 0 /proc/sys/vm/rcu_lazy.
Change value of /proc/sys/vm/rcu_lazy_jiffies to change max duration before flush.
Do not merge, only for debug for reviewers.
--- include/linux/sched/sysctl.h | 3 +++ kernel/rcu/tree_nocb.h | 9 +++++++++ kernel/sysctl.c | 17 +++++++++++++++++ 3 files changed, 29 insertions(+)
include/linux/sched/sysctl.h +3 -0
@@ -14,6 +14,9 @@ extern unsigned long sysctl_hung_task_timeout_secs;enum { sysctl_hung_task_timeout_secs =0 };#endif +extern unsigned int sysctl_rcu_lazy; +extern unsigned int sysctl_rcu_lazy_jiffies; +enum sched_tunable_scaling {SCHED_TUNABLESCALING_NONE ,SCHED_TUNABLESCALING_LOG ,
kernel/rcu/tree_nocb.h +9 -0
@@ -266,6 +266,9 @@ static bool wake_nocb_gp(struct rcu_data *rdp, bool force)#define LAZY_FLUSH_JIFFIES (10 * HZ)unsigned long jiffies_till_flush =LAZY_FLUSH_JIFFIES ; +unsigned int sysctl_rcu_lazy_jiffies =LAZY_FLUSH_JIFFIES ; +unsigned int sysctl_rcu_lazy =1 ; +#ifdef CONFIG_RCU_LAZY // To be called only from test code. void rcu_lazy_set_jiffies_till_flush (unsigned long jif)
@@ -292,6 +295,9 @@ static void wake_nocb_gp_defer(struct rcu_data *rdp, int waketype,struct rcu_data *rdp_gp = rdp->nocb_gp_rdp;unsigned long mod_jif =0 ; +/* debug: not for merge */ +rcu_lazy_set_jiffies_till_flush (sysctl_rcu_lazy_jiffies); +raw_spin_lock_irqsave (&rdp_gp->nocb_gp_lock, flags);/*
@@ -687,6 +693,9 @@ static void nocb_gp_wait(struct rcu_data *my_rdp)unsigned long wait_gp_seq =0 ;// Suppress "use uninitialized" warning. bool wasempty = false; +/* debug: not for merge */ +rcu_lazy_set_jiffies_till_flush (sysctl_rcu_lazy_jiffies); +/* * Each pass through the following loop checks for CBs and for the * nearest grace period (if any) to wait for next. The CB kthreads
kernel/sysctl.c +17 -0
@@ -2450,6 +2450,23 @@ static struct ctl_table vm_table[] = { .extra2 = SYSCTL_ONE, },#endif +#ifdef CONFIG_RCU_LAZY + { + .procname = "rcu_lazy", + .data = &sysctl_rcu_lazy, + .maxlen = sizeof(unsigned int), + .mode = 0644, + .proc_handler = proc_dointvec, + }, + { + .procname = "rcu_lazy_jiffies", + .data = &sysctl_rcu_lazy_jiffies, + .maxlen = sizeof(unsigned int), + .mode = 0644, + .proc_handler = proc_dointvec, + }, +#endif + { } };
Signature · 1 line
2.37.1.559.g78731f0fdb-goog
Quoted 9 lines · Joel Fernandes (Google)
Just a refresh of v3 with one additional debug patch. v3's cover letter is here:
https://lore.kernel.org/all/[email protected]/I just started working on this again while I have some time during paternity leave ;-) So I thought I'll just send it out again. No other changes other than that 1 debug patch I added on the top.
Next I am going to go refine the power results as mentioned in Paul's comments on the last cover letter.
Side note: Here is another big selling point for call_rcu_lazy(). Instead of _lazy(), if you just increased jiffies_till_first_fqs, and slowed *all* call_rcu() down to achieve the same effect, that would affect percpu refcounters switching to atomic-mode, for example.
They switch to atomic mode by calling __percpu_ref_switch_mode() which is called by percpu_ref_switch_to_atomic_sync().
This will slow this call down for the full lazy duration which will slow down suspend in blk_pre_runtime_suspend().
This is why, we cannot assume call_rcu() users will mostly just want to free memory. There could be cases just like this, and just blanket slow down of call_rcu() might bite at unexpected times.
I am going to add this as a selling point for selective lazyfication (hey I get to invent words while I'm inventing new features), to my cover letter and slides.
- Joel
Quoted 38 lines
Joel Fernandes (Google) (5):
rcu: Introducecall_rcu_lazy()API implementation
rcuscale: Add laziness and kfree tests
fs: Movecall_rcu()tocall_rcu_lazy()in some paths
rcutorture: Add test code forcall_rcu_lazy()
debug: Toggle lazy at runtime and change flush jiffiesVineeth Pillai (1):
rcu: shrinker for lazy rcufs/dcache.c | 4 +- fs/eventpoll.c | 2 +- fs/file_table.c | 2 +- fs/inode.c | 2 +- include/linux/rcu_segcblist.h | 1 + include/linux/rcupdate.h | 6 + include/linux/sched/sysctl.h | 3 + kernel/rcu/Kconfig | 8 + kernel/rcu/rcu.h | 12 + kernel/rcu/rcu_segcblist.c | 15 +- kernel/rcu/rcu_segcblist.h | 20 +- kernel/rcu/rcuscale.c | 74 +++++- kernel/rcu/rcutorture.c | 60 ++++- kernel/rcu/tree.c | 131 ++++++---- kernel/rcu/tree.h | 10 +- kernel/rcu/tree_nocb.h | 246 +++++++++++++++--- kernel/sysctl.c | 17 ++ .../selftests/rcutorture/configs/rcu/CFLIST | 1 + .../selftests/rcutorture/configs/rcu/TREE11 | 18 ++ .../rcutorture/configs/rcu/TREE11.boot | 8 + 20 files changed, 536 insertions(+), 104 deletions(-)create mode 100644
tools/testing/selftests/rcutorture/configs/rcu/TREE11create mode 100644tools/testing/selftests/rcutorture/configs/rcu/TREE11.boot--
2.37.1.559.g78731f0fdb-goog
Quoted 18 lines · Joel Fernandes
Quoted 9 lines · Joel Fernandes (Google)
Just a refresh of v3 with one additional debug patch. v3's cover letter is here:
https://lore.kernel.org/all/[email protected]/I just started working on this again while I have some time during paternity leave ;-) So I thought I'll just send it out again. No other changes other than that 1 debug patch I added on the top.
Next I am going to go refine the power results as mentioned in Paul's comments on the last cover letter.
Side note: Here is another big selling point for
call_rcu_lazy(). Instead of_lazy(), if you just increasedjiffies_till_first_fqs, and slowed *all*call_rcu()down to achieve the same effect, that would affect percpu refcounters switching to atomic-mode, for example.
Quoted 4 lines
They switch to atomic mode by calling
__percpu_ref_switch_mode()which is called bypercpu_ref_switch_to_atomic_sync().>
This will slow this call down for the full lazy duration which will slow down suspend inblk_pre_runtime_suspend().
Correction while I am going on the record (got to be careful these days). It *might* slow down RCU for the full lazy duration, unless of course a fly-by rescue call_rcu() comes in.
- Joel
Paul E. McKenney
maintainerQuoted 21 lines · Joel Fernandes
Quoted 18 lines · Joel Fernandes
Quoted 9 lines · Joel Fernandes (Google)
Just a refresh of v3 with one additional debug patch. v3's cover letter is here:
https://lore.kernel.org/all/[email protected]/I just started working on this again while I have some time during paternity leave ;-) So I thought I'll just send it out again. No other changes other than that 1 debug patch I added on the top.
Next I am going to go refine the power results as mentioned in Paul's comments on the last cover letter.
Side note: Here is another big selling point for
call_rcu_lazy(). Instead of_lazy(), if you just increasedjiffies_till_first_fqs, and slowed *all*call_rcu()down to achieve the same effect, that would affect percpu refcounters switching to atomic-mode, for example.
Quoted 8 lines
Quoted 4 lines
They switch to atomic mode by calling
__percpu_ref_switch_mode()which is called bypercpu_ref_switch_to_atomic_sync().>
This will slow this call down for the full lazy duration which will slow down suspend inblk_pre_runtime_suspend().Correction while I am going on the record (got to be careful these days). It *might* slow down RCU for the full lazy duration, unless of course a fly-by rescue
call_rcu()comes in.
Just unload a module, which if I remember correctly invokes rcu_barrier(). Lots of rescue callbacks. ;-)
Thanx, Paul
Quoted 27 lines · Paul E. McKenney
Quoted 26 lines · Joel Fernandes
Quoted 22 lines · Joel Fernandes
Quoted 9 lines · Joel Fernandes (Google)
Just a refresh of v3 with one additional debug patch. v3's cover letter is here:
https://lore.kernel.org/all/[email protected]/I just started working on this again while I have some time during paternity leave ;-) So I thought I'll just send it out again. No other changes other than that 1 debug patch I added on the top.
Next I am going to go refine the power results as mentioned in Paul's comments on the last cover letter.
Side note: Here is another big selling point for
call_rcu_lazy(). Instead of_lazy(), if you just increasedjiffies_till_first_fqs, and slowed *all*call_rcu()down to achieve the same effect, that would affect percpu refcounters switching to atomic-mode, for example.They switch to atomic mode by calling
__percpu_ref_switch_mode()which is called bypercpu_ref_switch_to_atomic_sync().>
This will slow this call down for the full lazy duration which will slow down suspend inblk_pre_runtime_suspend().
Quoted 6 lines
Quoted 3 lines
Correction while I am going on the record (got to be careful these days). It *might* slow down RCU for the full lazy duration, unless of course a fly-by rescue
call_rcu()comes in.Just unload a module, which if I remember correctly invokes
rcu_barrier(). Lots of rescue callbacks. ;-)
Haha. Yes I suppose the per-cpu atomic switch paths can also invoke rcu_barrier() but I suspect somebody might complain about IPIs :-P
Thanks,
- Joel
Paul E. McKenney
maintainerQuoted 34 lines · Joel Fernandes
Quoted 31 lines · Paul E. McKenney
Quoted 29 lines · Joel Fernandes
Quoted 18 lines · Joel Fernandes
Quoted 9 lines · Joel Fernandes (Google)
Just a refresh of v3 with one additional debug patch. v3's cover letter is here:
https://lore.kernel.org/all/[email protected]/I just started working on this again while I have some time during paternity leave ;-) So I thought I'll just send it out again. No other changes other than that 1 debug patch I added on the top.
Next I am going to go refine the power results as mentioned in Paul's comments on the last cover letter.
Side note: Here is another big selling point for
call_rcu_lazy(). Instead of_lazy(), if you just increasedjiffies_till_first_fqs, and slowed *all*call_rcu()down to achieve the same effect, that would affect percpu refcounters switching to atomic-mode, for example.Quoted 4 lines
They switch to atomic mode by calling
__percpu_ref_switch_mode()which is called bypercpu_ref_switch_to_atomic_sync().>
This will slow this call down for the full lazy duration which will slow down suspend inblk_pre_runtime_suspend().Correction while I am going on the record (got to be careful these days). It *might* slow down RCU for the full lazy duration, unless of course a fly-by rescue
call_rcu()comes in.
Quoted 5 lines
Quoted 2 lines
Just unload a module, which if I remember correctly invokes
rcu_barrier(). Lots of rescue callbacks. ;-)Haha. Yes I suppose the per-cpu atomic switch paths can also invoke
rcu_barrier()but I suspect somebody might complain about IPIs :-P
There is always a critic! ;-)
Thanx, Paul