login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2010
»
October
»
13
Re: [PATCH v3 2/7] sched: accumulate per-cfs_rq cpu usage
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Balbir Singh
Subject:
Re: [PATCH v3 2/7] sched: accumulate per-cfs_rq cpu usage
Date: Wednesday, October 13, 2010 - 6:30 am
* Bharata B Rao <bharata@linux.vnet.ibm.com> [2010-10-12 13:21:09]:
quoted text
> sched: accumulate per-cfs_rq cpu usage > > From: Paul Turner <pjt@google.com> > > Introduce account_cfs_rq_quota() to account bandwidth usage on the cfs_rq > level versus task_groups for which bandwidth has been assigned. This is > tracked by whether the local cfs_rq->quota_assigned is finite or infinite > (RUNTIME_INF). > > For cfs_rq's that belong to a bandwidth constrained task_group we introduce > tg_request_cfs_quota() which attempts to allocate quota from the global pool > for use locally. Updates involving the global pool are currently protected > under cfs_bandwidth->lock, local pools are protected by rq->lock. > > This patch only attempts to assign and track quota, no action is taken in the > case that cfs_rq->quota_used exceeds cfs_rq->quota_assigned. > > Signed-off-by: Paul Turner <pjt@google.com> > Signed-off-by: Nikhil Rao <ncrao@google.com> > Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com> > --- > include/linux/sched.h | 4 ++++ > kernel/sched.c | 13 +++++++++++++ > kernel/sched_fair.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ > kernel/sysctl.c | 10 ++++++++++ > 4 files changed, 77 insertions(+) > > --- a/include/linux/sched.h > +++ b/include/linux/sched.h > @@ -1898,6 +1898,10 @@ int sched_rt_handler(struct ctl_table *t > void __user *buffer, size_t *lenp, > loff_t *ppos); > > +#ifdef CONFIG_CFS_BANDWIDTH > +extern unsigned int sysctl_sched_cfs_bandwidth_slice; > +#endif > + > extern unsigned int sysctl_sched_compat_yield; > > #ifdef CONFIG_RT_MUTEXES > --- a/kernel/sched.c > +++ b/kernel/sched.c > @@ -1929,6 +1929,19 @@ static const struct sched_class rt_sched > * default: 0.5s > */ > static u64 sched_cfs_bandwidth_period = 500000000ULL; > + > +/* > + * default slice of quota to allocate from global tg to local cfs_rq pool on > + * each refresh > + * default: 10ms > + */ > +unsigned int sysctl_sched_cfs_bandwidth_slice = 10000UL; > + > +static inline u64 sched_cfs_bandwidth_slice(void) > +{ > + return (u64)sysctl_sched_cfs_bandwidth_slice * NSEC_PER_USEC; > +} > + > #endif > > #define sched_class_highest (&rt_sched_class) > --- a/kernel/sched_fair.c > +++ b/kernel/sched_fair.c > @@ -267,6 +267,16 @@ find_matching_se(struct sched_entity **s > > #endif /* CONFIG_FAIR_GROUP_SCHED */ > > +#ifdef CONFIG_CFS_BANDWIDTH > +static inline struct cfs_bandwidth *tg_cfs_bandwidth(struct task_group *tg) > +{ > + return &tg->cfs_bandwidth; > +} > + > +static void account_cfs_rq_quota(struct cfs_rq *cfs_rq, > + unsigned long delta_exec); > +#endif > + > > /************************************************************** > * Scheduling class tree data structure manipulation methods: > @@ -547,6 +557,9 @@ static void update_curr(struct cfs_rq *c > cpuacct_charge(curtask, delta_exec); > account_group_exec_runtime(curtask, delta_exec); > } > +#ifdef CONFIG_CFS_BANDWIDTH > + account_cfs_rq_quota(cfs_rq, delta_exec); > +#endif > } > > static inline void > @@ -1130,6 +1143,43 @@ static void yield_task_fair(struct rq *r > } > > #ifdef CONFIG_CFS_BANDWIDTH > +static u64 tg_request_cfs_quota(struct task_group *tg) > +{ > + struct cfs_bandwidth *cfs_b = tg_cfs_bandwidth(tg); > + u64 delta = 0; > + > + if (cfs_b->runtime > 0 || cfs_b->quota == RUNTIME_INF) {
Quick question for cfs_b->quota == RUNTIME_INF, won't cfs_b->runtime be always > 0?
quoted text
> + raw_spin_lock(&cfs_b->lock); > + /* > + * it's possible a bandwidth update has changed the global > + * pool. > + */ > + if (cfs_b->quota == RUNTIME_INF) > + delta = sched_cfs_bandwidth_slice(); > + else { > + delta = min(cfs_b->runtime, > + sched_cfs_bandwidth_slice()); > + cfs_b->runtime -= delta; > + } > + raw_spin_unlock(&cfs_b->lock); > + } > + return delta; > +} > + > +static void account_cfs_rq_quota(struct cfs_rq *cfs_rq, > + unsigned long delta_exec) > +{ > + if (cfs_rq->quota_assigned == RUNTIME_INF) > + return; > + > + cfs_rq->quota_used += delta_exec; > + > + if (cfs_rq->quota_used < cfs_rq->quota_assigned) > + return; > + > + cfs_rq->quota_assigned += tg_request_cfs_quota(cfs_rq->tg); > +} > + > static int do_sched_cfs_period_timer(struct cfs_bandwidth *cfs_b, int overrun) > { > return 1; > --- a/kernel/sysctl.c > +++ b/kernel/sysctl.c > @@ -384,6 +384,16 @@ static struct ctl_table kern_table[] = { > .mode = 0644, > .proc_handler = proc_dointvec, > }, > +#ifdef CONFIG_CFS_BANDWIDTH > + { > + .procname = "sched_cfs_bandwidth_slice_us", > + .data = &sysctl_sched_cfs_bandwidth_slice, > + .maxlen = sizeof(unsigned int), > + .mode = 0644, > + .proc_handler = proc_dointvec_minmax, > + .extra1 = &one, > + }, > +#endif > #ifdef CONFIG_PROVE_LOCKING > { > .procname = "prove_locking",
-- Three Cheers, Balbir --
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[PATCH v3 0/7] CFS Bandwidth Control
, Bharata B Rao
, (Tue Oct 12, 12:49 am)
[PATCH v3 1/7] sched: introduce primitives to account for ...
, Bharata B Rao
, (Tue Oct 12, 12:50 am)
[PATCH v3 2/7] sched: accumulate per-cfs_rq cpu usage
, Bharata B Rao
, (Tue Oct 12, 12:51 am)
[PATCH v3 3/7] sched: throttle cfs_rq entities which excee ...
, Bharata B Rao
, (Tue Oct 12, 12:52 am)
[PATCH v3 4/7] sched: unthrottle cfs_rq(s) who ran out of ...
, Bharata B Rao
, (Tue Oct 12, 12:52 am)
[PATCH v3 5/7] sched: add exports tracking cfs bandwidth c ...
, Bharata B Rao
, (Tue Oct 12, 12:53 am)
[PATCH v3 6/7] sched: hierarchical task accounting for FAI ...
, Bharata B Rao
, (Tue Oct 12, 12:54 am)
[PATCH v3 7/7] sched: Return/expire slack quota using gene ...
, Bharata B Rao
, (Tue Oct 12, 12:55 am)
Re: [PATCH v3 0/7] CFS Bandwidth Control
, KAMEZAWA Hiroyuki
, (Tue Oct 12, 10:14 pm)
Re: [PATCH v3 0/7] CFS Bandwidth Control
, Herbert Poetzl
, (Tue Oct 12, 10:44 pm)
Re: [PATCH v3 0/7] CFS Bandwidth Control
, Paul Turner
, (Tue Oct 12, 11:26 pm)
Re: [PATCH v3 3/7] sched: throttle cfs_rq entities which e ...
, KAMEZAWA Hiroyuki
, (Tue Oct 12, 11:34 pm)
Re: [PATCH v3 3/7] sched: throttle cfs_rq entities which e ...
, Paul Turner
, (Tue Oct 12, 11:44 pm)
Re: [PATCH v3 3/7] sched: throttle cfs_rq entities which e ...
, Bharata B Rao
, (Tue Oct 12, 11:47 pm)
Re: [PATCH v3 3/7] sched: throttle cfs_rq entities which e ...
, Paul Turner
, (Tue Oct 12, 11:52 pm)
Re: [PATCH v3 3/7] sched: throttle cfs_rq entities which e ...
, KAMEZAWA Hiroyuki
, (Wed Oct 13, 12:00 am)
Re: [PATCH v3 3/7] sched: throttle cfs_rq entities which e ...
, Paul Turner
, (Wed Oct 13, 12:13 am)
Re: [PATCH v3 1/7] sched: introduce primitives to account ...
, Balbir Singh
, (Wed Oct 13, 6:00 am)
Re: [PATCH v3 2/7] sched: accumulate per-cfs_rq cpu usage
, Balbir Singh
, (Wed Oct 13, 6:30 am)
Re: [PATCH v3 2/7] sched: accumulate per-cfs_rq cpu usage
, Nikhil Rao
, (Wed Oct 13, 6:46 am)
Re: [PATCH v3 2/7] sched: accumulate per-cfs_rq cpu usage
, Balbir Singh
, (Wed Oct 13, 6:59 am)
Re: [PATCH v3 2/7] sched: accumulate per-cfs_rq cpu usage
, Nikhil Rao
, (Wed Oct 13, 7:41 am)
Re: [PATCH v3 1/7] sched: introduce primitives to account ...
, Bharata B Rao
, (Wed Oct 13, 10:14 pm)
Re: [PATCH v3 2/7] sched: accumulate per-cfs_rq cpu usage
, Balbir Singh
, (Wed Oct 13, 10:39 pm)
Re: [PATCH v3 1/7] sched: introduce primitives to account ...
, Peter Zijlstra
, (Thu Oct 14, 12:52 am)
Re: [PATCH v3 2/7] sched: accumulate per-cfs_rq cpu usage
, Peter Zijlstra
, (Thu Oct 14, 1:57 am)
Re: [PATCH v3 2/7] sched: accumulate per-cfs_rq cpu usage
, Peter Zijlstra
, (Thu Oct 14, 2:01 am)
Re: [PATCH v3 2/7] sched: accumulate per-cfs_rq cpu usage
, Paul Turner
, (Thu Oct 14, 2:07 am)
Re: [PATCH v3 3/7] sched: throttle cfs_rq entities which e ...
, Peter Zijlstra
, (Thu Oct 14, 2:12 am)
Re: [PATCH v3 2/7] sched: accumulate per-cfs_rq cpu usage
, Peter Zijlstra
, (Thu Oct 14, 2:13 am)
Re: [PATCH v3 2/7] sched: accumulate per-cfs_rq cpu usage
, Paul Turner
, (Thu Oct 14, 2:14 am)
Re: [PATCH v3 2/7] sched: accumulate per-cfs_rq cpu usage
, Peter Zijlstra
, (Thu Oct 14, 2:19 am)
Re: [PATCH v3 2/7] sched: accumulate per-cfs_rq cpu usage
, Paul Turner
, (Thu Oct 14, 2:27 am)
Re: [PATCH v3 2/7] sched: accumulate per-cfs_rq cpu usage
, Peter Zijlstra
, (Thu Oct 14, 2:27 am)
Re: [PATCH v3 2/7] sched: accumulate per-cfs_rq cpu usage
, Bharata B Rao
, (Thu Oct 14, 2:40 am)
Re: [PATCH v3 3/7] sched: throttle cfs_rq entities which e ...
, KAMEZAWA Hiroyuki
, (Thu Oct 14, 2:50 am)
Re: [PATCH v3 2/7] sched: accumulate per-cfs_rq cpu usage
, Paul Turner
, (Thu Oct 14, 2:53 am)
Re: [PATCH v3 3/7] sched: throttle cfs_rq entities which e ...
, Paul Turner
, (Thu Oct 14, 2:58 am)
Re: [PATCH v3 3/7] sched: throttle cfs_rq entities which e ...
, Peter Zijlstra
, (Thu Oct 14, 2:59 am)
Re: [PATCH v3 3/7] sched: throttle cfs_rq entities which e ...
, KAMEZAWA Hiroyuki
, (Thu Oct 14, 3:08 am)
Re: [PATCH v3 3/7] sched: throttle cfs_rq entities which e ...
, Paul Turner
, (Thu Oct 14, 3:25 am)
Re: [PATCH v3 3/7] sched: throttle cfs_rq entities which e ...
, Peter Zijlstra
, (Thu Oct 14, 3:37 am)
Re: [PATCH v3 3/7] sched: throttle cfs_rq entities which e ...
, Peter Zijlstra
, (Thu Oct 14, 3:41 am)
Re: [PATCH v3 1/7] sched: introduce primitives to account ...
, Balbir Singh
, (Thu Oct 14, 5:38 am)
Re: [PATCH v3 1/7] sched: introduce primitives to account ...
, Peter Zijlstra
, (Thu Oct 14, 6:24 am)
Re: [PATCH v3 3/7] sched: throttle cfs_rq entities which e ...
, KAMEZAWA Hiroyuki
, (Thu Oct 14, 4:30 pm)
Re: [PATCH v3 4/7] sched: unthrottle cfs_rq(s) who ran out ...
, Balbir Singh
, (Thu Oct 14, 9:45 pm)
Re: [PATCH v3 0/7] CFS Bandwidth Control
, Lai Jiangshan
, (Wed Nov 17, 1:32 am)
Re: [PATCH v3 0/7] CFS Bandwidth Control
, Bharata B Rao
, (Thu Nov 18, 8:24 pm)
Re: [PATCH v3 1/7] sched: introduce primitives to account ...
, Bharata B Rao
, (Mon Dec 6, 2:02 am)
Re: [PATCH v3 4/7] sched: unthrottle cfs_rq(s) who ran out ...
, Bharata B Rao
, (Tue Dec 7, 6:13 am)
Navigation
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Greg KH
Og dreams of kernels
Jens Axboe
[PATCH 31/33] Fusion: sg chaining support
Arnd Bergmann
Re: finding your own dead "CONFIG_" variables
Mark Brown
[PATCH 2/2] Subject: natsemi: Allow users to disable workaround for DspCfg reset
Tony Breeds
[LGUEST] Look in object dir for .config
git
:
Brian Downing
Re: Git in a Nutshell guide
John Benes
Re: master has some toys
Matthias Lederhofer
[PATCH 4/7] introduce GIT_WORK_TREE to specify the work tree
Alexander Sulfrian
[RFC/PATCH] RE: git calls SSH_ASKPASS even if DISPLAY is not set
Junio C Hamano
Re: Rss produced by git is not valid xml?
git-commits-head
:
Linux Kernel Mailing List
iSeries: fix section mismatch in iseries_veth
Linux Kernel Mailing List
ixbge: remove TX lock and redo TX accounting.
Linux Kernel Mailing List
ixgbe: fix several counter register errata
Linux Kernel Mailing List
b43: fix build with CONFIG_SSB_PCIHOST=n
Linux Kernel Mailing List
9p: block-based virtio client
linux-netdev
:
Michael Breuer
Re: [PATCH] af_packet: Don't use skb after dev_queue_xmit()
Michael Breuer
Re: [PATCH] af_packet: Don't use skb after dev_queue_xm