[issue46968] Insufficient sigaltstack size used by CPython prevents extensions from using new ISA

2022-03-11 Thread Oleksandr Pavlyk


Oleksandr Pavlyk  added the comment:

So where getauxval(AT_MINSIGSTKSZ) < SIGSTKSZ the merged changes actually 
resulted in decrease of the allocated signal deliver stack. 

On Sapphire Rapids due to tile registers size we have getauxval(AT_MINSIGSTKSZ) 
> SIGSTKSZ.

This is why the initial proposal was to use SIGSTKSZ + 
max(getauxval(AT_MINSIGSTKSZ), SIGSTKSZ).

I suppose, ultimately I am saying that we should check that bpo-21131 does not 
regress.

--

___
Python tracker 
<https://bugs.python.org/issue46968>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46968] Insufficient sigaltstack size used by CPython prevents extensions from using new ISA

2022-03-09 Thread Oleksandr Pavlyk


Change by Oleksandr Pavlyk :


--
keywords: +patch
pull_requests: +29893
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/31789

___
Python tracker 
<https://bugs.python.org/issue46968>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46968] Insufficient sigaltstack size used by CPython prevents extensions from using new ISA

2022-03-09 Thread Oleksandr Pavlyk


New submission from Oleksandr Pavlyk :

The following snippet illustrates request by an extension to use AMX registers:

```
// no increase sigaltstack size fix will not wark till we fix python
void enable_amx_no_fix()
{

unsigned long bitmask;
long rc;

rc = syscall(SYS_arch_prctl, ARCH_REQ_XCOMP_PERM, XFEATURE_XTILEDATA);
if (rc) {
printf("The kernel rejects the AMX use.\n");
printf("errno %d\n",errno);
} else {
printf("The kernel allows to use AMX.\n");
}


rc = syscall(SYS_arch_prctl, ARCH_GET_XCOMP_PERM, );

if (rc) {
printf("rc error\n");
} else  {
if (( bitmask & XFEATURE_MASK_XTILEDATA) == 0){
printf("verify AMX permission faild bitmask %ld\n",bitmask);
}

}
}
```

This request fails on the account of too small a size for sigaltstack used by 
CPython allocated in Modules/faulthandler.c

The stack size used is 2*SIGSTKSZ, and does not take hardware capabilities into 
account.

Linux kernel 5.14 adds support to query minimum size of sigaltstack dynamically 
via getauxval(AT_MINSIGSTKSZ).

AMX support is added in Linux kernel 5.16 

CPython should make use of this when built against more recent Linux kernels.

--
components: Extension Modules
messages: 414809
nosy: oleksandr-pavlyk
priority: normal
severity: normal
status: open
title: Insufficient sigaltstack size used by CPython prevents extensions from 
using new ISA
type: behavior
versions: Python 3.10, Python 3.11, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue46968>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com