From: Rik van Riel on 14 Dec 2009 09:40 On 12/14/2009 07:30 AM, KOSAKI Motohiro wrote: > if we don't use exclusive queue, wake_up() function wake _all_ waited > task. This is simply cpu wasting. > > Signed-off-by: KOSAKI Motohiro<kosaki.motohiro(a)jp.fujitsu.com> > if (zone_watermark_ok(zone, sc->order, low_wmark_pages(zone), > 0, 0)) { > - wake_up(wq); > + wake_up_all(wq); > finish_wait(wq,&wait); > sc->nr_reclaimed += sc->nr_to_reclaim; > return -ERESTARTSYS; I believe we want to wake the processes up one at a time here. If the queue of waiting processes is very large and the amount of excess free memory is fairly low, the first processes that wake up can take the amount of free memory back down below the threshold. The rest of the waiters should stay asleep when this happens. -- All rights reversed. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: KOSAKI Motohiro on 14 Dec 2009 19:50 > On 12/14/2009 07:30 AM, KOSAKI Motohiro wrote: > > if we don't use exclusive queue, wake_up() function wake _all_ waited > > task. This is simply cpu wasting. > > > > Signed-off-by: KOSAKI Motohiro<kosaki.motohiro(a)jp.fujitsu.com> > > > if (zone_watermark_ok(zone, sc->order, low_wmark_pages(zone), > > 0, 0)) { > > - wake_up(wq); > > + wake_up_all(wq); > > finish_wait(wq,&wait); > > sc->nr_reclaimed += sc->nr_to_reclaim; > > return -ERESTARTSYS; > > I believe we want to wake the processes up one at a time > here. If the queue of waiting processes is very large > and the amount of excess free memory is fairly low, the > first processes that wake up can take the amount of free > memory back down below the threshold. The rest of the > waiters should stay asleep when this happens. OK. Actually, wake_up() and wake_up_all() aren't different so much. Although we use wake_up(), the task wake up next task before try to alloate memory. then, it's similar to wake_up_all(). However, there are few difference. recent scheduler latency improvement effort reduce default scheduler latency target. it mean, if we have lots tasks of running state, the task have very few time slice. too frequently context switch decrease VM efficiency. Thank you, Rik. I didn't notice wake_up() makes better performance than wake_up_all() on current kernel. Subject: [PATCH 9/8] replace wake_up_all with wake_up Fix typo. Signed-off-by: KOSAKI Motohiro <kosaki.motohiro(a)jp.fujitsu.com> --- mm/vmscan.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index e5adb7a..b3b4e77 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1644,7 +1644,7 @@ static int shrink_zone_begin(struct zone *zone, struct scan_control *sc) return 0; found_lots_memory: - wake_up_all(wq); + wake_up(wq); stop_reclaim: finish_wait(wq, &wait); sc->nr_reclaimed += sc->nr_to_reclaim; -- 1.6.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Rik van Riel on 15 Dec 2009 10:00 On 12/15/2009 12:32 AM, Mike Galbraith wrote: > On Tue, 2009-12-15 at 09:45 +0900, KOSAKI Motohiro wrote: >>> On 12/14/2009 07:30 AM, KOSAKI Motohiro wrote: >>>> if we don't use exclusive queue, wake_up() function wake _all_ waited >>>> task. This is simply cpu wasting. >>>> >>>> Signed-off-by: KOSAKI Motohiro<kosaki.motohiro(a)jp.fujitsu.com> >>> >>>> if (zone_watermark_ok(zone, sc->order, low_wmark_pages(zone), >>>> 0, 0)) { >>>> - wake_up(wq); >>>> + wake_up_all(wq); >>>> finish_wait(wq,&wait); >>>> sc->nr_reclaimed += sc->nr_to_reclaim; >>>> return -ERESTARTSYS; >>> >>> I believe we want to wake the processes up one at a time >>> here. >> Actually, wake_up() and wake_up_all() aren't different so much. >> Although we use wake_up(), the task wake up next task before >> try to alloate memory. then, it's similar to wake_up_all(). That is a good point. Maybe processes need to wait a little in this if() condition, before the wake_up(). That would give the previous process a chance to allocate memory and we can avoid waking up too many processes. > What happens to waiters should running tasks not allocate for a while? When a waiter is woken up, it will either: 1) see that there is enough free memory and wake up the next guy, or 2) run shrink_zone and wake up the next guy Either way, the processes that just got woken up will ensure that the sleepers behind them in the queue will get woken up. -- All rights reversed. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Rik van Riel on 15 Dec 2009 14:40 On 12/15/2009 01:43 PM, Mike Galbraith wrote: > On Tue, 2009-12-15 at 09:58 -0500, Rik van Riel wrote: >> On 12/15/2009 12:32 AM, Mike Galbraith wrote: >>> On Tue, 2009-12-15 at 09:45 +0900, KOSAKI Motohiro wrote: >>>>> On 12/14/2009 07:30 AM, KOSAKI Motohiro wrote: >>>>>> if we don't use exclusive queue, wake_up() function wake _all_ waited >>>>>> task. This is simply cpu wasting. >>>>>> >>>>>> Signed-off-by: KOSAKI Motohiro<kosaki.motohiro(a)jp.fujitsu.com> >>>>> >>>>>> if (zone_watermark_ok(zone, sc->order, low_wmark_pages(zone), >>>>>> 0, 0)) { >>>>>> - wake_up(wq); >>>>>> + wake_up_all(wq); >>>>>> finish_wait(wq,&wait); >>>>>> sc->nr_reclaimed += sc->nr_to_reclaim; >>>>>> return -ERESTARTSYS; >>>>> >>>>> I believe we want to wake the processes up one at a time >>>>> here. >> >>>> Actually, wake_up() and wake_up_all() aren't different so much. >>>> Although we use wake_up(), the task wake up next task before >>>> try to alloate memory. then, it's similar to wake_up_all(). >> >> That is a good point. Maybe processes need to wait a little >> in this if() condition, before the wake_up(). That would give >> the previous process a chance to allocate memory and we can >> avoid waking up too many processes. > > Pondering, I think I'd at least wake NR_CPUS. If there's not enough to > go round, oh darn, but if there is, you have full utilization quicker. That depends on what the other CPUs in the system are doing. If they were doing work, you've just wasted some resources. -- All rights reversed. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: KOSAKI Motohiro on 15 Dec 2009 19:50 > On 12/15/2009 12:32 AM, Mike Galbraith wrote: > > On Tue, 2009-12-15 at 09:45 +0900, KOSAKI Motohiro wrote: > >>> On 12/14/2009 07:30 AM, KOSAKI Motohiro wrote: > >>>> if we don't use exclusive queue, wake_up() function wake _all_ waited > >>>> task. This is simply cpu wasting. > >>>> > >>>> Signed-off-by: KOSAKI Motohiro<kosaki.motohiro(a)jp.fujitsu.com> > >>> > >>>> if (zone_watermark_ok(zone, sc->order, low_wmark_pages(zone), > >>>> 0, 0)) { > >>>> - wake_up(wq); > >>>> + wake_up_all(wq); > >>>> finish_wait(wq,&wait); > >>>> sc->nr_reclaimed += sc->nr_to_reclaim; > >>>> return -ERESTARTSYS; > >>> > >>> I believe we want to wake the processes up one at a time > >>> here. > > >> Actually, wake_up() and wake_up_all() aren't different so much. > >> Although we use wake_up(), the task wake up next task before > >> try to alloate memory. then, it's similar to wake_up_all(). > > That is a good point. Maybe processes need to wait a little > in this if() condition, before the wake_up(). That would give > the previous process a chance to allocate memory and we can > avoid waking up too many processes. if we really need wait a bit, Mike's wake_up_batch is best, I think. It mean - if another CPU is idle, wake up one process soon. iow, it don't make meaningless idle. - if another CPU is busy, woken process don't start to run awhile. then, zone_watermark_ok() can calculate correct value. > > What happens to waiters should running tasks not allocate for a while? > > When a waiter is woken up, it will either: > 1) see that there is enough free memory and wake up the next guy, or > 2) run shrink_zone and wake up the next guy > > Either way, the processes that just got woken up will ensure that > the sleepers behind them in the queue will get woken up. > > -- > All rights reversed. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|
Next
|
Last
Pages: 1 2 Prev: FRV: Fix no-hardware-breakpoint case Next: Use io_schedule() instead schedule() |