mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Nathan Chancellor <nathan@kernel.org>,
	kernel test robot <lkp@intel.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Masahiro Yamada <masahiroy@kernel.org>,
	kbuild-all@lists.01.org, clang-built-linux@googlegroups.com,
	linux-kernel@vger.kernel.org,
	Michael Ellerman <mpe@ellerman.id.au>
Subject: Re: arch/powerpc/kernel/optprobes.c:34:1: error: unused function 'is_kprobe_ppc_optinsn_slot'
Date: Thu, 13 May 2021 08:42:39 +0900	[thread overview]
Message-ID: <20210513084239.3af8c2498263e7f0b233b72e@kernel.org> (raw)
In-Reply-To: <8d12be5a-d700-c0aa-86ee-ebb97927c34c@csgroup.eu>

On Wed, 12 May 2021 17:12:32 +0200
Christophe Leroy <christophe.leroy@csgroup.eu> wrote:

> 
> 
> Le 12/05/2021 à 17:06, Masami Hiramatsu a écrit :
> > On Wed, 12 May 2021 21:50:57 +0900
> > Masami Hiramatsu <mhiramat@kernel.org> wrote:
> > 
> >> On Wed, 12 May 2021 11:52:30 +0200
> >> Christophe Leroy <christophe.leroy@csgroup.eu> wrote:
> > 
> >>>
> >>> Le 12/05/2021 à 11:36, Christophe Leroy a écrit :
> >>>>
> >>>>
> >>>> Le 11/05/2021 à 20:46, Nathan Chancellor a écrit :
> >>>>> On 5/11/2021 9:47 AM, Christophe Leroy wrote:
> >>>>>> Hi All,
> >>>>>>
> >>>>>> Le 11/05/2021 à 18:30, kernel test robot a écrit :
> >>>>>>> Hi Christophe,
> >>>>>>>
> >>>>>>> First bad commit (maybe != root cause):
> >>>>>>>
> >>>>>>> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> >>>>>>> head:   1140ab592e2ebf8153d2b322604031a8868ce7a5
> >>>>>>> commit: eacf4c0202654adfa94bbb17b5c5c77c0be14af8 powerpc: Enable OPTPROBES on PPC32
> >>>>
> >>>> Ok, the problem appears on PPC32 with that patch, but it must have been there on PPC64 since the
> >>>> implementation of optprobes with commit 51c9c0843993 ("powerpc/kprobes: Implement Optprobes")
> >>>>
> >>>>
> >>>>>>> date:   3 weeks ago
> >>>>>>> config: powerpc-randconfig-r033-20210511 (attached as .config)
> >>>>>>> compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project
> >>>>>>> a0fed635fe1701470062495a6ffee1c608f3f1bc)
> >>>>>>
> >>>>>> A clang issue ?
> >>>>>>
> >>>>>>
> >>>>>>> reproduce (this is a W=1 build):
> >>>>>>>           wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O
> >>>>>>> ~/bin/make.cross
> >>>>>>>           chmod +x ~/bin/make.cross
> >>>>>>>           # install powerpc cross compiling tool for clang build
> >>>>>>>           # apt-get install binutils-powerpc-linux-gnu
> >>>>>>>           #
> >>>>>>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=eacf4c0202654adfa94bbb17b5c5c77c0be14af8
> >>>>>>>
> >>>>>>>           git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> >>>>>>>           git fetch --no-tags linus master
> >>>>>>>           git checkout eacf4c0202654adfa94bbb17b5c5c77c0be14af8
> >>>>>>>           # save the attached .config to linux build tree
> >>>>>>>           COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=powerpc
> >>>>>>>
> >>>>>>> If you fix the issue, kindly add following tag as appropriate
> >>>>>>> Reported-by: kernel test robot <lkp@intel.com>
> >>>>>>>
> >>>>>>> All errors (new ones prefixed by >>):
> >>>>>>>
> >>>>>>>>> arch/powerpc/kernel/optprobes.c:34:1: error: unused function 'is_kprobe_ppc_optinsn_slot'
> >>>>>>>>> [-Werror,-Wunused-function]
> >>>>>>>      DEFINE_INSN_CACHE_OPS(ppc_optinsn);
> >>>>>>>      ^
> >>>>>>>      include/linux/kprobes.h:306:20: note: expanded from macro 'DEFINE_INSN_CACHE_OPS'
> >>>>>>>      static inline bool is_kprobe_##__name##_slot(unsigned long addr)        \
> >>>>>>
> >>>>>> That's a 'static inline', shouldn't generate an 'unused function' warning.
> >>>>> This is a W=1 build, which means that "inline" does not silence unused function warnings with
> >>>>> clang because of commit 6863f5643dd7 ("kbuild: allow Clang to find unused static inline functions
> >>>>> for W=1 build").
> >>>>
> >>>> Ok, I didn't know that.
> >>>
> >>> After looking at it in more details, I don't really know what should be done to avoid that.
> >>
> >> Ah, thanks for reporting!
> >>
> >>>
> >>> This unused function is defined as part of DEFINE_INSN_CACHE_OPS(ppc_optinsn).
> >>>
> >>> The code uses other items defined by macro DEFINE_INSN_CACHE_OPS, so it cannot be removed.
> >>>
> >>> Solution could be to hide that in a .h, but is that worth it ?
> >>
> >> The best solution is to remove ppc_optinsn, but that is defined in kernel/kprobes.c
> >> just because page allocation is different.
> >> I think the easiest fix is to add weak alloc_optinsn_page() and override it
> >> in arch/powerpc/kernel/optprobe.c.
> > 
> > Please try this patch.
> > 
> > Thank you,
> 
> 
> Yeah, look pretty similar to the two patches I sent 30 minutes ago.

Ah, I missed it.
OK, let me check.


> 
> 
> 
> > 
> >  From 7782fa154349923ed52baa8843cc1d5eed26e82d Mon Sep 17 00:00:00 2001
> > From: Masami Hiramatsu <mhiramat@kernel.org>
> > Date: Wed, 12 May 2021 23:33:10 +0900
> > Subject: [PATCH] powerpc/kprobes: Define arch specific optinsn memory
> >   allocation
> > 
> 
> > @@ -203,14 +193,14 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, struct kprobe *p)
> >   	unsigned long nip, size;
> >   	int rc, i;
> >   
> > -	kprobe_ppc_optinsn_slots.insn_size = MAX_OPTINSN_SIZE;
> > +	kprobe_optinsn_slots.insn_size = MAX_OPTINSN_SIZE;
> 
> Is this still needed ? It looks like it is already done by init_kprobes() in kernel/kprobes.c

No, not needed anymore.

Thanks!

> 
> >   
> >   	nip = can_optimize(p);
> >   	if (!nip)
> >   		return -EILSEQ;
> >   
> >   	/* Allocate instruction slot for detour buffer */
> > -	buff = get_ppc_optinsn_slot();
> > +	buff = get_optinsn_slot();
> >   	if (!buff)
> >   		return -ENOMEM;
> >   
> 
> Christophe


-- 
Masami Hiramatsu <mhiramat@kernel.org>

  reply	other threads:[~2021-05-12 23:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-11 16:30 kernel test robot
2021-05-11 16:47 ` Christophe Leroy
2021-05-11 18:46   ` Nathan Chancellor
2021-05-12  9:36     ` Christophe Leroy
2021-05-12  9:52       ` Christophe Leroy
2021-05-12 12:50         ` Masami Hiramatsu
2021-05-12 15:06           ` Masami Hiramatsu
2021-05-12 15:12             ` Christophe Leroy
2021-05-12 23:42               ` Masami Hiramatsu [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-04-29 15:33 kernel test robot
2021-04-20  7:43 kernel test robot
2021-03-23 14:06 kernel test robot
2021-03-19 17:00 kernel test robot
2021-03-04 20:34 kernel test robot

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=20210513084239.3af8c2498263e7f0b233b72e@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=christophe.leroy@csgroup.eu \
    --cc=clang-built-linux@googlegroups.com \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=masahiroy@kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    /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

Powered by JetHome