lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7336e00d-11d8-9be1-8856-92e47b42aa37@nvidia.com>
Date:   Sun, 9 Jun 2019 16:38:15 -0700
From:   John Hubbard <jhubbard@...dia.com>
To:     <paulmck@...ux.ibm.com>, <john.hubbard@...il.com>
CC:     LKML <linux-kernel@...r.kernel.org>,
        Frederic Weisbecker <frederic@...nel.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Will Deacon <will.deacon@....com>
Subject: Re: [PATCH 1/1] lockdep: fix warning: print_lock_trace defined but
 not used

On 6/9/19 6:51 AM, Paul E. McKenney wrote:
> On Tue, May 21, 2019 at 12:08:08AM -0700, john.hubbard@...il.com wrote:
>> From: John Hubbard <jhubbard@...dia.com>
>>
>> Commit 0d2cc3b34532 ("locking/lockdep: Move valid_state() inside
>> CONFIG_TRACE_IRQFLAGS && CONFIG_PROVE_LOCKING") moved the only usage of
>> print_lock_trace() that was originally outside of the CONFIG_PROVE_LOCKING
>> case. It moved that usage into a different case: CONFIG_PROVE_LOCKING &&
>> CONFIG_TRACE_IRQFLAGS. That leaves things not symmetrical, and as a result,
>> the following warning fires on my build, when I have
>>
>> !CONFIG_TRACE_IRQFLAGS && !CONFIG_PROVE_LOCKING
>>
>> set:
>>
>> kernel/locking/lockdep.c:2821:13: warning: ‘print_lock_trace’ defined
>>     but not used [-Wunused-function]
>>
>> Fix this by only defining print_lock_trace() in cases in which is it
>> called.
>>
>> Fixes: 0d2cc3b34532 ("locking/lockdep: Move valid_state() inside CONFIG_TRACE_IRQFLAGS && CONFIG_PROVE_LOCKING")
>> Cc: Frederic Weisbecker <frederic@...nel.org>
>> Cc: Andrew Morton <akpm@...ux-foundation.org>
>> Cc: Linus Torvalds <torvalds@...ux-foundation.org>
>> Cc: Paul E. McKenney <paulmck@...ux.vnet.ibm.com>
>> Cc: Peter Zijlstra <peterz@...radead.org>
>> Cc: Thomas Gleixner <tglx@...utronix.de>
>> Cc: Will Deacon <will.deacon@....com>
>> Signed-off-by: John Hubbard <jhubbard@...dia.com>
>> ---
>>  kernel/locking/lockdep.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
>> index d06190fa5082..3065dc36c27a 100644
>> --- a/kernel/locking/lockdep.c
>> +++ b/kernel/locking/lockdep.c
>> @@ -2817,11 +2817,14 @@ static inline int validate_chain(struct task_struct *curr,
>>  	return 1;
>>  }
>>
>> +#if defined(CONFIG_TRACE_IRQFLAGS)
>>  static void print_lock_trace(struct lock_trace *trace, unsigned int spaces)
> 
> This works, but another approach is to put "__maybe_unused" in the
> above declaration, which avoids the need to have "#if" in a .c file.


Good idea, that approach appeals to me here, because tracing is a natural fit
for "might not be used" types of functions.


> But this file already has quite a few #if and #ifdef commands, so maybe
> it is OK here.
> 
> Also, "#ifdef CONFIG_TRACE_IRQFLAGS" is a bit more conventional than
> the above, should the "__maybe_unused" be undesirable.

ah, OK, I'll keep that in mind. (The two seemed identical to my mind, but
it's good to make things look like surrounding code, of course.)

thanks,
-- 
John Hubbard
NVIDIA


> 
> Yet another approach is to move this function to include/linux/lockdep.h,
> where #ifdef is considered less objectionable.
> 
> But I must defer to the maintainers.
> 
> 							Thanx, Paul

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ