Hou Tao 62cf51cb0e bpf: Enable IRQ after irq_work_raise() completes in unit_free{_rcu}()
Both unit_free() and unit_free_rcu() invoke irq_work_raise() to free
freed objects back to slab and the invocation may also be preempted by
unit_alloc() and unit_alloc() may return NULL unexpectedly as shown in
the following case:

task A         task B

unit_free()
  // high_watermark = 48
  // free_cnt = 49 after free
  irq_work_raise()
    // mark irq work as IRQ_WORK_PENDING
    irq_work_claim()

               // task B preempts task A
               unit_alloc()
                 // free_cnt = 48 after alloc

               // does unit_alloc() 32-times
	       ......
	       // free_cnt = 16

	       unit_alloc()
	         // free_cnt = 15 after alloc
                 // irq work is already PENDING,
                 // so just return
                 irq_work_raise()

	       // does unit_alloc() 15-times
               ......
	       // free_cnt = 0

               unit_alloc()
                 // free_cnt = 0 before alloc
                 return NULL

Fix it by enabling IRQ after irq_work_raise() completes.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Link: https://lore.kernel.org/r/20230901111954.1804721-3-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2023-09-08 08:42:19 -07:00
..
2023-09-05 11:01:47 -07:00
2023-09-04 13:20:19 -07:00
2023-08-08 10:29:21 -07:00
2023-08-31 12:43:10 -07:00
2023-09-04 13:20:19 -07:00
2023-09-01 09:38:00 -07:00
2023-09-02 11:10:50 -07:00
2023-08-30 08:17:35 -07:00
2022-09-26 10:13:13 -07:00
2023-08-18 10:18:49 -07:00
2023-09-01 15:44:45 -07:00
2023-03-24 11:01:29 +01:00
2023-08-30 09:16:56 -07:00
2023-08-23 09:38:17 +09:00
2023-06-28 15:51:08 -07:00
2023-08-18 10:12:02 -07:00
2023-06-28 16:05:21 -07:00
2023-08-15 15:26:17 -07:00