Paolo has a fix, I will try this! Yay!

Alec


----- Forwarded Message -----

From: Paolo Mantegazza <paolo.mantega...@polimi.it>
To: Alec Ari <neotheu...@ymail.com>; RTAI RTAI <r...@rtai.org>
Sent: Friday, April 17, 2020, 2:59:20 PM CDT
Subject: RE: [Rtai] Fw: [Emc-developers] Kernel 4.19 series now added to RTAI 
for LinuxCNC


The fix should be this:

--- base/ipc/shm/shm.c  (revision 69)
+++ base/ipc/shm/shm.c  (working copy)
@@ -264,7 +264,7 @@
{
        unsigned long name;
        int size;
-      if (!vma->vm_ops) {
+      if (1 || !vma->vm_ops) {
                vma->vm_ops = &rtai_shm_vm_ops;
                vma->vm_flags |= VM_LOCKED;
                name = (unsigned long)(vma->vm_private_data = 
rtai_tskext(current, TSKEXT1));

It works back to 4.1.18. It is just a silly change  and, before finalizing and 
committing it, I would like it to be cross checked from your side too. 
Then there is still a thing I must remember/understand. Why I put a validation 
check on vma->vm_ops, which is there from a zillion years, followed by why 
suddenly things changed with linux 4.19.xx.
Cheers, Paolo.

________________________________________

From: Rtai [rtai-boun...@rtai.org] on behalf of Alec Ari [neotheu...@ymail.com]
Sent: Wednesday, April 15, 2020 11:55 PM
To: RTAI RTAI
Subject: [Rtai] Fw: [Emc-developers] Kernel 4.19 series now added to RTAI for 
LinuxCNC

Paolo, do you have any idea what's going on here?

----- Forwarded Message -----

From: andy pugh


OK, so in RTAI this code from src/shm.c:53

static inline void *_rt_shm_alloc(unsigned long name, int size, int suprt)
{
void *adr;

//suprt = USE_GFP_ATOMIC; // to force some testing
    if (!(adr = rt_get_adr_cnt(name)) && size > 0 && suprt >= 0 && 
RT_SHM_OP_PERM()) {
size = ((size - 1) & PAGE_MASK) + PAGE_SIZE;
if (adr = (suprt ? rkmalloc(&size, SUPRT[suprt]) : rvmalloc(size))) {
if (!rt_register(name, adr, suprt ? -size : size, 0)) {
if (suprt) {
                                        rkfree(adr, size);
                                } else {
                                        rvfree(adr, size);
                                }
return 0;
}
memset(ALIGN2PAGE(adr), 0, size);
}
}
    rt_printk("adr = %lx , ALIGN2PAGE(adr) = %lx\n", adr, ALIGN2PAGE(adr));
return ALIGN2PAGE(adr);
}

Prints:
[58253.421443] adr = ffffc90000409000 , ALIGN2PAGE(adr) = ffffc90000409000

And this, from LinuxCNC src/rtapi/rtapi_ulapi.c:101

int rtapi_init(const char *modname)
{
    int n, module_id;
    module_data *module;

    /* say hello */
    rtapi_print_msg(RTAPI_MSG_INFO, "RTAPI: initing module %s\n", modname);
    /* get shared memory block from OS and save its address */
    errno = 0;
    if(!rtapi_data){
        rtapi_print("!rtapi_data, initing\n");
        //rtapi_data = rtai_malloc(RTAPI_KEY, sizeof(rtapi_data_t));
        rtapi_data = (rtapi_data_t*)rt_shm_alloc(RTAPI_KEY, 
sizeof(rtapi_data_t), USE_GFP_ATOMIC);
        rtapi_print("rtapi_data = %p\n", rtapi_data);
    }
    if (rtapi_data == NULL || rtapi_data == MAP_FAILED) {
        rtapi_print_msg(RTAPI_MSG_ERR,
            "RTAPI: ERROR: could not open shared memory (%s)\n",
            (rtapi_data == MAP_FAILED ? "map failed" : strerror(errno)));
        check_memlock_limit("could not open shared memory");
        rtapi_data = 0;
        return -ENOMEM;
    }
    nummods++;

prints:

!rtapi_data, initing
rtapi_data = 0xffffffffffffffff
RTAPI: ERROR: could not open shared memory (map failed)
HAL: ERROR: could not initialize RTAPI


So, somehow and somewhere the adr ( ffffc90000409000 ) is being returned to 
rtapi_data as 0xffffffffffffffff

(the commented-out rtai_malloc is original LinuxCNC, I was trying to takeout a 
layer of macros. Reverting that makes no difference, nor does changing 
USE_GFP_ATOMIC to USE_VMALLOC which is the default)
https://www.rtai.org/userfiles/documentation/magma/html/api/group__shm.html#ga24


--
atp
"A motorcycle is a bicycle with a pandemonium attachment and is designed for 
the especial use of mechanical geniuses, daredevils and lunatics."
— George Fitch, Atlanta Constitution Newspaper, 1912

_______________________________________________
Rtai mailing list
r...@rtai.org
https://mail.rtai.org/cgi-bin/mailman/listinfo/rtai


_______________________________________________
Emc-developers mailing list
Emc-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to