From: Peter Zijlstra <peterz@infradead.org>
To: oleg@redhat.com, paulmck@linux.vnet.ibm.com, tj@kernel.org,
mingo@redhat.com, linux-kernel@vger.kernel.org, der.herr@hofr.at,
peterz@infradead.org, dave@stgolabs.net, riel@redhat.com,
viro@ZenIV.linux.org.uk, torvalds@linux-foundation.org,
wagi@monom.org
Subject: [PATCH 5/7] fs/locks: Use percpu_down_read_preempt_disable
Date: Mon, 05 Sep 2016 21:40:59 +0200 [thread overview]
Message-ID: <20160905194127.317680404@infradead.org> (raw)
In-Reply-To: <20160905194054.369038779@infradead.org>
[-- Attachment #1: peterz-percpu-rwsem-preempt-api-use.patch --]
[-- Type: text/plain, Size: 3634 bytes --]
Avoid spurious preemption by using the
percpu_{down,up}_preempt_{dis,en}able() APIs. This reduces things down
to a single preemption point at the end of this sequence (in the
normal case).
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
fs/locks.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -930,7 +930,7 @@ static int flock_lock_inode(struct inode
return -ENOMEM;
}
- percpu_down_read(&file_rwsem);
+ percpu_down_read_preempt_disable(&file_rwsem);
spin_lock(&ctx->flc_lock);
if (request->fl_flags & FL_ACCESS)
goto find_conflict;
@@ -971,7 +971,7 @@ static int flock_lock_inode(struct inode
out:
spin_unlock(&ctx->flc_lock);
- percpu_up_read(&file_rwsem);
+ percpu_up_read_preempt_enable(&file_rwsem);
if (new_fl)
locks_free_lock(new_fl);
locks_dispose_list(&dispose);
@@ -1008,7 +1008,7 @@ static int posix_lock_inode(struct inode
new_fl2 = locks_alloc_lock();
}
- percpu_down_read(&file_rwsem);
+ percpu_down_read_preempt_disable(&file_rwsem);
spin_lock(&ctx->flc_lock);
/*
* New lock request. Walk all POSIX locks and look for conflicts. If
@@ -1180,7 +1180,7 @@ static int posix_lock_inode(struct inode
}
out:
spin_unlock(&ctx->flc_lock);
- percpu_up_read(&file_rwsem);
+ percpu_up_read_preempt_enable(&file_rwsem);
/*
* Free any unused locks.
*/
@@ -1455,7 +1455,7 @@ int __break_lease(struct inode *inode, u
return error;
}
- percpu_down_read(&file_rwsem);
+ percpu_down_read_preempt_disable(&file_rwsem);
spin_lock(&ctx->flc_lock);
time_out_leases(inode, &dispose);
@@ -1507,13 +1507,13 @@ int __break_lease(struct inode *inode, u
locks_insert_block(fl, new_fl);
trace_break_lease_block(inode, new_fl);
spin_unlock(&ctx->flc_lock);
- percpu_up_read(&file_rwsem);
+ percpu_up_read_preempt_enable(&file_rwsem);
locks_dispose_list(&dispose);
error = wait_event_interruptible_timeout(new_fl->fl_wait,
!new_fl->fl_next, break_time);
- percpu_down_read(&file_rwsem);
+ percpu_down_read_preempt_disable(&file_rwsem);
spin_lock(&ctx->flc_lock);
trace_break_lease_unblock(inode, new_fl);
locks_delete_block(new_fl);
@@ -1530,7 +1530,7 @@ int __break_lease(struct inode *inode, u
}
out:
spin_unlock(&ctx->flc_lock);
- percpu_up_read(&file_rwsem);
+ percpu_up_read_preempt_enable(&file_rwsem);
locks_dispose_list(&dispose);
locks_free_lock(new_fl);
return error;
@@ -1685,7 +1685,7 @@ generic_add_lease(struct file *filp, lon
return -EINVAL;
}
- percpu_down_read(&file_rwsem);
+ percpu_down_read_preempt_disable(&file_rwsem);
spin_lock(&ctx->flc_lock);
time_out_leases(inode, &dispose);
error = check_conflicting_open(dentry, arg, lease->fl_flags);
@@ -1756,7 +1756,7 @@ generic_add_lease(struct file *filp, lon
lease->fl_lmops->lm_setup(lease, priv);
out:
spin_unlock(&ctx->flc_lock);
- percpu_up_read(&file_rwsem);
+ percpu_up_read_preempt_enable(&file_rwsem);
locks_dispose_list(&dispose);
if (is_deleg)
inode_unlock(inode);
@@ -1779,7 +1779,7 @@ static int generic_delete_lease(struct f
return error;
}
- percpu_down_read(&file_rwsem);
+ percpu_down_read_preempt_disable(&file_rwsem);
spin_lock(&ctx->flc_lock);
list_for_each_entry(fl, &ctx->flc_lease, fl_list) {
if (fl->fl_file == filp &&
@@ -1792,7 +1792,7 @@ static int generic_delete_lease(struct f
if (victim)
error = fl->fl_lmops->lm_change(victim, F_UNLCK, &dispose);
spin_unlock(&ctx->flc_lock);
- percpu_up_read(&file_rwsem);
+ percpu_up_read_preempt_enable(&file_rwsem);
locks_dispose_list(&dispose);
return error;
}
next prev parent reply other threads:[~2016-09-05 19:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-05 19:40 [PATCH 0/7] perpcu rwsem, fs/locks and killing lglocks Peter Zijlstra
2016-09-05 19:40 ` [PATCH 1/7] percpu-rwsem: DEFINE_STATIC_PERCPU_RWSEM Peter Zijlstra
2016-09-05 19:40 ` [PATCH 2/7] fs/locks: Replace lg_global with a percpu-rwsem Peter Zijlstra
2016-09-05 19:40 ` [PATCH 3/7] fs/locks: Replace lg_local with a per-cpu spinlock Peter Zijlstra
2016-09-05 19:40 ` [PATCH 4/7] percpu-rwsem: Add down_read_preempt_disable() Peter Zijlstra
2016-09-05 19:40 ` Peter Zijlstra [this message]
2016-09-05 19:41 ` [PATCH 6/7] stop_machine: Remove stop_cpus_lock and lg_double_lock/unlock() Peter Zijlstra
2016-09-05 19:41 ` [PATCH 7/7] locking: Remove lglock Peter Zijlstra
2016-09-06 4:45 ` [PATCH 0/7] perpcu rwsem, fs/locks and killing lglocks Mike Galbraith
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160905194127.317680404@infradead.org \
--to=peterz@infradead.org \
--cc=dave@stgolabs.net \
--cc=der.herr@hofr.at \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=oleg@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=riel@redhat.com \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@ZenIV.linux.org.uk \
--cc=wagi@monom.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®