From: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
To: Jan Stancek <jstancek@redhat.com>, ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH 2/4] cpu_hotplug: add get_hotplug_cpus, get_present_cpus
Date: Wed, 29 Apr 2015 15:56:03 +0300 [thread overview]
Message-ID: <5540D4E3.30800@oracle.com> (raw)
In-Reply-To: <1fa1d110f42b66a5b550ddb72473d4ebee026c15.1430305546.git.jstancek@redhat.com>
On 04/29/2015 02:17 PM, Jan Stancek wrote:
> From: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
>
> Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
> Signed-off-by: Jan Stancek <jstancek@redhat.com>
> ---
> .../cpu_hotplug/include/cpuhotplug_hotplug.sh | 73 +++++++++++++++++++++-
> 1 file changed, 70 insertions(+), 3 deletions(-)
>
> diff --git a/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh b/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh
> index f553d0c..a1c6ef6 100644
> --- a/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh
> +++ b/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh
> @@ -126,11 +126,78 @@ get_cpus_num()
> #
> get_all_cpus()
> {
> - [ -d /sys/devices/system/cpu/cpu0 ] || return 1
> - ls -dr /sys/devices/system/cpu/cpu[0-9]* | \
> - sed "s/\/sys\/devices\/system\/cpu\///g" || return 2
> + [ -d /sys/devices/system/cpu ] || return 1
> + (cd /sys/devices/system/cpu; ls -d cpu[0-9]*)
> }
>
> +# get_present_cpus()
> +#
> +# Prints a list of present CPUs, regardless of whether they're
> +# currently online or offline.
> +#
> +get_present_cpus()
> +{
> + # if sysfs present mask is missing, assume all cpu are present
> + if [ ! -e /sys/devices/system/cpu/present ]; then
> + get_all_cpus
> + return
> + fi
> +
> + local present_mask="/sys/devices/system/cpu/present"
Maybe use this variable in the above 'if [ ! -e
/sys/devices/system/cpu/present]' ?
> + local present_cpus=""
> +
> + for part in $(cat $present_mask | tr "," " "); do
> + if echo $part | grep -q "-"; then
> + range_low=$(echo $part | cut -d - -f 1)
> + range_high=$(echo $part | cut -d - -f 2)
> + else
> + range_low=$(part)
> + range_high=$(part)
> + fi
> + for cpu in $(seq $range_low $range_high); do
> + if [ -e /sys/devices/system/cpu/cpu$cpu ]; then
> + present_cpus="$present_cpus cpu$cpu"
> + fi
> + done
> + done
> + echo $present_cpus
> +}
> +
> +# get_present_cpus_num()
> +#
> +# Prints the number of present CPUs
> +#
> +get_present_cpus_num()
> +{
> + return $(get_present_cpus | wc -w)
> +}
> +
> +# get_hotplug_cpus()
> +#
> +# Prints a list of present hotpluggable CPUs, regardless of whether they're
> +# currently online or offline.
> +#
> +get_hotplug_cpus()
> +{
> + local present_cpus=$(get_present_cpus)
> + local hotplug_cpus=""
> +
> + for cpu in $present_cpus; do
> + if [ -e /sys/devices/system/cpu/$cpu/online ]; then
> + hotplug_cpus="$hotplug_cpus $cpu"
> + fi
> + done
> + echo $hotplug_cpus
> +}
> +
> +# get_hotplug_cpus_num()
> +#
> +# Prints the number of hotpluggable CPUs
> +#
> +get_hotplug_cpus_num()
> +{
> + return $(get_hotplug_cpus | wc -w)
> +}
>
> # get_all_cpu_states()
> #
>
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2015-04-29 12:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-29 11:17 [LTP] [PATCH 0/4 v2] (merged) cpuhotplug fixes Jan Stancek
2015-04-29 11:17 ` [LTP] [PATCH 1/4] cpuhotplug: use cpu states in cleanup Jan Stancek
2015-04-29 11:17 ` [LTP] [PATCH 2/4] cpu_hotplug: add get_hotplug_cpus, get_present_cpus Jan Stancek
2015-04-29 12:56 ` Stanislav Kholmanskikh [this message]
2015-04-29 11:18 ` [LTP] [PATCH 3/4] cpu_hotplug: use hotplug/present cpus functions Jan Stancek
2015-04-29 13:09 ` Stanislav Kholmanskikh
2015-04-29 14:41 ` Jan Stancek
2015-04-29 15:03 ` Stanislav Kholmanskikh
2015-04-29 11:18 ` [LTP] [PATCH 4/4] cpuhotplug04.sh: operate only with hotpluggable CPUs Jan Stancek
2015-04-29 13:11 ` [LTP] [PATCH 0/4 v2] (merged) cpuhotplug fixes Stanislav Kholmanskikh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5540D4E3.30800@oracle.com \
--to=stanislav.kholmanskikh@oracle.com \
--cc=jstancek@redhat.com \
--cc=ltp-list@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.