<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/eventpoll.c, branch linux-4.19.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.19.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.19.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2020-10-07T06:00:09Z</updated>
<entry>
<title>ep_create_wakeup_source(): dentry name can change under you...</title>
<updated>2020-10-07T06:00:09Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2020-09-24T23:41:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ced8ce5d2157142c469eccc5eef5ea8ad579fa5e'/>
<id>urn:sha1:ced8ce5d2157142c469eccc5eef5ea8ad579fa5e</id>
<content type='text'>
commit 3701cb59d892b88d569427586f01491552f377b1 upstream.

or get freed, for that matter, if it's a long (separately stored)
name.

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>epoll: EPOLL_CTL_ADD: close the race in decision to take fast path</title>
<updated>2020-10-07T06:00:09Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2020-09-10T12:33:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=90ef231ba534d43033884b8560df26e608ca0a21'/>
<id>urn:sha1:90ef231ba534d43033884b8560df26e608ca0a21</id>
<content type='text'>
commit fe0a916c1eae8e17e86c3753d13919177d63ed7e upstream.

Checking for the lack of epitems refering to the epoll we want to insert into
is not enough; we might have an insertion of that epoll into another one that
has already collected the set of files to recheck for excessive reverse paths,
but hasn't gotten to creating/inserting the epitem for it.

However, any such insertion in progress can be detected - it will update the
generation count in our epoll when it's done looking through it for files
to check.  That gets done under -&gt;mtx of our epoll and that allows us to
detect that safely.

We are *not* holding epmutex here, so the generation count is not stable.
However, since both the update of ep-&gt;gen by loop check and (later)
insertion into -&gt;f_ep_link are done with ep-&gt;mtx held, we are fine -
the sequence is
	grab epmutex
	bump loop_check_gen
	...
	grab tep-&gt;mtx		// 1
	tep-&gt;gen = loop_check_gen
	...
	drop tep-&gt;mtx		// 2
	...
	grab tep-&gt;mtx		// 3
	...
	insert into -&gt;f_ep_link
	...
	drop tep-&gt;mtx		// 4
	bump loop_check_gen
	drop epmutex
and if the fastpath check in another thread happens for that
eventpoll, it can come
	* before (1) - in that case fastpath is just fine
	* after (4) - we'll see non-empty -&gt;f_ep_link, slow path
taken
	* between (2) and (3) - loop_check_gen is stable,
with -&gt;mtx providing barriers and we end up taking slow path.

Note that -&gt;f_ep_link emptiness check is slightly racy - we are protected
against insertions into that list, but removals can happen right under us.
Not a problem - in the worst case we'll end up taking a slow path for
no good reason.

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>epoll: replace -&gt;visited/visited_list with generation count</title>
<updated>2020-10-07T06:00:08Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2020-09-10T12:30:05Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ff329915a5b1f6778344a6fc7b060c991376b095'/>
<id>urn:sha1:ff329915a5b1f6778344a6fc7b060c991376b095</id>
<content type='text'>
commit 18306c404abe18a0972587a6266830583c60c928 upstream.

removes the need to clear it, along with the races.

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>epoll: do not insert into poll queues until all sanity checks are done</title>
<updated>2020-10-07T06:00:08Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2020-09-10T02:25:06Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3e3bbc4d23eeb90bf282e98c7dfeca7702df3169'/>
<id>urn:sha1:3e3bbc4d23eeb90bf282e98c7dfeca7702df3169</id>
<content type='text'>
commit f8d4f44df056c5b504b0d49683fb7279218fd207 upstream.

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>fix regression in "epoll: Keep a reference on files added to the check list"</title>
<updated>2020-09-09T17:04:27Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2020-09-02T15:30:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=37d933e8b41b83bb8278815e366aec5a542b7e31'/>
<id>urn:sha1:37d933e8b41b83bb8278815e366aec5a542b7e31</id>
<content type='text'>
[ Upstream commit 77f4689de17c0887775bb77896f4cc11a39bf848 ]

epoll_loop_check_proc() can run into a file already committed to destruction;
we can't grab a reference on those and don't need to add them to the set for
reverse path check anyway.

Tested-by: Marc Zyngier &lt;maz@kernel.org&gt;
Fixes: a9ed4a6560b8 ("epoll: Keep a reference on files added to the check list")
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>do_epoll_ctl(): clean the failure exits up a bit</title>
<updated>2020-08-26T08:31:06Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2020-08-22T22:25:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=dcb6e6efb3298e59d90ee05c6ed33de810314892'/>
<id>urn:sha1:dcb6e6efb3298e59d90ee05c6ed33de810314892</id>
<content type='text'>
commit 52c479697c9b73f628140dcdfcd39ea302d05482 upstream.

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>epoll: Keep a reference on files added to the check list</title>
<updated>2020-08-26T08:31:06Z</updated>
<author>
<name>Marc Zyngier</name>
</author>
<published>2020-08-19T16:12:17Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4957d56414ff5ca8fe62f8f11f0f9814f35b1d11'/>
<id>urn:sha1:4957d56414ff5ca8fe62f8f11f0f9814f35b1d11</id>
<content type='text'>
commit a9ed4a6560b8562b7e2e2bed9527e88001f7b682 upstream.

When adding a new fd to an epoll, and that this new fd is an
epoll fd itself, we recursively scan the fds attached to it
to detect cycles, and add non-epool files to a "check list"
that gets subsequently parsed.

However, this check list isn't completely safe when deletions
can happen concurrently. To sidestep the issue, make sure that
a struct file placed on the check list sees its f_count increased,
ensuring that a concurrent deletion won't result in the file
disapearing from under our feet.

Cc: stable@vger.kernel.org
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>fs/epoll: drop ovflist branch prediction</title>
<updated>2019-02-12T18:47:19Z</updated>
<author>
<name>Davidlohr Bueso</name>
</author>
<published>2019-01-03T23:27:09Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9cb8f8088d9a105af7e763a315771e39eb8c16a4'/>
<id>urn:sha1:9cb8f8088d9a105af7e763a315771e39eb8c16a4</id>
<content type='text'>
[ Upstream commit 76699a67f3041ff4c7af6d6ee9be2bfbf1ffb671 ]

The ep-&gt;ovflist is a secondary ready-list to temporarily store events
that might occur when doing sproc without holding the ep-&gt;wq.lock.  This
accounts for every time we check for ready events and also send events
back to userspace; both callbacks, particularly the latter because of
copy_to_user, can account for a non-trivial time.

As such, the unlikely() check to see if the pointer is being used, seems
both misleading and sub-optimal.  In fact, we go to an awful lot of
trouble to sync both lists, and populating the ovflist is far from an
uncommon scenario.

For example, profiling a concurrent epoll_wait(2) benchmark, with
CONFIG_PROFILE_ANNOTATED_BRANCHES shows that for a two threads a 33%
incorrect rate was seen; and when incrementally increasing the number of
epoll instances (which is used, for example for multiple queuing load
balancing models), up to a 90% incorrect rate was seen.

Similarly, by deleting the prediction, 3% throughput boost was seen
across incremental threads.

Link: http://lkml.kernel.org/r/20181108051006.18751-4-dave@stgolabs.net
Signed-off-by: Davidlohr Bueso &lt;dbueso@suse.de&gt;
Reviewed-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Cc: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Cc: Jason Baron &lt;jbaron@akamai.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>fs/eventpoll.c: simplify ep_is_linked() callers</title>
<updated>2018-08-22T17:52:49Z</updated>
<author>
<name>Davidlohr Bueso</name>
</author>
<published>2018-08-22T04:58:26Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=992991c03ca033f779aae1afb5b0c27bcb7139c3'/>
<id>urn:sha1:992991c03ca033f779aae1afb5b0c27bcb7139c3</id>
<content type='text'>
Instead of having each caller pass the rdllink explicitly, just have
ep_is_linked() pass it while the callers just need the epi pointer.  This
helper is all about the rdllink, and this change, furthermore, improves
the function's self documentation.

Link: http://lkml.kernel.org/r/20180727053432.16679-3-dave@stgolabs.net
Signed-off-by: Davidlohr Bueso &lt;dbueso@suse.de&gt;
Reviewed-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Cc: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Cc: Jason Baron &lt;jbaron@akamai.com&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>fs/eventpoll.c: loosen irq safety in ep_poll()</title>
<updated>2018-08-22T17:52:49Z</updated>
<author>
<name>Davidlohr Bueso</name>
</author>
<published>2018-08-22T04:58:23Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=679abf381a18e945457b01921f667cee9e656a7f'/>
<id>urn:sha1:679abf381a18e945457b01921f667cee9e656a7f</id>
<content type='text'>
Similar to other calls, ep_poll() is not called with interrupts disabled,
and we can therefore avoid the irq save/restore dance and just disable
local irqs.  In fact, the call should never be called in irq context at
all, considering that the only path is

epoll_wait(2) -&gt; do_epoll_wait() -&gt; ep_poll().

When running on a 2 socket 40-core (ht) IvyBridge a common pipe based
epoll_wait(2) microbenchmark, the following performance improvements are
seen:

    # threads       vanilla         dirty
	 1          1805587	    2106412
	 2          1854064	    2090762
	 4          1805484	    2017436
	 8          1751222	    1974475
	 16         1725299	    1962104
	 32         1378463	    1571233
	 64          787368	     900784

Which is a pretty constantly near 15%.

Also add a lockdep check such that we detect any mischief before
deadlocking.

Link: http://lkml.kernel.org/r/20180727053432.16679-2-dave@stgolabs.net
Signed-off-by: Davidlohr Bueso &lt;dbueso@suse.de&gt;
Reviewed-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Cc: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Jason Baron &lt;jbaron@akamai.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
</feed>
