diff mbox

[RFC,1/8] epoll: remove epmutex from ep_free() & eventpoll_release_file()

Message ID 1509195507-29037-2-git-send-email-houtao1@huawei.com (mailing list archive)
State New, archived
Headers show

Commit Message

Hou Tao Oct. 28, 2017, 12:58 p.m. UTC
Remove the global epmutex from ep_free() and eventpoll_release_file().
In the later patches, we will add locks with a smaller granularity
to serve the same purposes of epmutex.

Signed-off-by: Hou Tao <houtao1@huawei.com>
---
 fs/eventpoll.c | 4 ----
 1 file changed, 4 deletions(-)

Comments

Davidlohr Bueso Oct. 28, 2017, 1:58 p.m. UTC | #1
On Sat, 28 Oct 2017, Hou Tao wrote:

>Remove the global epmutex from ep_free() and eventpoll_release_file().
>In the later patches, we will add locks with a smaller granularity
>to serve the same purposes of epmutex.
>
>Signed-off-by: Hou Tao <houtao1@huawei.com>
>---
> fs/eventpoll.c | 4 ----
> 1 file changed, 4 deletions(-)
>
>diff --git a/fs/eventpoll.c b/fs/eventpoll.c
>index 2fabd19..26ab0c5 100644
>--- a/fs/eventpoll.c
>+++ b/fs/eventpoll.c
>@@ -835,7 +835,6 @@ static void ep_free(struct eventpoll *ep)
> 	 * anymore. The only hit might come from eventpoll_release_file() but
> 	 * holding "epmutex" is sufficient here.
> 	 */
^^
What about this comment (and the equivalent one in eventpoll_release_file()?

>-	mutex_lock(&epmutex);

...even if you fix it in a later patch, this patch breaks bisection. Now
we just race between ep_free() and eventpoll_release_file(). This patch
should be folded in, no?

Thanks,
Davidlohr
Hou Tao Oct. 30, 2017, 7:09 a.m. UTC | #2
Hi,

On 2017/10/28 21:58, Davidlohr Bueso wrote:
> On Sat, 28 Oct 2017, Hou Tao wrote:
> 
>> Remove the global epmutex from ep_free() and eventpoll_release_file().
>> In the later patches, we will add locks with a smaller granularity
>> to serve the same purposes of epmutex.
>>
>> Signed-off-by: Hou Tao <houtao1@huawei.com>
>> ---
>> fs/eventpoll.c | 4 ----
>> 1 file changed, 4 deletions(-)
>>
>> diff --git a/fs/eventpoll.c b/fs/eventpoll.c
>> index 2fabd19..26ab0c5 100644
>> --- a/fs/eventpoll.c
>> +++ b/fs/eventpoll.c
>> @@ -835,7 +835,6 @@ static void ep_free(struct eventpoll *ep)
>>      * anymore. The only hit might come from eventpoll_release_file() but
>>      * holding "epmutex" is sufficient here.
>>      */
> ^^
> What about this comment (and the equivalent one in eventpoll_release_file()?
> 
>> -    mutex_lock(&epmutex);
> 
Thanks for your reminder. I will fix the related comments in a v1 patchset.

> ...even if you fix it in a later patch, this patch breaks bisection. Now
> we just race between ep_free() and eventpoll_release_file(). This patch
> should be folded in, no?
Yes, the patchset should be squashed into one patch, however it will be
difficult to explain the purpose of these modifications, so I break them
into little pieces, and hoped that these little patches can explain the
reason why the modification is needed in a cleaner way. It also will
be fixed in v1 patch.

Regards,

Tao

> Thanks,
> Davidlohr
> 
> .
>
diff mbox

Patch

diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 2fabd19..26ab0c5 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -835,7 +835,6 @@  static void ep_free(struct eventpoll *ep)
 	 * anymore. The only hit might come from eventpoll_release_file() but
 	 * holding "epmutex" is sufficient here.
 	 */
-	mutex_lock(&epmutex);
 
 	/*
 	 * Walks through the whole tree by unregistering poll callbacks.
@@ -863,7 +862,6 @@  static void ep_free(struct eventpoll *ep)
 	}
 	mutex_unlock(&ep->mtx);
 
-	mutex_unlock(&epmutex);
 	mutex_destroy(&ep->mtx);
 	free_uid(ep->user);
 	wakeup_source_unregister(ep->ws);
@@ -1013,14 +1011,12 @@  void eventpoll_release_file(struct file *file)
 	 *
 	 * Besides, ep_remove() acquires the lock, so we can't hold it here.
 	 */
-	mutex_lock(&epmutex);
 	list_for_each_entry_safe(epi, next, &file->f_ep_links, fllink) {
 		ep = epi->ep;
 		mutex_lock_nested(&ep->mtx, 0);
 		ep_remove(ep, epi);
 		mutex_unlock(&ep->mtx);
 	}
-	mutex_unlock(&epmutex);
 }
 
 static int ep_alloc(struct eventpoll **pep)