Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp415510lqh; Tue, 7 May 2024 03:11:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX136+GOVusdkgn0YFw0mtfIK/xRxzFWZf7nJlogycBghgryuMfGEHnG4bBluEpn9YZ1opgunBaH48NIb1P4mqoMQMqXNDJz+RHKHJN7g== X-Google-Smtp-Source: AGHT+IGi7pWMAn8kLiByGjBOWgOXWOF7MvzHoUDLHaGhp+SG3h4kBXtASollFKLkgAxxI15uxgno X-Received: by 2002:a05:6e02:12e1:b0:36c:4ff5:c168 with SMTP id l1-20020a056e0212e100b0036c4ff5c168mr17334744iln.14.1715076676398; Tue, 07 May 2024 03:11:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715076676; cv=pass; d=google.com; s=arc-20160816; b=GqdbiQS2tZoucsvqkcT7F7l6d2XTj8bnSvrGVGV5dftbk6Q6Q4HUO1OEl942SwFpfy Uaj7GJsxUqzR/P5fKMwviDpzbw/nA+hq9Z/YxYZHmOXwFxXzAhaJrI33KoNZkrHkjS7T YvrtD5vErASjQIDY4ICUJhzOVKlLuxa8VP/zPIWJ8MK+c+y2BZ1BqbTuHzB4f5vkPgkl tvoJ5dcvPxwLdKGxlHwXiy4iK/tfv2QqtMJrw7ny2N38h6H9oVlwe6099H1ro7T6s8VI Ezqqz0qsplErSA/iRp6DUCKS5Ap69wGLnJtEXS3HPn9iI8tim4XmbVnUquBwX97wCJjc db4g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=xRkoNOEv8gPHcq2P5UAKWS8B3jCr0cVjdP20g/cY62k=; fh=hIe7ZmaIoruJ83WQnFVK5cpATDXxaP3uAoRBM62BHjc=; b=UIBNH6eykns0433EU45xvpUNHJwHrrqtUnF1pSF1ZXlxrDsclCINLZcS7eEUTU3TPF KubehnE04rm+1jf7OkBFzpKgzmWX4JS6BGreFuRM2vYzZbvwr+FlQcYgQ5PHkAh6e6Sn 5D1tIjrFiGD8IPPmA0JPOP+ZsGpsIJ7GVAdLtSyOhZTGvmZCyY7v9uZRuH/lLePpTgXC 4IOw74Yz6UUgx0pT1yFDnecQsnTYZIBjzMEhbIrCCXigsfkmJk7b4EHmri9NcYI/IpQH ktPAbBClM8WyaRghmzx+ljx+retpAaacjnhTfdC3ISeuvlMYBdkwA4pLrgm/uokuWvYj BcAQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="L/QV+/dJ"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-171070-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171070-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j23-20020a635517000000b005f7ff55c41dsi5999344pgb.665.2024.05.07.03.11.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 03:11:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171070-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="L/QV+/dJ"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-171070-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171070-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 07141283A21 for ; Tue, 7 May 2024 10:11:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5172014EC65; Tue, 7 May 2024 10:11:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="L/QV+/dJ" Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B34D614E2FB for ; Tue, 7 May 2024 10:11:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715076667; cv=none; b=I0TBBZv9fRsU9X50s1csUAutYcOSps6di6u6876EbvRLTcd28bsGCqPqfhisNCmchA898OxxRZKkr6Yh1whipiRDW41HBO3rF7qkffMTvhpr6O63nkAbHO3nNOJzGoJlNMZ3LCpnwrGqweVrrz+D0GAU5RkI9jnHwLrX2Prw6fA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715076667; c=relaxed/simple; bh=pzN0QEsi5vW51SAWCGgbkaOsqw5VvfmrBvJ7uOk7Djk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IoSpNGvVpO/yzhlLJApDtEGqZr/EXQbeD1KOgmTAYl8kqybXESr6ZalgwAGZCUkBnp8/urAgBTNzK8jcSVkjah4jumGROwnzFH2jFLiocsJoIkoXbbF9Rn5I/1EX1cbVep03BX0sBYVaJeGcfh9l1a4vBg1UIXFJz0Xz4oRf+14= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=L/QV+/dJ; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-41bab13ca81so31478625e9.1 for ; Tue, 07 May 2024 03:11:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715076664; x=1715681464; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=xRkoNOEv8gPHcq2P5UAKWS8B3jCr0cVjdP20g/cY62k=; b=L/QV+/dJ7j42rpb8HLhc0HWVdxhS7FBN4FcTW8z4HzQMBAtZd12/MRDlMr+jaXVhzL 0gq/MQ7+jLEYc9cXq5ZI8qVm5dmGHd4lXhCx5oSmAD0wyZZQTsSuXF4gd404OL8BZBbU NMNIDoHbQWmAD2yy3JzA91DkbwbwNVAbUX0r+L4MbGiVBI7s6a3ZUCMKxkp0+OxABgo8 zEx47alEjrFV90mEneAac+26I4rlI/tvAjw2gjNCdKnrV612+JYPFHP54nvbeNXLU/ko if/JwpXjx7qxNClmWzw1EiUuY8ZdYzT6tnHBXmxbvyLUXLL9M9qQrmvW9b9uwssiE4zL 4CYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715076664; x=1715681464; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=xRkoNOEv8gPHcq2P5UAKWS8B3jCr0cVjdP20g/cY62k=; b=te4+Yp0pXbDELrK4CIv58vPn6w7sQy2aeaMm7/UGojtYdOZxUsN/GmuXxntLT+nzRp AVaF9Cobvof1A0rwZ9Zl1JPy7nTN1wVp8kcGU3e2n2qhsSydRXN+Ffr97/UZayEcWWUQ 2isJD2hvsjZAYSKqdYkjVbo3GVDdIIQngSectbYDS4ODql1gij3G1dTA21t1usOmj/4c 9mi0ntZ6cByJVKWKjo8LdW/EohJol/v63o+GCe/ZgQ11kOY8AFMAOhe2nw4xRbWarWxO KhJAaZnWxQ4LePIItCsy5xIoDbS8eFeS24vtSklWJxOxp1UY7Zo6ltnyycjy/7WwsY+K y4ZA== X-Forwarded-Encrypted: i=1; AJvYcCUKJ3V+LBFK0Jd+mJIiheBc6lQUclacAPjp6MIJedZ/BVrSG4WpocC3sFZF4Cw3phJ1gtQwJ5ZbypdOdKuy9eIWhASmavOBik3T94nD X-Gm-Message-State: AOJu0YyJFKhBsD1XYP1E+gakYAY+q/Emabt/RhayIhfTxXnJFGGb0Ppg QS/ICuPvemGULp2lSYX4GCecD27XSpeWF8liWl9uZP+1yKJmV0nB5wB+fTipAZo= X-Received: by 2002:a05:600c:1553:b0:41b:e94f:1e88 with SMTP id f19-20020a05600c155300b0041be94f1e88mr13064142wmg.24.1715076663825; Tue, 07 May 2024 03:11:03 -0700 (PDT) Received: from localhost ([102.222.70.76]) by smtp.gmail.com with ESMTPSA id n19-20020a05600c4f9300b0041c14061c71sm18935780wmq.15.2024.05.07.03.11.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 03:11:03 -0700 (PDT) Date: Tue, 7 May 2024 12:52:03 +0300 From: Dan Carpenter To: Ratheesh Kannoth Cc: Duoming Zhou , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hams@vger.kernel.org, pabeni@redhat.com, kuba@kernel.org, edumazet@google.com, jreuter@yaina.de Subject: Re: [PATCH net v5 1/4] ax25: Use kernel universal linked list to implement ax25_dev_list Message-ID: <5863f2fc-ab8e-4f6e-873e-2667bc0a2e4b@moroto.mountain> References: <20240507092917.GA1049473@maili.marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240507092917.GA1049473@maili.marvell.com> On Tue, May 07, 2024 at 02:59:17PM +0530, Ratheesh Kannoth wrote: > On 2024-05-07 at 12:33:39, Duoming Zhou (duoming@zju.edu.cn) wrote: > > The origin ax25_dev_list implements its own single linked list, > > which is complicated and error-prone. For example, when deleting > > the node of ax25_dev_list in ax25_dev_device_down(), we have to > > operate on the head node and other nodes separately. > > > > This patch uses kernel universal linked list to replace original > > ax25_dev_list, which make the operation of ax25_dev_list easier. > > There are two points that need to notice: > > > > [1] We should add a check to judge whether the list is empty before > > INIT_LIST_HEAD in ax25_dev_device_up(), otherwise it will empty the > > list for each new ax25_dev added. > > > > [2] We should do "dev->ax25_ptr = ax25_dev;" and "dev->ax25_ptr = NULL;" > > while holding the spinlock, otherwise the ax25_dev_device_up() and > > ax25_dev_device_down() could race, we're not guaranteed to find a match > > ax25_dev in ax25_dev_device_down(). > > > > Suggested-by: Dan Carpenter > > Signed-off-by: Duoming Zhou > > -ax25_dev *ax25_dev_list; > > +static struct list_head ax25_dev_list; > > DEFINE_SPINLOCK(ax25_dev_lock); > > > > ax25_dev *ax25_addr_ax25dev(ax25_address *addr) > > @@ -34,7 +35,7 @@ ax25_dev *ax25_addr_ax25dev(ax25_address *addr) > > ax25_dev *ax25_dev, *res = NULL; > > > > spin_lock_bh(&ax25_dev_lock); > > - for (ax25_dev = ax25_dev_list; ax25_dev != NULL; ax25_dev = ax25_dev->next) > > + list_for_each_entry(ax25_dev, &ax25_dev_list, list) > > if (ax25cmp(addr, (const ax25_address *)ax25_dev->dev->dev_addr) == 0) { > > res = ax25_dev; > > ax25_dev_hold(ax25_dev); > > @@ -52,6 +53,9 @@ void ax25_dev_device_up(struct net_device *dev) > > { > > ax25_dev *ax25_dev; > > > > + /* Initialized the list for the first entry */ > > + if (!ax25_dev_list.next) > > + INIT_LIST_HEAD(&ax25_dev_list); > if you define ax25_dev_list using 'static LIST_HEAD(ax25_dev_list)', you need this conditional check and > initialization ? > Ah, yes. That's the proper way to do it. regards, dan carpenter