From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B0D493858D32; Sat, 11 Nov 2023 06:29:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B0D493858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1699684196; bh=Ht/qULVrJfIJd949yUxFigvwcyjy6yrHS5q8nOn47LY=; h=From:To:Subject:Date:From; b=j9hQJQRD5tpSEIPeqR0vxMO3JaGE3gXDa3RFx2XIvHSVrIb24u+PmcB3rxkhNdtts TSM5USJIf43YKFTVWrQaCkIe6VGVOkabJlSmqHmc8ONcK22gqXxNDYvG8YEOiJ9nW+ xRThg0c9lEFWY4tVmtEf2kPTMcdPiD2cktRN9+Gg= From: "agentzh at gmail dot com" To: systemtap@sourceware.org Subject: [Bug runtime/31052] New: enabling -DDEBUG_MEMALLOC_MIGHT_SLEEP results in a lot of kernel errors Date: Sat, 11 Nov 2023 06:29:55 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: systemtap X-Bugzilla-Component: runtime X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: agentzh at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: systemtap at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31052 Bug ID: 31052 Summary: enabling -DDEBUG_MEMALLOC_MIGHT_SLEEP results in a lot of kernel errors Product: systemtap Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: runtime Assignee: systemtap at sourceware dot org Reporter: agentzh at gmail dot com Target Milestone: --- Enabling -DDEBUG_MEMALLOC_MIGHT_SLEEP leads to a lot of kernel dmesg errors like these: ``` [ 4537.268056] BUG: sleeping function called from invalid context at /home/agentzh/git/systemtap-plus/runtime/linux/alloc.c:303 [ 4537.268075] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 61507= 9, name: stapio [ 4537.268079] 4 locks held by stapio/615079: [ 4537.268082] #0: ffff888151b44980 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0xa7/0xc0 [ 4537.268101] #1: ffff8881092dc498 (sb_writers#3){.+.+}-{0:0}, at: ksys_write+0xe9/0x1b0 [ 4537.268117] #2: ffffffffc1024e30 (cmd_mutex){+.+.}-{3:3}, at: _stp_ctl_write_cmd+0x230/0x2de8 [test] [ 4537.268134] #3: ffffffff85486380 (rcu_read_lock){....}-{1:2}, at: _stp_ctl_write_cmd+0x12b7/0x2de8 [test] [ 4537.268151] CPU: 3 PID: 615079 Comm: stapio Tainted: G W OE=20= =20=20=20 5.11.22-100.orinc.fc32.x86_64+debug #1 [ 4537.268155] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1.fc35 04/01/2014 [ 4537.268157] Call Trace: [ 4537.268161] dump_stack+0xae/0xe5 [ 4537.268168] ___might_sleep.cold+0x150/0x17e [ 4537.268174] _stp_kmalloc_gfp+0x22/0x51 [test] [ 4537.268181] _stp_kmalloc+0xf/0x10 [test] [ 4537.268185] __stp_utrace_attach+0x31f/0xf10 [test] [ 4537.268201] _stp_ctl_write_cmd+0x14ad/0x2de8 [test] [ 4537.268209] ? lock_acquire+0x1cc/0x780 [ 4537.268218] ? _stp_cleanup_and_exit+0x65c/0x65c [test] [ 4537.268224] ? _cond_resched+0x15/0x30 [ 4537.268231] ? selinux_file_permission+0x30a/0x3f0 [ 4537.268239] proc_reg_write+0x1ac/0x270 [ 4537.268247] vfs_write+0x180/0x810 [ 4537.268256] ksys_write+0xe9/0x1b0 [ 4537.268260] ? __ia32_sys_read+0xb0/0xb0 [ 4537.268265] ? syscall_enter_from_user_mode+0x27/0x80 [ 4537.268272] do_syscall_64+0x33/0x40 [ 4537.268276] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 4537.268279] RIP: 0033:0x7fc63c87690f [ 4537.268284] Code: 89 54 24 18 48 89 74 24 10 89 7c 24 08 e8 29 fd ff ff = 48 8b 54 24 18 48 8b 74 24 10 41 89 c0 8b 7c 24 08 b8 01 00 00 00 0f 05 <48> 3= d 00 f0 ff ff 77 31 44 89 c7 48 89 44 24 08 e8 5c fd ff ff 48 [ 4537.268287] RSP: 002b:00007ffe95ab9770 EFLAGS: 00000293 ORIG_RAX: 0000000000000001 [ 4537.268294] RAX: ffffffffffffffda RBX: 0000000000000008 RCX: 00007fc63c87690f [ 4537.268297] RDX: 000000000000000c RSI: 00007ffe95ab97a0 RDI: 0000000000000004 [ 4537.268300] RBP: 0000000000008002 R08: 0000000000000000 R09: 00007fc62c675700 [ 4537.268302] R10: 00007fc62c6759d0 R11: 0000000000000293 R12: 000000000000000c [ 4537.268305] R13: 0000000000000001 R14: 0000000000000000 R15: 00007ffe95ab9c84 ``` The guilty code snippet is here: ``` static void *_stp_kmalloc_gfp(size_t size, gfp_t gfp_mask) { void *ret; #ifdef DEBUG_MEMALLOC_MIGHT_SLEEP might_sleep(); #endif ``` Seems like we should really enable `might_sleep()` only when the gfp_mask m= ight sleep? --=20 You are receiving this mail because: You are the assignee for the bug.=