{"action":"created","issue":{"url":"https://api.github.com/repos/SnabbCo/snabbswitch/issues/589","labels_url":"https://api.github.com/repos/SnabbCo/snabbswitch/issues/589/labels{/name}","comments_url":"https://api.github.com/repos/SnabbCo/snabbswitch/issues/589/comments","events_url":"https://api.github.com/repos/SnabbCo/snabbswitch/issues/589/events","html_url":"https://github.com/SnabbCo/snabbswitch/pull/589","id":99685445,"number":589,"title":"core.memory: Catch SIGSEGV to map DMA memory [PoC]","user":{"login":"lukego","id":13791,"avatar_url":"https://avatars.githubusercontent.com/u/13791?v=3","gravatar_id":"","url":"https://api.github.com/users/lukego","html_url":"https://github.com/lukego","followers_url":"https://api.github.com/users/lukego/followers","following_url":"https://api.github.com/users/lukego/following{/other_user}","gists_url":"https://api.github.com/users/lukego/gists{/gist_id}","starred_url":"https://api.github.com/users/lukego/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukego/subscriptions","organizations_url":"https://api.github.com/users/lukego/orgs","repos_url":"https://api.github.com/users/lukego/repos","events_url":"https://api.github.com/users/lukego/events{/privacy}","received_events_url":"https://api.github.com/users/lukego/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-07T16:44:40Z","updated_at":"2015-08-07T16:45:50Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/SnabbCo/snabbswitch/pulls/589","html_url":"https://github.com/SnabbCo/snabbswitch/pull/589","diff_url":"https://github.com/SnabbCo/snabbswitch/pull/589.diff","patch_url":"https://github.com/SnabbCo/snabbswitch/pull/589.patch"},"body":"This is a quick and dirty proof-of-concept hack done to support SnabbCo/snabbswitch#565 (multicore tests):\r\n\r\nExtend core.memory so that the virtual addresses of all packets are\r\nvalid in all Snabb Switch processes. The memory allocated by\r\nmemory.dma_alloc() is treated specially: if another process tries to\r\naccess it then this triggers a SIGSEGV handler that will detect which\r\nmemory is needed and automatically map it into the process.\r\n\r\nTwo simple test scripts are provided: s1 that allocates memory and s2\r\nthat modifies it without any explicit mapping.\r\n\r\nRun like this:\r\n\r\n    $ sudo ./snabb snsh s1\r\n    Installing SIGSEGV handler\r\n    address cdata<char *>: 0x5009f7c00000\r\n    current value = 0\r\n    current value = 0\r\n    current value = 0\r\n    ...\r\n\r\nThen use the same address to change the value with s2 that simply\r\nconverts it to a pointer and pokes it:\r\n\r\n    $ make && sudo strace  ./snabb snsh s2 0x5009f7c00000 42\r\n\r\nand now you see the new value in s1:\r\n\r\n    current value = 42\r\n\r\nThis is really quick and dirty! I will clean it up if it works and we decide to keep it.\r\n\r\ncc @javierguerragiraldez "},"comment":{"url":"https://api.github.com/repos/SnabbCo/snabbswitch/issues/comments/128760842","html_url":"https://github.com/SnabbCo/snabbswitch/pull/589#issuecomment-128760842","issue_url":"https://api.github.com/repos/SnabbCo/snabbswitch/issues/589","id":128760842,"user":{"login":"lukego","id":13791,"avatar_url":"https://avatars.githubusercontent.com/u/13791?v=3","gravatar_id":"","url":"https://api.github.com/users/lukego","html_url":"https://github.com/lukego","followers_url":"https://api.github.com/users/lukego/followers","following_url":"https://api.github.com/users/lukego/following{/other_user}","gists_url":"https://api.github.com/users/lukego/gists{/gist_id}","starred_url":"https://api.github.com/users/lukego/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukego/subscriptions","organizations_url":"https://api.github.com/users/lukego/orgs","repos_url":"https://api.github.com/users/lukego/repos","events_url":"https://api.github.com/users/lukego/events{/privacy}","received_events_url":"https://api.github.com/users/lukego/received_events","type":"User","site_admin":false},"created_at":"2015-08-07T16:45:50Z","updated_at":"2015-08-07T16:45:50Z","body":"This was the least disgusting implementation I could come up with when browsing kernel sources etc. The shm syscalls are really annoying and non-interoperable with other kernel features, but we seem to be stuck with them because `mremap()` doesn't work with hugetlb from mmap(). C'est la vie.\r\n\r\nWeekend!"}}