Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp4950623ybh; Tue, 6 Aug 2019 21:35:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqx9RJuXIhbt4kZBZEmIINIt8TgK63bhxpCj07QF2fK9j4wULyYnhCOW3SdfQKYa5QIw1+mA X-Received: by 2002:a17:90a:30cf:: with SMTP id h73mr6654537pjb.42.1565152523866; Tue, 06 Aug 2019 21:35:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565152523; cv=none; d=google.com; s=arc-20160816; b=bckRrbPK5BgxdNM7iahjq9kMsbi3nJ78K6G9Rs26HxeYA+6P9vZt+iD+u3zetDKpN/ bNBksHfBiqAU0G4ohHi0bcgZsfUQxKRBOCz1nk1w+3RfiVREmHYxvZyW8lK/F5H6gYPc 8mJaMdZsxUBb7SyR+VeMmYayFqGReBeB7gdhBeFqczsgqwV8uegT8XQzGbfnjxkQavX6 zzGysSeyjSgCX2UigJbr2C/2n+mohR5qJemhsgsrkCCwLlwhTulJsR9HfMtnUfo7MTfQ 34A9RbpYbB4rBvVmOwt2fDNGLKZw4GiYeWUmFJ5/s2NsVCAdKg4IaB2wMoF8/RcDYezM 2wsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:authenticated-by; bh=kdkh3RNYNXVHh1vI/8ZMj23cH3HEzjXsUi054U2C05k=; b=JxgRncEfKDmTL/FWPwm2zfleO6OJEnb6dv2VnXoF4IWscQfqBzdsZiwXfl5LesWOGX WoRQVw4UWdbh44ydVxcIse8SvmKwz82PoxTUQjcG9r5Arxj1VYq6KZhGGUjQDN33YQ0O bqh/L25WJtUUUU+ElIlMNdaWwnou0U6vpFytsE9nt9OAw/XBCewghndnkDYD7ybIM9nb c/uGz4i3pXko3hxx6LihvvjydvijAMHo3P+BqBBUCw2n54xy5ZvtCDu40jbg67w7l0zd HqmGh/ZX8cK52CgKBaksZimG57AXcE7pnSc8gpD+B9OyQdX/hYRYY74YzP/KVggV/qi3 WePQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d34si44762035pld.54.2019.08.06.21.35.08; Tue, 06 Aug 2019 21:35:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726566AbfHGEec convert rfc822-to-8bit (ORCPT + 99 others); Wed, 7 Aug 2019 00:34:32 -0400 Received: from rtits2.realtek.com ([211.75.126.72]:53428 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725835AbfHGEeb (ORCPT ); Wed, 7 Aug 2019 00:34:31 -0400 Authenticated-By: X-SpamFilter-By: BOX Solutions SpamTrap 5.62 with qID x774YQEn022830, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (RTITCASV02.realtek.com.tw[172.21.6.19]) by rtits2.realtek.com.tw (8.15.2/2.57/5.78) with ESMTPS id x774YQEn022830 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 7 Aug 2019 12:34:26 +0800 Received: from RTITMBSVM03.realtek.com.tw ([fe80::e1fe:b2c1:57ec:f8e1]) by RTITCASV02.realtek.com.tw ([::1]) with mapi id 14.03.0439.000; Wed, 7 Aug 2019 12:34:25 +0800 From: Hayes Wang To: Jakub Kicinski CC: "netdev@vger.kernel.org" , nic_swsd , "linux-kernel@vger.kernel.org" , "linux-usb@vger.kernel.org" Subject: RE: [PATCH net-next 2/5] r8152: replace array with linking list for rx information Thread-Topic: [PATCH net-next 2/5] r8152: replace array with linking list for rx information Thread-Index: AQHVTEi8dqICcI3sDEmqKF0S4wiBPqbuAp4AgAEQ7MA= Date: Wed, 7 Aug 2019 04:34:24 +0000 Message-ID: <0835B3720019904CB8F7AA43166CEEB2F18D04FA@RTITMBSVM03.realtek.com.tw> References: <1394712342-15778-289-albertk@realtek.com> <1394712342-15778-291-albertk@realtek.com> <20190806125342.4620a94f@cakuba.netronome.com> In-Reply-To: <20190806125342.4620a94f@cakuba.netronome.com> Accept-Language: zh-TW, en-US Content-Language: zh-TW X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.21.177.214] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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