06 Dec, 2008

2 commits

  • Previously driver resume would always set the current policy min/max with
    the cpuinfo min/max, defined by user_policy.min/max. Resulting in a reset
    of policy settings when policy.min/max != cpuinfo.min/max when coming out
    of suspend. Now user_policy is saved as the policy instead of cpuinfo to
    preserve what the user actually set.

    Signed-off-by: Mike Chan
    Signed-off-by: Dave Jones

    Mike Chan
     
  • p4-clockmod has a long history of abuse. It pretends to be a CPU
    frequency scaling driver, even though it doesn't actually change
    the CPU frequency, but instead just modulates the frequency with
    wait-states.
    The biggest misconception is that when running at the lower 'frequency'
    p4-clockmod is saving power. This isn't the case, as workloads running
    slower take longer to complete, preventing the CPU from entering deep C states.

    However p4-clockmod does have a purpose. It can prevent overheating.
    Having it hooked up to the cpufreq interfaces is the wrong way to achieve
    cooling however. It should instead be hooked up to ACPI.

    This diff introduces a means for a cpufreq driver to register with the
    cpufreq core, but not present a sysfs interface.

    Signed-off-by: Matthew Garrett
    Signed-off-by: Dave Jones

    Matthew Garrett
     

10 Oct, 2008

10 commits

  • Use get_cpu()/put_cpu() in cpufreq_ondemand init routine, instead of
    smp_processor_id() to avoid the following BUG:

    [ 35.313118] BUG: using smp_processor_id() in preemptible [00000000] code=: modprobe/4952
    [ 35.313132] caller is cpufreq_gov_dbs_init+0xa/0x8f [cpufreq_ondemand]
    [ 35.313140] Pid: 4952, comm: modprobe Not tainted 2.6.27-rc5-mm1 #23
    [ 35.313145] Call Trace:
    [ 35.313158] [] debug_smp_processor_id+0xd7/0xe0
    [ 35.313167] [] cpufreq_gov_dbs_init+0xa/0x8f [cpufreq_ondemand]
    [ 35.313176] [] _stext+0x3b/0x160
    [ 35.313185] [] __mutex_unlock_slowpath+0xe5/0x190
    [ 35.313195] [] trace_hardirqs_on_caller+0xca/0x140
    [ 35.313205] [] sys_init_module+0xdc/0x210
    [ 35.313212] [] system_call_fastpath+0x16/0x1b

    Signed-off-by: Andrea Righi
    Signed-off-by: Dave Jones

    Andrea Righi
     
  • We don't need to export the governors for use as the default governor,
    because the default governor will be built-in anyway and we can access
    the symbol directly.

    This also fixes the following sparse warnings:

    drivers/cpufreq/cpufreq_conservative.c:578:25: warning: symbol 'cpufreq_gov_conservative' was not declared. Should it be static?
    drivers/cpufreq/cpufreq_ondemand.c:582:25: warning: symbol 'cpufreq_gov_ondemand' was not declared. Should it be static?
    drivers/cpufreq/cpufreq_performance.c:39:25: warning: symbol 'cpufreq_gov_performance' was not declared. Should it be static?
    drivers/cpufreq/cpufreq_powersave.c:38:25: warning: symbol 'cpufreq_gov_powersave' was not declared. Should it be static?
    drivers/cpufreq/cpufreq_userspace.c:190:25: warning: symbol 'cpufreq_gov_userspace' was not declared. Should it be static?

    Signed-off-by: Sven Wegener
    Signed-off-by: Dave Jones

    Sven Wegener
     
  • Use get_cpu_idle_time_us() to get micro-accounted idle information.
    This enables ondemand to get more accurate idle and busy timings
    than the jiffy based calculation. As a result, we can decrease
    the ondemand safety gaurd band from 80-10 to 95-3.

    Results in more aggressive power savings.

    Signed-off-by: Venkatesh Pallipadi
    Signed-off-by: Dave Jones

    venkatesh.pallipadi@intel.com
     
  • Use a parameter for down differential, instead of hardcoded 10%. Follow-on
    patch changes the down-differential dynamically, based on whether
    we are using idle micro-accounting or not.

    Signed-off-by: Venkatesh Pallipadi
    Signed-off-by: Dave Jones

    venkatesh.pallipadi@intel.com
     
  • Preparatory changes for doing idle micro-accounting in ondemand governor.
    get_cpu_idle_time() gets extra parameter and returns idle time and also the
    wall time that corresponds to the idle time measurement.

    Signed-off-by: Venkatesh Pallipadi
    Signed-off-by: Dave Jones

    venkatesh.pallipadi@intel.com
     
  • Change the load calculation algorithm in ondemand to work well with software
    coordination of frequency across the dependent cpus.

    Multiply individual CPU utilization with the average freq of that logical CPU
    during the measurement interval (using getavg call). And find the max CPU
    utilization number in terms of CPU freq. That number is then used to
    get to the target freq for next sampling interval.

    Signed-off-by: Venkatesh Pallipadi
    Signed-off-by: Dave Jones

    venkatesh.pallipadi@intel.com
     
  • Add a cpu parameter to __cpufreq_driver_getavg(). This is needed for software
    cpufreq coordination where policy->cpu may not be same as the CPU on which we
    want to getavg frequency.

    A follow-on patch will use this parameter to getavg freq from all cpus
    in policy->cpus.

    Change since last patch. Fix the offline/online and suspend/resume
    oops reported by Youquan Song

    Signed-off-by: Venkatesh Pallipadi
    Signed-off-by: Dave Jones

    venkatesh.pallipadi@intel.com
     
  • Venki Pallipadi made a similar change to the ondemand governor a while
    back (in commit 28287033e12463c8ff89f1ea8038783d0360391c). It seems to
    work just as well in the conservative governor, leading to fewer wakeups
    as reported by powertop.

    Signed-off-by: Ben Slusky
    Signed-off-by: Dave Jones

    Ben Slusky
     
  • After calling cpufreq_cpu_get, error handling code should call
    cpufreq_cpu_put.

    The semantic match that finds this problem is as follows:
    (http://www.emn.fr/x-info/coccinelle/)

    //
    @r@
    expression x,E;
    statement S;
    position p1,p2,p3;
    @@

    (
    if ((x = cpufreq_cpu_get@p1(...)) == NULL || ...) S
    |
    x = cpufreq_cpu_get@p1(...)
    ... when != x
    if (x == NULL || ...) S
    )

    (
    return x;
    |
    return 0;
    |
    x = E
    |
    E = x
    |
    cpufreq_cpu_put(x)
    )

    @exists@
    position r.p1,r.p2,r.p3;
    expression x;
    int ret != 0;
    statement S;
    @@

    * x = cpufreq_cpu_get@p1(...)

    * return@p2 \(NULL\|ret\);
    //

    Signed-off-by: Julia Lawall
    Signed-off-by: Dave Jones

    Julia Lawall
     
  • Add error handling for cpufreq_register_governor() error

    Signed-off-by: Akinobu Mita
    Cc: cpufreq@lists.linux.org.uk
    Signed-off-by: Dave Jones

    Akinobu Mita
     

09 Aug, 2008

1 commit


31 Jul, 2008

1 commit

  • Ingo Molnar provided a fix to not call _PPC at processor driver
    initialization time in "[PATCH] ACPI: fix cpufreq regression" (git
    commit e4233dec749a3519069d9390561b5636a75c7579)

    But it can still happen that _PPC is called at processor driver
    initialization time.

    This patch should make sure that this is not possible anymore.

    Signed-off-by: Thomas Renninger
    Cc: Andi Kleen
    Cc: Len Brown
    Cc: Dave Jones
    Cc: Ingo Molnar
    Cc: Venkatesh Pallipadi
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Thomas Renninger
     

24 Jul, 2008

1 commit

  • * 'cpus4096-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (31 commits)
    NR_CPUS: Replace NR_CPUS in speedstep-centrino.c
    cpumask: Provide a generic set of CPUMASK_ALLOC macros, FIXUP
    NR_CPUS: Replace NR_CPUS in cpufreq userspace routines
    NR_CPUS: Replace per_cpu(..., smp_processor_id()) with __get_cpu_var
    NR_CPUS: Replace NR_CPUS in arch/x86/kernel/genapic_flat_64.c
    NR_CPUS: Replace NR_CPUS in arch/x86/kernel/genx2apic_uv_x.c
    NR_CPUS: Replace NR_CPUS in arch/x86/kernel/cpu/proc.c
    NR_CPUS: Replace NR_CPUS in arch/x86/kernel/cpu/mcheck/mce_64.c
    cpumask: Optimize cpumask_of_cpu in lib/smp_processor_id.c, fix
    cpumask: Use optimized CPUMASK_ALLOC macros in the centrino_target
    cpumask: Provide a generic set of CPUMASK_ALLOC macros
    cpumask: Optimize cpumask_of_cpu in lib/smp_processor_id.c
    cpumask: Optimize cpumask_of_cpu in kernel/time/tick-common.c
    cpumask: Optimize cpumask_of_cpu in drivers/misc/sgi-xp/xpc_main.c
    cpumask: Optimize cpumask_of_cpu in arch/x86/kernel/ldt.c
    cpumask: Optimize cpumask_of_cpu in arch/x86/kernel/io_apic_64.c
    cpumask: Replace cpumask_of_cpu with cpumask_of_cpu_ptr
    Revert "cpumask: introduce new APIs"
    cpumask: make for_each_cpu_mask a bit smaller
    net: Pass reference to cpumask variable in net/sunrpc/svc.c
    ...

    Fix up trivial conflicts in drivers/cpufreq/cpufreq.c manually

    Linus Torvalds
     

22 Jul, 2008

1 commit


20 Jul, 2008

1 commit

  • * Replace arrays sized by NR_CPUS with percpu variables.

    Prior reference: http://marc.info/?l=linux-kernel&m=120251421825989&w=4
    Subject: [PATCH 1/4] cpufreq: change cpu freq tables to per_cpu variables
    From: Mike Travis
    Date: 2008-02-08 23:37:39

    Signed-off-by: Mike Travis
    Signed-off-by: Ingo Molnar

    Mike Travis
     

06 Jul, 2008

1 commit


10 Jun, 2008

2 commits


07 Jun, 2008

1 commit

  • If cpu specific cpufreq driver(i.e. longrun) has "setpolicy" function,
    governor object isn't set into cpufreq_policy object at "__cpufreq_set_policy"
    function in driver/cpufreq/cpufreq.c .

    This causes a null object access at "store_scaling_setspeed" and
    "show_scaling_setspeed" function in driver/cpufreq/cpufreq.c when reading or
    writing through /sys interface (ex. cat
    /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed)

    Addresses:
    http://bugzilla.kernel.org/show_bug.cgi?id=10654
    https://bugzilla.redhat.com/show_bug.cgi?id=443354

    Signed-off-by: CHIKAMA Masaki
    Cc: Dave Jones
    Cc: Chuck Ebbert
    Acked-by: Dominik Brodowski
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    CHIKAMA masaki
     

30 May, 2008

1 commit

  • In drivers/cpufreq/cpufreq.c the function cpufreq_add_dev() takes the
    error exit 'err_out_unregister' from different places once with the
    'cpu_policy_rwsem' lock held, once with the lock released:
    | if (ret)
    | goto err_out_unregister;
    | }
    |
    | policy->governor = NULL; /* to assure that the starting sequence is
    | * run in cpufreq_set_policy */
    |
    | /* set default policy */
    | ret = __cpufreq_set_policy(policy, &new_policy);
    | policy->user_policy.policy = policy->policy;
    | policy->user_policy.governor = policy->governor;
    |
    | unlock_policy_rwsem_write(cpu);
    |
    | if (ret) {
    | dprintk("setting policy failed\n");
    | goto err_out_unregister;
    | }

    This leads to the following error message in case of a failing
    __cpufreq_set_policy() call:
    =====================================
    [ BUG: bad unlock balance detected! ]
    -------------------------------------
    swapper/1 is trying to release lock (&per_cpu(cpu_policy_rwsem, cpu)) at:
    [] unlock_policy_rwsem_write+0x30/0x40
    but there are no more locks to release!

    other info that might help us debug this:
    1 lock held by swapper/1:
    #0: (sysdev_drivers_lock){--..}, at: [] sysdev_driver_register+0x74/0x130

    stack backtrace:
    [] (dump_stack+0x0/0x14) from [] (print_unlock_inbalance_bug+0xc8/0x104)
    [] (print_unlock_inbalance_bug+0x0/0x104) from [] (lock_release_non_nested+0xc4/0x19c)
    r6:00000028 r5:c3c1ab80 r4:c01b4564
    [] (lock_release_non_nested+0x0/0x19c) from [] (lock_release+0x15c/0x18c)
    r8:60000013 r7:00000001 r6:c01b4564 r5:c0541bb4 r4:c3c1ab80
    [] (lock_release+0x0/0x18c) from [] (up_write+0x24/0x30)
    r8:c0541b80 r7:00000000 r6:ffffffea r5:c3c34828 r4:c0541b8c
    [] (up_write+0x0/0x30) from [] (unlock_policy_rwsem_write+0x30/0x40)
    r4:c3c34884
    [] (unlock_policy_rwsem_write+0x0/0x40) from [] (cpufreq_add_dev+0x324/0x398)
    [] (cpufreq_add_dev+0x0/0x398) from [] (sysdev_driver_register+0xc0/0x130)
    [] (sysdev_driver_register+0x0/0x130) from [] (cpufreq_register_driver+0xbc/0x174)

    Signed-off-by: Lothar Waßmann
    Signed-off-by: Dave Jones

    Lothar Waßmann
     

24 May, 2008

1 commit


23 May, 2008

1 commit


20 May, 2008

1 commit

  • Change cpufreq_policy and cpufreq_governor pointer tables
    from arrays to per_cpu variables in the cpufreq subsystem.

    Also some minor complaints from checkpatch.pl fixed.

    Based on:
    git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
    git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-x86.git

    Signed-off-by: Mike Travis
    Signed-off-by: Dave Jones

    Mike Travis
     

29 Apr, 2008

9 commits


06 Mar, 2008

3 commits

  • Fix the following warnings:
    WARNING: vmlinux.o(.text+0xfe6711): Section mismatch in reference from the function cpufreq_unregister_driver() to the variable .cpuinit.data:cpufreq_cpu_notifier
    WARNING: vmlinux.o(.text+0xfe68af): Section mismatch in reference from the function cpufreq_register_driver() to the variable .cpuinit.data:cpufreq_cpu_notifier
    WARNING: vmlinux.o(.exit.text+0xc4fa): Section mismatch in reference from the function cpufreq_stats_exit() to the variable .cpuinit.data:cpufreq_stat_cpu_notifier

    The warnings were casued by references to unregister_hotcpu_notifier()
    from normal functions or exit functions.
    This is flagged by modpost as a potential error because
    it does not know that for the non HOTPLUG_CPU
    scenario the unregister_hotcpu_notifier() is a nop.
    Silence the warning by replacing the __initdata
    annotation with a __refdata annotation.

    Signed-off-by: Sam Ravnborg
    Signed-off-by: Dave Jones

    Sam Ravnborg
     
  • refactor to use gotos instead of explicit exit paths

    Signed-off-by: Dave Jones

    Dave Jones
     
  • refactor to use gotos instead of explicit exit paths

    Signed-off-by: Dave Jones

    Dave Jones
     

22 Feb, 2008

1 commit

  • The cpufreq core should not take an extra kobject reference count for no
    reason, and then refuse to release it. This has been reported as
    keeping machines from properly powering down all the way.

    Signed-off-by: Balaji Rao
    Cc: Dave Jones
    Cc: Yi Yang
    Cc: Alan Stern
    Cc: Frans Pop
    Cc: Yinghai Lu
    Cc: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman

    Balaji Rao
     

07 Feb, 2008

2 commits

  • cpufreq support can't be built as a module. Fix the related configuration
    help message.

    Signed-off-by: Stefano Brivio
    Signed-off-by: Dave Jones

    Stefano Brivio
     
  • Eliminate cpufreq_userspace scaling_setspeed deadlock.

    Luming Yu recently uncovered yet another cpufreq related deadlock.
    One thread that continuously switches the governors and the other thread that
    repeatedly cats the contents of cpufreq directory causes both these threads to
    go into a deadlock.

    Detailed examination of the deadlock showed the exact flow before the deadlock
    as:

    Thread 1 Thread 2
    ________ ________
    cats files under /sys/devices/.../cpufreq/
    Set governor to userspace
    Adds a new sysfs entry for
    scaling_setspeed
    cats files under /sys/devices/.../cpufreq/

    Set governor to performance
    Holds cpufreq_rw_sem in write
    mode
    Sends a STOP notify to
    userspace governor
    cat /sys/devices/.../cpufreq/scaling_setspeed
    Gets a handle on the above sysfs entry with
    sysfs_get_active
    Blocks while trying to get cpufreq_rw_sem
    in read mode
    Remove a sysfs entry for
    scaling_setspeed
    Blocks on sysfs_deactivate
    while waiting for earlier
    get_active (on other thread)
    to drain

    At this point both threads go into deadlock and any other thread that tries to
    do anything with sysfs cpufreq will also block.

    There seems to be no easy way to avoid this deadlock as long as
    cpufreq_userspace adds/removes the sysfs entry under same kobject as cpufreq.
    Below patch moves scaling_setspeed to cpufreq.c, keeping it always and calling
    back the governor on read/write. This is the cleanest fix I could think of,
    even though adding two callbacks in governor structure just for this seems
    unnecessary.

    Note that the change makes scaling_setspeed under /sys/.../cpufreq permanent
    and returns when governor is not userspace.

    Signed-off-by: Venkatesh Pallipadi
    Signed-off-by: Dave Jones

    Venki Pallipadi