RE: [PATCH net-next 2/5] r8152: replace array with linking list for rx information

Hayes Wang
2019-08-07T04:34:35Z

Jakub Kicinski [mailto:jakub.kicinski@netronome.com]
[...]
> > static int rtl_stop_rx(struct r8152 *tp)
> > {
> > - int i;
> > + struct list_head *cursor, *next, tmp_list;
> > + unsigned long flags;
> > +
> > + INIT_LIST_HEAD(&tmp_list);
> >
> > - for (i = 0; i < RTL8152_MAX_RX; i++)
> > - usb_kill_urb(tp->rx_info[i].urb);
> > + /* The usb_kill_urb() couldn't be used in atomic.
> > + * Therefore, move the list of rx_info to a tmp one.
> > + * Then, list_for_each_safe could be used without
> > + * spin lock.
> > + */
>
> Would you mind explaining in a little more detail why taking the
> entries from the list for a brief period of time is safe?

Usually, it needs the spin lock before accessing the entry
of the list "tp->rx_info". However, for some reasons,
if we want to access the entry without spin lock, we
cloud move all entries to a local list temporally. Then,
we could make sure no other one could access the entries
included in the temporal local list.

For this case, when I move all entries to a temporal
local list, no other one could access them. Therefore,
I could access the entries included in the temporal local
list without spin lock.

Best Regards,
Hayes