lustre: ad-hoc fixes
cover lustre: ad-hoc fixes
There is no real pattern here, just minor tidy-up and minor bug-fix.
Thanks,
NeilBrown
---
NeilBrown (7):
lustre: use schedule_timeout_$state().
lustre/libcfs: fix freeing after kmalloc failure.
lustre/libfs: move debugfs registration from libcfs_setup back to libcfs_init
lustre: give different tcd_lock types different classes. lustre/libcfs: discard cfs_trace_allocate_string_buffer()
lustre: lnet: convert ni_refs to percpu_refcount.
lustre: change TASK_NOLOAD to TASK_IDLE.
.../staging/lustre/include/linux/lnet/lib-lnet.h | 11 +--- .../staging/lustre/include/linux/lnet/lib-types.h | 2 - .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 12 ++--- .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 6 +- .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 14 ++---- drivers/staging/lustre/lnet/libcfs/fail.c | 3 - drivers/staging/lustre/lnet/libcfs/hash.c | 2 - drivers/staging/lustre/lnet/libcfs/module.c | 14 +++--- drivers/staging/lustre/lnet/libcfs/tracefile.c | 49 +++++++++++--------- drivers/staging/lustre/lnet/libcfs/tracefile.h | 1 drivers/staging/lustre/lnet/lnet/acceptor.c | 3 - drivers/staging/lustre/lnet/lnet/api-ni.c | 40 +++++++--------- drivers/staging/lustre/lnet/lnet/config.c | 13 +++-- drivers/staging/lustre/lnet/lnet/lib-eq.c | 4 +- drivers/staging/lustre/lnet/lnet/peer.c | 3 - drivers/staging/lustre/lnet/lnet/router.c | 19 ++------ drivers/staging/lustre/lnet/lnet/router_proc.c | 2 - drivers/staging/lustre/lnet/selftest/conrpc.c | 3 - drivers/staging/lustre/lnet/selftest/rpc.c | 3 - drivers/staging/lustre/lnet/selftest/selftest.h | 3 - drivers/staging/lustre/lustre/include/lustre_mdc.h | 2 - drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 3 - drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 8 +-- drivers/staging/lustre/lustre/llite/llite_lib.c | 6 +- .../staging/lustre/lustre/obdecho/echo_client.c | 3 - drivers/staging/lustre/lustre/ptlrpc/client.c | 4 -- drivers/staging/lustre/lustre/ptlrpc/sec.c | 3 - 27 files changed, 101 insertions(+), 135 deletions(-)
--
Signature
PATCH 1/7 lustre: use schedule_timeout_$state().
Lustre has many calls to
set_current_state(STATE);
schedule_timeout(time);
These can more easily be done as
schedule_timeout_STATE(time);
Also clean up some oddities, such as setting the state to TASK_RUNNING after the timeout, and simplify some time calculations.
Some schedule_timeout() calls remain as the state was set earlier, before an 'add_wait_queue()'. It would be incorrect to convert these.
--- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 12 ++++-------- .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 6 ++---- .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 14 ++++++-------- drivers/staging/lustre/lnet/libcfs/fail.c | 3 +-- drivers/staging/lustre/lnet/libcfs/tracefile.c | 3 +-- drivers/staging/lustre/lnet/lnet/acceptor.c | 3 +-- drivers/staging/lustre/lnet/lnet/api-ni.c | 6 ++---- drivers/staging/lustre/lnet/lnet/peer.c | 3 +-- drivers/staging/lustre/lnet/lnet/router.c | 19 +++++-------------- drivers/staging/lustre/lnet/selftest/conrpc.c | 3 +-- drivers/staging/lustre/lnet/selftest/rpc.c | 3 +-- drivers/staging/lustre/lnet/selftest/selftest.h | 3 +-- drivers/staging/lustre/lustre/include/lustre_mdc.h | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 3 +-- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 8 +++----- drivers/staging/lustre/lustre/llite/llite_lib.c | 6 ++---- .../staging/lustre/lustre/obdecho/echo_client.c | 3 +-- drivers/staging/lustre/lustre/ptlrpc/client.c | 4 +--- drivers/staging/lustre/lustre/ptlrpc/sec.c | 3 +-- 19 files changed, 36 insertions(+), 71 deletions(-)
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +4 -8
@@ -1201,8 +1201,7 @@ static struct kib_hca_dev *kiblnd_current_hdev(struct kib_dev *dev)if (!(i++ %50 ))CDEBUG (D_NET ,"%s: Wait for failover\n" , dev->ibd_ifname); -set_current_state (TASK_INTERRUPTIBLE ); -schedule_timeout (HZ /100 ); +schedule_timeout_interruptible (HZ /100 );read_lock_irqsave (&kiblnd_data.kib_global_lock, flags); }
@@ -1916,8 +1915,7 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)CDEBUG (D_NET ,"Another thread is allocating new %s pool, waiting %d HZs for her to complete. trips = %d\n" , ps->ps_name, interval, trips); -set_current_state (TASK_INTERRUPTIBLE ); -schedule_timeout (interval); +schedule_timeout_interruptible (interval);if (interval <HZ ) interval *=2 ;
@@ -2548,8 +2546,7 @@ static void kiblnd_base_shutdown(void)CDEBUG (((i & (-i)) == i) ?D_WARNING :D_NET ,"Waiting for %d threads to terminate\n" ,atomic_read (&kiblnd_data.kib_nthreads)); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ ); }/* fall through */
@@ -2599,8 +2596,7 @@ static void kiblnd_shutdown(struct lnet_ni *ni)"%s: waiting for %d peers to disconnect\n" ,libcfs_nid2str (ni->ni_nid), atomic_read(&net->ibn_npeers)); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ ); }kiblnd_net_fini_pools (net);
drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +2 -4
@@ -2307,8 +2307,7 @@ ksocknal_base_shutdown(void)"waiting for %d threads to terminate\n" , ksocknal_data.ksnd_nthreads);read_unlock (&ksocknal_data.ksnd_global_lock); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ );read_lock (&ksocknal_data.ksnd_global_lock); }read_unlock (&ksocknal_data.ksnd_global_lock);
@@ -2533,8 +2532,7 @@ ksocknal_shutdown(struct lnet_ni *ni)CDEBUG (((i & (-i)) == i) ?D_WARNING :D_NET ,/* power of 2? */ "waiting for %d peers to disconnect\n" , net->ksnn_npeers); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ );ksocknal_debug_peerhash (ni);
drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +6 -8
@@ -188,10 +188,9 @@ ksocknal_transmit(struct ksock_conn *conn, struct ksock_tx *tx)int rc;int bufnob; -if (ksocknal_data.ksnd_stall_tx) { -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (ksocknal_data.ksnd_stall_tx *HZ ); - } +if (ksocknal_data.ksnd_stall_tx) +schedule_timeout_uninterruptible ( + ksocknal_data.ksnd_stall_tx *HZ );LASSERT (tx->tx_resid);
@@ -293,10 +292,9 @@ ksocknal_receive(struct ksock_conn *conn)*/ int rc; -if (ksocknal_data.ksnd_stall_rx) { -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (ksocknal_data.ksnd_stall_rx *HZ ); - } +if (ksocknal_data.ksnd_stall_rx) +schedule_timeout_uninterruptible ( + ksocknal_data.ksnd_stall_rx *HZ ); rc =ksocknal_connsock_addref (conn);if (rc) {
drivers/staging/lustre/lnet/libcfs/fail.c +1 -2
@@ -137,8 +137,7 @@ int __cfs_fail_timeout_set(u32 id, u32 value, int ms, int set)if (ret &&likely (ms >0 )) {CERROR ("cfs_fail_timeout id %x sleeping for %dms\n" , id, ms); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (ms *HZ /1000 ); +schedule_timeout_uninterruptible (ms *HZ /1000 );CERROR ("cfs_fail_timeout id %x awake\n" , id); }return ret;
drivers/staging/lustre/lnet/libcfs/tracefile.c +1 -2
@@ -1208,8 +1208,7 @@ static int tracefiled(void *arg) }init_waitqueue_entry (&__wait, current);add_wait_queue (&tctl->tctl_waitq, &__wait); -set_current_state (TASK_INTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_interruptible (HZ );remove_wait_queue (&tctl->tctl_waitq, &__wait); }complete (&tctl->tctl_stop);
drivers/staging/lustre/lnet/lnet/acceptor.c +1 -2
@@ -362,8 +362,7 @@ lnet_acceptor(void *arg)if (rc) {if (rc != -EAGAIN ) {CWARN ("Accept error %d: pausing...\n" , rc); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ ); }continue ; }
drivers/staging/lustre/lnet/lnet/api-ni.c +2 -4
@@ -955,8 +955,7 @@ lnet_ping_md_unlink(struct lnet_ping_info *pinfo,/* NB md could be busy; this just starts the unlink */ while (pinfo->pi_features !=LNET_PING_FEAT_INVAL ) {CDEBUG (D_NET ,"Still waiting for ping MD to unlink\n" ); -set_current_state (TASK_NOLOAD ); -schedule_timeout (HZ ); +schedule_timeout_idle (HZ ); } }
@@ -1093,8 +1092,7 @@ lnet_clear_zombies_nis_locked(void)CDEBUG (D_WARNING ,"Waiting for zombie LNI %s\n" ,libcfs_nid2str (ni->ni_nid)); } -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ );lnet_net_lock (LNET_LOCK_EX );continue ; }
drivers/staging/lustre/lnet/lnet/peer.c +1 -2
@@ -136,8 +136,7 @@ lnet_peer_table_deathrow_wait_locked(struct lnet_peer_table *ptable,"Waiting for %d zombies on peer table\n" , ptable->pt_zombies); } -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ >>1 ); +schedule_timeout_uninterruptible (HZ >>1 );lnet_net_lock (cpt_locked); } }
drivers/staging/lustre/lnet/lnet/router.c +5 -14
@@ -783,8 +783,7 @@ lnet_wait_known_routerstate(void)if (all_known)return ; -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ ); } }
@@ -1159,8 +1158,7 @@ lnet_prune_rc_data(int wait_unlink) i++;CDEBUG (((i & (-i)) == i) ?D_WARNING :D_NET ,"Waiting for rc buffers to unlink\n" ); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ /4 ); +schedule_timeout_uninterruptible (HZ /4 );lnet_net_lock (LNET_LOCK_EX ); }
@@ -1236,23 +1234,16 @@ lnet_router_checker(void *arg)lnet_prune_rc_data (0 );/* don't wait for UNLINK */ -/* -* Call schedule_timeout() here always adds 1 to load average -* because kernel counts # active tasks as nr_running -* + nr_uninterruptible. -*/ /* * if there are any routes then wakeup every second. If * there are no routes then sleep indefinitely until woken * up by a user adding a route */ if (!lnet_router_checker_active ()) -wait_event_interruptible (the_lnet.ln_rc_waitq, -lnet_router_checker_active ()); +wait_event_idle (the_lnet.ln_rc_waitq, +lnet_router_checker_active ());else -wait_event_interruptible_timeout (the_lnet.ln_rc_waitq, - false, -HZ ); +schedule_timeout_idle (HZ ); }lnet_prune_rc_data (1 );/* wait for UNLINK */
drivers/staging/lustre/lnet/selftest/conrpc.c +1 -2
@@ -1345,8 +1345,7 @@ lstcon_rpc_cleanup_wait(void)mutex_unlock (&console_session.ses_mutex);CWARN ("Session is shutting down, waiting for termination of transactions\n" ); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ );mutex_lock (&console_session.ses_mutex); }
drivers/staging/lustre/lnet/selftest/rpc.c +1 -2
@@ -1603,8 +1603,7 @@ srpc_startup(void)spin_lock_init (&srpc_data.rpc_glock);/* 1 second pause to avoid timestamp reuse */ -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ ); srpc_data.rpc_matchbits = ((__u64 )ktime_get_real_seconds ()) <<48 ; srpc_data.rpc_state =SRPC_STATE_NONE ;
drivers/staging/lustre/lnet/selftest/selftest.h +1 -2
@@ -573,8 +573,7 @@ swi_state2str(int state)#define selftest_wait_events () \ do { \ - set_current_state(TASK_UNINTERRUPTIBLE); \ - schedule_timeout(HZ / 10); \ + schedule_timeout_uninterruptible(HZ / 10); \ } while (0)#define lst_wait_until (cond, lock, fmt, ...) \
drivers/staging/lustre/lustre/include/lustre_mdc.h +1 -1
@@ -124,7 +124,7 @@ static inline void mdc_get_rpc_lock(struct mdc_rpc_lock *lck,*/ while (unlikely (lck->rpcl_it ==MDC_FAKE_RPCL_IT )) {mutex_unlock (&lck->rpcl_mutex); -schedule_timeout (HZ /4 ); +schedule_timeout_uninterruptible (HZ /4 ); goto again; }
drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +1 -2
@@ -167,8 +167,7 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req,int to =HZ ;while (to >0 ) { -set_current_state (TASK_INTERRUPTIBLE ); -schedule_timeout (to); +schedule_timeout_interruptible (to);if (lock->l_granted_mode == lock->l_req_mode ||ldlm_is_destroyed (lock))break ;
drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +3 -5
@@ -749,11 +749,9 @@ static void cleanup_resource(struct ldlm_resource *res, struct list_head *q,*/ unlock_res (res);LDLM_DEBUG (lock,"setting FL_LOCAL_ONLY" ); -if (lock->l_flags &LDLM_FL_FAIL_LOC ) { -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (4 *HZ ); -set_current_state (TASK_RUNNING ); - } +if (lock->l_flags &LDLM_FL_FAIL_LOC ) +schedule_timeout_uninterruptible (4 *HZ ); +if (lock->l_completion_ast) lock->l_completion_ast (lock,LDLM_FL_FAILED ,NULL );
drivers/staging/lustre/lustre/llite/llite_lib.c +2 -4
@@ -706,10 +706,8 @@ void ll_kill_super(struct super_block *sb) sbi->ll_umounting =1 ;/* wait running statahead threads to quit */ -while (atomic_read (&sbi->ll_sa_running) >0 ) { -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (msecs_to_jiffies (MSEC_PER_SEC >>3 )); - } +while (atomic_read (&sbi->ll_sa_running) >0 ) +schedule_timeout_uninterruptible (HZ >>3 ); } }
drivers/staging/lustre/lustre/obdecho/echo_client.c +1 -2
@@ -751,8 +751,7 @@ static struct lu_device *echo_device_free(const struct lu_env *env,while (!list_empty (&ec->ec_objects)) {spin_unlock (&ec->ec_lock);CERROR ("echo_client still has objects at cleanup time, wait for 1 second\n" ); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ );lu_site_purge (env, ed->ed_site,-1 );spin_lock (&ec->ec_lock); }
drivers/staging/lustre/lustre/ptlrpc/client.c +1 -3
@@ -761,9 +761,7 @@ int ptlrpc_request_bufs_pack(struct ptlrpc_request *request,/* The RPC is infected, let the test change the * fail_loc */ -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (2 *HZ ); -set_current_state (TASK_RUNNING ); +schedule_timeout_uninterruptible (2 *HZ ); } }
drivers/staging/lustre/lustre/ptlrpc/sec.c +1 -2
@@ -514,8 +514,7 @@ static int sptlrpc_req_replace_dead_ctx(struct ptlrpc_request *req)"ctx (%p, fl %lx) doesn't switch, relax a little bit\n" , newctx, newctx->cc_flags); -set_current_state (TASK_INTERRUPTIBLE ); -schedule_timeout (msecs_to_jiffies (MSEC_PER_SEC )); +schedule_timeout_interruptible (HZ ); }else if (unlikely (!test_bit (PTLRPC_CTX_UPTODATE_BIT , &newctx->cc_flags))) {/* * new ctx not up to date yet
PATCH 1/7 lustre: use schedule_timeout_$state().
Quoted 9 lines · NeilBrown
Lustre has many calls to
set_current_state(STATE);
schedule_timeout(time);These can more easily be done as
schedule_timeout_STATE(time);
Quoted 8 lines
Also clean up some oddities, such as setting the state to
TASK_RUNNINGafter the timeout, and simplify some time calculations.Some
schedule_timeout()calls remain as the state was set earlier, before an 'add_wait_queue()'. It would be incorrect to convert these.Signed-off-by NeilBrown <[email protected]>
Quoted 394 lines
---
.../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 12 ++++-------- .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 6 ++---- .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 14 ++++++-------- drivers/staging/lustre/lnet/libcfs/fail.c | 3 +-- drivers/staging/lustre/lnet/libcfs/tracefile.c | 3 +-- drivers/staging/lustre/lnet/lnet/acceptor.c | 3 +-- drivers/staging/lustre/lnet/lnet/api-ni.c | 6 ++---- drivers/staging/lustre/lnet/lnet/peer.c | 3 +-- drivers/staging/lustre/lnet/lnet/router.c | 19 +++++-------------- drivers/staging/lustre/lnet/selftest/conrpc.c | 3 +-- drivers/staging/lustre/lnet/selftest/rpc.c | 3 +-- drivers/staging/lustre/lnet/selftest/selftest.h | 3 +-- drivers/staging/lustre/lustre/include/lustre_mdc.h | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 3 +-- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 8 +++----- drivers/staging/lustre/lustre/llite/llite_lib.c | 6 ++---- .../staging/lustre/lustre/obdecho/echo_client.c | 3 +-- drivers/staging/lustre/lustre/ptlrpc/client.c | 4 +--- drivers/staging/lustre/lustre/ptlrpc/sec.c | 3 +-- 19 files changed, 36 insertions(+), 71 deletions(-)drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +4
-8@@ -1201,8 +1201,7 @@ static struct kib_hca_dev *kiblnd_current_hdev(struct kib_dev *dev)if (!(i++ %50 ))CDEBUG (D_NET ,"%s: Wait for failover\n" , dev->ibd_ifname); -set_current_state (TASK_INTERRUPTIBLE ); -schedule_timeout (HZ /100 ); +schedule_timeout_interruptible (HZ /100 );read_lock_irqsave (&kiblnd_data.kib_global_lock, flags); }@@ -1916,8 +1915,7 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)CDEBUG (D_NET ,"Another thread is allocating new %s pool, waiting %d HZs for her to complete. trips = %d\n" , ps->ps_name, interval, trips); -set_current_state (TASK_INTERRUPTIBLE ); -schedule_timeout (interval); +schedule_timeout_interruptible (interval);if (interval <HZ ) interval *=2 ;@@ -2548,8 +2546,7 @@ static void kiblnd_base_shutdown(void)CDEBUG (((i & (-i)) == i) ?D_WARNING :D_NET ,"Waiting for %d threads to terminate\n" ,atomic_read (&kiblnd_data.kib_nthreads)); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ ); }/* fall through */ @@ -2599,8 +2596,7 @@ static void kiblnd_shutdown(struct lnet_ni *ni)"%s: waiting for %d peers to disconnect\n" ,libcfs_nid2str (ni->ni_nid), atomic_read(&net->ibn_npeers)); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ ); }kiblnd_net_fini_pools (net);drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +2
-4@@ -2307,8 +2307,7 @@ ksocknal_base_shutdown(void)"waiting for %d threads to terminate\n" , ksocknal_data.ksnd_nthreads);read_unlock (&ksocknal_data.ksnd_global_lock); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ );read_lock (&ksocknal_data.ksnd_global_lock); }read_unlock (&ksocknal_data.ksnd_global_lock);@@ -2533,8 +2532,7 @@ ksocknal_shutdown(struct lnet_ni *ni)CDEBUG (((i & (-i)) == i) ?D_WARNING :D_NET ,/* power of 2? */ "waiting for %d peers to disconnect\n" , net->ksnn_npeers); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ );ksocknal_debug_peerhash (ni);drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +6
-8@@ -188,10 +188,9 @@ ksocknal_transmit(struct ksock_conn *conn, struct ksock_tx *tx)int rc;int bufnob; -if (ksocknal_data.ksnd_stall_tx) { -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (ksocknal_data.ksnd_stall_tx *HZ ); - } +if (ksocknal_data.ksnd_stall_tx) +schedule_timeout_uninterruptible ( + ksocknal_data.ksnd_stall_tx *HZ );LASSERT (tx->tx_resid);@@ -293,10 +292,9 @@ ksocknal_receive(struct ksock_conn *conn)*/ int rc; -if (ksocknal_data.ksnd_stall_rx) { -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (ksocknal_data.ksnd_stall_rx *HZ ); - } +if (ksocknal_data.ksnd_stall_rx) +schedule_timeout_uninterruptible ( + ksocknal_data.ksnd_stall_rx *HZ ); rc =ksocknal_connsock_addref (conn);if (rc) {drivers/staging/lustre/lnet/libcfs/fail.c +1
-2@@ -137,8 +137,7 @@ int __cfs_fail_timeout_set(u32 id, u32 value, int ms, int set)if (ret &&likely (ms >0 )) {CERROR ("cfs_fail_timeout id %x sleeping for %dms\n" , id, ms); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (ms *HZ /1000 ); +schedule_timeout_uninterruptible (ms *HZ /1000 );CERROR ("cfs_fail_timeout id %x awake\n" , id); }return ret;drivers/staging/lustre/lnet/libcfs/tracefile.c +1
-2@@ -1208,8 +1208,7 @@ static int tracefiled(void *arg) }init_waitqueue_entry (&__wait, current);add_wait_queue (&tctl->tctl_waitq, &__wait); -set_current_state (TASK_INTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_interruptible (HZ );remove_wait_queue (&tctl->tctl_waitq, &__wait); }complete (&tctl->tctl_stop);drivers/staging/lustre/lnet/lnet/acceptor.c +1
-2@@ -362,8 +362,7 @@ lnet_acceptor(void *arg)if (rc) {if (rc != -EAGAIN ) {CWARN ("Accept error %d: pausing...\n" , rc); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ ); }continue ; }drivers/staging/lustre/lnet/lnet/api-ni.c +2
-4@@ -955,8 +955,7 @@ lnet_ping_md_unlink(struct lnet_ping_info *pinfo,/* NB md could be busy; this just starts the unlink */ while (pinfo->pi_features !=LNET_PING_FEAT_INVAL ) {CDEBUG (D_NET ,"Still waiting for ping MD to unlink\n" ); -set_current_state (TASK_NOLOAD ); -schedule_timeout (HZ ); +schedule_timeout_idle (HZ ); } }@@ -1093,8 +1092,7 @@ lnet_clear_zombies_nis_locked(void)CDEBUG (D_WARNING ,"Waiting for zombie LNI %s\n" ,libcfs_nid2str (ni->ni_nid)); } -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ );lnet_net_lock (LNET_LOCK_EX );continue ; }drivers/staging/lustre/lnet/lnet/peer.c +1
-2@@ -136,8 +136,7 @@ lnet_peer_table_deathrow_wait_locked(struct lnet_peer_table *ptable,"Waiting for %d zombies on peer table\n" , ptable->pt_zombies); } -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ >>1 ); +schedule_timeout_uninterruptible (HZ >>1 );lnet_net_lock (cpt_locked); } }drivers/staging/lustre/lnet/lnet/router.c +5
-14@@ -783,8 +783,7 @@ lnet_wait_known_routerstate(void)if (all_known)return ; -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ ); } }@@ -1159,8 +1158,7 @@ lnet_prune_rc_data(int wait_unlink) i++;CDEBUG (((i & (-i)) == i) ?D_WARNING :D_NET ,"Waiting for rc buffers to unlink\n" ); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ /4 ); +schedule_timeout_uninterruptible (HZ /4 );lnet_net_lock (LNET_LOCK_EX ); }@@ -1236,23 +1234,16 @@ lnet_router_checker(void *arg)lnet_prune_rc_data (0 );/* don't wait for UNLINK */ -/* -* Call schedule_timeout() here always adds 1 to load average -* because kernel counts # active tasks as nr_running -* + nr_uninterruptible. -*/ /* * if there are any routes then wakeup every second. If * there are no routes then sleep indefinitely until woken * up by a user adding a route */ if (!lnet_router_checker_active ()) -wait_event_interruptible (the_lnet.ln_rc_waitq, -lnet_router_checker_active ()); +wait_event_idle (the_lnet.ln_rc_waitq, +lnet_router_checker_active ());else -wait_event_interruptible_timeout (the_lnet.ln_rc_waitq, - false, -HZ ); +schedule_timeout_idle (HZ ); }lnet_prune_rc_data (1 );/* wait for UNLINK */ drivers/staging/lustre/lnet/selftest/conrpc.c +1
-2@@ -1345,8 +1345,7 @@ lstcon_rpc_cleanup_wait(void)mutex_unlock (&console_session.ses_mutex);CWARN ("Session is shutting down, waiting for termination of transactions\n" ); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ );mutex_lock (&console_session.ses_mutex); }drivers/staging/lustre/lnet/selftest/rpc.c +1
-2@@ -1603,8 +1603,7 @@ srpc_startup(void)spin_lock_init (&srpc_data.rpc_glock);/* 1 second pause to avoid timestamp reuse */ -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ ); srpc_data.rpc_matchbits = ((__u64 )ktime_get_real_seconds ()) <<48 ; srpc_data.rpc_state =SRPC_STATE_NONE ;drivers/staging/lustre/lnet/selftest/selftest.h +1
-2@@ -573,8 +573,7 @@ swi_state2str(int state)#define selftest_wait_events () \ do { \ - set_current_state(TASK_UNINTERRUPTIBLE); \ - schedule_timeout(HZ / 10); \ + schedule_timeout_uninterruptible(HZ / 10); \ } while (0)#define lst_wait_until (cond, lock, fmt, ...) \drivers/staging/lustre/lustre/include/lustre_mdc.h +1
-1@@ -124,7 +124,7 @@ static inline void mdc_get_rpc_lock(struct mdc_rpc_lock *lck,*/ while (unlikely (lck->rpcl_it ==MDC_FAKE_RPCL_IT )) {mutex_unlock (&lck->rpcl_mutex); -schedule_timeout (HZ /4 ); +schedule_timeout_uninterruptible (HZ /4 ); goto again; }drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +1
-2@@ -167,8 +167,7 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req,int to =HZ ;while (to >0 ) { -set_current_state (TASK_INTERRUPTIBLE ); -schedule_timeout (to); +schedule_timeout_interruptible (to);if (lock->l_granted_mode == lock->l_req_mode ||ldlm_is_destroyed (lock))break ;drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +3
-5@@ -749,11 +749,9 @@ static void cleanup_resource(struct ldlm_resource *res, struct list_head *q,*/ unlock_res (res);LDLM_DEBUG (lock,"setting FL_LOCAL_ONLY" ); -if (lock->l_flags &LDLM_FL_FAIL_LOC ) { -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (4 *HZ ); -set_current_state (TASK_RUNNING ); - } +if (lock->l_flags &LDLM_FL_FAIL_LOC ) +schedule_timeout_uninterruptible (4 *HZ ); +if (lock->l_completion_ast) lock->l_completion_ast (lock,LDLM_FL_FAILED ,NULL );drivers/staging/lustre/lustre/llite/llite_lib.c +2
-4@@ -706,10 +706,8 @@ void ll_kill_super(struct super_block *sb) sbi->ll_umounting =1 ;/* wait running statahead threads to quit */ -while (atomic_read (&sbi->ll_sa_running) >0 ) { -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (msecs_to_jiffies (MSEC_PER_SEC >>3 )); - } +while (atomic_read (&sbi->ll_sa_running) >0 ) +schedule_timeout_uninterruptible (HZ >>3 ); } }drivers/staging/lustre/lustre/obdecho/echo_client.c +1
-2@@ -751,8 +751,7 @@ static struct lu_device *echo_device_free(const struct lu_env *env,while (!list_empty (&ec->ec_objects)) {spin_unlock (&ec->ec_lock);CERROR ("echo_client still has objects at cleanup time, wait for 1 second\n" ); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ );lu_site_purge (env, ed->ed_site,-1 );spin_lock (&ec->ec_lock); }drivers/staging/lustre/lustre/ptlrpc/client.c +1
-3@@ -761,9 +761,7 @@ int ptlrpc_request_bufs_pack(struct ptlrpc_request *request,/* The RPC is infected, let the test change the * fail_loc */ -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (2 *HZ ); -set_current_state (TASK_RUNNING ); +schedule_timeout_uninterruptible (2 *HZ ); } }drivers/staging/lustre/lustre/ptlrpc/sec.c +0
-0
drivers/staging/lustre/lustre/ptlrpc/sec.c static int sptlrpc_req_replace_dead_ctx(struct ptlrpc_request *req) · line 520
Quoted 9 lines
drivers/staging/lustre/lustre/ptlrpc/sec.c +1
-2@@ -514,8 +514,7 @@ static int sptlrpc_req_replace_dead_ctx(struct ptlrpc_request *req)"ctx (%p, fl %lx) doesn't switch, relax a little bit\n" , newctx, newctx->cc_flags); -set_current_state (TASK_INTERRUPTIBLE ); -schedule_timeout (msecs_to_jiffies (MSEC_PER_SEC )); +schedule_timeout_interruptible (HZ ); }else if (unlikely (!test_bit (PTLRPC_CTX_UPTODATE_BIT , &newctx->cc_flags))) {/* * new ctx not up to date yet
Cheers, Andreas
---
Andreas Dilger
CTO Whamcloud
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 235 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180730/af0d9a23/attachment.sig>
PATCH 1/7 lustre: use schedule_timeout_$state().
In reply to NeilBrownQuoted 7 lines
Lustre has many calls to
set_current_state(STATE); schedule_timeout(time);These can more easily be done as
Quoted 8 lines
schedule_timeout_STATE(time);Also clean up some oddities, such as setting the state to
TASK_RUNNINGafter the timeout, and simplify some time calculations.Some
schedule_timeout()calls remain as the state was set earlier, before an 'add_wait_queue()'. It would be incorrect to convert these.
From a time long ago.
Quoted 405 lines
Signed-off-by NeilBrown <[email protected]>--- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 12 ++++-------- .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 6 ++---- .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 14 ++++++-------- drivers/staging/lustre/lnet/libcfs/fail.c | 3 +-- drivers/staging/lustre/lnet/libcfs/tracefile.c | 3 +-- drivers/staging/lustre/lnet/lnet/acceptor.c | 3 +-- drivers/staging/lustre/lnet/lnet/api-ni.c | 6 ++---- drivers/staging/lustre/lnet/lnet/peer.c | 3 +-- drivers/staging/lustre/lnet/lnet/router.c | 19 +++++-------------- drivers/staging/lustre/lnet/selftest/conrpc.c | 3 +-- drivers/staging/lustre/lnet/selftest/rpc.c | 3 +-- drivers/staging/lustre/lnet/selftest/selftest.h | 3 +-- drivers/staging/lustre/lustre/include/lustre_mdc.h | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 3 +-- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 8 +++----- drivers/staging/lustre/lustre/llite/llite_lib.c | 6 ++---- .../staging/lustre/lustre/obdecho/echo_client.c | 3 +-- drivers/staging/lustre/lustre/ptlrpc/client.c | 4 +--- drivers/staging/lustre/lustre/ptlrpc/sec.c | 3 +-- 19 files changed, 36 insertions(+), 71 deletions(-)drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +4
-8@@ -1201,8 +1201,7 @@ static struct kib_hca_dev *kiblnd_current_hdev(struct kib_dev *dev)if (!(i++ %50 ))CDEBUG (D_NET ,"%s: Wait for failover\n" , dev->ibd_ifname); -set_current_state (TASK_INTERRUPTIBLE ); -schedule_timeout (HZ /100 ); +schedule_timeout_interruptible (HZ /100 );read_lock_irqsave (&kiblnd_data.kib_global_lock, flags); }@@ -1916,8 +1915,7 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)CDEBUG (D_NET ,"Another thread is allocating new %s pool, waiting %d HZs for her to complete. trips = %d\n" , ps->ps_name, interval, trips); -set_current_state (TASK_INTERRUPTIBLE ); -schedule_timeout (interval); +schedule_timeout_interruptible (interval);if (interval <HZ ) interval *=2 ;@@ -2548,8 +2546,7 @@ static void kiblnd_base_shutdown(void)CDEBUG (((i & (-i)) == i) ?D_WARNING :D_NET ,"Waiting for %d threads to terminate\n" ,atomic_read (&kiblnd_data.kib_nthreads)); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ ); }/* fall through */ @@ -2599,8 +2596,7 @@ static void kiblnd_shutdown(struct lnet_ni *ni)"%s: waiting for %d peers to disconnect\n" ,libcfs_nid2str (ni->ni_nid), atomic_read(&net->ibn_npeers)); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ ); }kiblnd_net_fini_pools (net);drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +2
-4@@ -2307,8 +2307,7 @@ ksocknal_base_shutdown(void)"waiting for %d threads to terminate\n" , ksocknal_data.ksnd_nthreads);read_unlock (&ksocknal_data.ksnd_global_lock); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ );read_lock (&ksocknal_data.ksnd_global_lock); }read_unlock (&ksocknal_data.ksnd_global_lock);@@ -2533,8 +2532,7 @@ ksocknal_shutdown(struct lnet_ni *ni)CDEBUG (((i & (-i)) == i) ?D_WARNING :D_NET ,/* power of 2? */ "waiting for %d peers to disconnect\n" , net->ksnn_npeers); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ );ksocknal_debug_peerhash (ni);drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +6
-8@@ -188,10 +188,9 @@ ksocknal_transmit(struct ksock_conn *conn, struct ksock_tx *tx)int rc;int bufnob; -if (ksocknal_data.ksnd_stall_tx) { -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (ksocknal_data.ksnd_stall_tx *HZ ); - } +if (ksocknal_data.ksnd_stall_tx) +schedule_timeout_uninterruptible ( + ksocknal_data.ksnd_stall_tx *HZ );LASSERT (tx->tx_resid);@@ -293,10 +292,9 @@ ksocknal_receive(struct ksock_conn *conn)*/ int rc; -if (ksocknal_data.ksnd_stall_rx) { -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (ksocknal_data.ksnd_stall_rx *HZ ); - } +if (ksocknal_data.ksnd_stall_rx) +schedule_timeout_uninterruptible ( + ksocknal_data.ksnd_stall_rx *HZ ); rc =ksocknal_connsock_addref (conn);if (rc) {drivers/staging/lustre/lnet/libcfs/fail.c +1
-2@@ -137,8 +137,7 @@ int __cfs_fail_timeout_set(u32 id, u32 value, int ms, int set)if (ret &&likely (ms >0 )) {CERROR ("cfs_fail_timeout id %x sleeping for %dms\n" , id, ms); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (ms *HZ /1000 ); +schedule_timeout_uninterruptible (ms *HZ /1000 );CERROR ("cfs_fail_timeout id %x awake\n" , id); }return ret;drivers/staging/lustre/lnet/libcfs/tracefile.c +1
-2@@ -1208,8 +1208,7 @@ static int tracefiled(void *arg) }init_waitqueue_entry (&__wait, current);add_wait_queue (&tctl->tctl_waitq, &__wait); -set_current_state (TASK_INTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_interruptible (HZ );remove_wait_queue (&tctl->tctl_waitq, &__wait); }complete (&tctl->tctl_stop);drivers/staging/lustre/lnet/lnet/acceptor.c +1
-2@@ -362,8 +362,7 @@ lnet_acceptor(void *arg)if (rc) {if (rc != -EAGAIN ) {CWARN ("Accept error %d: pausing...\n" , rc); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ ); }continue ; }drivers/staging/lustre/lnet/lnet/api-ni.c +2
-4@@ -955,8 +955,7 @@ lnet_ping_md_unlink(struct lnet_ping_info *pinfo,/* NB md could be busy; this just starts the unlink */ while (pinfo->pi_features !=LNET_PING_FEAT_INVAL ) {CDEBUG (D_NET ,"Still waiting for ping MD to unlink\n" ); -set_current_state (TASK_NOLOAD ); -schedule_timeout (HZ ); +schedule_timeout_idle (HZ ); } }@@ -1093,8 +1092,7 @@ lnet_clear_zombies_nis_locked(void)CDEBUG (D_WARNING ,"Waiting for zombie LNI %s\n" ,libcfs_nid2str (ni->ni_nid)); } -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ );lnet_net_lock (LNET_LOCK_EX );continue ; }drivers/staging/lustre/lnet/lnet/peer.c +1
-2@@ -136,8 +136,7 @@ lnet_peer_table_deathrow_wait_locked(struct lnet_peer_table *ptable,"Waiting for %d zombies on peer table\n" , ptable->pt_zombies); } -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ >>1 ); +schedule_timeout_uninterruptible (HZ >>1 );lnet_net_lock (cpt_locked); } }drivers/staging/lustre/lnet/lnet/router.c +5
-14@@ -783,8 +783,7 @@ lnet_wait_known_routerstate(void)if (all_known)return ; -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ ); } }@@ -1159,8 +1158,7 @@ lnet_prune_rc_data(int wait_unlink) i++;CDEBUG (((i & (-i)) == i) ?D_WARNING :D_NET ,"Waiting for rc buffers to unlink\n" ); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ /4 ); +schedule_timeout_uninterruptible (HZ /4 );lnet_net_lock (LNET_LOCK_EX ); }@@ -1236,23 +1234,16 @@ lnet_router_checker(void *arg)lnet_prune_rc_data (0 );/* don't wait for UNLINK */ -/* -* Call schedule_timeout() here always adds 1 to load average -* because kernel counts # active tasks as nr_running -* + nr_uninterruptible. -*/ /* * if there are any routes then wakeup every second. If * there are no routes then sleep indefinitely until woken * up by a user adding a route */ if (!lnet_router_checker_active ()) -wait_event_interruptible (the_lnet.ln_rc_waitq, -lnet_router_checker_active ()); +wait_event_idle (the_lnet.ln_rc_waitq, +lnet_router_checker_active ());else -wait_event_interruptible_timeout (the_lnet.ln_rc_waitq, - false, -HZ ); +schedule_timeout_idle (HZ ); }lnet_prune_rc_data (1 );/* wait for UNLINK */ drivers/staging/lustre/lnet/selftest/conrpc.c +1
-2@@ -1345,8 +1345,7 @@ lstcon_rpc_cleanup_wait(void)mutex_unlock (&console_session.ses_mutex);CWARN ("Session is shutting down, waiting for termination of transactions\n" ); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ );mutex_lock (&console_session.ses_mutex); }drivers/staging/lustre/lnet/selftest/rpc.c +1
-2@@ -1603,8 +1603,7 @@ srpc_startup(void)spin_lock_init (&srpc_data.rpc_glock);/* 1 second pause to avoid timestamp reuse */ -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ ); srpc_data.rpc_matchbits = ((__u64 )ktime_get_real_seconds ()) <<48 ; srpc_data.rpc_state =SRPC_STATE_NONE ;drivers/staging/lustre/lnet/selftest/selftest.h +1
-2@@ -573,8 +573,7 @@ swi_state2str(int state)#define selftest_wait_events () \ do { \ - set_current_state(TASK_UNINTERRUPTIBLE); \ - schedule_timeout(HZ / 10); \ + schedule_timeout_uninterruptible(HZ / 10); \ } while (0)#define lst_wait_until (cond, lock, fmt, ...) \drivers/staging/lustre/lustre/include/lustre_mdc.h +1
-1@@ -124,7 +124,7 @@ static inline void mdc_get_rpc_lock(struct mdc_rpc_lock *lck,*/ while (unlikely (lck->rpcl_it ==MDC_FAKE_RPCL_IT )) {mutex_unlock (&lck->rpcl_mutex); -schedule_timeout (HZ /4 ); +schedule_timeout_uninterruptible (HZ /4 ); goto again; }drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +1
-2@@ -167,8 +167,7 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req,int to =HZ ;while (to >0 ) { -set_current_state (TASK_INTERRUPTIBLE ); -schedule_timeout (to); +schedule_timeout_interruptible (to);if (lock->l_granted_mode == lock->l_req_mode ||ldlm_is_destroyed (lock))break ;drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +3
-5@@ -749,11 +749,9 @@ static void cleanup_resource(struct ldlm_resource *res, struct list_head *q,*/ unlock_res (res);LDLM_DEBUG (lock,"setting FL_LOCAL_ONLY" ); -if (lock->l_flags &LDLM_FL_FAIL_LOC ) { -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (4 *HZ ); -set_current_state (TASK_RUNNING ); - } +if (lock->l_flags &LDLM_FL_FAIL_LOC ) +schedule_timeout_uninterruptible (4 *HZ ); +if (lock->l_completion_ast) lock->l_completion_ast (lock,LDLM_FL_FAILED ,NULL );drivers/staging/lustre/lustre/llite/llite_lib.c +2
-4@@ -706,10 +706,8 @@ void ll_kill_super(struct super_block *sb) sbi->ll_umounting =1 ;/* wait running statahead threads to quit */ -while (atomic_read (&sbi->ll_sa_running) >0 ) { -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (msecs_to_jiffies (MSEC_PER_SEC >>3 )); - } +while (atomic_read (&sbi->ll_sa_running) >0 ) +schedule_timeout_uninterruptible (HZ >>3 ); } }drivers/staging/lustre/lustre/obdecho/echo_client.c +1
-2@@ -751,8 +751,7 @@ static struct lu_device *echo_device_free(const struct lu_env *env,while (!list_empty (&ec->ec_objects)) {spin_unlock (&ec->ec_lock);CERROR ("echo_client still has objects at cleanup time, wait for 1 second\n" ); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ ); +schedule_timeout_uninterruptible (HZ );lu_site_purge (env, ed->ed_site,-1 );spin_lock (&ec->ec_lock); }drivers/staging/lustre/lustre/ptlrpc/client.c +1
-3@@ -761,9 +761,7 @@ int ptlrpc_request_bufs_pack(struct ptlrpc_request *request,/* The RPC is infected, let the test change the * fail_loc */ -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (2 *HZ ); -set_current_state (TASK_RUNNING ); +schedule_timeout_uninterruptible (2 *HZ ); } }drivers/staging/lustre/lustre/ptlrpc/sec.c +1
-2@@ -514,8 +514,7 @@ static int sptlrpc_req_replace_dead_ctx(struct ptlrpc_request *req)"ctx (%p, fl %lx) doesn't switch, relax a little bit\n" , newctx, newctx->cc_flags); -set_current_state (TASK_INTERRUPTIBLE ); -schedule_timeout (msecs_to_jiffies (MSEC_PER_SEC )); +schedule_timeout_interruptible (HZ ); }else if (unlikely (!test_bit (PTLRPC_CTX_UPTODATE_BIT , &newctx->cc_flags))) {/* * new ctx not up to date yet
PATCH 2/7 lustre/libcfs: fix freeing after kmalloc failure.
In reply to NeilBrownThe new_bkts array is *not* zeroed (any more) so when freeing recently allocated buckets on failure, we must no free beyond the last bucket successfully allocated.
--- drivers/staging/lustre/lnet/libcfs/hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lnet/libcfs/hash.c +1 -1
@@ -904,7 +904,7 @@ cfs_hash_buckets_realloc(struct cfs_hash *hs, struct cfs_hash_bucket **old_bkts, new_bkts[i] =kzalloc (cfs_hash_bkt_size (hs),GFP_KERNEL );if (!new_bkts[i]) {cfs_hash_buckets_free (new_bkts,cfs_hash_bkt_size (hs), - old_size, new_size); + old_size, i);return NULL ; }
PATCH 2/7 lustre/libcfs: fix freeing after kmalloc failure.
Quoted 8 lines · NeilBrown
The
new_bktsarray is *not* zeroed (any more) so when freeing recently allocated buckets on failure, we must no free beyond the last bucket successfully allocated.Fixes 12e46c461cb9 ("staging: lustre: change some LIBCFS_ALLOC calls to k?alloc(GFP_KERNEL)")Signed-off-by NeilBrown <[email protected]>
Quoted 11 lines
---
drivers/staging/lustre/lnet/libcfs/hash.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/lustre/lnet/libcfs/hash.c +0
-0
drivers/staging/lustre/lnet/libcfs/hash.c cfs_hash_buckets_realloc(struct cfs_hash *hs, struct cfs_hash_bucket **old_bkts, · line 910
Quoted 8 lines
drivers/staging/lustre/lnet/libcfs/hash.c +1
-1@@ -904,7 +904,7 @@ cfs_hash_buckets_realloc(struct cfs_hash *hs, struct cfs_hash_bucket **old_bkts, new_bkts[i] =kzalloc (cfs_hash_bkt_size (hs),GFP_KERNEL );if (!new_bkts[i]) {cfs_hash_buckets_free (new_bkts,cfs_hash_bkt_size (hs), - old_size, new_size); + old_size, i);return NULL ; }
Cheers, Andreas
---
Andreas Dilger
CTO Whamcloud
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 235 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180730/3f7477a3/attachment-0001.sig>
PATCH 2/7 lustre/libcfs: fix freeing after kmalloc failure.
In reply to NeilBrownQuoted 5 lines
The
new_bktsarray is *not* zeroed (any more) so when freeing recently allocated buckets on failure, we must no free beyond the last bucket successfully allocated.
Quoted 22 lines
Fixes 12e46c461cb9 ("staging: lustre: change some LIBCFS_ALLOC calls to k?alloc(GFP_KERNEL)")Signed-off-by NeilBrown <[email protected]>--- drivers/staging/lustre/lnet/libcfs/hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/lustre/lnet/libcfs/hash.c +1
-1@@ -904,7 +904,7 @@ cfs_hash_buckets_realloc(struct cfs_hash *hs, struct cfs_hash_bucket **old_bkts, new_bkts[i] =kzalloc (cfs_hash_bkt_size (hs),GFP_KERNEL );if (!new_bkts[i]) {cfs_hash_buckets_free (new_bkts,cfs_hash_bkt_size (hs), - old_size, new_size); + old_size, i);return NULL ; }
PATCH 3/7 lustre/libfs: move debugfs registration from libcfs_setup back to libcfs_init
In reply to NeilBrownlarge memory allocations should be avoided at module-init, but registering services is appropriate.
So move the registration of debugfs files
back into libcfs_init().
Without this, /sys/kernel/debug/lnet etc are not visible immediately that libcfs is loaded.
No debugfs file access needs anything allocated by libcfs_setup().
--- drivers/staging/lustre/lnet/libcfs/module.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/lustre/lnet/libcfs/module.c +4 -4
@@ -719,10 +719,6 @@ int libcfs_setup(void) goto err; } -lnet_insert_debugfs (lnet_table); -if (!IS_ERR_OR_NULL (lnet_debugfs_root)) -lnet_insert_debugfs_links (lnet_debugfs_symlinks); -CDEBUG (D_OTHER ,"portals setup OK\n" ); out: libcfs_active =1 ;
@@ -743,6 +739,10 @@ static int libcfs_init(void) {int rc; +lnet_insert_debugfs (lnet_table); +if (!IS_ERR_OR_NULL (lnet_debugfs_root)) +lnet_insert_debugfs_links (lnet_debugfs_symlinks); + rc =misc_register (&libcfs_dev);if (rc)CERROR ("misc_register: error %d\n" , rc);
PATCH 3/7 lustre/libfs: move debugfs registration from libcfs_setup back to libcfs_init
Quoted 11 lines · NeilBrown
large memory allocations should be avoided at module-init, but registering services is appropriate.
So move the registration of debugfs files
back intolibcfs_init().
Without this,/sys/kernel/debug/lnetetc are not visible immediately that libcfs is loaded.
No debugfs file access needs anything allocated bylibcfs_setup().Fixes 64bf0b1a079d ("staging: lustre: refactor libcfs initialization.")Signed-off-by NeilBrown <[email protected]>
Quoted 22 lines
---
drivers/staging/lustre/lnet/libcfs/module.c| 8 ++++----1 file changed, 4 insertions(+), 4 deletions(-)drivers/staging/lustre/lnet/libcfs/module.c +0
-4@@ -719,10 +719,6 @@ int libcfs_setup(void) goto err; } -lnet_insert_debugfs (lnet_table); -if (!IS_ERR_OR_NULL (lnet_debugfs_root)) -lnet_insert_debugfs_links (lnet_debugfs_symlinks); -CDEBUG (D_OTHER ,"portals setup OK\n" );out:
libcfs_active = 1;
drivers/staging/lustre/lnet/libcfs/module.c static int libcfs_init(void) · line 748
Quoted 10 lines
drivers/staging/lustre/lnet/libcfs/module.c +4
-0@@ -743,6 +739,10 @@ static int libcfs_init(void) {int rc; +lnet_insert_debugfs (lnet_table); +if (!IS_ERR_OR_NULL (lnet_debugfs_root)) +lnet_insert_debugfs_links (lnet_debugfs_symlinks); + rc =misc_register (&libcfs_dev);if (rc)CERROR ("misc_register: error %d\n" , rc);
Cheers, Andreas
---
Andreas Dilger
CTO Whamcloud
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 235 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180730/55c1b423/attachment.sig>
PATCH 3/7 lustre/libfs: move debugfs registration from libcfs_setup back to libcfs_init
In reply to NeilBrownQuoted 8 lines
large memory allocations should be avoided at module-init, but registering services is appropriate.
So move the registration of debugfs files
back intolibcfs_init().
Without this,/sys/kernel/debug/lnetetc are not visible immediately that libcfs is loaded.
No debugfs file access needs anything allocated bylibcfs_setup().
Quoted 35 lines
Fixes 64bf0b1a079d ("staging: lustre: refactor libcfs initialization.")Signed-off-by NeilBrown <[email protected]>--- drivers/staging/lustre/lnet/libcfs/module.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/staging/lustre/lnet/libcfs/module.c +4
-4@@ -719,10 +719,6 @@ int libcfs_setup(void) goto err; } -lnet_insert_debugfs (lnet_table); -if (!IS_ERR_OR_NULL (lnet_debugfs_root)) -lnet_insert_debugfs_links (lnet_debugfs_symlinks); -CDEBUG (D_OTHER ,"portals setup OK\n" ); out: libcfs_active =1 ;@@ -743,6 +739,10 @@ static int libcfs_init(void) {int rc; +lnet_insert_debugfs (lnet_table); +if (!IS_ERR_OR_NULL (lnet_debugfs_root)) +lnet_insert_debugfs_links (lnet_debugfs_symlinks); + rc =misc_register (&libcfs_dev);if (rc)CERROR ("misc_register: error %d\n" , rc);
PATCH 4/7 lustre: give different tcd_lock types different classes.
In reply to NeilBrownThere are three different trace contexts:
process, softirq, irq.
Each has its own lock (tcd_lock) which is locked as appropriate for that context.
lockdep currently doesn't see that they are different and so deduces that the different uses might lead to deadlocks.
So use separate calls to spin_lock_init() so that they each get a separate lock class, and lockdep sees no problem.
--- drivers/staging/lustre/lnet/libcfs/tracefile.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/staging/lustre/lnet/libcfs/tracefile.c +17 -1
@@ -1285,7 +1285,23 @@ int cfs_tracefile_init(int max_pages)cfs_tcd_for_each (tcd, i, j) {int factor = pages_factor[i]; -spin_lock_init (&tcd->tcd_lock); +/* Note that we have three separate calls so +* they the locks get three separate classes +* and lockdep never thinks they are related. +* As they are used in different interrupt +* contexts, lockdep think the usage would conflict. +*/ +switch (i) { +case CFS_TCD_TYPE_PROC : +spin_lock_init (&tcd->tcd_lock); +break ; +case CFS_TCD_TYPE_SOFTIRQ : +spin_lock_init (&tcd->tcd_lock); +break ; +case CFS_TCD_TYPE_IRQ : +spin_lock_init (&tcd->tcd_lock); +break ; + } tcd->tcd_pages_factor = factor; tcd->tcd_type = i; tcd->tcd_cpu = j;
PATCH 4/7 lustre: give different tcd_lock types different classes.
Quoted 12 lines · NeilBrown
There are three different trace contexts:
process, softirq, irq.
Each has its own lock (tcd_lock) which is locked as appropriate for that context.
lockdep currently doesn't see that they are different and so deduces that the different uses might lead to deadlocks.
So use separate calls tospin_lock_init()so that they each get a separate lock class, and lockdep sees no problem.
Quoted 1 line
Signed-off-by NeilBrown <[email protected]>
Quoted 25 lines
---
drivers/staging/lustre/lnet/libcfs/tracefile.c| 18 +++++++++++++++++-1 file changed, 17 insertions(+), 1 deletion(-)drivers/staging/lustre/lnet/libcfs/tracefile.c +10
-1@@ -1285,7 +1285,23 @@ int cfs_tracefile_init(int max_pages)cfs_tcd_for_each (tcd, i, j) {int factor = pages_factor[i]; -spin_lock_init (&tcd->tcd_lock); +/* Note that we have three separate calls so +* they the locks get three separate classes +* and lockdep never thinks they are related. +* As they are used in different interrupt +* contexts, lockdep think the usage would conflict. +*/ +switch (i) { +case CFS_TCD_TYPE_PROC : +spin_lock_init (&tcd->tcd_lock); +break ;
drivers/staging/lustre/lnet/libcfs/tracefile.c int cfs_tracefile_init(int max_pages) · line 1307
Quoted 10 lines
drivers/staging/lustre/lnet/libcfs/tracefile.c +7
-0+case CFS_TCD_TYPE_SOFTIRQ : +spin_lock_init (&tcd->tcd_lock); +break ; +case CFS_TCD_TYPE_IRQ : +spin_lock_init (&tcd->tcd_lock); +break ; + } tcd->tcd_pages_factor = factor; tcd->tcd_type = i; tcd->tcd_cpu = j;
Cheers, Andreas
---
Andreas Dilger
CTO Whamcloud
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 235 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180730/6120dad5/attachment.sig>
PATCH 4/7 lustre: give different tcd_lock types different classes.
In reply to NeilBrownQuoted 11 lines
There are three different trace contexts:
process, softirq, irq.
Each has its own lock (tcd_lock) which is locked as appropriate for that context.
lockdep currently doesn't see that they are different and so deduces that the different uses might lead to deadlocks.
So use separate calls tospin_lock_init()so that they each get a separate lock class, and lockdep sees no problem.
Quoted 37 lines
Signed-off-by NeilBrown <[email protected]>--- drivers/staging/lustre/lnet/libcfs/tracefile.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)drivers/staging/lustre/lnet/libcfs/tracefile.c +17
-1@@ -1285,7 +1285,23 @@ int cfs_tracefile_init(int max_pages)cfs_tcd_for_each (tcd, i, j) {int factor = pages_factor[i]; -spin_lock_init (&tcd->tcd_lock); +/* Note that we have three separate calls so +* they the locks get three separate classes +* and lockdep never thinks they are related. +* As they are used in different interrupt +* contexts, lockdep think the usage would conflict. +*/ +switch (i) { +case CFS_TCD_TYPE_PROC : +spin_lock_init (&tcd->tcd_lock); +break ; +case CFS_TCD_TYPE_SOFTIRQ : +spin_lock_init (&tcd->tcd_lock); +break ; +case CFS_TCD_TYPE_IRQ : +spin_lock_init (&tcd->tcd_lock); +break ; + } tcd->tcd_pages_factor = factor; tcd->tcd_type = i; tcd->tcd_cpu = j;
PATCH 5/7 lustre/libcfs: discard cfs_trace_allocate_string_buffer()
In reply to NeilBrowncfs_trace_allocate_string_buffer() is a simple wrapper around kzalloc() that adds little value. The code is clearer if we perform the test and the allocation directly where needed.
Also change the test from '>' to '>=' to ensure we never try to allocate more than 2 pages, as that seems to be the intent.
--- drivers/staging/lustre/lnet/libcfs/module.c | 6 +++-- drivers/staging/lustre/lnet/libcfs/tracefile.c | 28 +++++++++--------------- drivers/staging/lustre/lnet/libcfs/tracefile.h | 1 - 3 files changed, 13 insertions(+), 22 deletions(-)
drivers/staging/lustre/lnet/libcfs/module.c +3 -3
@@ -305,9 +305,9 @@ static int proc_dobitmasks(struct ctl_table *table, int write,int is_subsys = (mask == &libcfs_subsystem_debug) ?1 :0 ;int is_printk = (mask == &libcfs_printk) ?1 :0 ; - rc =cfs_trace_allocate_string_buffer (&tmpstr, tmpstrlen); -if (rc <0 ) -return rc; + tmpstr =kzalloc (tmpstrlen,GFP_KERNEL ); +if (!tmpstr) +return -ENOMEM ;if (!write) {libcfs_debug_mask2str (tmpstr, tmpstrlen, *mask, is_subsys);
drivers/staging/lustre/lnet/libcfs/tracefile.c +10 -18
@@ -963,26 +963,16 @@ int cfs_trace_copyout_string(char __user *usr_buffer, int usr_buffer_nob, }EXPORT_SYMBOL (cfs_trace_copyout_string); -int cfs_trace_allocate_string_buffer (char **str,int nob) -{ -if (nob >2 *PAGE_SIZE )/* string must be "sensible" */ -return -EINVAL ; - - *str =kmalloc (nob,GFP_KERNEL | __GFP_ZERO); -if (!*str) -return -ENOMEM ; - -return 0 ; -} -int cfs_trace_dump_debug_buffer_usrstr (void __user *usr_str,int usr_str_nob) {char *str;int rc; - rc =cfs_trace_allocate_string_buffer (&str, usr_str_nob +1 ); -if (rc) -return rc; +if (usr_str_nob >=2 *PAGE_SIZE ) +return -EINVAL ; + str =kzalloc (usr_str_nob +1 ,GFP_KERNEL ); +if (!str) +return -ENOMEM ; rc =cfs_trace_copyin_string (str, usr_str_nob +1 , usr_str, usr_str_nob);
@@ -1044,9 +1034,11 @@ int cfs_trace_daemon_command_usrstr(void __user *usr_str, int usr_str_nob)char *str;int rc; - rc =cfs_trace_allocate_string_buffer (&str, usr_str_nob +1 ); -if (rc) -return rc; +if (usr_str_nob >=2 *PAGE_SIZE ) +return -EINVAL ; + str =kzalloc (usr_str_nob +1 ,GFP_KERNEL ); +if (!str) +return -ENOMEM ; rc =cfs_trace_copyin_string (str, usr_str_nob +1 , usr_str, usr_str_nob);
drivers/staging/lustre/lnet/libcfs/tracefile.h +0 -1
@@ -63,7 +63,6 @@ int cfs_trace_copyin_string(char *knl_buffer, int knl_buffer_nob, const char __user *usr_buffer, int usr_buffer_nob);int cfs_trace_copyout_string (char __user *usr_buffer,int usr_buffer_nob,const char *knl_str,char *append); -int cfs_trace_allocate_string_buffer (char **str,int nob);int cfs_trace_dump_debug_buffer_usrstr (void __user *usr_str,int usr_str_nob);int cfs_trace_daemon_command (char *str);int cfs_trace_daemon_command_usrstr (void __user *usr_str,int usr_str_nob);
PATCH 5/7 lustre/libcfs: discard cfs_trace_allocate_string_buffer()
Quoted 9 lines · NeilBrown
cfs_trace_allocate_string_buffer()is a simple wrapper aroundkzalloc()that adds little value. The code is clearer if we perform the test and the allocation directly where needed.
Quoted 5 lines
Also change the test from '>' to '>=' to ensure we never try to allocate more than 2 pages, as that seems to be the intent.
Signed-off-by NeilBrown <[email protected]>
I was going to say that we probably don't have even a single debug message that is larger than PAGE_SIZE, but I suspect in some cases, printing a message with a PATH_MAX-sized filename may result in a buffer that is larger than PAGE_SIZE, though smaller than 2x PAGE_SIZE.
It isn't clear that returning an error for = 2 * PAGE_SIZE makes sense, but I also don't think this corner case is critical (and it leaves a byte for a NUL terminator in the buffer).
Quoted 81 lines
---
drivers/staging/lustre/lnet/libcfs/module.c | 6 +++-- drivers/staging/lustre/lnet/libcfs/tracefile.c | 28 +++++++++--------------- drivers/staging/lustre/lnet/libcfs/tracefile.h | 1 - 3 files changed, 13 insertions(+), 22 deletions(-)drivers/staging/lustre/lnet/libcfs/module.c +3
-3@@ -305,9 +305,9 @@ static int proc_dobitmasks(struct ctl_table *table, int write,int is_subsys = (mask == &libcfs_subsystem_debug) ?1 :0 ;int is_printk = (mask == &libcfs_printk) ?1 :0 ; - rc =cfs_trace_allocate_string_buffer (&tmpstr, tmpstrlen); -if (rc <0 ) -return rc; + tmpstr =kzalloc (tmpstrlen,GFP_KERNEL ); +if (!tmpstr) +return -ENOMEM ;if (!write) {libcfs_debug_mask2str (tmpstr, tmpstrlen, *mask, is_subsys);drivers/staging/lustre/lnet/libcfs/tracefile.c +10
-18@@ -963,26 +963,16 @@ int cfs_trace_copyout_string(char __user *usr_buffer, int usr_buffer_nob, }EXPORT_SYMBOL (cfs_trace_copyout_string); -int cfs_trace_allocate_string_buffer (char **str,int nob) -{ -if (nob >2 *PAGE_SIZE )/* string must be "sensible" */ -return -EINVAL ; - - *str =kmalloc (nob,GFP_KERNEL | __GFP_ZERO); -if (!*str) -return -ENOMEM ; - -return 0 ; -} -int cfs_trace_dump_debug_buffer_usrstr (void __user *usr_str,int usr_str_nob) {char *str;int rc; - rc =cfs_trace_allocate_string_buffer (&str, usr_str_nob +1 ); -if (rc) -return rc; +if (usr_str_nob >=2 *PAGE_SIZE ) +return -EINVAL ; + str =kzalloc (usr_str_nob +1 ,GFP_KERNEL ); +if (!str) +return -ENOMEM ; rc =cfs_trace_copyin_string (str, usr_str_nob +1 , usr_str, usr_str_nob);@@ -1044,9 +1034,11 @@ int cfs_trace_daemon_command_usrstr(void __user *usr_str, int usr_str_nob)char *str;int rc; - rc =cfs_trace_allocate_string_buffer (&str, usr_str_nob +1 ); -if (rc) -return rc; +if (usr_str_nob >=2 *PAGE_SIZE ) +return -EINVAL ; + str =kzalloc (usr_str_nob +1 ,GFP_KERNEL ); +if (!str) +return -ENOMEM ; rc =cfs_trace_copyin_string (str, usr_str_nob +1 , usr_str, usr_str_nob);drivers/staging/lustre/lnet/libcfs/tracefile.h +0
-0
drivers/staging/lustre/lnet/libcfs/tracefile.h int cfs_trace_copyin_string(char *knl_buffer, int knl_buffer_nob, · line 68
Quoted 7 lines
drivers/staging/lustre/lnet/libcfs/tracefile.h +0
-1@@ -63,7 +63,6 @@ int cfs_trace_copyin_string(char *knl_buffer, int knl_buffer_nob, const char __user *usr_buffer, int usr_buffer_nob);int cfs_trace_copyout_string (char __user *usr_buffer,int usr_buffer_nob,const char *knl_str,char *append); -int cfs_trace_allocate_string_buffer (char **str,int nob);int cfs_trace_dump_debug_buffer_usrstr (void __user *usr_str,int usr_str_nob);int cfs_trace_daemon_command (char *str);int cfs_trace_daemon_command_usrstr (void __user *usr_str,int usr_str_nob);
Cheers, Andreas
---
Andreas Dilger
CTO Whamcloud
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 235 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180730/7ec4de1e/attachment.sig>
PATCH 5/7 lustre/libcfs: discard cfs_trace_allocate_string_buffer()
In reply to NeilBrownQuoted 9 lines
cfs_trace_allocate_string_buffer()is a simple wrapper aroundkzalloc()that adds little value. The code is clearer if we perform the test and the allocation directly where needed.Also change the test from '>' to '>=' to ensure we never try to allocate more than 2 pages, as that seems to be the intent.
Quoted 90 lines
Signed-off-by NeilBrown <[email protected]>--- drivers/staging/lustre/lnet/libcfs/module.c | 6 +++-- drivers/staging/lustre/lnet/libcfs/tracefile.c | 28 +++++++++--------------- drivers/staging/lustre/lnet/libcfs/tracefile.h | 1 - 3 files changed, 13 insertions(+), 22 deletions(-)drivers/staging/lustre/lnet/libcfs/module.c +3
-3@@ -305,9 +305,9 @@ static int proc_dobitmasks(struct ctl_table *table, int write,int is_subsys = (mask == &libcfs_subsystem_debug) ?1 :0 ;int is_printk = (mask == &libcfs_printk) ?1 :0 ; - rc =cfs_trace_allocate_string_buffer (&tmpstr, tmpstrlen); -if (rc <0 ) -return rc; + tmpstr =kzalloc (tmpstrlen,GFP_KERNEL ); +if (!tmpstr) +return -ENOMEM ;if (!write) {libcfs_debug_mask2str (tmpstr, tmpstrlen, *mask, is_subsys);drivers/staging/lustre/lnet/libcfs/tracefile.c +10
-18@@ -963,26 +963,16 @@ int cfs_trace_copyout_string(char __user *usr_buffer, int usr_buffer_nob, }EXPORT_SYMBOL (cfs_trace_copyout_string); -int cfs_trace_allocate_string_buffer (char **str,int nob) -{ -if (nob >2 *PAGE_SIZE )/* string must be "sensible" */ -return -EINVAL ; - - *str =kmalloc (nob,GFP_KERNEL | __GFP_ZERO); -if (!*str) -return -ENOMEM ; - -return 0 ; -} -int cfs_trace_dump_debug_buffer_usrstr (void __user *usr_str,int usr_str_nob) {char *str;int rc; - rc =cfs_trace_allocate_string_buffer (&str, usr_str_nob +1 ); -if (rc) -return rc; +if (usr_str_nob >=2 *PAGE_SIZE ) +return -EINVAL ; + str =kzalloc (usr_str_nob +1 ,GFP_KERNEL ); +if (!str) +return -ENOMEM ; rc =cfs_trace_copyin_string (str, usr_str_nob +1 , usr_str, usr_str_nob);@@ -1044,9 +1034,11 @@ int cfs_trace_daemon_command_usrstr(void __user *usr_str, int usr_str_nob)char *str;int rc; - rc =cfs_trace_allocate_string_buffer (&str, usr_str_nob +1 ); -if (rc) -return rc; +if (usr_str_nob >=2 *PAGE_SIZE ) +return -EINVAL ; + str =kzalloc (usr_str_nob +1 ,GFP_KERNEL ); +if (!str) +return -ENOMEM ; rc =cfs_trace_copyin_string (str, usr_str_nob +1 , usr_str, usr_str_nob);drivers/staging/lustre/lnet/libcfs/tracefile.h +0
-1@@ -63,7 +63,6 @@ int cfs_trace_copyin_string(char *knl_buffer, int knl_buffer_nob, const char __user *usr_buffer, int usr_buffer_nob);int cfs_trace_copyout_string (char __user *usr_buffer,int usr_buffer_nob,const char *knl_str,char *append); -int cfs_trace_allocate_string_buffer (char **str,int nob);int cfs_trace_dump_debug_buffer_usrstr (void __user *usr_str,int usr_str_nob);int cfs_trace_daemon_command (char *str);int cfs_trace_daemon_command_usrstr (void __user *usr_str,int usr_str_nob);
PATCH 6/7 lustre: lnet: convert ni_refs to percpu_refcount.
In reply to NeilBrownni_refs is a per-cpt refcount.
Linux already has a per-cpu refcount implementation which doesn't require anylocking.
So convert ni_refs to percpu_refcount.
As a bonus, we can get a wake-up when the refcount reaches zero, rather than having to wait a full second. The waiting in lnet_clear_zombies_nis_locked() is modified so that instead of waiting one second each time, and printing a warning on power-of-two seconds, we wait an increasing power-of-two seconds and print a warning if the wait ever timed out.
--- .../staging/lustre/include/linux/lnet/lib-lnet.h | 11 +----- .../staging/lustre/include/linux/lnet/lib-types.h | 2 + drivers/staging/lustre/lnet/lnet/api-ni.c | 34 +++++++++----------- drivers/staging/lustre/lnet/lnet/config.c | 13 +++++--- drivers/staging/lustre/lnet/lnet/router_proc.c | 2 + 5 files changed, 28 insertions(+), 34 deletions(-)
drivers/staging/lustre/include/linux/lnet/lib-lnet.h +2 -9
@@ -338,34 +338,27 @@ static inline void lnet_ni_addref_locked(struct lnet_ni *ni, int cpt) {LASSERT (cpt >=0 && cpt <LNET_CPT_NUMBER ); -LASSERT (*ni->ni_refs[cpt] >=0 ); - - (*ni->ni_refs[cpt])++; +percpu_ref_get (&ni->ni_refs); }static inline void lnet_ni_addref (struct lnet_ni *ni) { -lnet_net_lock (0 );lnet_ni_addref_locked (ni,0 ); -lnet_net_unlock (0 ); }static inline void lnet_ni_decref_locked (struct lnet_ni *ni,int cpt) {LASSERT (cpt >=0 && cpt <LNET_CPT_NUMBER ); -LASSERT (*ni->ni_refs[cpt] >0 ); - (*ni->ni_refs[cpt])--; +percpu_ref_put (&ni->ni_refs); }static inline void lnet_ni_decref (struct lnet_ni *ni) { -lnet_net_lock (0 );lnet_ni_decref_locked (ni,0 ); -lnet_net_unlock (0 ); }void lnet_ni_free (struct lnet_ni *ni);
drivers/staging/lustre/include/linux/lnet/lib-types.h +1 -1
@@ -269,7 +269,7 @@ struct lnet_ni {void *ni_data;/* instance-specific data */ struct lnet_lnd *ni_lnd;/* procedural interface */ struct lnet_tx_queue **ni_tx_queues;/* percpt TX queues */ -int **ni_refs;/* percpt reference count */ +struct percpu_ref ni_refs;time64_t ni_last_alive;/* when I was last alive */ struct lnet_ni_status *ni_status;/* my health status */ /* per NI LND tunables */
drivers/staging/lustre/lnet/lnet/api-ni.c +16 -18
@@ -1055,7 +1055,7 @@ lnet_ni_unlink_locked(struct lnet_ni *ni)/* move it to zombie list and nobody can find it anymore */ LASSERT (!list_empty (&ni->ni_list));list_move (&ni->ni_list, &the_lnet.ln_nis_zombie); -lnet_ni_decref_locked (ni,0 );/* drop ln_nis' ref */ +percpu_ref_kill_and_confirm (&ni->ni_refs,NULL );/* drop ln_nis' ref */ } static void
@@ -1069,34 +1069,32 @@ lnet_clear_zombies_nis_locked(void)* Now wait for the NI's I just nuked to show up on ln_zombie_nis * and shut them down in guaranteed thread context */ - i =2 ; + i =1 ;while (!list_empty (&the_lnet.ln_nis_zombie)) { -int *ref; -int j; ni =list_entry (the_lnet.ln_nis_zombie.next, struct lnet_ni, ni_list); -list_del_init (&ni->ni_list); -cfs_percpt_for_each (ref, j, ni->ni_refs) { -if (!*ref) -continue ; -/* still busy, add it back to zombie list */ -list_add (&ni->ni_list, &the_lnet.ln_nis_zombie); -break ; - } -if (!list_empty (&ni->ni_list)) { +if (!percpu_ref_is_zero (&ni->ni_refs)) { +/* still busy, wait a while */ +lnet_net_unlock (LNET_LOCK_EX ); ++i; -if ((i & (-i)) == i) { + +if (wait_var_event_timeout ( + &ni->ni_refs, +percpu_ref_is_zero (&ni->ni_refs), +HZ << i) ==0 )CDEBUG (D_WARNING ,"Waiting for zombie LNI %s\n" ,libcfs_nid2str (ni->ni_nid)); - } +schedule_timeout_uninterruptible (HZ );lnet_net_lock (LNET_LOCK_EX );continue ; } +list_del_init (&ni->ni_list); + ni->ni_lnd->lnd_refcount--;lnet_net_unlock (LNET_LOCK_EX );
@@ -1114,7 +1112,7 @@ lnet_clear_zombies_nis_locked(void) libcfs_nid2str(ni->ni_nid));lnet_ni_free (ni); - i =2 ; + i =1 ;lnet_net_lock (LNET_LOCK_EX ); }
@@ -1305,8 +1303,8 @@ lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)LASSERT (ni->ni_peertimeout <=0 || lnd->lnd_query);lnet_net_lock (LNET_LOCK_EX ); -/* refcount for ln_nis */ -lnet_ni_addref_locked (ni,0 ); +/* Initialise refcount for ln_nis to 1 */ +percpu_ref_reinit (&ni->ni_refs);list_add_tail (&ni->ni_list, &the_lnet.ln_nis);if (ni->ni_cpts) {lnet_ni_addref_locked (ni,0 );
drivers/staging/lustre/lnet/lnet/config.c +8 -5
@@ -96,8 +96,7 @@ lnet_ni_free(struct lnet_ni *ni) {int i; -if (ni->ni_refs) -cfs_percpt_free (ni->ni_refs); +percpu_ref_exit (&ni->ni_refs);if (ni->ni_tx_queues)cfs_percpt_free (ni->ni_tx_queues);
@@ -117,6 +116,11 @@ lnet_ni_free(struct lnet_ni *ni)kfree (ni); } +static void ref_release (struct percpu_ref *ref) +{ +wake_up_var (ref); +} +struct lnet_ni *lnet_ni_alloc (__u32 net,struct cfs_expr_list *el,struct list_head *nilist) {
@@ -140,9 +144,8 @@ lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist)spin_lock_init (&ni->ni_lock);INIT_LIST_HEAD (&ni->ni_cptlist); - ni->ni_refs =cfs_percpt_alloc (lnet_cpt_table (), -sizeof (*ni->ni_refs[0 ])); -if (!ni->ni_refs) +if (percpu_ref_init (&ni->ni_refs, ref_release, +PERCPU_REF_INIT_DEAD ,GFP_KERNEL ) <0 ) goto failed; ni->ni_tx_queues = cfs_percpt_alloc(lnet_cpt_table(),
drivers/staging/lustre/lnet/lnet/router_proc.c +1 -1
@@ -703,7 +703,7 @@ static int proc_lnet_nis(struct ctl_table *table, int write, s += snprintf(s, tmpstr + tmpsiz - s, "%-24s %6s %5lld %4d %4d %4d %5d %5d %5d\n", libcfs_nid2str(ni->ni_nid), stat, - last_alive, *ni->ni_refs[i], + last_alive, 0/* No per-cpt refcount */, ni->ni_peertxcredits, ni->ni_peerrtrcredits, tq->tq_credits_max,
PATCH 6/7 lustre: lnet: convert ni_refs to percpu_refcount.
Quoted 5 lines
ni_refsis a per-cpt refcount.
Linux already has a per-cpu refcount implementation which doesn't require anylocking.
Quoted 8 lines
So convert
ni_refstopercpu_refcount.
As a bonus, we can get a wake-up when the refcount reaches zero, rather than having to wait a full second. The waiting inlnet_clear_zombies_nis_locked()is modified so that instead of waiting one second each time, and printing a warning on power-of-two seconds, we wait an increasing power-of-two seconds and print a warning if the wait ever timed out.
Quoted 197 lines
Signed-off-by NeilBrown <[email protected]>--- .../staging/lustre/include/linux/lnet/lib-lnet.h | 11 +----- .../staging/lustre/include/linux/lnet/lib-types.h | 2 + drivers/staging/lustre/lnet/lnet/api-ni.c | 34 +++++++++----------- drivers/staging/lustre/lnet/lnet/config.c | 13 +++++--- drivers/staging/lustre/lnet/lnet/router_proc.c | 2 + 5 files changed, 28 insertions(+), 34 deletions(-)drivers/staging/lustre/include/linux/lnet/lib-lnet.h +2
-9@@ -338,34 +338,27 @@ static inline void lnet_ni_addref_locked(struct lnet_ni *ni, int cpt) {LASSERT (cpt >=0 && cpt <LNET_CPT_NUMBER ); -LASSERT (*ni->ni_refs[cpt] >=0 ); - - (*ni->ni_refs[cpt])++; +percpu_ref_get (&ni->ni_refs); }static inline void lnet_ni_addref (struct lnet_ni *ni) { -lnet_net_lock (0 );lnet_ni_addref_locked (ni,0 ); -lnet_net_unlock (0 ); }static inline void lnet_ni_decref_locked (struct lnet_ni *ni,int cpt) {LASSERT (cpt >=0 && cpt <LNET_CPT_NUMBER ); -LASSERT (*ni->ni_refs[cpt] >0 ); - (*ni->ni_refs[cpt])--; +percpu_ref_put (&ni->ni_refs); }static inline void lnet_ni_decref (struct lnet_ni *ni) { -lnet_net_lock (0 );lnet_ni_decref_locked (ni,0 ); -lnet_net_unlock (0 ); }void lnet_ni_free (struct lnet_ni *ni);drivers/staging/lustre/include/linux/lnet/lib-types.h +1
-1@@ -269,7 +269,7 @@ struct lnet_ni {void *ni_data;/* instance-specific data */ struct lnet_lnd *ni_lnd;/* procedural interface */ struct lnet_tx_queue **ni_tx_queues;/* percpt TX queues */ -int **ni_refs;/* percpt reference count */ +struct percpu_ref ni_refs;time64_t ni_last_alive;/* when I was last alive */ struct lnet_ni_status *ni_status;/* my health status */ /* per NI LND tunables */ drivers/staging/lustre/lnet/lnet/api-ni.c +16
-18@@ -1055,7 +1055,7 @@ lnet_ni_unlink_locked(struct lnet_ni *ni)/* move it to zombie list and nobody can find it anymore */ LASSERT (!list_empty (&ni->ni_list));list_move (&ni->ni_list, &the_lnet.ln_nis_zombie); -lnet_ni_decref_locked (ni,0 );/* drop ln_nis' ref */ +percpu_ref_kill_and_confirm (&ni->ni_refs,NULL );/* drop ln_nis' ref */ } static void@@ -1069,34 +1069,32 @@ lnet_clear_zombies_nis_locked(void)* Now wait for the NI's I just nuked to show up on ln_zombie_nis * and shut them down in guaranteed thread context */ - i =2 ; + i =1 ;while (!list_empty (&the_lnet.ln_nis_zombie)) { -int *ref; -int j; ni =list_entry (the_lnet.ln_nis_zombie.next, struct lnet_ni, ni_list); -list_del_init (&ni->ni_list); -cfs_percpt_for_each (ref, j, ni->ni_refs) { -if (!*ref) -continue ; -/* still busy, add it back to zombie list */ -list_add (&ni->ni_list, &the_lnet.ln_nis_zombie); -break ; - } -if (!list_empty (&ni->ni_list)) { +if (!percpu_ref_is_zero (&ni->ni_refs)) { +/* still busy, wait a while */ +lnet_net_unlock (LNET_LOCK_EX ); ++i; -if ((i & (-i)) == i) { + +if (wait_var_event_timeout ( + &ni->ni_refs, +percpu_ref_is_zero (&ni->ni_refs), +HZ << i) ==0 )CDEBUG (D_WARNING ,"Waiting for zombie LNI %s\n" ,libcfs_nid2str (ni->ni_nid)); - } +schedule_timeout_uninterruptible (HZ );lnet_net_lock (LNET_LOCK_EX );continue ; } +list_del_init (&ni->ni_list); + ni->ni_lnd->lnd_refcount--;lnet_net_unlock (LNET_LOCK_EX );@@ -1114,7 +1112,7 @@ lnet_clear_zombies_nis_locked(void) libcfs_nid2str(ni->ni_nid));lnet_ni_free (ni); - i =2 ; + i =1 ;lnet_net_lock (LNET_LOCK_EX ); }@@ -1305,8 +1303,8 @@ lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)LASSERT (ni->ni_peertimeout <=0 || lnd->lnd_query);lnet_net_lock (LNET_LOCK_EX ); -/* refcount for ln_nis */ -lnet_ni_addref_locked (ni,0 ); +/* Initialise refcount for ln_nis to 1 */ +percpu_ref_reinit (&ni->ni_refs);list_add_tail (&ni->ni_list, &the_lnet.ln_nis);if (ni->ni_cpts) {lnet_ni_addref_locked (ni,0 );drivers/staging/lustre/lnet/lnet/config.c +8
-5@@ -96,8 +96,7 @@ lnet_ni_free(struct lnet_ni *ni) {int i; -if (ni->ni_refs) -cfs_percpt_free (ni->ni_refs); +percpu_ref_exit (&ni->ni_refs);if (ni->ni_tx_queues)cfs_percpt_free (ni->ni_tx_queues);@@ -117,6 +116,11 @@ lnet_ni_free(struct lnet_ni *ni)kfree (ni); } +static void ref_release (struct percpu_ref *ref) +{ +wake_up_var (ref); +} +struct lnet_ni *lnet_ni_alloc (__u32 net,struct cfs_expr_list *el,struct list_head *nilist) {@@ -140,9 +144,8 @@ lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist)spin_lock_init (&ni->ni_lock);INIT_LIST_HEAD (&ni->ni_cptlist); - ni->ni_refs =cfs_percpt_alloc (lnet_cpt_table (), -sizeof (*ni->ni_refs[0 ])); -if (!ni->ni_refs) +if (percpu_ref_init (&ni->ni_refs, ref_release, +PERCPU_REF_INIT_DEAD ,GFP_KERNEL ) <0 ) goto failed; ni->ni_tx_queues = cfs_percpt_alloc(lnet_cpt_table(),drivers/staging/lustre/lnet/lnet/router_proc.c +1
-1@@ -703,7 +703,7 @@ static int proc_lnet_nis(struct ctl_table *table, int write, s += snprintf(s, tmpstr + tmpsiz - s, "%-24s %6s %5lld %4d %4d %4d %5d %5d %5d\n", libcfs_nid2str(ni->ni_nid), stat, - last_alive, *ni->ni_refs[i], + last_alive, 0/* No per-cpt refcount */, ni->ni_peertxcredits, ni->ni_peerrtrcredits, tq->tq_credits_max,
PATCH 7/7 lustre: change TASK_NOLOAD to TASK_IDLE.
In reply to NeilBrownTASK_NOLOAD is not a task state to be use by
itself, it should only be used together withTASK_UNINTERRUPTIBLE, which easily done
by using TASK_IDLE.
So convert to TASK_IDLE.
--- drivers/staging/lustre/lnet/lnet/lib-eq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/lustre/lnet/lnet/lib-eq.c +2 -2
@@ -349,7 +349,7 @@ __must_hold(&the_lnet.ln_eq_wait_lock)* \param timeout Time in jiffies to wait for an event to occur on * one of the EQs. The constant MAX_SCHEDULE_TIMEOUT can be used to indicate an * infinite timeout. -* \param interruptible, if true, use TASK_INTERRUPTIBLE, else TASK_NOLOAD +* \param interruptible, if true, use TASK_INTERRUPTIBLE, else TASK_IDLE * \param event,which On successful return (1 or -EOVERFLOW), \a event will * hold the next event in the EQs, and \a which will contain the index of the * EQ from which the event was taken.
@@ -406,7 +406,7 @@ LNetEQPoll(struct lnet_handle_eq *eventqs, int neq, signed long timeout,*/ wait =lnet_eq_wait_locked (&timeout, interruptible ?TASK_INTERRUPTIBLE - :TASK_NOLOAD ); + :TASK_IDLE );if (wait <0 )/* no new event */ break ; }
PATCH 7/7 lustre: change TASK_NOLOAD to TASK_IDLE.
Quoted 9 lines · NeilBrown
TASK_NOLOADis not a task state to be use by
itself, it should only be used together withTASK_UNINTERRUPTIBLE, which easily done
by usingTASK_IDLE.So convert to
TASK_IDLE.Signed-off-by NeilBrown <[email protected]>
Nice to see this infrastructure is available. I'm no fan of l_wait_event() complexity, but without TASK_IDLE (only added in 4.13) we had to find a way for servers to have lots of service threads without a load average of 100 or whatever...
Quoted 20 lines
---
drivers/staging/lustre/lnet/lnet/lib-eq.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/lustre/lnet/lnet/lib-eq.c +1
-1@@ -349,7 +349,7 @@ __must_hold(&the_lnet.ln_eq_wait_lock)* \param timeout Time in jiffies to wait for an event to occur on * one of the EQs. The constant MAX_SCHEDULE_TIMEOUT can be used to indicate an * infinite timeout. -* \param interruptible, if true, use TASK_INTERRUPTIBLE, else TASK_NOLOAD +* \param interruptible, if true, use TASK_INTERRUPTIBLE, else TASK_IDLE * \param event,which On successful return (1 or -EOVERFLOW), \a event will * hold the next event in the EQs, and \a which will contain the index of the * EQ from which the event was taken.
drivers/staging/lustre/lnet/lnet/lib-eq.c LNetEQPoll(struct lnet_handle_eq *eventqs, int neq, signed long timeout, · line 412
Quoted 8 lines
drivers/staging/lustre/lnet/lnet/lib-eq.c +1
-1@@ -406,7 +406,7 @@ LNetEQPoll(struct lnet_handle_eq *eventqs, int neq, signed long timeout,*/ wait =lnet_eq_wait_locked (&timeout, interruptible ?TASK_INTERRUPTIBLE - :TASK_NOLOAD ); + :TASK_IDLE );if (wait <0 )/* no new event */ break ; }
Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 235 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180730/b79ac136/attachment.sig>
PATCH 7/7 lustre: change TASK_NOLOAD to TASK_IDLE.
In reply to NeilBrownQuoted 7 lines
TASK_NOLOADis not a task state to be use by
itself, it should only be used together withTASK_UNINTERRUPTIBLE, which easily done
by usingTASK_IDLE.So convert to
TASK_IDLE.
Sad only the latest kernel support this :-(
Quoted 30 lines
Signed-off-by NeilBrown <[email protected]>--- drivers/staging/lustre/lnet/lnet/lib-eq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/lustre/lnet/lnet/lib-eq.c +2
-2@@ -349,7 +349,7 @@ __must_hold(&the_lnet.ln_eq_wait_lock)* \param timeout Time in jiffies to wait for an event to occur on * one of the EQs. The constant MAX_SCHEDULE_TIMEOUT can be used to indicate an * infinite timeout. -* \param interruptible, if true, use TASK_INTERRUPTIBLE, else TASK_NOLOAD +* \param interruptible, if true, use TASK_INTERRUPTIBLE, else TASK_IDLE * \param event,which On successful return (1 or -EOVERFLOW), \a event will * hold the next event in the EQs, and \a which will contain the index of the * EQ from which the event was taken. @@ -406,7 +406,7 @@ LNetEQPoll(struct lnet_handle_eq *eventqs, int neq, signed long timeout,*/ wait =lnet_eq_wait_locked (&timeout, interruptible ?TASK_INTERRUPTIBLE - :TASK_NOLOAD ); + :TASK_IDLE );if (wait <0 )/* no new event */ break ; }
PATCH 7/7 lustre: change TASK_NOLOAD to TASK_IDLE.
Quoted 8 lines · James Simmons
Quoted 6 lines
TASK_NOLOADis not a task state to be use by
itself, it should only be used together withTASK_UNINTERRUPTIBLE, which easily done
by usingTASK_IDLE.So convert to
TASK_IDLE.Sad only the latest kernel support this :-(
So? The patch to add support is trivial.
commit 80ed87c8a9ca0cad7ca66cf3bbdfb17559a66dcf
Author: Peter Zijlstra <[email protected]> Date: Fri May 8 14:23:45 2015 +0200
sched/wait: Introduce TASK_NOLOAD and TASK_IDLE
....
include/linux/sched.h | 10 +++++++--- include/trace/events/sched.h | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-)
You would then need to add some macors like wait_event_idle(), but they could go in the lustre code.
If you need it in any vendor kernel I'd be quite surprised if they wouldn't accept it, at least in a service-pack.
I just checked SLES and the only release that isn't in long-term-support (no new features) that doesn't already have this patch (linux 4.2 and later) is SLE11-SP4.
Do you still provide new features for older kernels, or just bug-fix updates?
NeilBrown
Quoted 25 lines
Reviewed-by James Simmons <[email protected]>Quoted 22 lines
Signed-off-by NeilBrown <[email protected]>--- drivers/staging/lustre/lnet/lnet/lib-eq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/lustre/lnet/lnet/lib-eq.c +1
-1@@ -349,7 +349,7 @@ __must_hold(&the_lnet.ln_eq_wait_lock)* \param timeout Time in jiffies to wait for an event to occur on * one of the EQs. The constant MAX_SCHEDULE_TIMEOUT can be used to indicate an * infinite timeout. -* \param interruptible, if true, use TASK_INTERRUPTIBLE, else TASK_NOLOAD +* \param interruptible, if true, use TASK_INTERRUPTIBLE, else TASK_IDLE * \param event,which On successful return (1 or -EOVERFLOW), \a event will * hold the next event in the EQs, and \a which will contain the index of the * EQ from which the event was taken. @@ -406,7 +406,7 @@ LNetEQPoll(struct lnet_handle_eq *eventqs, int neq, signed long timeout,*/ wait = lnet_eq_wait_locked(&timeout, interruptible ? TASK_INTERRUPTIBLE
Quoted 8 lines
drivers/staging/lustre/lnet/lnet/lib-eq.c LNetEQPoll(struct lnet_handle_eq *eventqs, int neq, signed long timeout, · line 412
Quoted 8 lines
drivers/staging/lustre/lnet/lnet/lib-eq.c +1
-1- : TASK_NOLOAD); + : TASK_IDLE);if (wait <0 )/* no new event */ break ; }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180802/d6a9462e/attachment.sig>
PATCH 7/7 lustre: change TASK_NOLOAD to TASK_IDLE.
We generally provide full updates for older kernels, until we don?t. There?s a gradually moving window of kernel support for new versions of Lustre, with a heavy eye on the major enterprise distro versions.
But when a feature depends on something new, we wrap it in config stuff and either disable it when not found, or we copy the required bits in to Lustre if they?re small or hard to do without.
So, kind of what you?re suggesting. No problem at all.
________________________________
From: lustre-devel <[email protected]> on behalf of NeilBrown <[email protected]>
Sent: Wednesday, August 1, 2018 11:18:57 PM
To: James Simmons
Cc: Lustre Development List
Subject: Re: [lustre-devel] [PATCH 7/7] lustre: change TASK_NOLOAD to TASK_IDLE.
Quoted 8 lines · James Simmons
Quoted 6 lines
TASK_NOLOADis not a task state to be use by
itself, it should only be used together withTASK_UNINTERRUPTIBLE, which easily done
by usingTASK_IDLE.So convert to
TASK_IDLE.Sad only the latest kernel support this :-(
So? The patch to add support is trivial.
commit 80ed87c8a9ca0cad7ca66cf3bbdfb17559a66dcf
Author: Peter Zijlstra <[email protected]> Date: Fri May 8 14:23:45 2015 +0200
sched/wait: Introduce TASK_NOLOAD and TASK_IDLE
....
include/linux/sched.h | 10 +++++++--- include/trace/events/sched.h | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-)
You would then need to add some macors like wait_event_idle(), but they could go in the lustre code.
If you need it in any vendor kernel I'd be quite surprised if they wouldn't accept it, at least in a service-pack.
I just checked SLES and the only release that isn't in long-term-support (no new features) that doesn't already have this patch (linux 4.2 and later) is SLE11-SP4.
Do you still provide new features for older kernels, or just bug-fix updates?
NeilBrown
Quoted 25 lines
Reviewed-by James Simmons <[email protected]>Quoted 22 lines
Signed-off-by NeilBrown <[email protected]>--- drivers/staging/lustre/lnet/lnet/lib-eq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/lustre/lnet/lnet/lib-eq.c +1
-1@@ -349,7 +349,7 @@ __must_hold(&the_lnet.ln_eq_wait_lock)* \param timeout Time in jiffies to wait for an event to occur on * one of the EQs. The constant MAX_SCHEDULE_TIMEOUT can be used to indicate an * infinite timeout. -* \param interruptible, if true, use TASK_INTERRUPTIBLE, else TASK_NOLOAD +* \param interruptible, if true, use TASK_INTERRUPTIBLE, else TASK_IDLE * \param event,which On successful return (1 or -EOVERFLOW), \a event will * hold the next event in the EQs, and \a which will contain the index of the * EQ from which the event was taken. @@ -406,7 +406,7 @@ LNetEQPoll(struct lnet_handle_eq *eventqs, int neq, signed long timeout,*/ wait = lnet_eq_wait_locked(&timeout, interruptible ? TASK_INTERRUPTIBLE
Quoted 8 lines
drivers/staging/lustre/lnet/lnet/lib-eq.c LNetEQPoll(struct lnet_handle_eq *eventqs, int neq, signed long timeout, · line 412
Quoted 8 lines
drivers/staging/lustre/lnet/lnet/lib-eq.c +1
-1- : TASK_NOLOAD); + : TASK_IDLE);if (wait <0 )/* no new event */ break ; }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180802/6942a578/attachment-0001.html>
cover lustre: ad-hoc fixes
In reply to NeilBrownQuoted 2 lines · NeilBrown
There is no real pattern here, just minor tidy-up and minor bug-fix.
I didn't review the 6/7 patch, nor a couple of the list_head changes since they are more involved in LNet and better reviewed by someone with more experience in that code.
Cheers, Andreas
---
Andreas Dilger
CTO Whamcloud
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 235 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180730/36f78979/attachment.sig>