public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: "ira.weiny" <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Mike Marciniszyn
	<mike.marciniszyn-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] IB/hfi1,IB/qib: Fix qp_stats sleep with rcu read lock held
Date: Mon, 22 Aug 2016 14:21:32 -0400	[thread overview]
Message-ID: <8e1fa0b2-9e09-a4a8-d686-ca5e00eb33cf@redhat.com> (raw)
In-Reply-To: <20160810055151.GB32695-W4f6Xiosr+yv7QzWx2u06xL4W9x8LtSr@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 2098 bytes --]

On 8/10/2016 1:51 AM, ira.weiny wrote:
> On Tue, Aug 09, 2016 at 09:11:46PM +0300, Leon Romanovsky wrote:
>> On Tue, Aug 09, 2016 at 11:16:26AM -0400, ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org wrote:
>>> From: Mike Marciniszyn <mike.marciniszyn-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>>>
> 
> [snip]
> 
>>> diff --git a/drivers/infiniband/hw/hfi1/debugfs.c b/drivers/infiniband/hw/hfi1/debugfs.c
>>> index dbab9d9cc288..c35bef8dd5aa 100644
>>> --- a/drivers/infiniband/hw/hfi1/debugfs.c
>>> +++ b/drivers/infiniband/hw/hfi1/debugfs.c
>>> @@ -223,28 +223,35 @@ DEBUGFS_SEQ_FILE_OPEN(ctx_stats)
>>>  DEBUGFS_FILE_OPS(ctx_stats);
>>>  
>>>  static void *_qp_stats_seq_start(struct seq_file *s, loff_t *pos)
>>> -__acquires(RCU)
>>> +	__acquires(RCU)
>>>  {
>>>  	struct qp_iter *iter;
>>>  	loff_t n = *pos;
>>>  
>>> -	rcu_read_lock();
>>>  	iter = qp_iter_init(s->private);
>>> +
>>> +	/* stop calls rcu_read_unlock */
>>> +	rcu_read_lock();
>>
>> IMHO, it should be placed after your if(!iter) check below.
> 
> I know this seems weird but this makes the rcu locking "balanced".  Returning
> NULL here still calls "stop" which is going to call rcu_read_unlock.  If we
> move rcu_read_lock we need to maintain state to determine if we called lock or
> not.  This is easier.  To me it does seem odd that the sequence operation does
> not stop on its own when NULL is returned but that is the way it works.
> 
>>
>>> +
>>>  	if (!iter)
>>>  		return NULL;
>>>  
>>> -	while (n--) {
>>> +	if (qp_iter_next(iter)) {
>>> +		kfree(iter);
>>> +		return NULL;
>>> +	}
>>> +	while (n--)
>>>  		if (qp_iter_next(iter)) {
>>>  			kfree(iter);
>>>  			return NULL;
>>>  		}
>>
>> It looks like you forgot to remove the lines above.
> 
> Nope this replaces a call to qp_iter_next which was in qp_iter_init.
> 
> As the commit messages says we move the implict next's back into the respective
> start functions.
> 
> Ira

Thanks, applied.


-- 
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
    GPG Key ID: 0E572FDD


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]

      parent reply	other threads:[~2016-08-22 18:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-09 15:16 [PATCH] IB/hfi1,IB/qib: Fix qp_stats sleep with rcu read lock held ira.weiny
2016-08-09 18:11 ` Leon Romanovsky
2016-08-10  5:51   ` ira.weiny
     [not found]     ` <20160810055151.GB32695-W4f6Xiosr+yv7QzWx2u06xL4W9x8LtSr@public.gmane.org>
2016-08-10  8:24       ` Leon Romanovsky
2016-08-10 10:17       ` Leon Romanovsky
2016-08-22 18:21       ` Doug Ledford [this message]

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=8e1fa0b2-9e09-a4a8-d686-ca5e00eb33cf@redhat.com \
    --to=dledford-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mike.marciniszyn-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.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