mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jules Irenge <jbi.octave@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Jules Irenge <jbi.octave@gmail.com>,
	boqun.feng@gmail.com, Ingo Molnar <mingo@redhat.com>,
	Will Deacon <will@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] mutex: Add missing annotations
Date: Sat, 1 Feb 2020 00:27:02 +0000 (GMT)	[thread overview]
Message-ID: <alpine.LFD.2.21.2002010020350.3466@ninjahub.org> (raw)
In-Reply-To: <20200127085118.GJ14914@hirez.programming.kicks-ass.net>


Thanks for the feedback, I did not have a thorough analyse.

I just realised it. Yes, some warnings generated after are 
pointless others look genuine. Next time I will 
have a thorough analyse and test before sending. 

I apologise for this.  

I really appreciate your feedback.

Kind regards,
Jules

On Mon, 27 Jan 2020, Peter Zijlstra wrote:

> On Fri, Jan 24, 2020 at 08:12:20PM +0000, Jules Irenge wrote:
> > Sparse reports false warnings and hide real warnings
> > where mutex_lock() and mutex_unlock() are used within the kernel
> > An example is within the kernel cgroup files
> > where the below warnings are found
> > |warning: context imbalance in cgroup_lock_and_drain_offline()
> > | - wrong count at exit
> > |warning: context imbalance in cgroup_procs_write_finish()
> > |- wrong count at exit
> > |warning: context imbalance in cgroup_procs_write_start()
> > |- wrong count at exit.
> > 
> > To fix these,
> > an __acquires(lock) is added to mutex_lock() declaration
> > a __releases(lock) to mutex_unlock() declaration
> > 
> > Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
> > ---
> >  include/linux/mutex.h | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/include/linux/mutex.h b/include/linux/mutex.h
> > index aca8f36dfac9..a8ab4029913e 100644
> > --- a/include/linux/mutex.h
> > +++ b/include/linux/mutex.h
> > @@ -162,7 +162,7 @@ do {									\
> >  } while (0)
> >  
> >  #else
> > -extern void mutex_lock(struct mutex *lock);
> > +extern void mutex_lock(struct mutex *lock) __acquires(lock);
> >  extern int __must_check mutex_lock_interruptible(struct mutex *lock);
> >  extern int __must_check mutex_lock_killable(struct mutex *lock);
> >  extern void mutex_lock_io(struct mutex *lock);
> > @@ -181,7 +181,7 @@ extern void mutex_lock_io(struct mutex *lock);
> >   * Returns 1 if the mutex has been acquired successfully, and 0 on contention.
> >   */
> >  extern int mutex_trylock(struct mutex *lock);
> > -extern void mutex_unlock(struct mutex *lock);
> > +extern void mutex_unlock(struct mutex *lock) __releases(lock);
> >  
> >  extern int atomic_dec_and_mutex_lock(atomic_t *cnt, struct mutex *lock);
> 
> *groan*, I despise these sparse things.
> 
> The proposed patch only annotates a tiny part of the mutex interface,
> and will thereby generate a flood of new (pointless) warnings. Worse,
> annotating them all properly will require that __cond_lock() trainwreck.
> 
> 

  reply	other threads:[~2020-02-01  0:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <0/3>
2020-01-24 20:08 ` [PATCH 0/3] Lock warning cleanup Jules Irenge
2020-01-24 20:12   ` [PATCH 2/3] futex: Add missing annotation for wake_futex_pi() Jules Irenge
2020-01-24 20:12   ` [PATCH 3/3] mutex: Add missing annotations Jules Irenge
2020-01-27  8:51     ` Peter Zijlstra
2020-02-01  0:27       ` Jules Irenge [this message]
2020-01-24 20:12   ` [PATCH 1/3] time: Add missing annotation to lock_hrtimer_base() Jules Irenge
2020-01-24 22:04     ` Thomas Gleixner
2020-01-25  1:26       ` Jules Irenge
2020-02-01  0:04 ` [PATCH 0/3] Lock warning cleanups Jules Irenge
2020-02-01  0:04   ` [PATCH 1/3] hrtimer: Add missing annotation to lock_hrtimer_base() Jules Irenge
2020-02-01  0:04   ` [PATCH 2/3] futex: Add missing annotation for wake_futex_pi() Jules Irenge
2020-02-01  0:04   ` [PATCH 3/3] futex: Add missing annotation for fixup_pi_state_owner() Jules Irenge

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=alpine.LFD.2.21.2002010020350.3466@ninjahub.org \
    --to=jbi.octave@gmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=will@kernel.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®