X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=libcfs%2Flibcfs%2Fworkitem.c;h=aa243a047bf849120290a80c17c3f8ba9c7d33c9;hp=386ba170c32362946d125b05a54c39354051212d;hb=cb5644f7fc9ce7a7da56910f6a34747a02a69a98;hpb=d40b3f9663c7627f0f08c4e3b5efa6cd206ca0f0 diff --git a/libcfs/libcfs/workitem.c b/libcfs/libcfs/workitem.c index 386ba17..aa243a0 100644 --- a/libcfs/libcfs/workitem.c +++ b/libcfs/libcfs/workitem.c @@ -15,11 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ @@ -27,7 +23,7 @@ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2011, 2014, Intel Corporation. + * Copyright (c) 2011, 2013, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -87,32 +83,20 @@ static struct cfs_workitem_data { int wi_stopping; } cfs_wi_data; -static inline void -cfs_wi_sched_lock(struct cfs_wi_sched *sched) -{ - spin_lock(&sched->ws_lock); -} - -static inline void -cfs_wi_sched_unlock(struct cfs_wi_sched *sched) -{ - spin_unlock(&sched->ws_lock); -} - static inline int cfs_wi_sched_cansleep(struct cfs_wi_sched *sched) { - cfs_wi_sched_lock(sched); + spin_lock(&sched->ws_lock); if (sched->ws_stopping) { - cfs_wi_sched_unlock(sched); + spin_unlock(&sched->ws_lock); return 0; } if (!list_empty(&sched->ws_runq)) { - cfs_wi_sched_unlock(sched); + spin_unlock(&sched->ws_lock); return 0; } - cfs_wi_sched_unlock(sched); + spin_unlock(&sched->ws_lock); return 1; } @@ -126,7 +110,7 @@ cfs_wi_exit(struct cfs_wi_sched *sched, struct cfs_workitem *wi) LASSERT(!in_interrupt()); /* because we use plain spinlock */ LASSERT(!sched->ws_stopping); - cfs_wi_sched_lock(sched); + spin_lock(&sched->ws_lock); LASSERT(wi->wi_running); @@ -141,9 +125,7 @@ cfs_wi_exit(struct cfs_wi_sched *sched, struct cfs_workitem *wi) LASSERT(list_empty(&wi->wi_list)); wi->wi_scheduled = 1; /* LBUG future schedule attempts */ - cfs_wi_sched_unlock(sched); - - return; + spin_unlock(&sched->ws_lock); } EXPORT_SYMBOL(cfs_wi_exit); @@ -163,7 +145,7 @@ cfs_wi_deschedule(struct cfs_wi_sched *sched, struct cfs_workitem *wi) * means the workitem will not be scheduled and will not have * any race with wi_action. */ - cfs_wi_sched_lock(sched); + spin_lock(&sched->ws_lock); rc = !(wi->wi_running); @@ -179,7 +161,7 @@ cfs_wi_deschedule(struct cfs_wi_sched *sched, struct cfs_workitem *wi) LASSERT (list_empty(&wi->wi_list)); - cfs_wi_sched_unlock(sched); + spin_unlock(&sched->ws_lock); return rc; } EXPORT_SYMBOL(cfs_wi_deschedule); @@ -197,7 +179,7 @@ cfs_wi_schedule(struct cfs_wi_sched *sched, struct cfs_workitem *wi) LASSERT(!in_interrupt()); /* because we use plain spinlock */ LASSERT(!sched->ws_stopping); - cfs_wi_sched_lock(sched); + spin_lock(&sched->ws_lock); if (!wi->wi_scheduled) { LASSERT (list_empty(&wi->wi_list)); @@ -213,8 +195,7 @@ cfs_wi_schedule(struct cfs_wi_sched *sched, struct cfs_workitem *wi) } LASSERT (!list_empty(&wi->wi_list)); - cfs_wi_sched_unlock(sched); - return; + spin_unlock(&sched->ws_lock); } EXPORT_SYMBOL(cfs_wi_schedule); @@ -223,12 +204,10 @@ cfs_wi_scheduler(void *arg) { struct cfs_wi_sched *sched = (struct cfs_wi_sched *)arg; - cfs_block_allsigs(); - /* CPT affinity scheduler? */ if (sched->ws_cptab != NULL) if (cfs_cpt_bind(sched->ws_cptab, sched->ws_cpt) != 0) - CWARN("Failed to bind %s on CPT %d\n", + CWARN("Unable to bind %s on CPU partition %d\n", sched->ws_name, sched->ws_cpt); spin_lock(&cfs_wi_data.wi_glock); @@ -239,7 +218,7 @@ cfs_wi_scheduler(void *arg) spin_unlock(&cfs_wi_data.wi_glock); - cfs_wi_sched_lock(sched); + spin_lock(&sched->ws_lock); while (!sched->ws_stopping) { int nloops = 0; @@ -260,13 +239,12 @@ cfs_wi_scheduler(void *arg) wi->wi_running = 1; wi->wi_scheduled = 0; - - cfs_wi_sched_unlock(sched); + spin_unlock(&sched->ws_lock); nloops++; rc = (*wi->wi_action) (wi); - cfs_wi_sched_lock(sched); + spin_lock(&sched->ws_lock); if (rc != 0) /* WI should be dead, even be freed! */ continue; @@ -281,21 +259,21 @@ cfs_wi_scheduler(void *arg) } if (!list_empty(&sched->ws_runq)) { - cfs_wi_sched_unlock(sched); + spin_unlock(&sched->ws_lock); /* don't sleep because some workitems still * expect me to come back soon */ cond_resched(); - cfs_wi_sched_lock(sched); + spin_lock(&sched->ws_lock); continue; } - cfs_wi_sched_unlock(sched); + spin_unlock(&sched->ws_lock); rc = wait_event_interruptible_exclusive(sched->ws_waitq, !cfs_wi_sched_cansleep(sched)); - cfs_wi_sched_lock(sched); + spin_lock(&sched->ws_lock); } - cfs_wi_sched_unlock(sched); + spin_unlock(&sched->ws_lock); spin_lock(&cfs_wi_data.wi_glock); sched->ws_nthreads--; @@ -330,14 +308,13 @@ cfs_wi_sched_destroy(struct cfs_wi_sched *sched) int i = 2; while (sched->ws_nthreads > 0) { - CDEBUG(IS_PO2(++i) ? D_WARNING : D_NET, - "waiting for %d threads of WI sched[%s] to " - "terminate\n", sched->ws_nthreads, - sched->ws_name); + CDEBUG(is_power_of_2(++i / 20) ? D_WARNING : D_NET, + "waiting %us for %d %s worker threads to exit\n", + i / 20, sched->ws_nthreads, sched->ws_name); spin_unlock(&cfs_wi_data.wi_glock); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(cfs_time_seconds(1) / 20); + schedule_timeout_uninterruptible(cfs_time_seconds(1) + / 20); spin_lock(&cfs_wi_data.wi_glock); } } @@ -406,7 +383,7 @@ cfs_wi_sched_create(char *name, struct cfs_cpt_table *cptab, sched->ws_name, sched->ws_nthreads); } - task = kthread_run(cfs_wi_scheduler, sched, name); + task = kthread_run(cfs_wi_scheduler, sched, "%s", name); if (IS_ERR(task)) { int rc = PTR_ERR(task); @@ -467,8 +444,8 @@ cfs_wi_shutdown (void) while (sched->ws_nthreads != 0) { spin_unlock(&cfs_wi_data.wi_glock); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(cfs_time_seconds(1) / 20); + schedule_timeout_uninterruptible(cfs_time_seconds(1) + / 20); spin_lock(&cfs_wi_data.wi_glock); } spin_unlock(&cfs_wi_data.wi_glock);