All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiubo Li <xiubli@redhat.com>
To: Jeff Layton <jlayton@kernel.org>, idryomov@gmail.com, zyan@redhat.com
Cc: sage@redhat.com, pdonnell@redhat.com, ceph-devel@vger.kernel.org
Subject: Re: [PATCH v3 2/8] ceph: add caps perf metric for each session
Date: Thu, 16 Jan 2020 09:57:19 +0800	[thread overview]
Message-ID: <7574d509-7aed-ef8e-265f-6220f865d8e0@redhat.com> (raw)
In-Reply-To: <52b531a7092a8bd09f7ade52fb17b0cee68ffd8a.camel@kernel.org>

On 2020/1/15 22:24, Jeff Layton wrote:
> On Tue, 2020-01-14 at 22:44 -0500, xiubli@redhat.com wrote:
[...]
>> +/*
>> + * Counts the cap metric.
>> + */
>> +void __ceph_caps_metric(struct ceph_inode_info *ci, int mask)
>> +{
>> +	int have = ci->i_snap_caps;
>> +	struct ceph_mds_session *s;
>> +	struct ceph_cap *cap;
>> +	struct rb_node *p;
>> +	bool skip_auth = false;
>> +
>> +	if (mask <= 0)
>> +		return;
>> +
>> +	/* Counts the snap caps metric in the auth cap */
>> +	if (ci->i_auth_cap) {
>> +		cap = ci->i_auth_cap;
>> +		if (have) {
>> +			have |= cap->issued;
>> +
>> +			dout("%s %p cap %p issued %s, mask %s\n", __func__,
>> +			     &ci->vfs_inode, cap, ceph_cap_string(cap->issued),
>> +			     ceph_cap_string(mask));
>> +
>> +			s = ceph_get_mds_session(cap->session);
>> +			if (s) {
>> +				if (mask & have)
>> +					percpu_counter_inc(&s->i_caps_hit);
>> +				else
>> +					percpu_counter_inc(&s->i_caps_mis);
>> +				ceph_put_mds_session(s);
>> +			}
>> +			skip_auth = true;
>> +		}
>> +	}
>> +
>> +	if ((mask & have) == mask)
>> +		return;
>> +
>> +	/* Checks others */
>
> Iterating over i_caps requires that you hold the i_ceph_lock. Some
> callers of __ceph_caps_metric already hold it but some of the callers
> don't.
>
> The simple fix would be to wrap this function in another that takes and
> drops the i_ceph_lock before calling this one. It would also be good to
> add this at the top of this function as well:
>
> 	lockdep_assert_held(&ci->i_ceph_lock);

Yeah, let fix it using the simple way for now.


>
> The bad part is that this does mean adding in extra spinlocking to some
> of these codepaths, which is less than ideal. Eventually, I think we
> ought to convert the cap handling to use RCU and move the i_caps tree to
> a linked list. That would allow us to avoid a lot of the locking for
> stuff like this, and it never has _that_ many entries to where a tree
> really matters.
>
>> +	for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) {
>> +		cap = rb_entry(p, struct ceph_cap, ci_node);
>> +		if (!__cap_is_valid(cap))
>> +			continue;
>> +
>> +		if (skip_auth && cap == ci->i_auth_cap)
>> +			continue;
>> +
>> +		dout("%s %p cap %p issued %s, mask %s\n", __func__,

[...]
>> @@ -2603,6 +2671,8 @@ static int try_get_cap_refs(struct inode *inode, int need, int want,
>>   		spin_lock(&ci->i_ceph_lock);
>>   	}
>>   
>> +	__ceph_caps_metric(ci, need);
>> +
> Should "want" also count toward hits and misses here? IOW:
>
> 	__ceph_caps_metric(ci, need | want);
>
> ?

Yeah, this makes sense.


>
[...]
>> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
>> index 1e6cdf2dfe90..b32aba4023b3 100644
>> --- a/fs/ceph/file.c
>> +++ b/fs/ceph/file.c
>> @@ -393,6 +393,7 @@ int ceph_open(struct inode *inode, struct file *file)
>>   		     inode, fmode, ceph_cap_string(wanted),
>>   		     ceph_cap_string(issued));
>>   		__ceph_get_fmode(ci, fmode);
>> +		__ceph_caps_metric(ci, fmode);
> This looks wrong. fmode is not a cap mask.
>
It should be "wanted" here.

Thanks

  reply	other threads:[~2020-01-16  1:57 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-15  3:44 [PATCH v3 0/8] ceph: add perf metrics support xiubli
2020-01-15  3:44 ` [PATCH v3 1/8] ceph: add global dentry lease metric support xiubli
2020-01-15  3:44 ` [PATCH v3 2/8] ceph: add caps perf metric for each session xiubli
2020-01-15 14:24   ` Jeff Layton
2020-01-16  1:57     ` Xiubo Li [this message]
2020-01-15  3:44 ` [PATCH v3 3/8] ceph: add global read latency metric support xiubli
2020-01-15  3:44 ` [PATCH v3 4/8] ceph: add global write " xiubli
2020-01-16 14:14   ` Jeff Layton
2020-01-16 14:46     ` Ilya Dryomov
2020-01-16 16:31       ` Jeff Layton
2020-01-16 19:36         ` Ilya Dryomov
2020-01-17  1:56           ` Xiubo Li
2020-01-17  0:55     ` Xiubo Li
2020-01-15  3:44 ` [PATCH v3 5/8] ceph: add global metadata perf " xiubli
2020-01-15  3:44 ` [PATCH v3 6/8] ceph: periodically send perf metrics to MDS xiubli
2020-01-15  3:44 ` [PATCH v3 7/8] ceph: add reset metrics support xiubli
2020-01-15  3:44 ` [PATCH v3 8/8] ceph: send client provided metric flags in client metadata xiubli

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=7574d509-7aed-ef8e-265f-6220f865d8e0@redhat.com \
    --to=xiubli@redhat.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=idryomov@gmail.com \
    --cc=jlayton@kernel.org \
    --cc=pdonnell@redhat.com \
    --cc=sage@redhat.com \
    --cc=zyan@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.