Re: Finding SPARC patches worth upstreaming in the UEK kernel
On 10/25/25 04:56, John Paul Adrian Glaubitz wrote:
Hi,
as many of you may know, Oracle's UEK kernel for SPARC contains a number of improvements
that never made it upstream into the Linux kernel.
I am just now running/building 6.17.5 on both Debian and Gentoo with
the ORACLE S7-2 server. These are inside the hardware LDOM's of
course. There seems to be some things already upstreamed into 6.17.5
mainline with regards to the memcpy asm code. Other things are still
absent.
The patch that myself and other are using looks like :
--- arch/sparc/include/asm/spitfire.h.orig 2025-09-21 15:08:52.000000000
-0700
+++ arch/sparc/include/asm/spitfire.h 2025-09-27 19:34:31.515000000 -0700
@@ -49,6 +49,7 @@
#define SUN4V_CHIP_SPARC_M6 0x06
#define SUN4V_CHIP_SPARC_M7 0x07
#define SUN4V_CHIP_SPARC_M8 0x08
+#define SUN4V_CHIP_SPARC_S7 0x7a
#define SUN4V_CHIP_SPARC64X 0x8a
#define SUN4V_CHIP_SPARC_SN 0x8b
#define SUN4V_CHIP_UNKNOWN 0xff
--- arch/sparc/kernel/cpu.c.orig 2025-09-21 15:08:52.000000000 -0700
+++ arch/sparc/kernel/cpu.c 2025-09-27 19:35:53.631000000 -0700
@@ -512,6 +512,12 @@
sparc_fpu_type = "SPARC-M8 integrated FPU";
sparc_pmu_type = "sparc-m8";
break;
+
+ case SUN4V_CHIP_SPARC_S7:
+ sparc_cpu_type = "SPARC-S7 (Sonoma)";
+ sparc_fpu_type = "SPARC-S7 integrated FPU";
+ sparc_pmu_type = "sparc-s7";
+ break;
case SUN4V_CHIP_SPARC_SN:
sparc_cpu_type = "SPARC-SN";
--- arch/sparc/kernel/head_64.S.orig 2025-09-21 15:08:52.000000000 -0700
+++ arch/sparc/kernel/head_64.S 2025-09-27 19:42:18.848000000 -0700
@@ -421,6 +421,7 @@
cmp %g2, 'M'
be,pt %xcc, 70f
cmp %g2, 'S'
+ be,pt %xcc, 71f
bne,pn %xcc, 49f
nop
@@ -443,9 +444,13 @@
cmp %g2, CPU_ID_M8
be,pt %xcc, 5f
mov SUN4V_CHIP_SPARC_M8, %g4
- cmp %g2, CPU_ID_SONOMA1
+ ba,pt %xcc, 49f
+ nop
+71:
+ ldub [%g1 + 7], %g2
+ cmp %g2, '7'
be,pt %xcc, 5f
- mov SUN4V_CHIP_SPARC_SN, %g4
+ mov SUN4V_CHIP_SPARC_S7, %g4
ba,pt %xcc, 49f
nop
--- arch/sparc/kernel/pcr.c.orig 2025-09-21 15:08:52.000000000 -0700
+++ arch/sparc/kernel/pcr.c 2025-09-27 19:48:58.246000000 -0700
@@ -275,6 +275,7 @@
break;
case SUN4V_CHIP_SPARC_M7:
+ case SUN4V_CHIP_SPARC_S7:
perf_hsvc_group = HV_GRP_M7_PERF;
break;
@@ -324,6 +325,7 @@
break;
case SUN4V_CHIP_SPARC_M7:
+ case SUN4V_CHIP_SPARC_S7:
pcr_ops = &m7_pcr_ops;
break;
--- arch/sparc/kernel/perf_event.c.orig 2025-09-21 15:08:52.000000000 -0700
+++ arch/sparc/kernel/perf_event.c 2025-09-27 20:30:21.664000000 -0700
@@ -1701,7 +1701,9 @@
return true;
}
if (!strcmp(sparc_pmu_type, "niagara4") ||
- !strcmp(sparc_pmu_type, "niagara5")) {
+ !strcmp(sparc_pmu_type, "niagara5") ||
+ !strcmp(sparc_pmu_type, "sparc-m7") ||
+ !strcmp(sparc_pmu_type, "sparc-s7")) {
sparc_pmu = &niagara4_pmu;
return true;
}
--- arch/sparc/kernel/setup_64.c.orig 2025-09-21 15:08:52.000000000 -0700
+++ arch/sparc/kernel/setup_64.c 2025-09-27 19:46:39.849000000 -0700
@@ -278,7 +278,7 @@
switch (sun4v_chip_type) {
case SUN4V_CHIP_SPARC_M7:
case SUN4V_CHIP_SPARC_M8:
- case SUN4V_CHIP_SPARC_SN:
+ case SUN4V_CHIP_SPARC_S7:
sun4v_patch_1insn_range(&__sun_m7_1insn_patch,
&__sun_m7_1insn_patch_end);
sun_m7_patch_2insn_range(&__sun_m7_2insn_patch,
@@ -531,6 +531,7 @@
sun4v_chip_type == SUN4V_CHIP_SPARC_M6 ||
sun4v_chip_type == SUN4V_CHIP_SPARC_M7 ||
sun4v_chip_type == SUN4V_CHIP_SPARC_M8 ||
+ sun4v_chip_type == SUN4V_CHIP_SPARC_S7 ||
sun4v_chip_type == SUN4V_CHIP_SPARC_SN ||
sun4v_chip_type == SUN4V_CHIP_SPARC64X)
cap |= HWCAP_SPARC_BLKINIT;
@@ -541,6 +542,7 @@
sun4v_chip_type == SUN4V_CHIP_SPARC_M6 ||
sun4v_chip_type == SUN4V_CHIP_SPARC_M7 ||
sun4v_chip_type == SUN4V_CHIP_SPARC_M8 ||
+ sun4v_chip_type == SUN4V_CHIP_SPARC_S7 ||
sun4v_chip_type == SUN4V_CHIP_SPARC_SN ||
sun4v_chip_type == SUN4V_CHIP_SPARC64X)
cap |= HWCAP_SPARC_N2;
@@ -572,6 +574,7 @@
sun4v_chip_type == SUN4V_CHIP_SPARC_M6 ||
sun4v_chip_type == SUN4V_CHIP_SPARC_M7 ||
sun4v_chip_type == SUN4V_CHIP_SPARC_M8 ||
+ sun4v_chip_type == SUN4V_CHIP_SPARC_S7 ||
sun4v_chip_type == SUN4V_CHIP_SPARC_SN ||
sun4v_chip_type == SUN4V_CHIP_SPARC64X)
cap |= (AV_SPARC_VIS | AV_SPARC_VIS2 |
@@ -583,6 +586,7 @@
sun4v_chip_type == SUN4V_CHIP_SPARC_M6 ||
sun4v_chip_type == SUN4V_CHIP_SPARC_M7 ||
sun4v_chip_type == SUN4V_CHIP_SPARC_M8 ||
+ sun4v_chip_type == SUN4V_CHIP_SPARC_S7 ||
sun4v_chip_type == SUN4V_CHIP_SPARC_SN ||
sun4v_chip_type == SUN4V_CHIP_SPARC64X)
cap |= (AV_SPARC_VIS3 | AV_SPARC_HPC |
--- arch/sparc/mm/init_64.c.orig 2025-09-21 15:08:52.000000000 -0700
+++ arch/sparc/mm/init_64.c 2025-09-27 19:47:31.836000000 -0700
@@ -1989,6 +1989,7 @@
max_phys_bits = 47;
break;
case SUN4V_CHIP_SPARC_M7:
+ case SUN4V_CHIP_SPARC_S7:
case SUN4V_CHIP_SPARC_SN:
/* M7 and later support 52-bit virtual addresses. */
sparc64_va_hole_top = 0xfff8000000000000UL;
@@ -2218,6 +2219,7 @@
switch (sun4v_chip_type) {
case SUN4V_CHIP_SPARC_M7:
case SUN4V_CHIP_SPARC_M8:
+ case SUN4V_CHIP_SPARC_S7:
case SUN4V_CHIP_SPARC_SN:
pagecv_flag = 0x00;
break;
@@ -2333,6 +2335,7 @@
switch (sun4v_chip_type) {
case SUN4V_CHIP_SPARC_M7:
case SUN4V_CHIP_SPARC_M8:
+ case SUN4V_CHIP_SPARC_S7:
case SUN4V_CHIP_SPARC_SN:
page_cache4v_flag = _PAGE_CP_4V;
break;
--- drivers/block/sunvdc.c.orig 2025-09-21 15:08:52.000000000 -0700
+++ drivers/block/sunvdc.c 2025-09-27 19:32:44.355000000 -0700
@@ -45,8 +45,6 @@
#define WAITING_FOR_GEN_CMD 0x04
#define WAITING_FOR_ANY -1
-#define VDC_MAX_RETRIES 10
-
static struct workqueue_struct *sunvdc_wq;
struct vdc_req_entry {
@@ -437,7 +435,6 @@
.end_idx = dr->prod,
};
int err, delay;
- int retries = 0;
hdr.seq = dr->snd_nxt;
delay = 1;
@@ -450,8 +447,6 @@
udelay(delay);
if ((delay <<= 1) > 128)
delay = 128;
- if (retries++ > VDC_MAX_RETRIES)
- break;
} while (err == -EAGAIN);
if (err == -ENOTCONN)
I have not pushed this around too much but the LDOM has reasonable
resources for some testing :
helios$
helios$ uname -a
Linux helios 6.17.5-genunix #1 SMP Thu Oct 23 21:39:43 UTC 2025 sparc64
GNU/Linux
helios$
helios$ cat /etc/debian_version
forky/sid
helios$
helios$ lscpu
Architecture: sparc64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Big Endian
CPU(s): 32
On-line CPU(s) list: 0-31
Model name: SPARC-S7 (Sonoma)
Thread(s) per core: 8
Core(s) per socket: 4
Socket(s): 1
Flags: sun4v
Caches (sum of all):
L1d: 512 KiB (32 instances)
L1i: 512 KiB (32 instances)
L2: 8 MiB (32 instances)
NUMA:
NUMA node(s): 1
NUMA node0 CPU(s): 0-31
helios$
helios$ head /proc/meminfo
MemTotal: 66361344 kB
MemFree: 65775416 kB
MemAvailable: 65664032 kB
Buffers: 28000 kB
Cached: 178184 kB
SwapCached: 0 kB
Active: 174608 kB
Inactive: 55336 kB
Active(anon): 34712 kB
Inactive(anon): 0 kB
helios$
Single threaded FPU type tests are terrible performance compared to a
Fujitsu SPARC64 processor iff the gcc optimization flags are absent.
With full optimizations we get reasonable single threaded FPU type
throughput where the numbers are correct also. About what you would
expect from a RPi5. I am running a few hand coded tests that push the
LDOM into severe memory pressure as well as CPU load. See oom killer
statement attached. Thus far no magic smoke[1] seen and I do not think
there is an ORACLE Part number for that.
--
--
Dennis Clarke
RISC-V/SPARC/PPC/ARM/CISC
UNIX and Linux spoken
[1] https://en.wikipedia.org/wiki/Magic_smoke#Usage
[86812.238609] q_work invoked oom-killer: gfp_mask=0x140cca(GFP_HIGHUSER_MOVABLE|__GFP_COMP), order=0, oom_score_adj=0
[86812.238662] CPU: 14 UID: 16411 PID: 2430 Comm: q_work Tainted: G W 6.17.5-genunix #1 NONE
[86812.238675] Tainted: [W]=WARN
[86812.238679] Call Trace:
[86812.238683] [<00000000004383e0>] dump_stack+0x8/0x20
[86812.238698] [<000000000042d010>] dump_header+0x30/0x1ec
[86812.238709] [<0000000000733314>] oom_kill_process+0x254/0x2e0
[86812.238720] [<0000000000733c0c>] out_of_memory+0xec/0x660
[86812.238729] [<00000000007c5384>] __alloc_pages_slowpath.constprop.0+0xa24/0xf80
[86812.238741] [<00000000007c5c14>] __alloc_frozen_pages_noprof+0x334/0x380
[86812.238749] [<00000000007f8ae4>] alloc_pages_mpol+0x84/0x200
[86812.238757] [<00000000007fb1ec>] vma_alloc_folio_noprof+0x6c/0x140
[86812.238766] [<000000000079274c>] __handle_mm_fault+0xc2c/0x1340
[86812.238778] [<0000000000792f64>] handle_mm_fault+0x104/0x320
[86812.238787] [<000000000124600c>] do_sparc64_fault+0x7ec/0xc40
[86812.238798] [<0000000000407714>] sparc64_realfault_common+0x10/0x20
[86812.238810] Mem-Info:
[86812.238982] active_anon:6140312 inactive_anon:2091825 isolated_anon:0
[86812.238982] active_file:0 inactive_file:1629 isolated_file:0
[86812.238982] unevictable:2845 dirty:0 writeback:0
[86812.238982] slab_reclaimable:4516 slab_unreclaimable:19512
[86812.238982] mapped:2289 shmem:28 pagetables:10324
[86812.238982] sec_pagetables:0 bounce:0
[86812.238982] kernel_misc_reclaimable:0
[86812.238982] free:12344 free_pcp:2705 free_cma:0
[86812.239072] Node 0 active_anon:49122496kB inactive_anon:16734600kB active_file:0kB inactive_file:12064kB unevictable:22760kB isolated(anon):0kB isolated(file):0kB mapped:18312kB dirty:0kB writeback:0kB shmem:224kB shmem_thp:0kB shmem_pmdmapped:0kB anon_thp:48021504kB kernel_stack:5808kB pagetables:82592kB sec_pagetables:0kB all_unreclaimable? no Balloon:0kB
[86812.239143] Node 0 Normal free:100688kB boost:0kB min:90112kB low:156160kB high:222208kB reserved_highatomic:0KB free_highatomic:0KB active_anon:49122496kB inactive_anon:16734600kB active_file:0kB inactive_file:12064kB unevictable:22760kB writepending:0kB present:67094040kB managed:66361344kB mlocked:22760kB bounce:0kB free_pcp:20136kB local_pcp:432kB free_cma:0kB
[86812.239203] lowmem_reserve[]: 0 0
[86812.239230] Node 0 Normal: 210*8kB (UME) 144*16kB (UME) 145*32kB (UME) 95*64kB (UME) 100*128kB (UME) 46*256kB (UME) 18*512kB (UME) 6*1024kB (UME) 3*2048kB (ME) 9*4096kB (UM) 0*8192kB 0*16384kB 0*32768kB = 97648kB
[86812.239407] Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=64kB
[86812.239433] Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=8192kB
[86812.239456] Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=262144kB
[86812.239481] Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=2097152kB
[86812.239509] 3984 total pagecache pages
[86812.239525] 2162 pages in swap cache
[86812.239541] Free swap = 0kB
[86812.239556] Total swap = 15625208kB
[86812.239573] 8386755 pages RAM
[86812.239588] 0 pages HighMem/MovableOnly
[86812.239603] 91587 pages reserved
[86812.239620] 0 pages cma reserved
[86812.239637] Tasks state (memory values in pages):
[86812.239655] [ pid ] uid tgid total_vm rss rss_anon rss_file rss_shmem pgtables_bytes swapents oom_score_adj name
[86812.239706] [ 530] 0 530 11427 1363 128 1235 0 172032 0 -250 systemd-journal
[86812.239745] [ 589] 0 589 7794 1005 0 1005 0 139264 192 -1000 systemd-udevd
[86812.239783] [ 763] 0 763 2216 270 0 270 0 90112 0 0 cron
[86812.239810] [ 766] 989 766 3475 407 0 407 0 98304 0 -900 dbus-daemon
[86812.239841] [ 770] 0 770 5627 1182 192 990 0 122880 0 0 systemd-logind
[86812.239878] [ 794] 0 794 1746 205 0 205 0 81920 0 0 agetty
[86812.239911] [ 795] 0 795 8581 675 128 547 0 163840 0 0 login
[86812.239949] [ 800] 101 800 13033 2765 1302 1463 0 122880 0 0 ntpd
[86812.239985] [ 808] 0 808 2378 853 128 725 0 90112 0 -1000 sshd
[86812.240017] [ 834] 0 834 5752 1392 256 1136 0 122880 0 100 systemd
[86812.240048] [ 836] 0 836 9932 432 157 275 0 172032 64 100 (sd-pam)
[86812.240084] [ 846] 0 846 1525 539 128 411 0 73728 64 0 bash
[86812.240118] [ 1535] 0 1535 11113 1376 256 1120 0 188416 0 0 sshd-session
[86812.240155] [ 1540] 16411 1540 5765 1392 256 1136 0 131072 0 100 systemd
[86812.240195] [ 1542] 16411 1542 9934 498 223 275 0 172032 0 100 (sd-pam)
[86812.240235] [ 1556] 16411 1556 11146 913 253 660 0 188416 0 0 sshd-session
[86812.240271] [ 1557] 16411 1557 1527 542 192 350 0 73728 0 0 bash
[86812.240306] [ 1810] 0 1810 11113 1376 256 1120 0 188416 0 0 sshd-session
[86812.240342] [ 1817] 16411 1817 11146 913 253 660 0 188416 0 0 sshd-session
[86812.240376] [ 1818] 16411 1818 1527 739 320 419 0 73728 0 0 bash
[86812.240410] [ 2138] 0 2138 11113 1376 256 1120 0 188416 0 0 sshd-session
[86812.240442] [ 2143] 1000 2143 5765 1200 64 1136 0 131072 192 100 systemd
[86812.240479] [ 2145] 1000 2145 9934 275 0 275 0 180224 256 100 (sd-pam)
[86812.240514] [ 2157] 1000 2157 11146 913 253 660 0 188416 0 0 sshd-session
[86812.240553] [ 2158] 1000 2158 1513 471 192 279 0 73728 0 0 bash
[86812.240629] [ 2305] 1000 2305 2089 528 128 400 0 81920 0 0 htop
[86812.240671] [ 2424] 16411 2424 17072906 8228971 8228835 136 0 82288640 1950272 0 q_work
[86812.240712] [ 2457] 0 2457 5053 202 0 202 0 122880 0 0 cron
[86812.240752] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/user.slice/user-16411.slice/session-35.scope,task=q_work,pid=2424,uid=16411
[86812.240891] Out of memory: Killed process 2424 (q_work) total-vm:136583248kB, anon-rss:65831704kB, file-rss:1088kB, shmem-rss:0kB, UID:16411 pgtables:80360kB oom_score_adj:0
[86830.317633] oom_reaper: reaped process 2424 (q_work), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
helios#
Reply to: