lkml.org 
[lkml]   [2020]   [Jun]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: BUG: using smp_processor_id() in preemptible code in radix_tree_node_alloc
On Fri, Jun 05, 2020 at 04:29:22AM -0700, Matthew Wilcox wrote:
> On Thu, Jun 04, 2020 at 08:55:55PM -0700, Eric Biggers wrote:
> > Possibly a bug in lib/radix-tree.c? this_cpu_ptr() in radix_tree_node_alloc()
> > can be reached without a prior preempt_disable(). Or is the caller of
> > idr_alloc() doing something wrong?
>
> Yes, the idr_alloc() call is plainly wrong:
>
> mutex_lock(&qrtr_port_lock);
> if (!*port) {
> rc = idr_alloc(&qrtr_ports, ipc,
> QRTR_MIN_EPH_SOCKET, QRTR_MAX_EPH_SOCKET + 1,
> GFP_ATOMIC);
>
> If we can take a mutex lock, there's no excuse to be using GFP_ATOMIC.
> That (and the call slightly lower in the function) should be GFP_KERNEL
> as the minimal fix (below). I'll send a followup patch which converts
> this IDR to the XArray instead.

I did see that the GFP_ATOMIC was unnecessary, but it wasn't obvious to me that
it was actually *wrong*.

Shouldn't this requirement be documented for the @gfp argument to idr_alloc()?

- Eric

\
 
 \ /
  Last update: 2020-06-05 18:12    [W:2.115 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site