linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: Nick Desaulniers <ndesaulniers@google.com>,
	Ingo Molnar <mingo@redhat.com>, Boqun Feng <boqun.feng@gmail.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Andy Lutomirski <luto@kernel.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Daniel Bristot de Oliveira <bristot@redhat.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Joey Gouly <joey.gouly@arm.com>, Marc Zyngier <maz@kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH] lockdep: fix -Wunused-parameter for _THIS_IP_
Date: Tue, 15 Mar 2022 11:00:04 -0400	[thread overview]
Message-ID: <2a77efcb-8dbb-732d-bc5d-d4cfe4c32184@redhat.com> (raw)
In-Reply-To: <20220314221909.2027027-1-ndesaulniers@google.com>

On 3/14/22 18:19, Nick Desaulniers wrote:
> While looking into a bug related to the compiler's handling of addresses
> of labels, I noticed some uses of _THIS_IP_ seemed unused in lockdep.
> Drive by cleanup.
>
> -Wunused-parameter:
> kernel/locking/lockdep.c:1383:22: warning: unused parameter 'ip'
> kernel/locking/lockdep.c:4246:48: warning: unused parameter 'ip'
> kernel/locking/lockdep.c:4844:19: warning: unused parameter 'ip'
>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
>   arch/arm64/kernel/entry-common.c |  8 ++++----
>   include/linux/irqflags.h         |  4 ++--
>   include/linux/kvm_host.h         |  2 +-
>   kernel/entry/common.c            |  6 +++---
>   kernel/locking/lockdep.c         | 22 ++++++++--------------
>   kernel/sched/idle.c              |  2 +-
>   kernel/trace/trace_preemptirq.c  |  4 ++--
>   7 files changed, 21 insertions(+), 27 deletions(-)
>
> diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c
> index ef7fcefb96bd..8a4244316e25 100644
> --- a/arch/arm64/kernel/entry-common.c
> +++ b/arch/arm64/kernel/entry-common.c
> @@ -73,7 +73,7 @@ static __always_inline void __exit_to_kernel_mode(struct pt_regs *regs)
>   	if (interrupts_enabled(regs)) {
>   		if (regs->exit_rcu) {
>   			trace_hardirqs_on_prepare();
> -			lockdep_hardirqs_on_prepare(CALLER_ADDR0);
> +			lockdep_hardirqs_on_prepare();
>   			rcu_irq_exit();
>   			lockdep_hardirqs_on(CALLER_ADDR0);
>   			return;
> @@ -118,7 +118,7 @@ static __always_inline void enter_from_user_mode(struct pt_regs *regs)
>   static __always_inline void __exit_to_user_mode(void)
>   {
>   	trace_hardirqs_on_prepare();
> -	lockdep_hardirqs_on_prepare(CALLER_ADDR0);
> +	lockdep_hardirqs_on_prepare();
>   	user_enter_irqoff();
>   	lockdep_hardirqs_on(CALLER_ADDR0);
>   }
> @@ -176,7 +176,7 @@ static void noinstr arm64_exit_nmi(struct pt_regs *regs)
>   	ftrace_nmi_exit();
>   	if (restore) {
>   		trace_hardirqs_on_prepare();
> -		lockdep_hardirqs_on_prepare(CALLER_ADDR0);
> +		lockdep_hardirqs_on_prepare();
>   	}
>   
>   	rcu_nmi_exit();
> @@ -212,7 +212,7 @@ static void noinstr arm64_exit_el1_dbg(struct pt_regs *regs)
>   
>   	if (restore) {
>   		trace_hardirqs_on_prepare();
> -		lockdep_hardirqs_on_prepare(CALLER_ADDR0);
> +		lockdep_hardirqs_on_prepare();
>   	}
>   
>   	rcu_nmi_exit();
> diff --git a/include/linux/irqflags.h b/include/linux/irqflags.h
> index 4b140938b03e..5ec0fa71399e 100644
> --- a/include/linux/irqflags.h
> +++ b/include/linux/irqflags.h
> @@ -20,13 +20,13 @@
>   #ifdef CONFIG_PROVE_LOCKING
>     extern void lockdep_softirqs_on(unsigned long ip);
>     extern void lockdep_softirqs_off(unsigned long ip);
> -  extern void lockdep_hardirqs_on_prepare(unsigned long ip);
> +  extern void lockdep_hardirqs_on_prepare(void);
>     extern void lockdep_hardirqs_on(unsigned long ip);
>     extern void lockdep_hardirqs_off(unsigned long ip);
>   #else
>     static inline void lockdep_softirqs_on(unsigned long ip) { }
>     static inline void lockdep_softirqs_off(unsigned long ip) { }
> -  static inline void lockdep_hardirqs_on_prepare(unsigned long ip) { }
> +  static inline void lockdep_hardirqs_on_prepare(void) { }
>     static inline void lockdep_hardirqs_on(unsigned long ip) { }
>     static inline void lockdep_hardirqs_off(unsigned long ip) { }
>   #endif
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index f11039944c08..f32bed70a5c5 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -441,7 +441,7 @@ static __always_inline void guest_state_enter_irqoff(void)
>   {
>   	instrumentation_begin();
>   	trace_hardirqs_on_prepare();
> -	lockdep_hardirqs_on_prepare(CALLER_ADDR0);
> +	lockdep_hardirqs_on_prepare();
>   	instrumentation_end();
>   
>   	guest_context_enter_irqoff();
> diff --git a/kernel/entry/common.c b/kernel/entry/common.c
> index bad713684c2e..3ce3a0a6c762 100644
> --- a/kernel/entry/common.c
> +++ b/kernel/entry/common.c
> @@ -124,7 +124,7 @@ static __always_inline void __exit_to_user_mode(void)
>   {
>   	instrumentation_begin();
>   	trace_hardirqs_on_prepare();
> -	lockdep_hardirqs_on_prepare(CALLER_ADDR0);
> +	lockdep_hardirqs_on_prepare();
>   	instrumentation_end();
>   
>   	user_enter_irqoff();
> @@ -412,7 +412,7 @@ noinstr void irqentry_exit(struct pt_regs *regs, irqentry_state_t state)
>   			instrumentation_begin();
>   			/* Tell the tracer that IRET will enable interrupts */
>   			trace_hardirqs_on_prepare();
> -			lockdep_hardirqs_on_prepare(CALLER_ADDR0);
> +			lockdep_hardirqs_on_prepare();
>   			instrumentation_end();
>   			rcu_irq_exit();
>   			lockdep_hardirqs_on(CALLER_ADDR0);
> @@ -465,7 +465,7 @@ void noinstr irqentry_nmi_exit(struct pt_regs *regs, irqentry_state_t irq_state)
>   	ftrace_nmi_exit();
>   	if (irq_state.lockdep) {
>   		trace_hardirqs_on_prepare();
> -		lockdep_hardirqs_on_prepare(CALLER_ADDR0);
> +		lockdep_hardirqs_on_prepare();
>   	}
>   	instrumentation_end();
>   
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index f8a0212189ca..05604795b39c 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -1378,7 +1378,7 @@ static struct lock_list *alloc_list_entry(void)
>    */
>   static int add_lock_to_list(struct lock_class *this,
>   			    struct lock_class *links_to, struct list_head *head,
> -			    unsigned long ip, u16 distance, u8 dep,
> +			    u16 distance, u8 dep,
>   			    const struct lock_trace *trace)
>   {
>   	struct lock_list *entry;
> @@ -3131,19 +3131,15 @@ check_prev_add(struct task_struct *curr, struct held_lock *prev,
>   	 * to the previous lock's dependency list:
>   	 */
>   	ret = add_lock_to_list(hlock_class(next), hlock_class(prev),
> -			       &hlock_class(prev)->locks_after,
> -			       next->acquire_ip, distance,
> -			       calc_dep(prev, next),
> -			       *trace);
> +			       &hlock_class(prev)->locks_after, distance,
> +			       calc_dep(prev, next), *trace);
>   
>   	if (!ret)
>   		return 0;
>   
>   	ret = add_lock_to_list(hlock_class(prev), hlock_class(next),
> -			       &hlock_class(next)->locks_before,
> -			       next->acquire_ip, distance,
> -			       calc_depb(prev, next),
> -			       *trace);
> +			       &hlock_class(next)->locks_before, distance,
> +			       calc_depb(prev, next), *trace);
>   	if (!ret)
>   		return 0;
>   
> @@ -4234,14 +4230,13 @@ static void __trace_hardirqs_on_caller(void)
>   
>   /**
>    * lockdep_hardirqs_on_prepare - Prepare for enabling interrupts
> - * @ip:		Caller address
>    *
>    * Invoked before a possible transition to RCU idle from exit to user or
>    * guest mode. This ensures that all RCU operations are done before RCU
>    * stops watching. After the RCU transition lockdep_hardirqs_on() has to be
>    * invoked to set the final state.
>    */
> -void lockdep_hardirqs_on_prepare(unsigned long ip)
> +void lockdep_hardirqs_on_prepare(void)
>   {
>   	if (unlikely(!debug_locks))
>   		return;
> @@ -4838,8 +4833,7 @@ EXPORT_SYMBOL_GPL(__lockdep_no_validate__);
>   
>   static void
>   print_lock_nested_lock_not_held(struct task_struct *curr,
> -				struct held_lock *hlock,
> -				unsigned long ip)
> +				struct held_lock *hlock)
>   {
>   	if (!debug_locks_off())
>   		return;
> @@ -5015,7 +5009,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
>   	chain_key = iterate_chain_key(chain_key, hlock_id(hlock));
>   
>   	if (nest_lock && !__lock_is_held(nest_lock, -1)) {
> -		print_lock_nested_lock_not_held(curr, hlock, ip);
> +		print_lock_nested_lock_not_held(curr, hlock);
>   		return 0;
>   	}
>   
> diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
> index d17b0a5ce6ac..499a3e286cd0 100644
> --- a/kernel/sched/idle.c
> +++ b/kernel/sched/idle.c
> @@ -105,7 +105,7 @@ void __cpuidle default_idle_call(void)
>   		 * last -- this is very similar to the entry code.
>   		 */
>   		trace_hardirqs_on_prepare();
> -		lockdep_hardirqs_on_prepare(_THIS_IP_);
> +		lockdep_hardirqs_on_prepare();
>   		rcu_idle_enter();
>   		lockdep_hardirqs_on(_THIS_IP_);
>   
> diff --git a/kernel/trace/trace_preemptirq.c b/kernel/trace/trace_preemptirq.c
> index f4938040c228..95b58bd757ce 100644
> --- a/kernel/trace/trace_preemptirq.c
> +++ b/kernel/trace/trace_preemptirq.c
> @@ -46,7 +46,7 @@ void trace_hardirqs_on(void)
>   		this_cpu_write(tracing_irq_cpu, 0);
>   	}
>   
> -	lockdep_hardirqs_on_prepare(CALLER_ADDR0);
> +	lockdep_hardirqs_on_prepare();
>   	lockdep_hardirqs_on(CALLER_ADDR0);
>   }
>   EXPORT_SYMBOL(trace_hardirqs_on);
> @@ -94,7 +94,7 @@ __visible void trace_hardirqs_on_caller(unsigned long caller_addr)
>   		this_cpu_write(tracing_irq_cpu, 0);
>   	}
>   
> -	lockdep_hardirqs_on_prepare(CALLER_ADDR0);
> +	lockdep_hardirqs_on_prepare();
>   	lockdep_hardirqs_on(CALLER_ADDR0);
>   }
>   EXPORT_SYMBOL(trace_hardirqs_on_caller);

LGTM

Acked-by: Waiman Long <longman@redhat.com>


  reply	other threads:[~2022-03-15 15:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-14 22:19 [PATCH] lockdep: fix -Wunused-parameter for _THIS_IP_ Nick Desaulniers
2022-03-15 15:00 ` Waiman Long [this message]
2022-04-05  8:36 ` [tip: locking/core] lockdep: Fix " tip-bot2 for Nick Desaulniers

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=2a77efcb-8dbb-732d-bc5d-d4cfe4c32184@redhat.com \
    --to=longman@redhat.com \
    --cc=boqun.feng@gmail.com \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=catalin.marinas@arm.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=joey.gouly@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=ndesaulniers@google.com \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=vincent.guittot@linaro.org \
    --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;
as well as URLs for NNTP newsgroup(s).