From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932324AbcIFAWR (ORCPT ); Mon, 5 Sep 2016 20:22:17 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:26915 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752958AbcIFAWO (ORCPT ); Mon, 5 Sep 2016 20:22:14 -0400 Subject: Re: [PATCH] RDS: Simplify code To: Leon Romanovsky , Christophe JAILLET References: <1472880809-29216-1-git-send-email-christophe.jaillet@wanadoo.fr> <20160904122049.GQ21847@leon.nu> <20160904182354.GR21847@leon.nu> Cc: davem@davemloft.net, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org From: "santosh.shilimkar@oracle.com" Organization: Oracle Corporation Message-ID: <26832741-da10-7581-11d2-d88e6df43c4e@oracle.com> Date: Mon, 5 Sep 2016 17:22:06 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20160904182354.GR21847@leon.nu> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/4/16 11:23 AM, Leon Romanovsky wrote: > On Sun, Sep 04, 2016 at 05:57:20PM +0200, Christophe JAILLET wrote: >> Le 04/09/2016 à 14:20, Leon Romanovsky a écrit : >>> On Sat, Sep 03, 2016 at 07:33:29AM +0200, Christophe JAILLET wrote: >>>> Calling 'list_splice' followed by 'INIT_LIST_HEAD' is equivalent to >>>> 'list_splice_init'. >>> It is not 100% accurate >>> >>> list_splice(y, z) >>> INIT_LIST_HEAD(y) >>> >>> ==> >>> >>> if (!list_empty(y)) >>> __list_splice(y, z, z>next); >>> INIT_LIST_HEAD(y) >>> >>> and not >>> >>> if (!list_empty(y)) { >>> __list_splice(y, z, z>next); >>> INIT_LIST_HEAD(y) >>> } >>> >>> as list_splice_init will do. >>> >> You are right but if you dig further you will see that calling >> INIT_LIST_HEAD on an empty list is a no-op (AFAIK). >> And if this list was not already correctly initialized, then you would have >> some other troubles. > > Thank you for the suggestion, > It looks like the code after that can be skipped in case of loop_conns > list is empty, the tmp_list will be empty too. > > 174 list_for_each_entry_safe(lc, _lc, &tmp_list, loop_node) { > 175 WARN_ON(lc->conn->c_passive); > 176 rds_conn_destroy(lc->conn); > 177 } > Thanks for trying. As already pointed, your change doesn't simplify much rather change the behavior. The loop cursor already takes care of list empty case. I don't see any reason to change that code. Regards, Santosh