linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] fuse: Small cleanup series
@ 2018-07-31 10:25 Kirill Tkhai
  2018-07-31 10:25 ` [PATCH 1/2] fuse: Use list_first_entry() in flush_bg_queue() Kirill Tkhai
  2018-07-31 10:25 ` [PATCH 2/2] fuse: Move clear_bit() up in request_end() Kirill Tkhai
  0 siblings, 2 replies; 6+ messages in thread
From: Kirill Tkhai @ 2018-07-31 10:25 UTC (permalink / raw)
  To: miklos, linux-fsdevel, ktkhai

This is a small cleanup series without functional changes.

---

Kirill Tkhai (2):
      fuse: Use list_first_entry() in flush_bg_queue()
      fuse: Move clear_bit() up in request_end()


 fs/fuse/dev.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

--
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] fuse: Use list_first_entry() in flush_bg_queue()
  2018-07-31 10:25 [PATCH 0/2] fuse: Small cleanup series Kirill Tkhai
@ 2018-07-31 10:25 ` Kirill Tkhai
  2018-08-07 12:26   ` Miklos Szeredi
  2018-07-31 10:25 ` [PATCH 2/2] fuse: Move clear_bit() up in request_end() Kirill Tkhai
  1 sibling, 1 reply; 6+ messages in thread
From: Kirill Tkhai @ 2018-07-31 10:25 UTC (permalink / raw)
  To: miklos, linux-fsdevel, ktkhai

This cleanup patch makes the function to use the primitive
instead of direct dereferencing.

Also, move fiq dereferencing out of cycle, since it's
always constant.


Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 fs/fuse/dev.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 11ea2c4a38ab..214ce96b1d26 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -353,12 +353,13 @@ void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget,
 
 static void flush_bg_queue(struct fuse_conn *fc)
 {
+	struct fuse_iqueue *fiq = &fc->iq;
+
 	while (fc->active_background < fc->max_background &&
 	       !list_empty(&fc->bg_queue)) {
 		struct fuse_req *req;
-		struct fuse_iqueue *fiq = &fc->iq;
 
-		req = list_entry(fc->bg_queue.next, struct fuse_req, list);
+		req = list_first_entry(&fc->bg_queue, struct fuse_req, list);
 		list_del(&req->list);
 		fc->active_background++;
 		spin_lock(&fiq->waitq.lock);

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] fuse: Move clear_bit() up in request_end()
  2018-07-31 10:25 [PATCH 0/2] fuse: Small cleanup series Kirill Tkhai
  2018-07-31 10:25 ` [PATCH 1/2] fuse: Use list_first_entry() in flush_bg_queue() Kirill Tkhai
@ 2018-07-31 10:25 ` Kirill Tkhai
  2018-08-07 12:22   ` Miklos Szeredi
  1 sibling, 1 reply; 6+ messages in thread
From: Kirill Tkhai @ 2018-07-31 10:25 UTC (permalink / raw)
  To: miklos, linux-fsdevel, ktkhai

Nobody can clear FR_BACKGROUND bit on processing
request in parallel, so it's possible to do it
out of fc->lock.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 fs/fuse/dev.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 214ce96b1d26..ce07a41ff8fe 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -390,8 +390,8 @@ static void request_end(struct fuse_conn *fc, struct fuse_req *req)
 	WARN_ON(test_bit(FR_PENDING, &req->flags));
 	WARN_ON(test_bit(FR_SENT, &req->flags));
 	if (test_bit(FR_BACKGROUND, &req->flags)) {
-		spin_lock(&fc->lock);
 		clear_bit(FR_BACKGROUND, &req->flags);
+		spin_lock(&fc->lock);
 		if (fc->num_background == fc->max_background)
 			fc->blocked = 0;
 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] fuse: Move clear_bit() up in request_end()
  2018-07-31 10:25 ` [PATCH 2/2] fuse: Move clear_bit() up in request_end() Kirill Tkhai
@ 2018-08-07 12:22   ` Miklos Szeredi
  2018-08-07 12:32     ` Kirill Tkhai
  0 siblings, 1 reply; 6+ messages in thread
From: Miklos Szeredi @ 2018-08-07 12:22 UTC (permalink / raw)
  To: Kirill Tkhai; +Cc: linux-fsdevel

On Tue, Jul 31, 2018 at 12:25 PM, Kirill Tkhai <ktkhai@virtuozzo.com> wrote:
> Nobody can clear FR_BACKGROUND bit on processing
> request in parallel, so it's possible to do it
> out of fc->lock.

Moving such a cheap operation outside the splinlock won't make any
difference in real life.

And anyway the biggest problem with fc->lock is not contention (hold
for long period of time), I would guess, but cachline pingponging
(being acquired on different CPUs one after the other).

So there's definitely work to do regarding locking in fuse, but it
needs a bigger axe.

Thanks,
Miklos

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] fuse: Use list_first_entry() in flush_bg_queue()
  2018-07-31 10:25 ` [PATCH 1/2] fuse: Use list_first_entry() in flush_bg_queue() Kirill Tkhai
@ 2018-08-07 12:26   ` Miklos Szeredi
  0 siblings, 0 replies; 6+ messages in thread
From: Miklos Szeredi @ 2018-08-07 12:26 UTC (permalink / raw)
  To: Kirill Tkhai; +Cc: linux-fsdevel

On Tue, Jul 31, 2018 at 12:25 PM, Kirill Tkhai <ktkhai@virtuozzo.com> wrote:
> This cleanup patch makes the function to use the primitive
> instead of direct dereferencing.

Okay.

>
> Also, move fiq dereferencing out of cycle, since it's
> always constant.

Not much win.  The compiler can guess as much...

Applied, anyway.

Thanks,
Miklos

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] fuse: Move clear_bit() up in request_end()
  2018-08-07 12:22   ` Miklos Szeredi
@ 2018-08-07 12:32     ` Kirill Tkhai
  0 siblings, 0 replies; 6+ messages in thread
From: Kirill Tkhai @ 2018-08-07 12:32 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: linux-fsdevel

On 07.08.2018 15:22, Miklos Szeredi wrote:
> On Tue, Jul 31, 2018 at 12:25 PM, Kirill Tkhai <ktkhai@virtuozzo.com> wrote:
>> Nobody can clear FR_BACKGROUND bit on processing
>> request in parallel, so it's possible to do it
>> out of fc->lock.
> 
> Moving such a cheap operation outside the splinlock won't make any
> difference in real life.

It's not about difference in real life, it's about readability.
Testing the bit outside the lock and clearing it inside the lock
confuses a reader, and makes he to thing there is a tricky synchronization,
while there is no tricky synchronization.

> And anyway the biggest problem with fc->lock is not contention (hold
> for long period of time), I would guess, but cachline pingponging
> (being acquired on different CPUs one after the other).
> 
> So there's definitely work to do regarding locking in fuse, but it
> needs a bigger axe.

I've moved background stuff at a separate lock in my sandbox tree,
and this was pretty easy. Not yet sent to you, since I'm going to do
some performance testing on this. I've locked for tests used to measure
the performance in fuse git log, but there is no one pointing in the log
I found. Could you tell, what fuse driver do you use to measure performance
and which test you use?

Kirill

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-08-07 14:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-31 10:25 [PATCH 0/2] fuse: Small cleanup series Kirill Tkhai
2018-07-31 10:25 ` [PATCH 1/2] fuse: Use list_first_entry() in flush_bg_queue() Kirill Tkhai
2018-08-07 12:26   ` Miklos Szeredi
2018-07-31 10:25 ` [PATCH 2/2] fuse: Move clear_bit() up in request_end() Kirill Tkhai
2018-08-07 12:22   ` Miklos Szeredi
2018-08-07 12:32     ` Kirill Tkhai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).