linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/11] Lock warning cleanup
       [not found] <0/11>
@ 2020-02-09 22:24 ` Jules Irenge
  2020-02-09 22:48   ` [PATCH 09/11] kasan: add missing annotation for start_report() Jules Irenge
                     ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jules Irenge @ 2020-02-09 22:24 UTC (permalink / raw)
  To: boqun.feng
  Cc: linux-kernel, linux-mm, kasan-dev, akpm, dvyukov, glider,
	aryabinin, bsegall, rostedt, dietmar.eggemann, vincent.guittot,
	juri.lelli, peterz, mingo, mgorman, dvhart, tglx, namhyung,
	jolsa, alexander.shishkin, mark.rutland, acme, viro,
	linux-fsdevel, Jules Irenge

This patch series adds missing annotations to functions that register warnings of context imbalance when built with Sparse tool.
The adds fix the warnings and give insight on what the functions are actually doing.

1. Within the futex subsystem, a __releases(&pi_state->.pi_mutex.wait_lock) is added because wake_futex_pi() only releases the lock at exit,
must_hold(q->lock_ptr) have been added to fixup_pi_state_owner() because the lock is held at entry and exit;
a __releases(&hb->lock) added to futex_wait_queue_me() as it only releases the lock.

2. Within fs_pin, a __releases(RCU) is added because the function exit RCU critical section at exit.

3. In kasan, an __acquires(&report_lock) has been added to start_report() and   __releases(&report_lock) to end_report() 

4. Within ring_buffer subsystem, a __releases(RCU) has been added perf_output_end() 

5. schedule subsystem recorded an addition of the __releases(rq->lock) annotation and a __must_hold(this_rq->lock)

6. At hrtimer subsystem, __acquires(timer) is added  to lock_hrtimer_base() as the function acquire the lock but never releases it.
Jules Irenge (11):
  hrtimer: Add missing annotation to lock_hrtimer_base()
  futex: Add missing annotation for wake_futex_pi()
  futex: Add missing annotation for fixup_pi_state_owner()
  perf/ring_buffer: Add missing annotation to perf_output_end()
  sched/fair: Add missing annotation for nohz_newidle_balance()
  sched/deadline: Add missing annotation for dl_task_offline_migration()
  fs_pin: Add missing annotation for pin_kill() declaration
  fs_pin: Add missing annotation for pin_kill() definition
  kasan: add missing annotation for start_report()
  kasan: add missing annotation for end_report()
  futex: Add missing annotation for futex_wait_queue_me()

 fs/fs_pin.c                 | 2 +-
 include/linux/fs_pin.h      | 2 +-
 kernel/events/ring_buffer.c | 2 +-
 kernel/futex.c              | 3 +++
 kernel/sched/deadline.c     | 1 +
 kernel/sched/fair.c         | 2 +-
 kernel/time/hrtimer.c       | 1 +
 mm/kasan/report.c           | 4 ++--
 8 files changed, 11 insertions(+), 6 deletions(-)

-- 
2.24.1



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

* [PATCH 09/11] kasan: add missing annotation for start_report()
  2020-02-09 22:24 ` [PATCH 00/11] Lock warning cleanup Jules Irenge
@ 2020-02-09 22:48   ` Jules Irenge
  2020-02-10  7:27     ` Dmitry Vyukov
  2020-02-09 22:49   ` [PATCH 10/11] kasan: add missing annotation for end_report() Jules Irenge
  2020-02-10  5:06   ` [PATCH 00/11] Lock warning cleanup Boqun Feng
  2 siblings, 1 reply; 7+ messages in thread
From: Jules Irenge @ 2020-02-09 22:48 UTC (permalink / raw)
  To: boqun.feng
  Cc: linux-kernel, linux-mm, kasan-dev, akpm, dvyukov, glider,
	aryabinin, Jules Irenge

Sparse reports a warning at start_report()

warning: context imbalance in start_report() - wrong count at exit

The root cause is a missing annotation at start_report()

Add the missing annotation __acquires(&report_lock)

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
---
 mm/kasan/report.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/kasan/report.c b/mm/kasan/report.c
index 5ef9f24f566b..5451624c4e09 100644
--- a/mm/kasan/report.c
+++ b/mm/kasan/report.c
@@ -77,7 +77,7 @@ static void print_error_description(struct kasan_access_info *info)
 
 static DEFINE_SPINLOCK(report_lock);
 
-static void start_report(unsigned long *flags)
+static void start_report(unsigned long *flags) __acquires(&report_lock)
 {
 	/*
 	 * Make sure we don't end up in loop.
-- 
2.24.1



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

* [PATCH 10/11] kasan: add missing annotation for end_report()
  2020-02-09 22:24 ` [PATCH 00/11] Lock warning cleanup Jules Irenge
  2020-02-09 22:48   ` [PATCH 09/11] kasan: add missing annotation for start_report() Jules Irenge
@ 2020-02-09 22:49   ` Jules Irenge
  2020-02-10  7:27     ` Dmitry Vyukov
  2020-02-10  5:06   ` [PATCH 00/11] Lock warning cleanup Boqun Feng
  2 siblings, 1 reply; 7+ messages in thread
From: Jules Irenge @ 2020-02-09 22:49 UTC (permalink / raw)
  To: boqun.feng
  Cc: linux-kernel, linux-mm, kasan-dev, akpm, dvyukov, glider,
	aryabinin, Jules Irenge

Sparse reports a warning at end_report()

warning: context imbalance in end_report() - unexpected lock

The root cause is a missing annotation at end_report()

Add the missing annotation __releases(&report_lock)

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
---
 mm/kasan/report.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/kasan/report.c b/mm/kasan/report.c
index 5451624c4e09..8adaa4eaee31 100644
--- a/mm/kasan/report.c
+++ b/mm/kasan/report.c
@@ -87,7 +87,7 @@ static void start_report(unsigned long *flags) __acquires(&report_lock)
 	pr_err("==================================================================\n");
 }
 
-static void end_report(unsigned long *flags)
+static void end_report(unsigned long *flags)  __releases(&report_lock)
 {
 	pr_err("==================================================================\n");
 	add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);
-- 
2.24.1



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

* Re: [PATCH 00/11] Lock warning cleanup
  2020-02-09 22:24 ` [PATCH 00/11] Lock warning cleanup Jules Irenge
  2020-02-09 22:48   ` [PATCH 09/11] kasan: add missing annotation for start_report() Jules Irenge
  2020-02-09 22:49   ` [PATCH 10/11] kasan: add missing annotation for end_report() Jules Irenge
@ 2020-02-10  5:06   ` Boqun Feng
  2020-02-10 23:09     ` Jules Irenge
  2 siblings, 1 reply; 7+ messages in thread
From: Boqun Feng @ 2020-02-10  5:06 UTC (permalink / raw)
  To: Jules Irenge
  Cc: linux-kernel, linux-mm, kasan-dev, akpm, dvyukov, glider,
	aryabinin, bsegall, rostedt, dietmar.eggemann, vincent.guittot,
	juri.lelli, peterz, mingo, mgorman, dvhart, tglx, namhyung,
	jolsa, alexander.shishkin, mark.rutland, acme, viro,
	linux-fsdevel

Hi Jules,

On Sun, Feb 09, 2020 at 10:24:42PM +0000, Jules Irenge wrote:
> This patch series adds missing annotations to functions that register warnings of context imbalance when built with Sparse tool.
> The adds fix the warnings and give insight on what the functions are actually doing.
> 
> 1. Within the futex subsystem, a __releases(&pi_state->.pi_mutex.wait_lock) is added because wake_futex_pi() only releases the lock at exit,
> must_hold(q->lock_ptr) have been added to fixup_pi_state_owner() because the lock is held at entry and exit;
> a __releases(&hb->lock) added to futex_wait_queue_me() as it only releases the lock.
> 
> 2. Within fs_pin, a __releases(RCU) is added because the function exit RCU critical section at exit.
> 
> 3. In kasan, an __acquires(&report_lock) has been added to start_report() and   __releases(&report_lock) to end_report() 
> 
> 4. Within ring_buffer subsystem, a __releases(RCU) has been added perf_output_end() 
> 
> 5. schedule subsystem recorded an addition of the __releases(rq->lock) annotation and a __must_hold(this_rq->lock)
> 
> 6. At hrtimer subsystem, __acquires(timer) is added  to lock_hrtimer_base() as the function acquire the lock but never releases it.
> Jules Irenge (11):
>   hrtimer: Add missing annotation to lock_hrtimer_base()
>   futex: Add missing annotation for wake_futex_pi()
>   futex: Add missing annotation for fixup_pi_state_owner()

Given that those three patches have been sent and reviewed, please do
increase the version number (this time, for example, using v2) when
sending the updated ones. Also please add a few sentences after the
commit log describing what you have changed between versions.

Here is an example:

	https://lore.kernel.org/lkml/20200124231834.63628-4-pmalani@chromium.org/

Regards,
Boqun

>   perf/ring_buffer: Add missing annotation to perf_output_end()
>   sched/fair: Add missing annotation for nohz_newidle_balance()
>   sched/deadline: Add missing annotation for dl_task_offline_migration()
>   fs_pin: Add missing annotation for pin_kill() declaration
>   fs_pin: Add missing annotation for pin_kill() definition
>   kasan: add missing annotation for start_report()
>   kasan: add missing annotation for end_report()
>   futex: Add missing annotation for futex_wait_queue_me()
> 
>  fs/fs_pin.c                 | 2 +-
>  include/linux/fs_pin.h      | 2 +-
>  kernel/events/ring_buffer.c | 2 +-
>  kernel/futex.c              | 3 +++
>  kernel/sched/deadline.c     | 1 +
>  kernel/sched/fair.c         | 2 +-
>  kernel/time/hrtimer.c       | 1 +
>  mm/kasan/report.c           | 4 ++--
>  8 files changed, 11 insertions(+), 6 deletions(-)
> 
> -- 
> 2.24.1
> 


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

* Re: [PATCH 10/11] kasan: add missing annotation for end_report()
  2020-02-09 22:49   ` [PATCH 10/11] kasan: add missing annotation for end_report() Jules Irenge
@ 2020-02-10  7:27     ` Dmitry Vyukov
  0 siblings, 0 replies; 7+ messages in thread
From: Dmitry Vyukov @ 2020-02-10  7:27 UTC (permalink / raw)
  To: Jules Irenge
  Cc: Boqun Feng, LKML, Linux-MM, kasan-dev, Andrew Morton,
	Alexander Potapenko, Andrey Ryabinin

On Sun, Feb 9, 2020 at 11:49 PM Jules Irenge <jbi.octave@gmail.com> wrote:
>
> Sparse reports a warning at end_report()
>
> warning: context imbalance in end_report() - unexpected lock
>
> The root cause is a missing annotation at end_report()
>
> Add the missing annotation __releases(&report_lock)
>
> Signed-off-by: Jules Irenge <jbi.octave@gmail.com>

Acked-by: Dmitry Vyukov <dvyukov@google.com>

> ---
>  mm/kasan/report.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/kasan/report.c b/mm/kasan/report.c
> index 5451624c4e09..8adaa4eaee31 100644
> --- a/mm/kasan/report.c
> +++ b/mm/kasan/report.c
> @@ -87,7 +87,7 @@ static void start_report(unsigned long *flags) __acquires(&report_lock)
>         pr_err("==================================================================\n");
>  }
>
> -static void end_report(unsigned long *flags)
> +static void end_report(unsigned long *flags)  __releases(&report_lock)
>  {
>         pr_err("==================================================================\n");
>         add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);
> --
> 2.24.1
>


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

* Re: [PATCH 09/11] kasan: add missing annotation for start_report()
  2020-02-09 22:48   ` [PATCH 09/11] kasan: add missing annotation for start_report() Jules Irenge
@ 2020-02-10  7:27     ` Dmitry Vyukov
  0 siblings, 0 replies; 7+ messages in thread
From: Dmitry Vyukov @ 2020-02-10  7:27 UTC (permalink / raw)
  To: Jules Irenge
  Cc: Boqun Feng, LKML, Linux-MM, kasan-dev, Andrew Morton,
	Alexander Potapenko, Andrey Ryabinin

On Sun, Feb 9, 2020 at 11:48 PM Jules Irenge <jbi.octave@gmail.com> wrote:
>
> Sparse reports a warning at start_report()
>
> warning: context imbalance in start_report() - wrong count at exit
>
> The root cause is a missing annotation at start_report()
>
> Add the missing annotation __acquires(&report_lock)
>
> Signed-off-by: Jules Irenge <jbi.octave@gmail.com>

Acked-by: Dmitry Vyukov <dvyukov@google.com>

> ---
>  mm/kasan/report.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/kasan/report.c b/mm/kasan/report.c
> index 5ef9f24f566b..5451624c4e09 100644
> --- a/mm/kasan/report.c
> +++ b/mm/kasan/report.c
> @@ -77,7 +77,7 @@ static void print_error_description(struct kasan_access_info *info)
>
>  static DEFINE_SPINLOCK(report_lock);
>
> -static void start_report(unsigned long *flags)
> +static void start_report(unsigned long *flags) __acquires(&report_lock)
>  {
>         /*
>          * Make sure we don't end up in loop.
> --
> 2.24.1
>


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

* Re: [PATCH 00/11] Lock warning cleanup
  2020-02-10  5:06   ` [PATCH 00/11] Lock warning cleanup Boqun Feng
@ 2020-02-10 23:09     ` Jules Irenge
  0 siblings, 0 replies; 7+ messages in thread
From: Jules Irenge @ 2020-02-10 23:09 UTC (permalink / raw)
  To: Boqun Feng
  Cc: Jules Irenge, linux-kernel, linux-mm, kasan-dev, akpm, dvyukov,
	glider, aryabinin, bsegall, rostedt, dietmar.eggemann,
	vincent.guittot, juri.lelli, peterz, mingo, mgorman, dvhart,
	tglx, namhyung, jolsa, alexander.shishkin, mark.rutland, acme,
	viro, linux-fsdevel



On Mon, 10 Feb 2020, Boqun Feng wrote:

> Hi Jules,
> 
> On Sun, Feb 09, 2020 at 10:24:42PM +0000, Jules Irenge wrote:
> > This patch series adds missing annotations to functions that register warnings of context imbalance when built with Sparse tool.
> > The adds fix the warnings and give insight on what the functions are actually doing.
> > 
> > 1. Within the futex subsystem, a __releases(&pi_state->.pi_mutex.wait_lock) is added because wake_futex_pi() only releases the lock at exit,
> > must_hold(q->lock_ptr) have been added to fixup_pi_state_owner() because the lock is held at entry and exit;
> > a __releases(&hb->lock) added to futex_wait_queue_me() as it only releases the lock.
> > 
> > 2. Within fs_pin, a __releases(RCU) is added because the function exit RCU critical section at exit.
> > 
> > 3. In kasan, an __acquires(&report_lock) has been added to start_report() and   __releases(&report_lock) to end_report() 
> > 
> > 4. Within ring_buffer subsystem, a __releases(RCU) has been added perf_output_end() 
> > 
> > 5. schedule subsystem recorded an addition of the __releases(rq->lock) annotation and a __must_hold(this_rq->lock)
> > 
> > 6. At hrtimer subsystem, __acquires(timer) is added  to lock_hrtimer_base() as the function acquire the lock but never releases it.
> > Jules Irenge (11):
> >   hrtimer: Add missing annotation to lock_hrtimer_base()
> >   futex: Add missing annotation for wake_futex_pi()
> >   futex: Add missing annotation for fixup_pi_state_owner()
> 
> Given that those three patches have been sent and reviewed, please do
> increase the version number (this time, for example, using v2) when
> sending the updated ones. Also please add a few sentences after the
> commit log describing what you have changed between versions.
> 
> Here is an example:
> 
> 	https://lore.kernel.org/lkml/20200124231834.63628-4-pmalani@chromium.org/
> 
> Regards,
> Boqun
> 
> >   perf/ring_buffer: Add missing annotation to perf_output_end()
> >   sched/fair: Add missing annotation for nohz_newidle_balance()
> >   sched/deadline: Add missing annotation for dl_task_offline_migration()
> >   fs_pin: Add missing annotation for pin_kill() declaration
> >   fs_pin: Add missing annotation for pin_kill() definition
> >   kasan: add missing annotation for start_report()
> >   kasan: add missing annotation for end_report()
> >   futex: Add missing annotation for futex_wait_queue_me()
> > 
> >  fs/fs_pin.c                 | 2 +-
> >  include/linux/fs_pin.h      | 2 +-
> >  kernel/events/ring_buffer.c | 2 +-
> >  kernel/futex.c              | 3 +++
> >  kernel/sched/deadline.c     | 1 +
> >  kernel/sched/fair.c         | 2 +-
> >  kernel/time/hrtimer.c       | 1 +
> >  mm/kasan/report.c           | 4 ++--
> >  8 files changed, 11 insertions(+), 6 deletions(-)
> > 
> > -- 
> > 2.24.1
> > 
> 

Thanks for the feedback, I take good notes. I am working on the 
second version.

Kind regards,
Jules


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

end of thread, other threads:[~2020-02-10 23:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <0/11>
2020-02-09 22:24 ` [PATCH 00/11] Lock warning cleanup Jules Irenge
2020-02-09 22:48   ` [PATCH 09/11] kasan: add missing annotation for start_report() Jules Irenge
2020-02-10  7:27     ` Dmitry Vyukov
2020-02-09 22:49   ` [PATCH 10/11] kasan: add missing annotation for end_report() Jules Irenge
2020-02-10  7:27     ` Dmitry Vyukov
2020-02-10  5:06   ` [PATCH 00/11] Lock warning cleanup Boqun Feng
2020-02-10 23:09     ` Jules Irenge

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).