From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 00803C433EF for ; Sun, 10 Apr 2022 20:36:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2ahiEl9laFJXb84aEkN7FuLiyCQ2coZUxHilQ9f7AI0=; b=IiuioqD6hSJYPa UlOAExUeLKyIhy96TBhU7/6qfPbg6p2g16UxQn90QiaO49Nzp7TasUksmtTe3XpqXRFrnUN4MZqzp /3AcCLrOuCcCNGfodFJHe+HxhDQ+979iyH+7hcgAaImHdDUQbLvD2vsOZ7uaJD4JTPVEsZPOR4IMn jrirlyKzpF40iRPCcDHcazQNOkz/342LdRKwbfFCzpxbwYhfNLz4+LkPW5BI3r7TvuZ/XG9U+W/ZC OegGaKFsEkl2BWqlbtULzJHdx4DfWnA4t78XcdljRBgVJEQ0BUTh9E8oCOjUe5b5pNNeKm1KkUF8B BFfsU39Nw7N59j3eBz9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ndeH4-005SQd-Ju; Sun, 10 Apr 2022 20:35:06 +0000 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ndeH1-005SOt-IX for linux-arm-kernel@lists.infradead.org; Sun, 10 Apr 2022 20:35:04 +0000 Received: by mail-ed1-x530.google.com with SMTP id d10so16095655edj.0 for ; Sun, 10 Apr 2022 13:35:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=dCmksJmPxgakgPcETkyiMkdEpAIfPO8dTB6JgwQ/+0c=; b=fJz20MHNwDvsBXdmgdMPNyq04BZ5BUG60QpxolftSlFksOd7su6HQLoU6Ym3gzUS9Z 1HOHAI1W86fYaCzaxUN5sXZRzTzF/FgAhUMtk7w7n4SKYTDfggk4U2NXEHuuhBg5bOQj 7AmYBCt6RZKmk/JrDlUwsJpoUULpi+QFAllfEIz2JBYO/eXqDK3Iev7FQY9dKcvA4Mmi tQGnUFhaplfYowHS0ggxLJH7BKaETYZLgXmFDsdvnDdMysaS0fSWOExFy96UIba2+vWu mz4aSQmoRlql8Scvd4xNgNcCvlcKYqi0CPXxIMHdzILmeexpscOm7rOOgg8pNpvJhqYL im3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=dCmksJmPxgakgPcETkyiMkdEpAIfPO8dTB6JgwQ/+0c=; b=1i5hpdjPV9HVMuZ3RS4SKw13twky36xrznwyOviYOPkLwsVF2tZeZ83idODw4RVzwU TjXa7KKF+Cj00vcBQUjlMqPmAg3AkPsSRB8f5G0jAtmIzYqDTm8NXO6I/M5gVR985sWR JDAXw+6VF96DYRPaMV2eL0tkhUECivlMYRbSJj8vTPeMvWvu53K6i26t6B6esKs90kP5 5LHIdI00EUPwDM13kazi5abf532srWBeQa/lW5xm0qon5jaYl18y8266a/6OSE3cwi1o KtwzRm3Nfpvtos3w/dK1P8mK+K/hCbkn2mZbSpVUBSLiYfVhQpEy4JOwTzcP3Mcz5WHw H+Ig== X-Gm-Message-State: AOAM530qyI/5fngf7+idqqMYmwVPI/aV+627MDx90uhdxLnRH5xqbkiY cryMpbvaDHqI0K+RFAkt7Mg= X-Google-Smtp-Source: ABdhPJwZznt2lJwO+hf+ALxhFuyiAjJq2pf8wY+nER92urPfEHHhtB2vyJZ36qkUOAwve20Kv235ZQ== X-Received: by 2002:a05:6402:34b:b0:41d:7026:d9e3 with SMTP id r11-20020a056402034b00b0041d7026d9e3mr7280900edw.168.1649622900513; Sun, 10 Apr 2022 13:35:00 -0700 (PDT) Received: from skbuf ([188.26.57.45]) by smtp.gmail.com with ESMTPSA id u25-20020a170906b11900b006e08588afedsm11183676ejy.132.2022.04.10.13.34.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Apr 2022 13:35:00 -0700 (PDT) Date: Sun, 10 Apr 2022 23:34:57 +0300 From: Vladimir Oltean To: Jakob Koschel Cc: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Vivien Didelot , Florian Fainelli , Lars Povlsen , Steen Hegelund , UNGLinuxDriver@microchip.com, Ariel Elior , Manish Chopra , Edward Cree , Martin Habets , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Jiri Pirko , Casper Andersson , Bjarni Jonasson , Colin Ian King , Michael Walle , Christophe JAILLET , Arnd Bergmann , Eric Dumazet , Xu Wang , Netdev , LKML , Linux ARM , linuxppc-dev , Mike Rapoport , Brian Johannesmeyer , Cristiano Giuffrida , "Bos, H.J." Subject: Re: [PATCH net-next 02/15] net: dsa: sja1105: Remove usage of iterator for list_add() after loop Message-ID: <20220410203457.3las4i3qcmaitsjt@skbuf> References: <20220407102900.3086255-1-jakobkoschel@gmail.com> <20220407102900.3086255-3-jakobkoschel@gmail.com> <20220408114120.tvf2lxvhfqbnrlml@skbuf> <20220410110508.em3r7z62ufqcbrfm@skbuf> <935062D0-C657-4C79-A0BE-70141D052EC0@gmail.com> <20220410200235.6mtdkd2f73ijxknn@skbuf> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220410_133503_663430_2D3CC75E X-CRM114-Status: GOOD ( 28.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sun, Apr 10, 2022 at 10:30:31PM +0200, Jakob Koschel wrote: > > On 10. Apr 2022, at 22:02, Vladimir Oltean wrote: > > > > On Sun, Apr 10, 2022 at 08:24:37PM +0200, Jakob Koschel wrote: > >> Btw, I just realized that the if (!pos) is not necessary. This should simply do it: > >> > >> diff --git a/drivers/net/dsa/sja1105/sja1105_vl.c b/drivers/net/dsa/sja1105/sja1105_vl.c > >> index b7e95d60a6e4..2d59e75a9e3d 100644 > >> --- a/drivers/net/dsa/sja1105/sja1105_vl.c > >> +++ b/drivers/net/dsa/sja1105/sja1105_vl.c > >> @@ -28,6 +28,7 @@ static int sja1105_insert_gate_entry(struct sja1105_gating_config *gating_cfg, > >> list_add(&e->list, &gating_cfg->entries); > >> } else { > >> + struct list_head *pos = &gating_cfg->entries; > >> struct sja1105_gate_entry *p; > >> > >> list_for_each_entry(p, &gating_cfg->entries, list) { > >> if (p->interval == e->interval) { > >> @@ -37,10 +38,12 @@ static int sja1105_insert_gate_entry(struct sja1105_gating_config *gating_cfg, > >> goto err; > >> } > >> > >> - if (e->interval < p->interval) > >> + if (e->interval < p->interval) { > >> + pos = &p->list; > >> break; > >> + } > >> } > >> - list_add(&e->list, p->list.prev); > >> + list_add(&e->list, pos->prev); > >> } > >> > >> gating_cfg->num_entries++; > >> -- > >> 2.25.1 > > > > I think we can give this a turn that is actually beneficial for the driver. > > I've prepared and tested 3 patches on this function, see below. > > Concrete improvements: > > - that thing with list_for_each_entry() and list_for_each() > > - no more special-casing of an empty list > > - simplifying the error path > > - that thing with list_add_tail() > > > > What do you think about the changes below? > > Thanks for all the good cooperation and help. The changes look great. > I'll include them in v2 unless you want to do that separately, then I'll > just remove them from the patch series. I think it's less of a synchronization hassle if you send them along with your list of others. Good luck. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel