* [Qemu-devel] [QEMU-PPC] [PATCH v2] powerpc/spapr: Add host threads parameter to ibm, get_system_parameter
@ 2019-06-26 5:19 Suraj Jitindar Singh
2019-06-26 5:38 ` no-reply
0 siblings, 1 reply; 3+ messages in thread
From: Suraj Jitindar Singh @ 2019-06-26 5:19 UTC (permalink / raw)
To: qemu-ppc; +Cc: groug, qemu-devel, sjitindarsingh, david
The ibm,get_system_parameter rtas call is used by the guest to retrieve
data relating to certain parameters of the system. The SPLPAR
characteristics option (token 20) is used to determin characteristics of
the environment in which the lpar will run.
It may be useful for a guest to know the number of physical host threads
present on the underlying system where it is being run. Add the
characteristic "HostThrs" to the SPLPAR Characteristics
ibm,get_system_parameter rtas call to expose this information to a
guest and provide an implementation which determines this information
based on the number of interrupt servers present in the device tree.
Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
---
V1 -> V2:
- Take into account that the core may be operating in split core mode
meaning a single core may be split into multiple subcores.
---
hw/ppc/spapr_rtas.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
index 5bc1a93271..9b15e7606b 100644
--- a/hw/ppc/spapr_rtas.c
+++ b/hw/ppc/spapr_rtas.c
@@ -229,6 +229,55 @@ static inline int sysparm_st(target_ulong addr, target_ulong len,
return RTAS_OUT_SUCCESS;
}
+#define CPUS_PATH "/proc/device-tree/cpus/"
+#define SUBCORE_PATH "/sys/devices/system/cpu/subcores_per_core"
+
+static int rtas_get_num_host_threads(void)
+{
+ int num_threads = -1;
+ unsigned long len;
+ const char *entry;
+ char *buf;
+ GDir *dir;
+
+ if (!kvm_enabled())
+ return 1;
+
+ /* Read interrupt servers to determine number of threads per core */
+ dir = g_dir_open(CPUS_PATH, 0, NULL);
+ if (!dir)
+ return -1;
+
+ while ((entry = g_dir_read_name(dir))) {
+ if (!strncmp(entry, "PowerPC,POWER", strlen("PowerPC,POWER"))) {
+ char *path;
+
+ path = g_strconcat(CPUS_PATH, entry, "/ibm,ppc-interrupt-server#s",
+ NULL);
+ if (g_file_get_contents(path, &buf, &len, NULL)) {
+ num_threads = len / sizeof(int);
+ g_free(buf);
+ }
+
+ g_free(path);
+ break;
+ }
+ }
+
+ g_dir_close(dir);
+
+ /* Check if split core mode in use */
+ if (g_file_get_contents(SUBCORE_PATH, &buf, &len, NULL)) {
+ int subcores = g_ascii_strtoll(buf, NULL, 10);
+
+ if (subcores)
+ num_threads /= subcores;
+ g_free(buf);
+ }
+
+ return num_threads;
+}
+
static void rtas_ibm_get_system_parameter(PowerPCCPU *cpu,
SpaprMachineState *spapr,
uint32_t token, uint32_t nargs,
@@ -250,6 +299,16 @@ static void rtas_ibm_get_system_parameter(PowerPCCPU *cpu,
current_machine->ram_size / MiB,
smp_cpus,
max_cpus);
+ int num_host_threads = rtas_get_num_host_threads();
+
+ if (num_host_threads > 0) {
+ char *hostthr_val, *old = param_val;
+
+ hostthr_val = g_strdup_printf(",HostThrs=%d", num_host_threads);
+ param_val = g_strconcat(param_val, hostthr_val, NULL);
+ g_free(hostthr_val);
+ g_free(old);
+ }
ret = sysparm_st(buffer, length, param_val, strlen(param_val) + 1);
g_free(param_val);
break;
--
2.13.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [QEMU-PPC] [PATCH v2] powerpc/spapr: Add host threads parameter to ibm, get_system_parameter
2019-06-26 5:19 [Qemu-devel] [QEMU-PPC] [PATCH v2] powerpc/spapr: Add host threads parameter to ibm, get_system_parameter Suraj Jitindar Singh
@ 2019-06-26 5:38 ` no-reply
2019-06-28 2:33 ` David Gibson
0 siblings, 1 reply; 3+ messages in thread
From: no-reply @ 2019-06-26 5:38 UTC (permalink / raw)
To: sjitindarsingh; +Cc: david, qemu-ppc, groug, sjitindarsingh, qemu-devel
Patchew URL: https://patchew.org/QEMU/20190626051903.26829-1-sjitindarsingh@gmail.com/
Hi,
This series seems to have some coding style problems. See output below for
more information:
Message-id: 20190626051903.26829-1-sjitindarsingh@gmail.com
Type: series
Subject: [Qemu-devel] [QEMU-PPC] [PATCH v2] powerpc/spapr: Add host threads parameter to ibm, get_system_parameter
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Switched to a new branch 'test'
83350a8 powerpc/spapr: Add host threads parameter to ibm, get_system_parameter
=== OUTPUT BEGIN ===
ERROR: braces {} are necessary for all arms of this statement
#42: FILE: hw/ppc/spapr_rtas.c:243:
+ if (!kvm_enabled())
[...]
ERROR: braces {} are necessary for all arms of this statement
#47: FILE: hw/ppc/spapr_rtas.c:248:
+ if (!dir)
[...]
ERROR: braces {} are necessary for all arms of this statement
#72: FILE: hw/ppc/spapr_rtas.c:273:
+ if (subcores)
[...]
total: 3 errors, 0 warnings, 71 lines checked
Commit 83350a8ff0c8 (powerpc/spapr: Add host threads parameter to ibm, get_system_parameter) has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/20190626051903.26829-1-sjitindarsingh@gmail.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [QEMU-PPC] [PATCH v2] powerpc/spapr: Add host threads parameter to ibm, get_system_parameter
2019-06-26 5:38 ` no-reply
@ 2019-06-28 2:33 ` David Gibson
0 siblings, 0 replies; 3+ messages in thread
From: David Gibson @ 2019-06-28 2:33 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, groug, sjitindarsingh
[-- Attachment #1: Type: text/plain, Size: 2229 bytes --]
On Tue, Jun 25, 2019 at 10:38:24PM -0700, no-reply@patchew.org wrote:
> Patchew URL: https://patchew.org/QEMU/20190626051903.26829-1-sjitindarsingh@gmail.com/
>
>
>
> Hi,
>
> This series seems to have some coding style problems. See output below for
> more information:
Suraj, please fix up these style errors.
>
> Message-id: 20190626051903.26829-1-sjitindarsingh@gmail.com
> Type: series
> Subject: [Qemu-devel] [QEMU-PPC] [PATCH v2] powerpc/spapr: Add host threads parameter to ibm, get_system_parameter
>
> === TEST SCRIPT BEGIN ===
> #!/bin/bash
> git rev-parse base > /dev/null || exit 0
> git config --local diff.renamelimit 0
> git config --local diff.renames True
> git config --local diff.algorithm histogram
> ./scripts/checkpatch.pl --mailback base..
> === TEST SCRIPT END ===
>
> Switched to a new branch 'test'
> 83350a8 powerpc/spapr: Add host threads parameter to ibm, get_system_parameter
>
> === OUTPUT BEGIN ===
> ERROR: braces {} are necessary for all arms of this statement
> #42: FILE: hw/ppc/spapr_rtas.c:243:
> + if (!kvm_enabled())
> [...]
>
> ERROR: braces {} are necessary for all arms of this statement
> #47: FILE: hw/ppc/spapr_rtas.c:248:
> + if (!dir)
> [...]
>
> ERROR: braces {} are necessary for all arms of this statement
> #72: FILE: hw/ppc/spapr_rtas.c:273:
> + if (subcores)
> [...]
>
> total: 3 errors, 0 warnings, 71 lines checked
>
> Commit 83350a8ff0c8 (powerpc/spapr: Add host threads parameter to ibm, get_system_parameter) has style problems, please review. If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
> === OUTPUT END ===
>
> Test command exited with code: 1
>
>
> The full log is available at
> http://patchew.org/logs/20190626051903.26829-1-sjitindarsingh@gmail.com/testing.checkpatch/?type=message.
> ---
> Email generated automatically by Patchew [https://patchew.org/].
> Please send your feedback to patchew-devel@redhat.com
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-06-28 5:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-26 5:19 [Qemu-devel] [QEMU-PPC] [PATCH v2] powerpc/spapr: Add host threads parameter to ibm, get_system_parameter Suraj Jitindar Singh
2019-06-26 5:38 ` no-reply
2019-06-28 2:33 ` David Gibson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).