You are not logged in.

#1 2012-03-19 09:57:47

RubenL
Member
Registered: 2011-07-23
Posts: 3

changing cpufreq_ondemand's up_threshold through acpid?

hello everyone,

i'm trying to configure how my netbook should handle powersaving through cpufrequtils, acpid and laptopmodetools.
i have configre laptopmodetools to set the governor to performance when its on ac and to on demand on battery.
it works, however i cant seem to configure when it should scale up while on battery...
the wiki sugested adding the line

(sleep 10 && echo -n 25 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold)

to rc.local, but the file up_threshold only exists when the ondemand governor is active so i tried this in /etc/acpi/handler.sh

#!/bin/sh
# Default acpi script that takes an entry for all actions

minspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq`
maxspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq`
setspeed="/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"

set $*

case "$1" in
    button/power)
        #echo "PowerButton pressed!">/dev/tty5
        case "$2" in
            PBTN|PWRF)  logger "PowerButton pressed: $2" ;;
            *)          logger "ACPI action undefined: $2" ;;
        esac
        ;;
    button/sleep)
        case "$2" in
            SLPB|SBTN)   echo -n mem >/sys/power/state ;;
            *)      logger "ACPI action undefined: $2" ;;
        esac
        ;;
    ac_adapter)
        case "$2" in
            AC|ACAD|ADP0)
                case "$4" in
                    00000000)
                        echo -n $minspeed >$setspeed &
                        #/etc/laptop-mode/laptop-mode start
                        sleep 10 && echo -n 15 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
                    ;;
                    00000001)
                        echo -n $maxspeed >$setspeed
                        #/etc/laptop-mode/laptop-mode stop
                    ;;
                esac
                ;;
            *)  logger "ACPI action undefined: $2" ;;
        esac
        ;;
    battery)
        case "$2" in
            BAT0)
                case "$4" in
                    00000000)   #echo "offline" >/dev/tty5
                    ;;
                    00000001)   #echo "online"  >/dev/tty5
                    ;;
                esac
                ;;
            CPU0)	
                ;;
            *)  logger "ACPI action undefined: $2" ;;
        esac
        ;;
    button/lid)
       	case "$3" in
	    close)
		#echo "LID closed!">/dev/tty5
		/usr/sbin/pm-suspend
                ;;
	    open)
		#echo "LID opened!">/dev/tty5
        	;;
	esac
	;;

    *)
        logger "ACPI group/action undefined: $1 / $2"
        ;;
esac

but it doesnt work, the up scaling threshold is still set at 95% when i unplug the ac cable...
any ideas?

thanks,
RubenL

Offline

#2 2012-03-21 01:35:28

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

Re: changing cpufreq_ondemand's up_threshold through acpid?

Do you really need to set your computer to performance mode? I'm afraid you might waste electricity and create noise & heat without any gain compared to ondemand.

Offline

#3 2012-04-01 05:42:56

AidanSonoda
Member
Registered: 2012-04-01
Posts: 4

Re: changing cpufreq_ondemand's up_threshold through acpid?

Came looking for help with this exact issue.  stqn's input is welcome (we should all try to be efficient) but giving the op and myself the benefit of the doubt (assuming we have valid reasons for wanting to achieve the configuration specified) and providing an actual answer would be polite!


Aidan Sonoda
   ~Coimhéad fearg fhear na foighde.~
In necessariis unitas, in dubiis libertas, in omnibus caritas.
   AidanSonoda@ftml.net  |  ICQ: 422990753

Offline

#4 2012-04-01 12:36:35

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

Re: changing cpufreq_ondemand's up_threshold through acpid?

Actual politeness would be to give your reason for wanting this behaviour so that people who might help you know they’re not wasting their time doing so.

Offline

#5 2012-04-04 18:37:05

AidanSonoda
Member
Registered: 2012-04-01
Posts: 4

Re: changing cpufreq_ondemand's up_threshold through acpid?

Alright,

The lack of responsiveness clocking up from idle after a period of inactivity with the ondemand governor is annoying to me, particularly when moving text from web pages into libreoffice - something I do frequently.  The delay while I find & select the text I need is invariably enough for the governor to clock down and on my budget intel atom netbook the delay bringing libreoffice into the foreground is bothersome when making frequent switches between editor and browser.  While tolerable in exchange for improved battery life, using the performance governor remedies this for me when on AC power.

I'm still not sure I like the idea if having to justify myself to the community before being offered assistance, but I suppose beggars can't be choosers eh?  Hopefully my reasons will be found worthy in your judgement.


Aidan Sonoda
   ~Coimhéad fearg fhear na foighde.~
In necessariis unitas, in dubiis libertas, in omnibus caritas.
   AidanSonoda@ftml.net  |  ICQ: 422990753

Offline

#6 2012-04-05 20:14:37

rwd
Member
Registered: 2009-02-08
Posts: 664

Re: changing cpufreq_ondemand's up_threshold through acpid?

It is not a matter of justifying, but rather giving information that helps the helper.  Questions asked here are so often based on wrong assumptions that you can't expect benefit of the doubt.

It seems you put '-n' in the wrong place as 'man echo' would have shown. As always, if some line of a script doesn't seem to work, test that line manually. If that works, but it doesn't work from the script add some logging to see if it gets executed at all, or shows errors. For example in handler.sh  something like

echo "changing up_threshold" >> /tmp/test.log 
echo -n 15 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold >> /tmp/test.log 2>&1

Last edited by rwd (2012-04-05 21:25:54)

Offline

#7 2012-04-05 22:56:01

AidanSonoda
Member
Registered: 2012-04-01
Posts: 4

Re: changing cpufreq_ondemand's up_threshold through acpid?

First off, thanks so much for actually trying to help.  That said, my problem isn't with syntax.  Indeed the command works fine issued from the terminal.  It even works fine from rc.local assuming I boot on battery power.  As RubenL pointed out in the original post:

RubenL wrote:

the file up_threshold only exists when the ondemand governor is active

Hence the problem: if I boot my netbook when it is plugged in the command fails because /sys/devices/system/cpu/cpufreq/ondemand/up_threshold doesn't exist when on the 'performance' governor.

That said I'm afraid I don't quite understand your assertion regarding syntax...

Here's the command from RubenL's original script:

echo -n 15 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold

You suggested:

echo -n 15 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold >> /tmp/test.log 2>&1

What exactly is different about the use of the echo command between these two?  In what way is the '-n' in the wrong place?

Sorry for being dense, thanks again for trying to help out!


Aidan Sonoda
   ~Coimhéad fearg fhear na foighde.~
In necessariis unitas, in dubiis libertas, in omnibus caritas.
   AidanSonoda@ftml.net  |  ICQ: 422990753

Offline

#8 2012-04-06 06:56:54

rwd
Member
Registered: 2009-02-08
Posts: 664

Re: changing cpufreq_ondemand's up_threshold through acpid?

AidanSonoda wrote:

What exactly is different about the use of the echo command between these two?  In what way is the '-n' in the wrong place?

Sorry my mistake, syntax is ok.

AidanSonoda wrote:

    the file up_threshold only exists when the ondemand governor is active

this is logical as it isn't needed with the performance governor. Also in Rubens script laptop-mode is commented out so the governor is never changed to ondemand by laptop-mode,

It seems to me for this to work you need to make sure that laptop-mode changes governors by setting BATT_CPU_GOVERNOR=ondemand in  /etc/laptop-mode/conf.d/cpufreq.conf, and not commenting out laptop-mode in handler.sh

To prevent cluttering  handler.sh you can also put a script in  /etc/laptop-mode/batt-start/ to do the changing of  up_threshold, though I don't know if it is executed before or after the changing of governor. Something like

#!/bin/bash
case "$1" in
    start)
        # battery action here:
...
    ;;
    stop)
        # ac action here:
...
    ;;
esac
exit 0

Use logging to see what's going on, by putting LOG_TO_SYSLOG=1 in laptop-mode.conf or like I mentioned in the other post.

Last edited by rwd (2012-04-06 07:39:33)

Offline

Board footer

Powered by FluxBB