Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp5786411ybh; Wed, 7 Aug 2019 11:23:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhMaKszjUZOsICRGbNoK5X0sbqPYnhxvIY7c72F3pTVQc5Vr2nr6ew4vpVDzpVB5EpbSEN X-Received: by 2002:a63:205f:: with SMTP id r31mr6462157pgm.159.1565202185285; Wed, 07 Aug 2019 11:23:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565202185; cv=none; d=google.com; s=arc-20160816; b=vaB9WTvK5bnyp7CP5tnrV0FbG7Q+hn7At0PiXR1AiSQ0rSb1070UGU7o0LxYohG6Lu fHzsoVKkxD1oniNeseO4S+q4GY2QRizRUUZzuviFiFmfkrajeiKgEDSZp63efI/PEJ9b 1KlJijjes3Lcyg9eujx/FyLxVDefH3Af31qrXfDwE9dgtyWZqg/n4JRVJXBSh1fJNMPQ uBLAOq7DD/76wwZ5GK5uFskfaPAgXYXkWQnHY/VM3xtemR2QDl7rYEGhPgzMgqwJ8fEc /NmdQWmzp5Mfi9xz32EZgGOmeU4N3TWsvdVorDssBduerYzfBywjznx0j/kx7M4o0Yr7 1JSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=8YCZW1nCWkhUCnbT+gGC+VgekshYKuG5HsTIw4CfnXs=; b=aT8hwPwYtzsQ9ntLYbRQyLPAsycXwUk+svJy1qYClU2t5TU7CvsjAqQp9mnZBQDMYn ktkE9on2qvX1goqbj9dmZqG3R1u6bQ/ltNbn9YTllCCx2QzXFhHmxdYv1GWrkTiparva ZxHPfH45zUqnpL/q+o8oEhQe37HOAoltKjxesUSlGbAThxMjqp8LrxmKApQPPCwRjq5w Js5q1a4pgWZZ4oopqA9tbGcw6jr7T640Fhfg8vKTz6UtmiNUBPvjQeLPfC22KGNfoj7I bHNGDjZHVzs8XS8lUwgThjwO0hWBFLEQ7ww+THS7BMEpuY7SiNvOoSEPRHAjr58o1mzN 2TFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=CYNek6kN; 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 x9si52526315pfi.211.2019.08.07.11.22.49; Wed, 07 Aug 2019 11:23:05 -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; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=CYNek6kN; 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 S2389242AbfHGSWI (ORCPT + 99 others); Wed, 7 Aug 2019 14:22:08 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:43386 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389043AbfHGSWI (ORCPT ); Wed, 7 Aug 2019 14:22:08 -0400 Received: by mail-qk1-f196.google.com with SMTP id m2so2301625qkd.10 for ; Wed, 07 Aug 2019 11:22:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=8YCZW1nCWkhUCnbT+gGC+VgekshYKuG5HsTIw4CfnXs=; b=CYNek6kNuhPECMxVcoFZkR4x+/i7TpMbbHYGRxCkTuhhbSELP9iE+d5GfCQM80n727 C73sseXo7dWNu5DIvicVUTlvIU7LiUCj5R2c79YbsyOXgszrzYwtL8NtIm4a19EjmQic LQVaz6tYhl+anExo46prvpwWceTbh8d6mTlFViZ/52u1xVXviXlrIrKaiquiW0cnYupt RUZJrQvP7EyfIxNQlyQL5xIKi0fDBRRD5GTh3J/F2W8netpVFrI+oorXMCFEvKroQIeK GAeNcq5aFCTFy3+b8pJLifT0vcPc2CL1ZoSiRVRm9IuA481w8f5O4fPumcJpugnQXGwQ 0XDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=8YCZW1nCWkhUCnbT+gGC+VgekshYKuG5HsTIw4CfnXs=; b=XRDqwFRIzlkkrGcZF1dCZAZBivwUo5eHqHLwIA9nZewKjiAPb3LQlQolQSPnMRYHEG sJfmljC4SYVk79AjxDDgLBmXY5Zv9hV2Ko15+JdJ+x24gttpvBiO9oIGrfkAGKes8rFd j2nLlfUKiQGbk7s5AHIDv0y1kQAle74c5+aq03ku5RPZOPsL7nAo8753z5+f5P38sLsk vtpTMNx5CCvWkl7md8SFhIWcTpyjHETzWmEk+/L5Lrhd8BiIF50DWsiWMs0BFC+XkBYE QgPcJmubVK332HnWha4aKdQY+W2mXxmluvDCCsBCzLYJ9XFWWVguGBdN/EA5pGx4gr5V N5OQ== X-Gm-Message-State: APjAAAWeQXBYHhJ820oLkU6/rHcOrXb5Fh5HfRF9nBm5lEk63Z8ezAdm FWL2yCKZgdzgBpDCA9J9zJ//JEILt50= X-Received: by 2002:a37:6dc3:: with SMTP id i186mr121541qkc.376.1565202127476; Wed, 07 Aug 2019 11:22:07 -0700 (PDT) Received: from cakuba.netronome.com ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id t76sm40871746qke.79.2019.08.07.11.22.06 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 07 Aug 2019 11:22:07 -0700 (PDT) Date: Wed, 7 Aug 2019 11:21:39 -0700 From: Jakub Kicinski To: Hayes Wang 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 Message-ID: <20190807112139.3eb53313@cakuba.netronome.com> In-Reply-To: <0835B3720019904CB8F7AA43166CEEB2F18D04FA@RTITMBSVM03.realtek.com.tw> References: <1394712342-15778-289-albertk@realtek.com> <1394712342-15778-291-albertk@realtek.com> <20190806125342.4620a94f@cakuba.netronome.com> <0835B3720019904CB8F7AA43166CEEB2F18D04FA@RTITMBSVM03.realtek.com.tw> Organization: Netronome Systems, Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 7 Aug 2019 04:34:24 +0000, Hayes Wang wrote: > 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. I see, thanks for the explanation.