public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sarah Sharp <sarah.a.sharp@linux.intel.com>
To: Jan Kara <jack@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	Hans de Goede <hdegoede@redhat.com>,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: Warning when calling radix_tree_insert on 3.12-rc4
Date: Mon, 14 Oct 2013 11:17:21 -0700	[thread overview]
Message-ID: <20131014181721.GA18408@xanatos> (raw)
In-Reply-To: <20131014123034.GF19604@quack.suse.cz>

On Mon, Oct 14, 2013 at 02:30:34PM +0200, Jan Kara wrote:
>   Hello Sarah,
> 
> On Fri 11-10-13 15:13:15, Sarah Sharp wrote:
> > I'm testing out some changes to the xHCI USB host controller driver
> > (which uses a radix tree when a UAS device is attached to the host), and
> > I noticed the following warning:
> > 
> > Oct 11 14:42:08 xanatos kernel: [18165.819014] usb 2-2: new SuperSpeed USB device number 2 using xhci_hcd
> > Oct 11 14:42:08 xanatos kernel: [18165.836264] usb 2-2: New USB device found, idVendor=174c, idProduct=55aa
> > Oct 11 14:42:08 xanatos kernel: [18165.836271] usb 2-2: New USB device strings: Mfr=2, Product=3, SerialNumber=1
> > Oct 11 14:42:08 xanatos kernel: [18165.836275] usb 2-2: Product: Plugable USB3-SATA-UASP1
> > Oct 11 14:42:08 xanatos kernel: [18165.836279] usb 2-2: Manufacturer: ASM1053E
> > Oct 11 14:42:08 xanatos kernel: [18165.836291] usb 2-2: SerialNumber: 123456789045
> > Oct 11 14:42:08 xanatos kernel: [18165.847661] BUG: using smp_processor_id() in preemptible [00000000] code: modprobe/8759
> > Oct 11 14:42:08 xanatos kernel: [18165.847667] caller is radix_tree_node_alloc+0x5c/0xa0
>   Well, this warning seems to come from the __get_cpu_var() function. I don't
> see how my commit could have caused what you observe. It seems you are
> calling radix_tree_insert() for a radix tree which has atomic gfp mask set
> and you don't do radix_tree_preload() / radix_tree_preload_end() around
> that? That was always problematic and could lead to the above warning.

I see.  Ok, we'll need to fix that.  The code went into the kernel years
ago, but wasn't really tested until now.

Do we only need to call radix_tree_preload() and
radix_tree_preload_end() only around the radix_tree_insert()?  Or will
we need it around radix_tree_delete() as well?

> I'm not sure in which contexts xhci_update_stream_ring() can be called. But
> if you are guaranteed non-atomic context, then using radix_tree_preload()
> with a more relaxed gfp mask is good (lowers pressure on atomic allocations).
>
> If the context depends on the caller, things are more complex. Generally,
> you can use radix_tree_maybe_preload() but you have to set gfp mask
> argument according to the context. The function then figures out whether
> it's worth it to do a preload or not (but it always does preempt_disable()
> which will silence the warning).

There are a couple ways xhci_update_stream_ring() could be called:

 - xhci_alloc_stream_info can be called while the bandwidth mutex is
   held, so that must be in process context

 - xhci_ring_free is called when the command to disable a slot
   completes, in interrupt context.

 - xhci_ring_expansion during URB submission, which can happen in
   interrupt context.

So it looks like the context depends on the caller, and we'll have to
call radix_tree_maybe_preload().

Sarah Sharp

  reply	other threads:[~2013-10-14 18:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-11 22:13 Warning when calling radix_tree_insert on 3.12-rc4 Sarah Sharp
2013-10-14 12:30 ` Jan Kara
2013-10-14 18:17   ` Sarah Sharp [this message]
2013-10-14 18:39     ` Jan Kara
2013-10-15  1:54       ` [PATCH v2] xhci: fix usb3 streams Gerd Hoffmann
2013-10-15  6:13         ` Hans de Goede
2013-10-15 14:53         ` Alan Stern
2013-10-16 23:43           ` Sarah Sharp
2013-10-17 14:30             ` Alan Stern
2013-10-17 18:40         ` Sarah Sharp
2013-10-17 19:44           ` [PATCH] xhci: Remove segments from radix tree on failed insert Sarah Sharp
2013-10-17 21:12             ` Hans de Goede

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=20131014181721.GA18408@xanatos \
    --to=sarah.a.sharp@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=hdegoede@redhat.com \
    --cc=jack@suse.cz \
    --cc=kraxel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox