Re: [PATCH 1/1] epoll: call final ep_events_available() check under the lock

2020-05-05 Thread Roman Penyaev
On 2020-05-05 22:03, Andrew Morton wrote: On Tue, 05 May 2020 10:42:05 +0200 Roman Penyaev wrote: May I ask you to remove "epoll: ensure ep_poll() doesn't miss wakeup events" from your -mm queue? Jason lately found out that the patch does not fully solve the problem and this

[PATCH v2] epoll: call final ep_events_available() check under the lock

2020-05-05 Thread Roman Penyaev
_pending() check was added: c257a340ede0 ("fs, epoll: short circuit fetching events if thread has been killed"). Fixes: 339ddb53d373 ("fs/epoll: remove unnecessary wakeups of nested epoll") Signed-off-by: Roman Penyaev Reported-by: Jason Baron Reviewed-by: Jason Baron Cc: Andre

Re: [PATCH 1/1] epoll: call final ep_events_available() check under the lock

2020-05-05 Thread Roman Penyaev
the final check under the lock). Previous changes are not needed. Thanks. -- Roman On 2020-05-05 10:40, Roman Penyaev wrote: The original problem was described here: https://lkml.org/lkml/2020/4/27/1121 There is a possible race when ep_scan_ready_list() leaves ->rdllist and ->obflist emp

[PATCH 1/1] epoll: call final ep_events_available() check under the lock

2020-05-05 Thread Roman Penyaev
hort circuit fetching events if thread has been killed"). Signed-off-by: Roman Penyaev Reported-by: Jason Baron Cc: Andrew Morton Cc: Khazhismel Kumykov Cc: Alexander Viro Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: sta...@vger.kernel.or

Re: [PATCH] epoll: ensure ep_poll() doesn't miss wakeup events

2020-05-04 Thread Roman Penyaev
On 2020-05-04 06:59, Jason Baron wrote: On 5/4/20 12:29 AM, Jason Baron wrote: On 5/3/20 6:24 AM, Roman Penyaev wrote: On 2020-05-02 00:09, Jason Baron wrote: On 5/1/20 5:02 PM, Roman Penyaev wrote: Hi Jason, That is indeed a nice catch. Seems we need smp_rmb() pair between

Re: [PATCH] epoll: ensure ep_poll() doesn't miss wakeup events

2020-05-03 Thread Roman Penyaev
On 2020-05-02 00:09, Jason Baron wrote: On 5/1/20 5:02 PM, Roman Penyaev wrote: Hi Jason, That is indeed a nice catch. Seems we need smp_rmb() pair between list_empty_careful(&rp->rdllist) and READ_ONCE(ep->ovflist) for ep_events_available(), do we? Hi Roman, Good point, even i

Re: [PATCH] epoll: ensure ep_poll() doesn't miss wakeup events

2020-05-01 Thread Roman Penyaev
Hi Jason, That is indeed a nice catch. Seems we need smp_rmb() pair between list_empty_careful(&rp->rdllist) and READ_ONCE(ep->ovflist) for ep_events_available(), do we? Other than that: Reviewed-by: Roman Penyaev -- Roman On 2020-05-01 21:15, Jason Baron wrote: No

[PATCH 1/2] kselftests: introduce new epoll60 testcase for catching lost wakeups

2020-04-30 Thread Roman Penyaev
n ep_poll_callback") the other problem is when several sequential events hit the same waiting thread, thus other waiters get no wakeups. Problem is fixed in the following patch. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Khazhismel Kumykov Cc: Alexander Viro Cc: Heiher Cc: Jaso

[PATCH 2/2] epoll: atomically remove wait entry on wake up

2020-04-30 Thread Roman Penyaev
" represents overall time spent doing the benchmark, thus lower is better) [1] tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c [2] https://github.com/rouming/test-tools/blob/master/stress-epoll.c Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Khazhismel Kumykov Cc: Alex

Re: [PATCH v2] eventpoll: fix missing wakeup for ovflist in ep_poll_callback

2020-04-29 Thread Roman Penyaev
On 2020-04-29 06:12, Jason Baron wrote: On 4/28/20 2:10 PM, Roman Penyaev wrote: On 2020-04-27 22:38, Jason Baron wrote: On 4/25/20 4:59 PM, Khazhismel Kumykov wrote: On Sat, Apr 25, 2020 at 9:17 AM Jason Baron wrote: On 4/24/20 3:00 PM, Khazhismel Kumykov wrote: In the event that we add

Re: [PATCH v2] eventpoll: fix missing wakeup for ovflist in ep_poll_callback

2020-04-28 Thread Roman Penyaev
On 2020-04-27 22:38, Jason Baron wrote: On 4/25/20 4:59 PM, Khazhismel Kumykov wrote: On Sat, Apr 25, 2020 at 9:17 AM Jason Baron wrote: On 4/24/20 3:00 PM, Khazhismel Kumykov wrote: In the event that we add to ovflist, before 339ddb53d373 we would be woken up by ep_scan_ready_list, and di

Re: [PATCH] selftests: add epoll selftests

2019-10-09 Thread Roman Penyaev
up, i.e. selftests/epoll? Reviewed-by: Roman Penyaev -- Roman

Re: [PATCH RESEND v5] fs/epoll: Remove unnecessary wakeups of nested epoll

2019-10-09 Thread Roman Penyaev
ll-wakeup Cc: Al Viro Cc: Andrew Morton Cc: Davide Libenzi Cc: Davidlohr Bueso Cc: Dominik Brodowski Cc: Eric Wong Cc: Jason Baron Cc: Linus Torvalds Cc: Roman Penyaev Cc: Sridhar Samudrala Cc: linux-kernel@vger.kernel.org Cc: linux-fsde...@vger.kernel.org Signed-off-by: hev --- fs/

Re: [PATCH RESEND v4] fs/epoll: Remove unnecessary wakeups of nested epoll that in ET mode

2019-10-08 Thread Roman Penyaev
On 2019-10-07 20:43, Jason Baron wrote: [...] But what if to make this wakeup explicit if we have more events to process? (nothing is tested, just a guess) @@ -255,6 +255,7 @@ struct ep_pqueue {  struct ep_send_events_data {     int maxevents;     struct epoll_event __user *events; + 

Re: [PATCH RESEND v4] fs/epoll: Remove unnecessary wakeups of nested epoll that in ET mode

2019-10-07 Thread Roman Penyaev
On 2019-10-07 20:43, Jason Baron wrote: On 10/7/19 2:30 PM, Roman Penyaev wrote: On 2019-10-07 18:42, Jason Baron wrote: On 10/7/19 6:54 AM, Roman Penyaev wrote: On 2019-10-03 18:13, Jason Baron wrote: On 9/30/19 7:55 AM, Roman Penyaev wrote: On 2019-09-28 04:29, Andrew Morton wrote: On

Re: [PATCH RESEND v4] fs/epoll: Remove unnecessary wakeups of nested epoll that in ET mode

2019-10-07 Thread Roman Penyaev
On 2019-10-07 18:42, Jason Baron wrote: On 10/7/19 6:54 AM, Roman Penyaev wrote: On 2019-10-03 18:13, Jason Baron wrote: On 9/30/19 7:55 AM, Roman Penyaev wrote: On 2019-09-28 04:29, Andrew Morton wrote: On Wed, 25 Sep 2019 09:56:03 +0800 hev wrote: From: Heiher Take the case where we

Re: [PATCH RESEND v4] fs/epoll: Remove unnecessary wakeups of nested epoll that in ET mode

2019-10-07 Thread Roman Penyaev
On 2019-10-03 18:13, Jason Baron wrote: On 9/30/19 7:55 AM, Roman Penyaev wrote: On 2019-09-28 04:29, Andrew Morton wrote: On Wed, 25 Sep 2019 09:56:03 +0800 hev wrote: From: Heiher Take the case where we have:     t0 | (ew)     e0 | (et)     e1

Re: [PATCH RESEND v4] fs/epoll: Remove unnecessary wakeups of nested epoll that in ET mode

2019-09-30 Thread Roman Penyaev
On 2019-09-28 04:29, Andrew Morton wrote: On Wed, 25 Sep 2019 09:56:03 +0800 hev wrote: From: Heiher Take the case where we have: t0 | (ew) e0 | (et) e1 | (lt) s0 t0: thread 0 e0: epoll fd 0 e1: epoll fd 1 s0: socket fd 0 ew: epoll

Re: [PATCH RESEND v4] fs/epoll: Remove unnecessary wakeups of nested epoll that in ET mode

2019-09-28 Thread Roman Penyaev
On 2019-09-28 04:29, Andrew Morton wrote: On Wed, 25 Sep 2019 09:56:03 +0800 hev wrote: From: Heiher Take the case where we have: t0 | (ew) e0 | (et) e1 | (lt) s0 t0: thread 0 e0: epoll fd 0 e1: epoll fd 1 s0: socket fd 0 ew: epoll

Re: [PATCH] epoll: simplify ep_poll_safewake() for CONFIG_DEBUG_LOCK_ALLOC

2019-09-24 Thread Roman Penyaev
On 2019-09-24 19:34, Jason Baron wrote: On 9/23/19 3:23 PM, Roman Penyaev wrote: On 2019-09-23 17:43, Jason Baron wrote: On 9/4/19 4:22 PM, Jason Baron wrote: Currently, ep_poll_safewake() in the CONFIG_DEBUG_LOCK_ALLOC case uses ep_call_nested() in order to pass the correct subclass

Re: [PATCH] epoll: simplify ep_poll_safewake() for CONFIG_DEBUG_LOCK_ALLOC

2019-09-23 Thread Roman Penyaev
for epoll depth and loops that are already verified when doing EPOLL_CTL_ADD. This mirrors a conversion that was done for !CONFIG_DEBUG_LOCK_ALLOC in: commit 37b5e5212a44 ("epoll: remove ep_call_nested() from ep_eventpoll_poll()") Signed-off-by: Jason Baron Cc: Davidlohr Bueso Cc: Rom

Re: [PATCH RESEND] fs/epoll: fix the edge-triggered mode for nested epoll

2019-09-05 Thread Roman Penyaev
:02 PM Heiher wrote: > > Hi, > > On Wed, Sep 4, 2019 at 8:02 PM Jason Baron wrote: > > > > > > > > On 9/4/19 5:57 AM, Roman Penyaev wrote: > > > On 2019-09-03 23:08, Jason Baron wrote: > > >> On 9/2/19 11:36 AM, Roman Penyaev wrote: >

Re: [PATCH RESEND] fs/epoll: fix the edge-triggered mode for nested epoll

2019-09-04 Thread Roman Penyaev
On 2019-09-03 23:08, Jason Baron wrote: On 9/2/19 11:36 AM, Roman Penyaev wrote: Hi, This is indeed a bug. (quick side note: could you please remove efd[1] from your test, because it is not related to the reproduction of a current bug). Your patch lacks a good description, what exactly you&#x

Re: [PATCH RESEND] fs/epoll: fix the edge-triggered mode for nested epoll

2019-09-02 Thread Roman Penyaev
se(efd[1]); close(efd[0]); close(sfd[0]); close(sfd[1]); printf("PASS\n"); return 0; out: printf("FAIL\n"); return -1; } Cc: Al Viro Cc: Andrew Morton Cc: Davide Libenzi Cc: Davidlohr Bueso Cc: Dominik Brodows

Re: [PATCH v5 00/14] epoll: support pollable epoll from userspace

2019-06-25 Thread Roman Penyaev
On 2019-06-24 22:38, Linus Torvalds wrote: On Mon, Jun 24, 2019 at 10:42 PM Roman Penyaev wrote: So harvesting events from userspace gives 15% gain. Though bench_http is not ideal benchmark, but at least it is the part of libevent and was easy to modify. Worth to mention that uepoll is

Re: [PATCH v5 00/14] epoll: support pollable epoll from userspace

2019-06-25 Thread Roman Penyaev
On 2019-06-25 02:24, Eric Wong wrote: Roman Penyaev wrote: Hi all, +cc Jason Baron ** Limitations 4. No support for EPOLLEXCLUSIVE If device does not pass pollflags to wake_up() there is no way to call poll() from the context under spinlock, thus special work is

Re: [PATCH v5 13/14] epoll: implement epoll_create2() syscall

2019-06-24 Thread Roman Penyaev
On 2019-06-24 18:14, Arnd Bergmann wrote: On Mon, Jun 24, 2019 at 4:42 PM Roman Penyaev wrote: epoll_create2() is needed to accept EPOLL_USERPOLL flags and size, i.e. this patch wires up polling from userspace. Can you explain in the patch description more what it's needed for? Sure.

[PATCH v5 01/14] epoll: move private helpers from a header to the source

2019-06-24 Thread Roman Penyaev
Those helpers will access private eventpoll structure in future patches, so keep those helpers close to callers. Nothing important here. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- fs

[PATCH v5 02/14] epoll: introduce user structures for polling from userspace

2019-06-24 Thread Roman Penyaev
This one introduces structures of user items array: struct epoll_uheader - describes inserted epoll items. struct epoll_uitem - single epoll item visible to userspace. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc

[PATCH v5 00/14] epoll: support pollable epoll from userspace

2019-06-24 Thread Roman Penyaev
d. * Is there any testing app available? There is a small app [2] which starts many threads with many event fds and produces many events, while single consumer fetches them from userspace and goes to kernel from time to time in order to wait. Also libevent modification [1] is available, see &qu

[PATCH v5 05/14] epoll: offload polling to a work in case of epfd polled from userspace

2019-06-24 Thread Roman Penyaev
ng patches. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- fs/eventpoll.c | 131 - 1 file changed, 107 insertions(+), 24 deletions(-) diff

[PATCH v5 10/14] epoll: support polling from userspace for ep_modify()

2019-06-24 Thread Roman Penyaev
When epfd is polled from userspace and item is being modified: 1. Update user item with new pointer or poll flags. 2. Add event to user ring if needed. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel

[PATCH v5 09/14] epoll: support polling from userspace for ep_remove()

2019-06-24 Thread Roman Penyaev
On ep_remove() simply mark a user item with EPOLLREMOVE if the item was ready (i.e. has some bits set). That will prevent further user index entry creation on item ->bit reuse. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org

[PATCH v5 04/14] epoll: some sanity flags checks for epoll syscalls for polling from userspace

2019-06-24 Thread Roman Penyaev
) for epfd, created with EPOLL_USERPOLL flag, accepts events as NULL and maxevents as 0. No other values are accepted. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- fs/eventpoll.c

[PATCH v5 06/14] epoll: introduce helpers for adding/removing events to uring

2019-06-24 Thread Roman Penyaev
(): o user item is marked as EPOLLREMOVED only if it was ready, thus userspace will obseve previously added entry in index uring and correct "removed" state of the item. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: Peter Zi

[PATCH v5 13/14] epoll: implement epoll_create2() syscall

2019-06-24 Thread Roman Penyaev
epoll_create2() is needed to accept EPOLL_USERPOLL flags and size, i.e. this patch wires up polling from userspace. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Arnd Bergmann Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- arch

[PATCH v5 08/14] epoll: support polling from userspace for ep_insert()

2019-06-24 Thread Roman Penyaev
When epfd is polled by userspace and new item is inserted new bit should be get from a bitmap and then user item is set accordingly. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- fs

[PATCH v5 12/14] epoll: support mapping for epfd when polled from userspace

2019-06-24 Thread Roman Penyaev
User has to mmap user_header and user_index vmalloce'd pointers in order to consume events from userspace. Also we do not let any copies of vma on fork(). Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-k

[PATCH v5 14/14] kselftest: add uepoll-test which tests polling from userspace

2019-06-24 Thread Roman Penyaev
Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/uepoll/.gitignore | 1 + tools/testing/selftests/uepoll

[PATCH v5 07/14] epoll: call ep_add_event_to_uring() from ep_poll_callback()

2019-06-24 Thread Roman Penyaev
call from another cpu. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- fs/eventpoll.c | 38 ++ 1 file changed, 38 insertions(+) diff --git a/fs/eventpoll.c b

[PATCH v5 11/14] epoll: support polling from userspace for ep_poll()

2019-06-24 Thread Roman Penyaev
Rule of thumb for epfd polled from userspace is simple: epfd has events if ->head != ->tail, no traversing of each item is performed. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org -

[PATCH v5 03/14] epoll: allocate user header and user events ring for polling from userspace

2019-06-24 Thread Roman Penyaev
be corrupted or observed correctly. For these archs -EOPNOTSUP is returned. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- fs/eventpoll.c |

Re: [BUG]: mm/vmalloc: uninitialized variable access in pcpu_get_vm_areas

2019-06-17 Thread Roman Penyaev
On 2019-06-17 16:44, Arnd Bergmann wrote: On Mon, Jun 17, 2019 at 4:12 PM Uladzislau Rezki wrote: On Mon, Jun 17, 2019 at 02:14:11PM +0200, Arnd Bergmann wrote: > gcc points out some obviously broken code in linux-next > > mm/vmalloc.c: In function 'pcpu_get_vm_areas': > mm/vmalloc.c:991:4: er

Re: [BUG]: mm/vmalloc: uninitialized variable access in pcpu_get_vm_areas

2019-06-17 Thread Roman Penyaev
On 2019-06-17 16:04, Arnd Bergmann wrote: On Mon, Jun 17, 2019 at 3:49 PM Roman Penyaev wrote: > augment_tree_propagate_from(va); > > - if (type == NE_FIT_TYPE) > - insert_vmap_area_augment(lva,

Re: [BUG]: mm/vmalloc: uninitialized variable access in pcpu_get_vm_areas

2019-06-17 Thread Roman Penyaev
On 2019-06-17 14:14, Arnd Bergmann wrote: gcc points out some obviously broken code in linux-next mm/vmalloc.c: In function 'pcpu_get_vm_areas': mm/vmalloc.c:991:4: error: 'lva' may be used uninitialized in this function [-Werror=maybe-uninitialized] insert_vmap_area_augment(lva, &va->rb_nod

Re: [PATCH] mm/vmalloc: Check absolute error return from vmap_[p4d|pud|pmd|pte]_range()

2019-06-13 Thread Roman Penyaev
On 2019-06-13 10:12, Anshuman Khandual wrote: vmap_pte_range() returns an -EBUSY when it encounters a non-empty PTE. But currently vmap_pmd_range() unifies both -EBUSY and -ENOMEM return code as -ENOMEM and send it up the call chain which is wrong. Interestingly enough vmap_page_range_noflush()

[PATCH v4 02/14] epoll: introduce user structures for polling from userspace

2019-06-11 Thread Roman Penyaev
This one introduces structures of user items array: struct epoll_uheader - describes inserted epoll items. struct epoll_uitem - single epoll item visible to userspace. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc

[PATCH v4 08/14] epoll: support polling from userspace for ep_insert()

2019-06-11 Thread Roman Penyaev
When epfd is polled by userspace and new item is inserted new bit should be get from a bitmap and then user item is set accordingly. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- fs

[PATCH v4 05/14] epoll: offload polling to a work in case of epfd polled from userspace

2019-06-11 Thread Roman Penyaev
ng patches. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- fs/eventpoll.c | 131 - 1 file changed, 107 insertions(+), 24 deletions(-) diff

[PATCH v4 03/14] epoll: allocate user header and user events ring for polling from userspace

2019-06-11 Thread Roman Penyaev
This one allocates user header and user events ring according to max items number, passed as a parameter. User events (index) ring is in a pow2. Pages, which will be shared between kernel and userspace, are accounted through user->locked_vm counter. Signed-off-by: Roman Penyaev Cc: And

[PATCH v4 09/14] epoll: support polling from userspace for ep_remove()

2019-06-11 Thread Roman Penyaev
On ep_remove() simply mark a user item with EPOLLREMOVE if the item was ready (i.e. has some bits set). That will prevent further user index entry creation on item ->bit reuse. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org

[PATCH v4 11/14] epoll: support polling from userspace for ep_poll()

2019-06-11 Thread Roman Penyaev
Rule of thumb for epfd polled from userspace is simple: epfd has events if ->head != ->tail, no traversing of each item is performed. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org -

[PATCH v4 07/14] epoll: call ep_add_event_to_uring() from ep_poll_callback()

2019-06-11 Thread Roman Penyaev
call from another cpu. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- fs/eventpoll.c | 38 ++ 1 file changed, 38 insertions(+) diff --git a/fs/eventpoll.c b

[PATCH v4 14/14] kselftest: add uepoll-test which tests polling from userspace

2019-06-11 Thread Roman Penyaev
Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/uepoll/.gitignore | 1 + tools/testing/selftests/uepoll

[PATCH v4 13/14] epoll: implement epoll_create2() syscall

2019-06-11 Thread Roman Penyaev
epoll_create2() is needed to accept EPOLL_USERPOLL flags and size, i.e. this patch wires up polling from userspace. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Arnd Bergmann Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- Hi Arnd

[PATCH v4 12/14] epoll: support mapping for epfd when polled from userspace

2019-06-11 Thread Roman Penyaev
User has to mmap user_header and user_index vmalloce'd pointers in order to consume events from userspace. Also we do not let any copies of vma on fork(). Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-k

[PATCH v4 06/14] epoll: introduce helpers for adding/removing events to uring

2019-06-11 Thread Roman Penyaev
(): o user item is marked as EPOLLREMOVED only if it was ready, thus userspace will obseve previously added entry in index uring and correct "removed" state of the item. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: Peter Zi

[PATCH v4 04/14] epoll: some sanity flags checks for epoll syscalls for polling from userspace

2019-06-11 Thread Roman Penyaev
epfd, created with EPOLL_USERPOLL flag, accepts events as NULL and maxevents as 0. No other values are accepted. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- fs/eventpoll.c

[PATCH v4 01/14] epoll: move private helpers from a header to the source

2019-06-11 Thread Roman Penyaev
Those helpers will access private eventpoll structure in future patches, so keep those helpers close to callers. Nothing important here. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- fs

[PATCH v4 00/14] epoll: support pollable epoll from userspace

2019-06-11 Thread Roman Penyaev
ernel from time to time in order to wait. Also libevent modification [1] is available, see "measurements" section above. [1] https://github.com/libevent/libevent/pull/801 [2] https://github.com/rouming/test-tools/blob/master/userpolled-epoll.c Roman Penyaev (14): epoll: move private

[PATCH v4 10/14] epoll: support polling from userspace for ep_modify()

2019-06-11 Thread Roman Penyaev
When epfd is polled from userspace and item is being modified: 1. Update user item with new pointer or poll flags. 2. Add event to user ring if needed. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel

Re: [PATCH 1/1] eventfd new tag EFD_VPOLL: generate epoll events

2019-06-06 Thread Roman Penyaev
Hi Renzo, On 2019-06-03 17:00, Renzo Davoli wrote: Hi Roman, I sorry for the delay in my answer, but I needed to set up a minimal tutorial to show what I am working on and why I need a feature like the one I am proposing. Please, have a look of the README.md page here: https://github.

Re: [PATCH v3 00/13] epoll: support pollable epoll from userspace

2019-06-04 Thread Roman Penyaev
On 2019-05-31 23:09, Jens Axboe wrote: On 5/31/19 1:45 PM, Roman Penyaev wrote: On 2019-05-31 18:54, Jens Axboe wrote: On 5/31/19 10:02 AM, Roman Penyaev wrote: On 2019-05-31 16:48, Jens Axboe wrote: On 5/16/19 2:57 AM, Roman Penyaev wrote: Hi all, This is v3 which introduces pollable

Re: [PATCH v3 06/13] epoll: introduce helpers for adding/removing events to uring

2019-06-03 Thread Roman Penyaev
On 2019-06-03 11:09, Peter Zijlstra wrote: On Fri, May 31, 2019 at 08:58:19PM +0200, Roman Penyaev wrote: On 2019-05-31 18:51, Peter Zijlstra wrote: > But like you show, it can be done. It also makes the thing wait-free, as > opposed to merely lockless. You think it's better?

Re: [PATCH v3 00/13] epoll: support pollable epoll from userspace

2019-05-31 Thread Roman Penyaev
On 2019-05-31 18:54, Jens Axboe wrote: On 5/31/19 10:02 AM, Roman Penyaev wrote: On 2019-05-31 16:48, Jens Axboe wrote: On 5/16/19 2:57 AM, Roman Penyaev wrote: Hi all, This is v3 which introduces pollable epoll from userspace. v3: - Measurements made, represented below. - Fix

Re: [PATCH v3 06/13] epoll: introduce helpers for adding/removing events to uring

2019-05-31 Thread Roman Penyaev
On 2019-05-31 18:51, Peter Zijlstra wrote: On Fri, May 31, 2019 at 04:21:30PM +0200, Roman Penyaev wrote: The ep_add_event_to_uring() is lockless, thus I can't increase tail after, I need to reserve the index slot, where to write to. I can use shadow tail, which is not seen by userspace

Re: [PATCH v3 00/13] epoll: support pollable epoll from userspace

2019-05-31 Thread Roman Penyaev
On 2019-05-31 18:33, Peter Zijlstra wrote: On Thu, May 16, 2019 at 10:57:57AM +0200, Roman Penyaev wrote: When new event comes for some epoll item kernel does the following: struct epoll_uitem *uitem; /* Each item has a bit (index in user items array), discussed later */ uitem

Re: [PATCH v3 00/13] epoll: support pollable epoll from userspace

2019-05-31 Thread Roman Penyaev
On 2019-05-31 16:48, Jens Axboe wrote: On 5/16/19 2:57 AM, Roman Penyaev wrote: Hi all, This is v3 which introduces pollable epoll from userspace. v3: - Measurements made, represented below. - Fix alignment for epoll_uitem structure on all 64-bit archs except x86-64. epoll_uitem

Re: [PATCH v3 07/13] epoll: call ep_add_event_to_uring() from ep_poll_callback()

2019-05-31 Thread Roman Penyaev
On 2019-05-31 15:05, Peter Zijlstra wrote: On Fri, May 31, 2019 at 01:22:54PM +0200, Roman Penyaev wrote: On 2019-05-31 11:56, Peter Zijlstra wrote: > On Thu, May 16, 2019 at 10:58:04AM +0200, Roman Penyaev wrote: > > +static inline bool ep_clear_public_event_bits(struct ep

Re: [PATCH v3 06/13] epoll: introduce helpers for adding/removing events to uring

2019-05-31 Thread Roman Penyaev
On 2019-05-31 14:53, Peter Zijlstra wrote: On Fri, May 31, 2019 at 01:15:21PM +0200, Roman Penyaev wrote: On 2019-05-31 11:56, Peter Zijlstra wrote: > On Thu, May 16, 2019 at 10:58:03AM +0200, Roman Penyaev wrote: > > + i = __atomic_fetch_add(&ep->user

Re: [PATCH v3 06/13] epoll: introduce helpers for adding/removing events to uring

2019-05-31 Thread Roman Penyaev
On 2019-05-31 14:56, Peter Zijlstra wrote: On Fri, May 31, 2019 at 01:15:21PM +0200, Roman Penyaev wrote: On 2019-05-31 11:56, Peter Zijlstra wrote: > On Thu, May 16, 2019 at 10:58:03AM +0200, Roman Penyaev wrote: > > +static inline bool ep_add_event_to_uring(struct epitem *epi, >

Re: [PATCH 1/1] eventfd new tag EFD_VPOLL: generate epoll events

2019-05-31 Thread Roman Penyaev
On 2019-05-31 12:45, Renzo Davoli wrote: HI Roman, On Fri, May 31, 2019 at 11:34:08AM +0200, Roman Penyaev wrote: On 2019-05-27 15:36, Renzo Davoli wrote: > Unfortunately this approach cannot be applied to > poll/select/ppoll/pselect/epoll. If you have to override other systemcalls, w

Re: [PATCH v3 06/13] epoll: introduce helpers for adding/removing events to uring

2019-05-31 Thread Roman Penyaev
On 2019-05-31 11:55, Peter Zijlstra wrote: On Thu, May 16, 2019 at 10:58:03AM +0200, Roman Penyaev wrote: +#define atomic_set_unless_zero(ptr, flags) \ +({ \ + typeof(ptr) _ptr = (ptr

Re: [PATCH v3 07/13] epoll: call ep_add_event_to_uring() from ep_poll_callback()

2019-05-31 Thread Roman Penyaev
On 2019-05-31 11:56, Peter Zijlstra wrote: On Thu, May 16, 2019 at 10:58:04AM +0200, Roman Penyaev wrote: Each ep_poll_callback() is called when fd calls wakeup() on epfd. So account new event in user ring. The tricky part here is EPOLLONESHOT. Since we are lockless we have to be deal with

Re: [PATCH v3 06/13] epoll: introduce helpers for adding/removing events to uring

2019-05-31 Thread Roman Penyaev
On 2019-05-31 11:56, Peter Zijlstra wrote: On Thu, May 16, 2019 at 10:58:03AM +0200, Roman Penyaev wrote: +static inline bool ep_add_event_to_uring(struct epitem *epi, __poll_t pollflags) +{ + struct eventpoll *ep = epi->ep; + struct epoll_uitem *uitem; + bool added = fa

Re: [PATCH 1/1] eventfd new tag EFD_VPOLL: generate epoll events

2019-05-31 Thread Roman Penyaev
Hi Renzo, On 2019-05-27 15:36, Renzo Davoli wrote: On Mon, May 27, 2019 at 09:33:32AM +0200, Greg KH wrote: On Sun, May 26, 2019 at 04:25:21PM +0200, Renzo Davoli wrote: > This patch implements an extension of eventfd to define file descriptors > whose I/O events can be generated at user level.

Re: [PATCH v3 05/13] epoll: offload polling to a work in case of epfd polled from userspace

2019-05-22 Thread Roman Penyaev
On 2019-05-21 09:51, Eric Wong wrote: Roman Penyaev wrote: diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 81da4571f1e0..9d3905c0afbf 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -44,6 +44,7 @@ #include #include #include +#include #include /* @@ -185,6 +186,9 @@ struct

Re: [PATCH v3 13/13] epoll: implement epoll_create2() syscall

2019-05-22 Thread Roman Penyaev
On 2019-05-22 04:33, Andrew Morton wrote: On Thu, 16 May 2019 12:20:50 +0200 Roman Penyaev wrote: On 2019-05-16 12:03, Arnd Bergmann wrote: > On Thu, May 16, 2019 at 10:59 AM Roman Penyaev > wrote: >> >> epoll_create2() is needed to accept EPOLL_USERPOLL flags >> a

Re: [PATCH v3 13/13] epoll: implement epoll_create2() syscall

2019-05-16 Thread Roman Penyaev
On 2019-05-16 12:03, Arnd Bergmann wrote: On Thu, May 16, 2019 at 10:59 AM Roman Penyaev wrote: epoll_create2() is needed to accept EPOLL_USERPOLL flags and size, i.e. this patch wires up polling from userspace. Could you add the system call to all syscall*.tbl files at the same time here

[PATCH v3 00/13] epoll: support pollable epoll from userspace

2019-05-16 Thread Roman Penyaev
ads with many event fds and produces many events, while single consumer fetches them from userspace and goes to kernel from time to time in order to wait. [1] https://github.com/libevent/libevent/pull/801 [2] https://github.com/rouming/test-tools/blob/master/userpolled-epoll.c Roman Penyaev (1

[PATCH v3 02/13] epoll: introduce user structures for polling from userspace

2019-05-16 Thread Roman Penyaev
This one introduces structures of user items array: struct epoll_uheader - describes inserted epoll items. struct epoll_uitem - single epoll item visible to userspace. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc

[PATCH v3 07/13] epoll: call ep_add_event_to_uring() from ep_poll_callback()

2019-05-16 Thread Roman Penyaev
call from another cpu. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 2f551c005640..55612da9651e 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c

[PATCH v3 04/13] epoll: some sanity flags checks for epoll syscalls for polling from userspace

2019-05-16 Thread Roman Penyaev
epfd, created with EPOLL_USERPOLL flag, accepts events as NULL and maxevents as 0. No other values are accepted. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org diff --git a/fs/eventpoll.c

[PATCH v3 06/13] epoll: introduce helpers for adding/removing events to uring

2019-05-16 Thread Roman Penyaev
(): o user item is marked as EPOLLREMOVED only if it was ready, thus userspace will obseve previously added entry in index uring and correct "removed" state of the item. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc:

[PATCH v3 12/13] epoll: support mapping for epfd when polled from userspace

2019-05-16 Thread Roman Penyaev
User has to mmap user_header and user_index vmalloce'd pointers in order to consume events from userspace. Also we do not let any copies of vma on fork(). Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-k

[PATCH v3 09/13] epoll: support polling from userspace for ep_remove()

2019-05-16 Thread Roman Penyaev
On ep_remove() simply mark a user item with EPOLLREMOVE if the item was ready (i.e. has some bits set). That will prevent further user index entry creation on item ->bit reuse. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org

[PATCH v3 11/13] epoll: support polling from userspace for ep_poll()

2019-05-16 Thread Roman Penyaev
Rule of thumb for epfd polled from userspace is simple: epfd has events if ->head != ->tail, no traversing of each item is performed. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org diff -

[PATCH v3 10/13] epoll: support polling from userspace for ep_modify()

2019-05-16 Thread Roman Penyaev
When epfd is polled from userspace and item is being modified: 1. Update user item with new pointer or poll flags. 2. Add event to user ring if needed. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel

[PATCH v3 03/13] epoll: allocate user header and user events ring for polling from userspace

2019-05-16 Thread Roman Penyaev
This one allocates user header and user events ring according to max items number, passed as a parameter. User events (index) ring is in a pow2. Pages, which will be shared between kernel and userspace, are accounted through user->locked_vm counter. Signed-off-by: Roman Penyaev Cc: And

[PATCH v3 08/13] epoll: support polling from userspace for ep_insert()

2019-05-16 Thread Roman Penyaev
When epfd is polled by userspace and new item is inserted new bit should be get from a bitmap and then user item is set accordingly. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org diff --git a

[PATCH v3 01/13] epoll: move private helpers from a header to the source

2019-05-16 Thread Roman Penyaev
Those helpers will access private eventpoll structure in future patches, so keep those helpers close to callers. Nothing important here. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org diff

[PATCH v3 13/13] epoll: implement epoll_create2() syscall

2019-05-16 Thread Roman Penyaev
epoll_create2() is needed to accept EPOLL_USERPOLL flags and size, i.e. this patch wires up polling from userspace. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org diff --git a/arch/x86/entry

[PATCH v3 05/13] epoll: offload polling to a work in case of epfd polled from userspace

2019-05-16 Thread Roman Penyaev
k and then to call ep_poll_callback() with pollflags in a hand. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Linus Torvalds Cc: linux-fsde...@vger.kernel.org Cc: linux-kernel@vger.kernel.org diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 81da4571f1e0..9d3905c0afbf 10064

Re: [PATCH] fs/epoll: remove an unnecessary argument of ep_busy_loop()

2019-03-19 Thread Roman Penyaev
On 2019-03-08 09:14, Peng Wang wrote: When ep_busy_loop() is called, timed_out is always zero, otherwise ep_poll() would return first. Yes, that's correct. Reviewed-by: Roman Penyaev

Re: WARNING in ep_poll_callback

2019-03-11 Thread Roman Penyaev
On 2019-03-11 17:37, Dmitry Vyukov wrote: On Mon, Mar 11, 2019 at 5:36 PM syzbot wrote: > On Mon, Mar 11, 2019 at 2:53 PM Roman Penyaev wrote: >> On 2019-03-11 14:45, Dmitry Vyukov wrote: >> > On Mon, Mar 11, 2019 at 2:37 PM Roman Penyaev wrote: >> >> >>

Re: WARNING in ep_poll_callback

2019-03-11 Thread Roman Penyaev
On 2019-03-11 14:45, Dmitry Vyukov wrote: On Mon, Mar 11, 2019 at 2:37 PM Roman Penyaev wrote: Hi Andrew, I thought "epoll: loosen irq safety in ep_poll_callback()" patch was removed from your tree, at least I got a notification on 9th of january, also I do not see it in the

Re: WARNING in ep_poll_callback

2019-03-11 Thread Roman Penyaev
syzbot has bisected this bug to: commit f92cacf118171208f62519d92502a8dd0341286d Author: Roman Penyaev Date: Tue Jan 8 01:15:44 2019 + epoll: loosen irq safety in ep_poll_callback() bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=107ae15f20 start commit: f92cacf1 epo

Re: [RFC PATCH v2 02/13] epoll: introduce user structures for polling from userspace

2019-01-22 Thread Roman Penyaev
On 2019-01-21 22:34, Linus Torvalds wrote: So I'm not entirely convinced, but I guess actual numbers and users might convince me otherwise. However, a quick comment: On Tue, Jan 22, 2019 at 9:15 AM Roman Penyaev wrote: +struct epoll_uitem { + __poll_t ready_events; + s

[RFC PATCH v2 01/13] epoll: move private helpers from a header to the source

2019-01-21 Thread Roman Penyaev
Those helpers will access private eventpoll structure in future patches, so keep those helpers close to callers. Nothing important here. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Davidlohr Bueso Cc: Jason Baron Cc: Al Viro Cc: "Paul E. McKenney" Cc: Linus Torvalds

[RFC PATCH v2 00/13] epoll: support pollable epoll from userspace

2019-01-21 Thread Roman Penyaev
[1] which starts many threads with many event fds and produces many events, while single consumer fetches them from userspace and goes to kernel from time to time in order to wait. [1] https://github.com/rouming/test-tools/blob/master/userpolled-epoll.c Roman Penyaev (13): epoll: move private

  1   2   3   >