public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [Bug runtime/31052] New: enabling -DDEBUG_MEMALLOC_MIGHT_SLEEP results in a lot of kernel errors
@ 2023-11-11  6:29 agentzh at gmail dot com
  2023-11-14 20:50 ` [Bug runtime/31052] " agentzh at gmail dot com
  0 siblings, 1 reply; 2+ messages in thread
From: agentzh at gmail dot com @ 2023-11-11  6:29 UTC (permalink / raw)
  To: systemtap

https://sourceware.org/bugzilla/show_bug.cgi?id=31052

            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: 615079,
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    
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> 3d 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 might
sleep?

-- 
You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug runtime/31052] enabling -DDEBUG_MEMALLOC_MIGHT_SLEEP results in a lot of kernel errors
  2023-11-11  6:29 [Bug runtime/31052] New: enabling -DDEBUG_MEMALLOC_MIGHT_SLEEP results in a lot of kernel errors agentzh at gmail dot com
@ 2023-11-14 20:50 ` agentzh at gmail dot com
  0 siblings, 0 replies; 2+ messages in thread
From: agentzh at gmail dot com @ 2023-11-14 20:50 UTC (permalink / raw)
  To: systemtap

https://sourceware.org/bugzilla/show_bug.cgi?id=31052

agentzh <agentzh at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from agentzh <agentzh at gmail dot com> ---
Fixed in commit 3217411404.

-- 
You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-14 20:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-11  6:29 [Bug runtime/31052] New: enabling -DDEBUG_MEMALLOC_MIGHT_SLEEP results in a lot of kernel errors agentzh at gmail dot com
2023-11-14 20:50 ` [Bug runtime/31052] " agentzh at gmail dot com

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 read-only IMAP folder(s) and NNTP newsgroup(s).