Skip to contentSkip to conversation

s390: Add support for z13

PATCH William Cohen 3 participants 6 messages Oct 12, 2016 – Oct 14, 2016 7 messages not in the archive

lore
Share & tools
lore
#7 lore raw
In reply to a message not in the archive
Quoted 10 lines · Michael Petlan
Quoted 9 lines · Andreas Arnez
Quoted 6 lines · Michael Petlan

Hi Andreas,

have you or anyone tested this patch and/or s390 oprofile support in general? I'd love to know more about the results or at least, if there any, what has been tested and what not + whether there are any known issues regarding to HW sampling on s390.

Quoted 4 lines
Quoted 4 lines

IIRC, I just performed a quick smoke test before submitting this patch; and oprofile didn't crash. Other than that, I don't really know what works and what doesn't.

Hi Andreas and Andreas,

Is there support for IBM z13 perf counters in the upstream linux kernel? I didn't see perf support for IBM z13 in the mainline kernel git repository.

There is a difference between the kernel and oprofile is the s390 identification. The kernel is using hex numbers such as 0x2817 and 0x2818 for Z196 identification (http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/s390/kernel/perf_cpum_cf_events.c#n303), but oprofile is reading the numbers as decimal for idenfication (https://sourceforge.net/p/oprofile/oprofile/ci/master/tree/libop/op_cpu_type.c). oprofile should also be using hex numbers like the kernel.

-Will

Quoted 40 lines

Could you please try it with setting /proc/sys/kernel/kptr_restrict to '0' and /proc/sys/kernel/perf_event_paranoid to '-1', being logged as root user?

ophelp -r
--> should detect the machine, print "IBM z13"

ophelp -d
--> should print default event "CPU_CYCLES"

ocount ls
--> should return some non-zero value for event CPU_CYCLES

ocount -e INSTRUCTIONS ls
--> should use INSTRUCTIONS and return a non-zero value too

Please try out also the --system-wide mode as root.

If the above commands work, at least the basic z13 support can be verified.

Quoted 8 lines

Some people mentioned various issues with oprofile on s390, depending on kernel version and environment. Since I'm currently more focused on other projects, I haven't investigated them. Here are some (unconfirmed) examples:

* The --help/--usage options of operf and ocount behave strangely. E.g., they attempt perf_open and just emit a cryptic error message if that fails. And upon success they still yield exit code 1.

Maybe if /proc/sys/kernel/perf_event_paranoid is '2' and the user is not root, this might happen.

Quoted 6 lines

* operf is showing a warning message:

Kernel profiling is not possible with current system config. Set /proc/sys/kernel/kptr_restrict to 0 to collect kernel samples.

Is kptr_restrict set to '0'?

Quoted 14 lines
Quoted 1 line

* Without the --system-wide option, operf generates all-zero statistics.

Does ocount do the same? If yes, the event counting probably does not work as expected.

Thanks!
Michael

Quoted 5 lines
Signature · 2 lines
-- 
Andreas

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot

#8 lore raw
Quoted 8 lines · William Cohen
Quoted 6 lines · Michael Petlan
Quoted 5 lines · Andreas Arnez

IIRC, I just performed a quick smoke test before submitting this patch; and oprofile didn't crash. Other than that, I don't really know what works and what doesn't.

Quoted 5 lines

Hi Andreas and Andreas,

Is there support for IBM z13 perf counters in the upstream linux kernel? I didn't see perf support for IBM z13 in the mainline kernel git repository.

There is a difference between the kernel and oprofile is the s390 identification. The kernel is using hex numbers such as 0x2817 and 0x2818 for Z196 identification (http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/s390/kernel/perf_cpum_cf_events.c#n303), but oprofile is reading the numbers as decimal for idenfication (https://sourceforge.net/p/oprofile/oprofile/ci/master/tree/libop/op_cpu_type.c). oprofile should also be using hex numbers like the kernel.

I have looked at this and although it is not ideal, it works OK in OProfile, since it reads the numbers from string, thus it works with decimals.

I have also checked that zEC12 detection works correctly with 1.1.

Michael

Quoted 3 lines

-Will

Quoted 1 line
#9 lore raw
Quoted 13 lines · Michael Petlan
Quoted 12 lines · William Cohen
Quoted 6 lines · Michael Petlan
Quoted 5 lines · Andreas Arnez

IIRC, I just performed a quick smoke test before submitting this patch; and oprofile didn't crash. Other than that, I don't really know what works and what doesn't.

Hi Andreas and Andreas,

Is there support for IBM z13 perf counters in the upstream linux kernel? I didn't see perf support for IBM z13 in the mainline kernel git repository.

Quoted 8 lines
Quoted 1 line

There is a difference between the kernel and oprofile is the s390 identification. The kernel is using hex numbers such as 0x2817 and 0x2818 for Z196 identification (http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/s390/kernel/perf_cpum_cf_events.c#n303), but oprofile is reading the numbers as decimal for idenfication (https://sourceforge.net/p/oprofile/oprofile/ci/master/tree/libop/op_cpu_type.c). oprofile should also be using hex numbers like the kernel.

I have looked at this and although it is not ideal, it works OK in OProfile, since it reads the numbers from string, thus it works with decimals.

I have also checked that zEC12 detection works correctly with 1.1.

Michael

Yes, the s390 processor detection in oprofile is not ideal with the kernel outputting the id in hex and the oprofile reading it in as a decimal. Good thing that none of the s390 id values have a-f in the digits. Attached is a patch that reads in the values as hex to better line up with the kernel's handling of the s390 identification. Could one of the IBM people try this patch?

-Will

libop/op_cpu_type.c +8 -9
index e70e4f6..ea5ff76 100644
@@ -668,20 +668,19 @@ static op_cpu _get_s390_cpu_type(void)
 		return CPU_NO_GOOD;
 
 	ptr += sizeof(prefix) - 1;
-	if (sscanf(ptr, "%u", &model) != 1)
-		return CPU_NO_GOOD;
+	model = strtol(ptr, NULL, 16);
 
 	switch (model) {
-	case 2097:
-	case 2098:
+	case 0x2097:
+	case 0x2098:
 		return CPU_S390_Z10;
-	case 2817:
-	case 2818:
+	case 0x2817:
+	case 0x2818:
 		return CPU_S390_Z196;
-	case 2827:
-	case 2828:
+	case 0x2827:
+	case 0x2828:
 		return CPU_S390_ZEC12;
-	case 2964:
+	case 0x2964:
 		return CPU_S390_Z13;
 	}
 	return CPU_NO_GOOD;

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot

_______________________________________________
oprofile-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oprofile-list

#11 lore raw
In reply to William Cohen
Quoted 3 lines · William Cohen

Is there support for IBM z13 perf counters in the upstream linux kernel? I didn't see perf support for IBM z13 in the mainline kernel git repository.

To my understanding, there is currently no support for z13-specific counters, but generic counters should still work. This certainly limits the number of available counters on z13 significantly.

--
Andreas

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot

#12 lore raw
Quoted 6 lines · Andreas Arnez
Quoted 3 lines · William Cohen

Is there support for IBM z13 perf counters in the upstream linux kernel? I didn't see perf support for IBM z13 in the mainline kernel git repository.

Quoted 7 lines

To my understanding, there is currently no support for z13-specific counters, but generic counters should still work. This certainly limits the number of available counters on z13 significantly.

--
Andreas

Hi Andreas,

In the past on x86_64 machine if the cpu wasn't identified the performance monitoring hardware would be not used at all. The upstream code arch/s390/kernel/perf_cpum_cf_events.c it doesn't identify the z13, but it does look like it falls back to cpumcf_pmu_event_attr array of events. However, I don't have much experience running things on IBM series machine, so want to verify that things are working on it.

-Will

#10 lore raw
In reply to William Cohen
Quoted 6 lines · William Cohen

Yes, the s390 processor detection in oprofile is not ideal with the kernel outputting the id in hex and the oprofile reading it in as a decimal. Good thing that none of the s390 id values have a-f in the digits. Attached is a patch that reads in the values as hex to better line up with the kernel's handling of the s390 identification. Could one of the IBM people try this patch?

Sure. The patch looks good to me, and I've verified it on one of the affected machines.

--
Andreas