(Forward to the right address for linaro-dev)
-------- Original Message -------- Subject: [PATCH] vexpress: Setup IRQ affinity to A7s for TC2 Date: Wed, 9 Jan 2013 14:20:19 +0000 From: Punit Agrawal punit.agrawal@arm.commailto:punit.agrawal@arm.com To: tixy@linaro.orgmailto:tixy@linaro.org tixy@linaro.orgmailto:tixy@linaro.org CC: linaro-dev@linaro.orgmailto:linaro-dev@linaro.org linaro-dev@linaro.orgmailto:linaro-dev@linaro.org, Punit Agrawal Punit.Agrawal@arm.commailto:Punit.Agrawal@arm.com
On TC2, to maximise power savings, it helps to affine the IRQs to the A7s. Now that the cpu to parts mapping is available via /proc/cpuinfo, this patch introduces a script to parse this file and build a mask of particular CPU type and change the IRQ affinity to this mask.
The patch also makes the necessary changes to platform specific init script to call above script and affine the IRQs to the A7s.
Lastly, it changes the makefile to include the new script in the target.
Change-Id: I2fd2840acd4602d9145c7c2f2e839e5dda09ff99 Signed-off-by: Punit Agrawal punit.agrawal@arm.commailto:punit.agrawal@arm.com ---
Hi Tixy,
I am not quite sure where to send this patch to get it included in Linaro. But you seem to have a few patches in this repo, so maybe you can apply this one.
Let me know if you have any feedback on this as well. I would be happy to incorporate that as long as the intent of the patches carries through.
Thanks, Punit
device.mk | 3 ++- init.arm-versatileexpress.rc | 6 ++++++ set_irq_affinity.sh | 45 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100755 set_irq_affinity.sh
diff --git a/device.mk b/device.mk index 6e6c6dd..9ca73e3 100644 --- a/device.mk +++ b/device.mk @@ -9,7 +9,8 @@ PRODUCT_COPY_FILES += \ device/linaro/vexpress/init.v2p-aarch64.rc:root/init.v2p-aarch64.rc \ device/linaro/vexpress/ueventd.v2p-aarch64.rc:root/ueventd.v2p-aarch64.rc \ device/linaro/vexpress/init.vexpress.sh:system/etc/init.vexpress.sh \ - device/linaro/vexpress/initlogo.rle:root/initlogo.rle + device/linaro/vexpress/initlogo.rle:root/initlogo.rle \ + device/linaro/vexpress/set_irq_affinity.sh:root/set_irq_affinity.sh
PRODUCT_CHARACTERISTICS := tablet,nosdcard
diff --git a/init.arm-versatileexpress.rc b/init.arm-versatileexpress.rc index a71e491..d710f36 100644 --- a/init.arm-versatileexpress.rc +++ b/init.arm-versatileexpress.rc @@ -33,6 +33,12 @@ on boot chown system system /sys/class/graphics/fb0/fit_to_screen chown system system /sys/class/graphics/fb1/overlays
+# setup IRQ affinity to the A7s +service setirqaffinity /set_irq_affinity 0xc07 + class main + user root + oneshot + service faketsd /system/bin/faketsd class main user bluetooth diff --git a/set_irq_affinity.sh b/set_irq_affinity.sh new file mode 100755 index 0000000..4a09d61 --- /dev/null +++ b/set_irq_affinity.sh @@ -0,0 +1,45 @@ +#!/system/bin/sh + +# This script sets the default affinity to the processors with the given part id. +# - part id is in hex (as seen in /proc/cpuinfo) + +function build_mask_from_part_id { + local IFS + local mask + local ref_part_id + + ref_part_id=$1 + IFS=$'\n' + + for line in `cat /proc/cpuinfo` + do + IFS=':' + set -A tokens $line + + if [ "${line#'processor'}" != "$line" ] + then + cpu="${tokens[1]##' '}" + elif [ "${line#'CPU part'}" != "$line" ] + then + part_id="${tokens[1]##' '}" + + if [ "$part_id" == "$ref_part_id" ] + then + (( mask |= 1 << $cpu )) + fi + fi + done + echo $(printf "%x" $mask) +} + +ref_part_id=$(echo $1 | tr '[A-Z]' '[a-z]') +mask=$(build_mask_from_part_id $ref_part_id) +[ -z "$mask" ] && exit + +echo $mask > /proc/irq/default_smp_affinity + +for i in `ls /proc/irq` +do + affinity_file="/proc/irq/$i/smp_affinity" + [ -e $affinity_file ] && echo $mask > $affinity_file +done -- 1.7.9.5
-- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
Subject: [PATCH] vexpress: Setup IRQ affinity to A7s for TC2 Date: Wed, 9 Jan 2013 14:20:19 +0000 From: Punit Agrawal punit.agrawal@arm.commailto:punit.agrawal@arm.com To: tixy@linaro.orgmailto:tixy@linaro.org tixy@linaro.orgmailto:tixy@linaro.org CC: linaro-dev@linaro.orgmailto:linaro-dev@linaro.org linaro-dev@linaro.orgmailto:linaro-dev@linaro.org, Punit Agrawal Punit.Agrawal@arm.commailto:Punit.Agrawal@arm.com
On TC2, to maximise power savings, it helps to affine the IRQs to the A7s. Now that the cpu to parts mapping is available via /proc/cpuinfo, this patch introduces a script to parse this file and build a mask of particular CPU type and change the IRQ affinity to this mask.
The patch also makes the necessary changes to platform specific init script to call above script and affine the IRQs to the A7s.
Lastly, it changes the makefile to include the new script in the target.
Change-Id: I2fd2840acd4602d9145c7c2f2e839e5dda09ff99 Signed-off-by: Punit Agrawal punit.agrawal@arm.commailto:punit.agrawal@arm.com
Hi Tixy,
I am not quite sure where to send this patch to get it included in Linaro. But you seem to have a few patches in this repo, so maybe you can apply this one.
Yes, I can do that. It looks like it copes OK for devices without any A7's but will give it a test to check that first :-)
We also need to consider how this behaves with the big.LITTLE switcher, I'll have to ask about that.
Let me know if you have any feedback on this as well. I would be happy to incorporate that as long as the intent of the patches carries through.
One question, what happens if I offline all the A7's at run time? Will the system stop responding to interrupts, prevent the last A7 being offlined or migrate the IRQs to the A15s? Guess I can try it out when I test it, but this might not be until tomorrow now.
--- Tixy
Thanks, Punit
device.mk | 3 ++- init.arm-versatileexpress.rc | 6 ++++++ set_irq_affinity.sh | 45 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100755 set_irq_affinity.sh
diff --git a/device.mk b/device.mk index 6e6c6dd..9ca73e3 100644 --- a/device.mk +++ b/device.mk @@ -9,7 +9,8 @@ PRODUCT_COPY_FILES += \ device/linaro/vexpress/init.v2p-aarch64.rc:root/init.v2p-aarch64.rc \ device/linaro/vexpress/ueventd.v2p-aarch64.rc:root/ueventd.v2p-aarch64.rc \ device/linaro/vexpress/init.vexpress.sh:system/etc/init.vexpress.sh \
- device/linaro/vexpress/initlogo.rle:root/initlogo.rle
- device/linaro/vexpress/initlogo.rle:root/initlogo.rle \
- device/linaro/vexpress/set_irq_affinity.sh:root/set_irq_affinity.sh
PRODUCT_CHARACTERISTICS := tablet,nosdcard
diff --git a/init.arm-versatileexpress.rc b/init.arm-versatileexpress.rc index a71e491..d710f36 100644 --- a/init.arm-versatileexpress.rc +++ b/init.arm-versatileexpress.rc @@ -33,6 +33,12 @@ on boot chown system system /sys/class/graphics/fb0/fit_to_screen chown system system /sys/class/graphics/fb1/overlays
+# setup IRQ affinity to the A7s +service setirqaffinity /set_irq_affinity 0xc07
- class main
- user root
- oneshot
service faketsd /system/bin/faketsd class main user bluetooth diff --git a/set_irq_affinity.sh b/set_irq_affinity.sh new file mode 100755 index 0000000..4a09d61 --- /dev/null +++ b/set_irq_affinity.sh @@ -0,0 +1,45 @@ +#!/system/bin/sh
+# This script sets the default affinity to the processors with the given part id. +# - part id is in hex (as seen in /proc/cpuinfo)
+function build_mask_from_part_id {
- local IFS
- local mask
- local ref_part_id
- ref_part_id=$1
- IFS=$'\n'
- for line in `cat /proc/cpuinfo`
- do
IFS=':'
set -A tokens $line
if [ "${line#'processor'}" != "$line" ]
then
cpu="${tokens[1]##' '}"
elif [ "${line#'CPU part'}" != "$line" ]
then
part_id="${tokens[1]##' '}"
if [ "$part_id" == "$ref_part_id" ]
then
(( mask |= 1 << $cpu ))
fi
fi
- done
- echo $(printf "%x" $mask)
+}
+ref_part_id=$(echo $1 | tr '[A-Z]' '[a-z]') +mask=$(build_mask_from_part_id $ref_part_id) +[ -z "$mask" ] && exit
+echo $mask > /proc/irq/default_smp_affinity
+for i in `ls /proc/irq` +do
- affinity_file="/proc/irq/$i/smp_affinity"
- [ -e $affinity_file ] && echo $mask > $affinity_file
+done
1.7.9.5
Hi Tixy,
On 09/01/13 15:25, Jon Medhurst (Tixy) wrote:
Subject: [PATCH] vexpress: Setup IRQ affinity to A7s for TC2 Date: Wed, 9 Jan 2013 14:20:19 +0000 From: Punit Agrawal punit.agrawal@arm.commailto:punit.agrawal@arm.com To: tixy@linaro.orgmailto:tixy@linaro.org tixy@linaro.orgmailto:tixy@linaro.org CC: linaro-dev@linaro.orgmailto:linaro-dev@linaro.org linaro-dev@linaro.orgmailto:linaro-dev@linaro.org, Punit Agrawal Punit.Agrawal@arm.commailto:Punit.Agrawal@arm.com
On TC2, to maximise power savings, it helps to affine the IRQs to the A7s. Now that the cpu to parts mapping is available via /proc/cpuinfo, this patch introduces a script to parse this file and build a mask of particular CPU type and change the IRQ affinity to this mask.
The patch also makes the necessary changes to platform specific init script to call above script and affine the IRQs to the A7s.
Lastly, it changes the makefile to include the new script in the target.
Change-Id: I2fd2840acd4602d9145c7c2f2e839e5dda09ff99 Signed-off-by: Punit Agrawal punit.agrawal@arm.commailto:punit.agrawal@arm.com
Hi Tixy,
I am not quite sure where to send this patch to get it included in Linaro. But you seem to have a few patches in this repo, so maybe you can apply this one.
Yes, I can do that. It looks like it copes OK for devices without any A7's but will give it a test to check that first :-)
I tried to ensure this was the case, but don't have anything other than TC2, so testing on other devices is most appreciated.
We also need to consider how this behaves with the big.LITTLE switcher, I'll have to ask about that.
Let me know if you have any feedback on this as well. I would be happy to incorporate that as long as the intent of the patches carries through.
One question, what happens if I offline all the A7's at run time? Will the system stop responding to interrupts, prevent the last A7 being offlined or migrate the IRQs to the A15s? Guess I can try it out when I test it, but this might not be until tomorrow now.
I just tried this - unplugging all the A7s. The irq affinity got updated to the A15s. So at least this doesn't kill the system.
Let me know if you run into issues.
Thanks, Punit
Tixy
Thanks, Punit
device.mk | 3 ++- init.arm-versatileexpress.rc | 6 ++++++ set_irq_affinity.sh | 45 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100755 set_irq_affinity.sh
diff --git a/device.mk b/device.mk index 6e6c6dd..9ca73e3 100644 --- a/device.mk +++ b/device.mk @@ -9,7 +9,8 @@ PRODUCT_COPY_FILES += \ device/linaro/vexpress/init.v2p-aarch64.rc:root/init.v2p-aarch64.rc \ device/linaro/vexpress/ueventd.v2p-aarch64.rc:root/ueventd.v2p-aarch64.rc \ device/linaro/vexpress/init.vexpress.sh:system/etc/init.vexpress.sh \
- device/linaro/vexpress/initlogo.rle:root/initlogo.rle
device/linaro/vexpress/initlogo.rle:root/initlogo.rle \
device/linaro/vexpress/set_irq_affinity.sh:root/set_irq_affinity.sh
PRODUCT_CHARACTERISTICS := tablet,nosdcard
diff --git a/init.arm-versatileexpress.rc b/init.arm-versatileexpress.rc index a71e491..d710f36 100644 --- a/init.arm-versatileexpress.rc +++ b/init.arm-versatileexpress.rc @@ -33,6 +33,12 @@ on boot chown system system /sys/class/graphics/fb0/fit_to_screen chown system system /sys/class/graphics/fb1/overlays
+# setup IRQ affinity to the A7s +service setirqaffinity /set_irq_affinity 0xc07
- class main
- user root
- oneshot
- service faketsd /system/bin/faketsd class main user bluetooth
diff --git a/set_irq_affinity.sh b/set_irq_affinity.sh new file mode 100755 index 0000000..4a09d61 --- /dev/null +++ b/set_irq_affinity.sh @@ -0,0 +1,45 @@ +#!/system/bin/sh
+# This script sets the default affinity to the processors with the given part id. +# - part id is in hex (as seen in /proc/cpuinfo)
+function build_mask_from_part_id {
- local IFS
- local mask
- local ref_part_id
- ref_part_id=$1
- IFS=$'\n'
- for line in `cat /proc/cpuinfo`
- do
IFS=':'
set -A tokens $line
if [ "${line#'processor'}" != "$line" ]
then
cpu="${tokens[1]##' '}"
elif [ "${line#'CPU part'}" != "$line" ]
then
part_id="${tokens[1]##' '}"
if [ "$part_id" == "$ref_part_id" ]
then
(( mask |= 1 << $cpu ))
fi
fi
- done
- echo $(printf "%x" $mask)
+}
+ref_part_id=$(echo $1 | tr '[A-Z]' '[a-z]') +mask=$(build_mask_from_part_id $ref_part_id) +[ -z "$mask" ] && exit
+echo $mask > /proc/irq/default_smp_affinity
+for i in `ls /proc/irq` +do
- affinity_file="/proc/irq/$i/smp_affinity"
- [ -e $affinity_file ] && echo $mask > $affinity_file
+done
1.7.9.5
-- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
On Wed, 2013-01-09 at 16:04 +0000, Punit Agrawal wrote:
I am not quite sure where to send this patch to get it included in Linaro. But you seem to have a few patches in this repo, so maybe you can apply this one.
Yes, I can do that. It looks like it copes OK for devices without any A7's but will give it a test to check that first :-)
I tried to ensure this was the case, but don't have anything other than TC2, so testing on other devices is most appreciated.
I had to fix the line which gets the script called at boot:
-service setirqaffinity /set_irq_affinity 0xc07 +service setirqaffinity /set_irq_affinity.sh 0xc07
and testing on TC2, A9, and big.LITTLE Fast Models shows IRQ affinities getting set as we expect, i.e. to A7 cores if they exist, otherwise to all cores. I spoke to someone about the possible issues with IKS (the In Kernel Switcher for big.LITTLE) and the conclusion was that this patch would be innocuous.
After fixing some whitespace issues and adding that '.sh' into init.arm-versatileexpress I've pushed the change into Gerrit http://review.android.git.linaro.org/#change,3240
On 10/01/13 12:14, Jon Medhurst (Tixy) wrote:
[...]
I had to fix the line which gets the script called at boot:
-service setirqaffinity /set_irq_affinity 0xc07 +service setirqaffinity /set_irq_affinity.sh 0xc07
Thanks for fixing this. I was debating different names and looks like submitted the patch which was neither here nor there.
and testing on TC2, A9, and big.LITTLE Fast Models shows IRQ affinities getting set as we expect, i.e. to A7 cores if they exist, otherwise to all cores. I spoke to someone about the possible issues with IKS (the In Kernel Switcher for big.LITTLE) and the conclusion was that this patch would be innocuous.
Speaking to some IKS folk internally, I had reached a similar conclusion. So its good to see this being a more general view as well.
After fixing some whitespace issues and adding that '.sh' into init.arm-versatileexpress I've pushed the change into Gerrit http://review.android.git.linaro.org/#change,3240
I am not sure if review responses will make it to my mailbox but shoutout if any changes are needed.
Cheers, Punit
-- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
This is needed so the file is given executable permissions when it is placed in the initrd. (Android doesn't use the file's attributes when creating filesystems, instead it applies the set of rules in system/core/include/private/android_filesystem_config.h)
This fixes bug: https://bugs.launchpad.net/linaro-android/+bug/1099486
Change-Id: Icfa2a6a0523558fc261e5ef1dfaeb8e726dc67a9 Signed-off-by: Jon Medhurst tixy@linaro.org ---
I'm posting this fix for the record and it is in Gerrit at: http://review.android.git.linaro.org/#change,3247
I didn't notice this issue in my initial testing as I updated the initrd by hand, rather than using a full Android build.
device.mk | 2 +- init.arm-versatileexpress.rc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/device.mk b/device.mk index 934d313..74ba29b 100644 --- a/device.mk +++ b/device.mk @@ -18,7 +18,7 @@ PRODUCT_COPY_FILES += \ device/linaro/vexpress/ueventd.v2p-aarch64.rc:root/ueventd.v2p-aarch64.rc \ device/linaro/vexpress/init.vexpress.sh:system/etc/init.vexpress.sh \ device/linaro/vexpress/initlogo.rle:root/initlogo.rle \ - device/linaro/vexpress/set_irq_affinity.sh:root/set_irq_affinity.sh + device/linaro/vexpress/set_irq_affinity.sh:root/sbin/set_irq_affinity.sh
PRODUCT_CHARACTERISTICS := tablet,nosdcard
diff --git a/init.arm-versatileexpress.rc b/init.arm-versatileexpress.rc index b7d7c8b..3950938 100644 --- a/init.arm-versatileexpress.rc +++ b/init.arm-versatileexpress.rc @@ -34,7 +34,7 @@ on boot chown system system /sys/class/graphics/fb1/overlays
# setup IRQ affinity to the A7s -service setirqaffinity /set_irq_affinity.sh 0xc07 +service setirqaffinity /sbin/set_irq_affinity.sh 0xc07 class main user root oneshot