Re: [patch 1/6] sched: use rt.nr_cpus_allowed to recoverselect_task_rq() cycles

From: Hillf Danton
Date: Fri Nov 18 2011 - 10:39:49 EST


On Fri, Nov 18, 2011 at 11:17 PM, Mike Galbraith <efault@xxxxxx> wrote:
>
> rt.nr_cpus_allowed is always available, use it to bail from select_task_rq()
> when only one cpu can be used, and saves some cycles for pinned tasks.
>
> taskset -c 3 pipe-test
>
> Â PerfTop: Â Â 997 irqs/sec Âkernel:89.5% Âexact: Â0.0% [1000Hz cycles], Â(all, CPU: 3)
> ------------------------------------------------------------------------------------------------
>
>       Virgin                  ÂPatched
>       samples Âpcnt function          Âsamples Âpcnt function
> Â Â Â Â Â Â _______ _____ ___________________________ _______ _____ ___________________________
>
>       2880.00 10.2% __schedule         Â3136.00 11.3% __schedule
>       1634.00 Â5.8% pipe_read          1615.00 Â5.8% pipe_read
>       1458.00 Â5.2% system_call         1534.00 Â5.5% system_call
>       1382.00 Â4.9% _raw_spin_lock_irqsave   Â1412.00 Â5.1% _raw_spin_lock_irqsave
>       1202.00 Â4.3% pipe_write         Â1255.00 Â4.5% copy_user_generic_string
>       1164.00 Â4.1% copy_user_generic_string  Â1241.00 Â4.5% __switch_to
>       1097.00 Â3.9% __switch_to         Â929.00 Â3.3% mutex_lock
>       Â872.00 Â3.1% mutex_lock          846.00 Â3.0% mutex_unlock
>       Â687.00 Â2.4% mutex_unlock         804.00 Â2.9% pipe_write
>       Â682.00 Â2.4% native_sched_clock      713.00 Â2.6% native_sched_clock
>       Â643.00 Â2.3% system_call_after_swapgs   653.00 Â2.3% _raw_spin_unlock_irqrestore
>       Â617.00 Â2.2% sched_clock_local      Â633.00 Â2.3% fsnotify
>       Â612.00 Â2.2% fsnotify           605.00 Â2.2% sched_clock_local
> Â Â Â Â Â Â Â596.00 Â2.1% _raw_spin_unlock_irqrestore Â593.00 Â2.1% system_call_after_swapgs
>       Â542.00 Â1.9% sysret_check         559.00 Â2.0% sysret_check
>       Â467.00 Â1.7% fget_light          472.00 Â1.7% fget_light
>       Â462.00 Â1.6% finish_task_switch      461.00 Â1.7% finish_task_switch
>       Â437.00 Â1.5% vfs_write          Â442.00 Â1.6% vfs_write
>       Â431.00 Â1.5% do_sync_write        Â428.00 Â1.5% do_sync_write
> *       413.00 Â1.5% select_task_rq_fair     Â404.00 Â1.5% _raw_spin_lock_irq
>       Â386.00 Â1.4% update_curr         Â402.00 Â1.4% update_curr
>       Â385.00 Â1.4% rw_verify_area        389.00 Â1.4% do_sync_read
>       Â377.00 Â1.3% _raw_spin_lock_irq      378.00 Â1.4% vfs_read
>       Â369.00 Â1.3% do_sync_read         340.00 Â1.2% pipe_iov_copy_from_user
>       Â360.00 Â1.3% vfs_read           316.00 Â1.1% __wake_up_sync_key
>       Â342.00 Â1.2% hrtick_start_fair      Â313.00 Â1.1% __wake_up_common
>
> Signed-off-by: Mike Galbraith <efault@xxxxxx>
>

Acked-by: Hillf Danton <dhillf@xxxxxxxxx>

> ---
> Âkernel/sched_fair.c | Â Â3 +++
> Âkernel/sched_rt.c  |  Â3 +++
> Â2 files changed, 6 insertions(+)
>
> Index: linux-3.2.git/kernel/sched_fair.c
> ===================================================================
> --- linux-3.2.git.orig/kernel/sched_fair.c
> +++ linux-3.2.git/kernel/sched_fair.c
> @@ -2340,6 +2340,9 @@ select_task_rq_fair(struct task_struct *
> Â Â Â Âint want_sd = 1;
> Â Â Â Âint sync = wake_flags & WF_SYNC;
>
> + Â Â Â if (p->rt.nr_cpus_allowed < 2)
> + Â Â Â Â Â Â Â return prev_cpu;
> +
> Â Â Â Âif (sd_flag & SD_BALANCE_WAKE) {
> Â Â Â Â Â Â Â Âif (cpumask_test_cpu(cpu, tsk_cpus_allowed(p)))
> Â Â Â Â Â Â Â Â Â Â Â Âwant_affine = 1;
> Index: linux-3.2.git/kernel/sched_rt.c
> ===================================================================
> --- linux-3.2.git.orig/kernel/sched_rt.c
> +++ linux-3.2.git/kernel/sched_rt.c
> @@ -999,6 +999,9 @@ select_task_rq_rt(struct task_struct *p,
>
> Â Â Â Âcpu = task_cpu(p);
>
> + Â Â Â if (p->rt.nr_cpus_allowed < 2)
> + Â Â Â Â Â Â Â goto out;
> +
> Â Â Â Â/* For anything but wake ups, just return the task_cpu */
> Â Â Â Âif (sd_flag != SD_BALANCE_WAKE && sd_flag != SD_BALANCE_FORK)
> Â Â Â Â Â Â Â Âgoto out;
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at Âhttp://vger.kernel.org/majordomo-info.html
> Please read the FAQ at Âhttp://www.tux.org/lkml/
>
>
>
¢éì®&Þ~º&¶¬–+-±éÝ¥Šw®žË±Êâmébžìdz¹Þ)í…æèw*jg¬±¨¶‰šŽŠÝj/êäz¹ÞŠà2ŠÞ¨è­Ú&¢)ß«a¶Úþø®G«éh®æj:+v‰¨Šwè†Ù>Wš±êÞiÛaxPjØm¶Ÿÿà -»+ƒùdš_