Linux-RISC-V Archive on lore.kernel.org
 help / color / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: "Quentin Monnet" <quentin@isovalent.com>,
	"Ian Rogers" <irogers@google.com>,
	"Song Liu" <songliubraving@fb.com>,
	"open list:DOCUMENTATION" <linux-doc@vger.kernel.org>,
	"Zi Shen Lim" <zlim.lnx@gmail.com>,
	"Paul Walmsley" <paul.walmsley@sifive.com>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Paul Mackerras" <paulus@samba.org>,
	"Sandipan Das" <sandipan@linux.ibm.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	sparclinux@vger.kernel.org,
	"Shubham Bansal" <illusionist.neo@gmail.com>,
	"Mahesh Bandewar" <maheshb@google.com>,
	"Will Deacon" <will@kernel.org>,
	"Nicolas Dichtel" <nicolas.dichtel@6wind.com>,
	linux-s390 <linux-s390@vger.kernel.org>,
	"Ilya Leoshkevich" <iii@linux.ibm.com>,
	paulburton@kernel.org, "Jonathan Corbet" <corbet@lwn.net>,
	"Mauro Carvalho Chehab" <mchehab+huawei@kernel.org>,
	"Masahiro Yamada" <masahiroy@kernel.org>,
	"X86 ML" <x86@kernel.org>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"Russell King" <linux@armlinux.org.uk>,
	linux-riscv <linux-riscv@lists.infradead.org>,
	"Christian Borntraeger" <borntraeger@de.ibm.com>,
	"Ingo Molnar" <mingo@redhat.com>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Naveen N . Rao" <naveen.n.rao@linux.ibm.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Tobias Klauser" <tklauser@distanz.ch>,
	linux-mips@vger.kernel.org, grantseltzer@gmail.com,
	"Xi Wang" <xi.wang@gmail.com>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	"Kees Cook" <keescook@chromium.org>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Luke Nelson" <luke.r.nels@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>,
	"Heiko Carstens" <hca@linux.ibm.com>,
	ppc-dev <linuxppc-dev@lists.ozlabs.org>,
	"KP Singh" <kpsingh@kernel.org>,
	iecedge@gmail.com, "Simon Horman" <horms@verge.net.au>,
	"Borislav Petkov" <bp@alien8.de>,
	"Alexander Viro" <viro@zeniv.linux.org.uk>,
	"Yonghong Song" <yhs@fb.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Dmitry Vyukov" <dvyukov@google.com>,
	tsbogend@alpha.franken.de,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Hideaki YOSHIFUJI" <yoshfuji@linux-ipv6.org>,
	"Network Development" <netdev@vger.kernel.org>,
	"David Ahern" <dsahern@kernel.org>,
	"Wang YanQing" <udknight@gmail.com>,
	"Martin KaFai Lau" <kafai@fb.com>,
	"Björn Töpel" <bjorn@kernel.org>,
	"Palmer Dabbelt" <palmer@dabbelt.com>, bpf <bpf@vger.kernel.org>,
	"Jianlin Lv" <Jianlin.Lv@arm.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH bpf-next 1/2] bpf: Remove bpf_jit_enable=2 debugging mode
Date: Fri, 23 Apr 2021 09:19:06 +0200
Message-ID: <be132117-f267-5817-136d-e1aeb8409c2a@csgroup.eu> (raw)
In-Reply-To: <CAADnVQ+oQT6C7Qv7P5TV-x7im54omKoCYYKtYhcnhb1Uv3LPMQ@mail.gmail.com>



Le 20/04/2021 à 05:28, Alexei Starovoitov a écrit :
> On Sat, Apr 17, 2021 at 1:16 AM Christophe Leroy
> <christophe.leroy@csgroup.eu> wrote:
>>
>>
>>
>> Le 16/04/2021 à 01:49, Alexei Starovoitov a écrit :
>>> On Thu, Apr 15, 2021 at 8:41 AM Quentin Monnet <quentin@isovalent.com> wrote:
>>>>
>>>> 2021-04-15 16:37 UTC+0200 ~ Daniel Borkmann <daniel@iogearbox.net>
>>>>> On 4/15/21 11:32 AM, Jianlin Lv wrote:
>>>>>> For debugging JITs, dumping the JITed image to kernel log is discouraged,
>>>>>> "bpftool prog dump jited" is much better way to examine JITed dumps.
>>>>>> This patch get rid of the code related to bpf_jit_enable=2 mode and
>>>>>> update the proc handler of bpf_jit_enable, also added auxiliary
>>>>>> information to explain how to use bpf_jit_disasm tool after this change.
>>>>>>
>>>>>> Signed-off-by: Jianlin Lv <Jianlin.Lv@arm.com>
>>>>
>>>> Hello,
>>>>
>>>> For what it's worth, I have already seen people dump the JIT image in
>>>> kernel logs in Qemu VMs running with just a busybox, not for kernel
>>>> development, but in a context where buiding/using bpftool was not
>>>> possible.
>>>
>>> If building/using bpftool is not possible then majority of selftests won't
>>> be exercised. I don't think such environment is suitable for any kind
>>> of bpf development. Much so for JIT debugging.
>>> While bpf_jit_enable=2 is nothing but the debugging tool for JIT developers.
>>> I'd rather nuke that code instead of carrying it from kernel to kernel.
>>>
>>
>> When I implemented JIT for PPC32, it was extremely helpfull.
>>
>> As far as I understand, for the time being bpftool is not usable in my environment because it
>> doesn't support cross compilation when the target's endianess differs from the building host
>> endianess, see discussion at
>> https://lore.kernel.org/bpf/21e66a09-514f-f426-b9e2-13baab0b938b@csgroup.eu/
>>
>> That's right that selftests can't be exercised because they don't build.
>>
>> The question might be candid as I didn't investigate much about the replacement of "bpf_jit_enable=2
>> debugging mode" by bpftool, how do we use bpftool exactly for that ? Especially when using the BPF
>> test module ?
> 
> the kernel developers can add any amount of printk and dumps to debug
> their code,
> but such debugging aid should not be part of the production kernel.
> That sysctl was two things at once: debugging tool for kernel devs and
> introspection for users.
> bpftool jit dump solves the 2nd part. It provides JIT introspection to users.
> Debugging of the kernel can be done with any amount of auxiliary code
> including calling print_hex_dump() during jiting.
> 

I finally managed to cross compile bpftool with libbpf, libopcodes, readline, ncurses, libcap, libz 
and all needed stuff. Was not easy but I made it.

Now, how do I use it ?

Let say I want to dump the jitted code generated from a call to 'tcpdump'. How do I do that with 
'bpftool prog dump jited' ?

I thought by calling this line I would then get programs dumped in a way or another just like when 
setting 'bpf_jit_enable=2', but calling that line just provides me some bpftool help text.

By the way, I would be nice to have a kernel OPTION that selects all OPTIONS required for building 
bpftool. Because you discover them one by one at every build failure. I had to had CONFIG_IPV6, 
CONFIG_DEBUG_BTF, CONFIG_CGROUPS, ... If there could be an option like "Build a 'bpftool' ready 
kernel" that selected all those, it would be great.

Christophe

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  parent reply index

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-15  9:32 Jianlin Lv
2021-04-15  9:32 ` [PATCH bpf-next 2/2] docs: bpf: bpf_jit_enable mode changed Jianlin Lv
2021-04-15 14:37 ` [PATCH bpf-next 1/2] bpf: Remove bpf_jit_enable=2 debugging mode Daniel Borkmann
2021-04-15 15:41   ` Quentin Monnet
2021-04-15 23:49     ` Alexei Starovoitov
2021-04-17  8:16       ` Christophe Leroy
2021-04-20  3:28         ` Alexei Starovoitov
2021-04-21 13:10           ` Christophe Leroy
2021-04-21 15:27             ` Quentin Monnet
2021-04-21 16:29             ` John Fastabend
2021-04-23  7:19           ` Christophe Leroy [this message]
2021-04-23 10:26             ` Quentin Monnet
2021-04-23 10:46               ` Christophe Leroy
2021-04-23 10:59                 ` Quentin Monnet
2021-04-23 11:29                   ` Christophe Leroy
2021-05-14  6:34               ` Christophe Leroy
2021-04-16 13:38   ` Jianlin Lv

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=be132117-f267-5817-136d-e1aeb8409c2a@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=Jianlin.Lv@arm.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=ast@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=borntraeger@de.ibm.com \
    --cc=bp@alien8.de \
    --cc=bpf@vger.kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=corbet@lwn.net \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=dvyukov@google.com \
    --cc=gor@linux.ibm.com \
    --cc=grantseltzer@gmail.com \
    --cc=hca@linux.ibm.com \
    --cc=horms@verge.net.au \
    --cc=hpa@zytor.com \
    --cc=iecedge@gmail.com \
    --cc=iii@linux.ibm.com \
    --cc=illusionist.neo@gmail.com \
    --cc=irogers@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=keescook@chromium.org \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=luke.r.nels@gmail.com \
    --cc=maheshb@google.com \
    --cc=masahiroy@kernel.org \
    --cc=mchehab+huawei@kernel.org \
    --cc=mingo@redhat.com \
    --cc=naveen.n.rao@linux.ibm.com \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.dichtel@6wind.com \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=paulburton@kernel.org \
    --cc=paulus@samba.org \
    --cc=quentin@isovalent.com \
    --cc=sandipan@linux.ibm.com \
    --cc=songliubraving@fb.com \
    --cc=sparclinux@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=tklauser@distanz.ch \
    --cc=tsbogend@alpha.franken.de \
    --cc=udknight@gmail.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    --cc=xi.wang@gmail.com \
    --cc=yhs@fb.com \
    --cc=yoshfuji@linux-ipv6.org \
    --cc=zlim.lnx@gmail.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

Linux-RISC-V Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-riscv/0 linux-riscv/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-riscv linux-riscv/ https://lore.kernel.org/linux-riscv \
		linux-riscv@lists.infradead.org
	public-inbox-index linux-riscv

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-riscv


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git