Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3428105pxb; Mon, 4 Apr 2022 16:41:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxS/HN0AYap/+rd9x+K0Wr9gAXzWCd+6Q6B9YhubJUkav0LHHCXSK59exJG/SAQ5knRSNQ X-Received: by 2002:a05:6a00:15d6:b0:4fa:f217:e2b2 with SMTP id o22-20020a056a0015d600b004faf217e2b2mr539721pfu.64.1649115685070; Mon, 04 Apr 2022 16:41:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1649115685; cv=pass; d=google.com; s=arc-20160816; b=bEuy/fFed6YpwEe86kbuvlDoHj1nJhDooSBIA1dxjcekquXwwSNx4Fy5Fw5pbvG8gT brMw22EZB0lCsyf1FQqx72iRaWSs94aCj5j1XecyIJ/Bc+cNKJjxJQuqzGagCkwRO2Ab fBlt9Jmg57U9jPX36m1rcqJ9XDIHfh2pwnjsbzOyzOLzjrZW3d00NH4aFs4QSpfF4Pd8 yTC0bRv/IV0JKoPYRNo1W2ReZZrQ6OgTvHJyQaz5JSr+J8NG9vXFk7w1HZSvv3TJfzLe cci0HAfuWQd5Dn31taLhnhFXinX6h8Ax404ucOp+M9bauRNymA2jJY2ruCi1inPXDqWF 4OAA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=JjXhLMP0QJ/PQdyr2LO98rgNwGJpzcrykvJBye00gec=; b=E64LUl4afzv5If3KTHHSo2Uulrh03Kx1ATJ2aThkI+e/hPOLsk2WpNSK9GkYyoW929 oxpVE+77e1tQ6nlodR3LNCUh2OwPHP7fJ2nOCBSiiZXok8zbHvSZq1Oa7ubaGg6G5ph1 THafvtuWZwSn+PZBNsy/LB0pGPybjo3rDyvxRa8WN/zJKQgHHmRVhQhzd3h5KHrey7Im Z45hJszXRGFikxia3XssNd8yzRwHxICB2w9w1P0kYbdyHM31GZVmxXGknodV99oLVFVJ yTzV6gG2/FCE9R/f8itm+lu4+D/ExVqfD41LLD6DuPguJuJjgp5zyqvUHlVrK+j99Jxg nMLg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cornelisnetworks.com header.s=selector1 header.b=ZcH6gMjU; arc=pass (i=1 spf=pass spfdomain=cornelisnetworks.com dkim=pass dkdomain=cornelisnetworks.com dmarc=pass fromdomain=cornelisnetworks.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x2-20020a634842000000b0039915955d0asi5220747pgk.791.2022.04.04.16.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 16:41:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@cornelisnetworks.com header.s=selector1 header.b=ZcH6gMjU; arc=pass (i=1 spf=pass spfdomain=cornelisnetworks.com dkim=pass dkdomain=cornelisnetworks.com dmarc=pass fromdomain=cornelisnetworks.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4EAF854BC1; Mon, 4 Apr 2022 16:32:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350772AbiDAPAd (ORCPT + 99 others); Fri, 1 Apr 2022 11:00:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348900AbiDAOpD (ORCPT ); Fri, 1 Apr 2022 10:45:03 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2131.outbound.protection.outlook.com [40.107.93.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C11F92976E6; Fri, 1 Apr 2022 07:35:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VeFI5tmY4IjOwRLndJJAmbdVYjwLzfZ9bXjc/zcsVToNpdmZfdI7jqVqaW8eLaJWS5oR4lw+RH2RJVLbcibX8llXJ3TBBb4ZWgept2iStoBmO4VFtvLa3yYOyK+F0vvKd1EWsfZ4w8U7MXdUn0NrA0kvZkc+CKxTajiUlOEPMZlbTrdCZDo+xs0xzisXWuoiIWq73X08mGnDUFbe5rnzqXVCOJZHuJKwbyKuktkC9m/gvI05SQPr/Gsm8qM5afRcoMEmI0CgY+jaENqbD3oU6O7OEbpTRKLUqB6cNCgos3Grzy9a0OTLjY+9zbYvm1jC3DFtZwURtaRM7h35Euao3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JjXhLMP0QJ/PQdyr2LO98rgNwGJpzcrykvJBye00gec=; b=KIuLd+zGUnZVmSeKRwkYkGzYlri+zan6V7r6A0a3PlgX5k9PhIFDEE6lO4kdYOcWo8WmqGwCOpbqheXD9Aj/QZVFpW1TiT1ckX5DTFKZ1dFEZH3Bsl+E/0AFoz1VE6jYoGiDe78Fau1u5B8LAKpHmfZ0qiG1krJG7fAssWIVt/96h06WYnI7Lqbm7ggfZ2x+5b8co7wsiasG8naGLJZZjA0xhQdfCceo5i1hz+xCmbsczOQfCnrrIxiyhT35FqOpFFyewBTI5SiZ+MtAdvJCmtdErq+bokY0gwkMLJ3k6IW1vyyAl8ZK8d2UsY6090mGCoUIQFs5s2/r3qI/dCw+Fg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cornelisnetworks.com; dmarc=pass action=none header.from=cornelisnetworks.com; dkim=pass header.d=cornelisnetworks.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cornelisnetworks.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JjXhLMP0QJ/PQdyr2LO98rgNwGJpzcrykvJBye00gec=; b=ZcH6gMjUSXnzzKRuGoE+KDSxr+oHLsUXlPcO+W0x0bWMzqhWRNxK/yNvdbWlQ/uFKBRn7b1JSluKF4D8+pMZbXVICHHe9+K6EOmoX2yLiprWd3VeX0QzKJAlJl4nbPz6IfbvR2yLmSEWR/OBAZ3Qkm5xuxdD9UqDMf9Yq2VRlfsCpsnjSm/WHWnddRwWzfSEZUs1bmzUt5I3tb1j2ke0bjGcVJ7LAWgHPA230b+bUkJPWJJbM67ZMa4M7Zp0v1ZUnBlPomsA3Y7No5xu5gow8Q70+ILvEF2crRzP9taiktEOZvmWz3PbfK5T6Z0LzFFoYsiaR94msH7B52X4hxw4LA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=cornelisnetworks.com; Received: from PH0PR01MB6439.prod.exchangelabs.com (2603:10b6:510:d::22) by BL3PR01MB7042.prod.exchangelabs.com (2603:10b6:208:35d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.18; Fri, 1 Apr 2022 14:34:30 +0000 Received: from PH0PR01MB6439.prod.exchangelabs.com ([fe80::98bd:3eac:d0e:875]) by PH0PR01MB6439.prod.exchangelabs.com ([fe80::98bd:3eac:d0e:875%5]) with mapi id 15.20.5102.025; Fri, 1 Apr 2022 14:34:30 +0000 Message-ID: <0d3e61ea-b3b8-620a-f418-0c91b381b67d@cornelisnetworks.com> Date: Fri, 1 Apr 2022 10:34:26 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH] IB/hfi1: remove check of list iterator against head past the loop body Content-Language: en-US To: Jakob Koschel , Mike Marciniszyn Cc: Jason Gunthorpe , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Mike Rapoport , Brian Johannesmeyer , Cristiano Giuffrida , "Bos, H.J." References: <20220331224501.904039-1-jakobkoschel@gmail.com> From: Dennis Dalessandro In-Reply-To: <20220331224501.904039-1-jakobkoschel@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: BL1PR13CA0433.namprd13.prod.outlook.com (2603:10b6:208:2c3::18) To PH0PR01MB6439.prod.exchangelabs.com (2603:10b6:510:d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 55f4db38-92dd-4c2b-0651-08da13ecbb12 X-MS-TrafficTypeDiagnostic: BL3PR01MB7042:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZXyYDKiT10jKT+IRgOzsF4mVREt+bm7d0N5s7ALbhx1HI7Lwz+/yWwuqsgNnMPLgMhT9MxcGRD6m49g8Qe1FsipUnsRgwqn7FGG8mt/kqZ5f+qLn4C1yPHzAgCvpOOQJMBO/LFgcTV6QwlQzJfUK3pzqCP8ItJrxs0opWkzMX0YHFGtati2EeJ7FIUMbPagw2EftJynaSjgvDkGKVA20gkwQS4XoNb5fmoTY9qyFcL8DxVWDwqHPrJbmCYY63mfzKCOOEBg3XzQfWuSOv+TZuyZC322Zm5VkkFb3d5+u7nzWxzgRNfPdHAmWIS0juFblHdmKITWsYUzfRLoZxS7Lnux9HWpPCljsJky7PuCxFoVYkSGTkXYQd4QtbJ0buaZhgkQgk6IwTN7rnUXn1KsGFsgx9+F/rBEw6hNwxtP8O2Ve/Dn5aLkLZP8C2Gc9z5kT5KfEjHeH0sDJLozeTYxaJTNJBy3rhd8TJBYUXIhdTwb6pMgNs+zuuPtonHsnTGHBhOh+AxUPajcRrVMKyBLEaVdeWuhW5C7pt+MqzpOVrcpjfKoU9nlHNmzJaHgjgawZHjB/6bCuwTDOby1FdF70ZH32ZlzFovEsQDKDmLGReCjonGj4GLRoKqBmC/gzUfuoCFFjLcgm/6+3P21O9kX6E4vL7eKu+1rvM3BV7Rbe7ie/tKwBWsK/wbMihOZiFV4R5YB2JCPrpHmmo21HIxBJZgBzH95CBTXAdbNCLJanhuOF9nBLvdVjTVz0+orsfVAn/aVsp4hNsf4JJ6q6iXNz4lhnpjGTRD5h+ulqiOSiKxqFG2FoeGboYRFmcY0f3hq+ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR01MB6439.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(39840400004)(376002)(346002)(366004)(396003)(136003)(6506007)(2616005)(6512007)(186003)(2906002)(52116002)(44832011)(53546011)(26005)(8936002)(38100700002)(31686004)(66946007)(54906003)(110136005)(66556008)(66476007)(6636002)(4326008)(8676002)(966005)(6666004)(38350700002)(83380400001)(6486002)(5660300002)(31696002)(508600001)(86362001)(36756003)(316002)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?LzRTTU9UVmd5YUNXZ1VMSkI0MzZFc0xDNExscDZxUzVjUnZRZERkUkNEOHI0?= =?utf-8?B?QlNacHJ1VnRycEFnejVaMzBQMFBZeStTZXhGU09jSU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?= =?utf-8?B?SSsvNHRzaFdDNERHV2VYRGN5UllnQnVZbHBkOHhPNW9RMFBYODJIUnpTd0xS?= =?utf-8?B?bWhBY2tVV0c1TllkTVdoSHl3SlppaUJTWlNYdXA2ZktmN0M4UjRwVCtyTlVG?= =?utf-8?B?TmEvOEw0SlFhVG5iNEdINkd6ZUpZeS9aNVNZN2NZcTB6eTNmZyt1OWx3RVpt?= =?utf-8?B?T2d5WkEzN1Uyenp4bml4Q0JtUlBYRENKemJENjgzVk1YQzVoc0Z6aWwrZWVy?= =?utf-8?B?Z0U1TnZMNjBCdmxwelhBc0txY3pYeE00L3oySVQ1aFE3MnNrSk56WDZBZnBt?= =?utf-8?B?UTlJVXo1WFVRbmx3Y2V3YWdkN081UWNQbGp1QlZZYWpMbXV3SUVIY3NtMlBN?= =?utf-8?B?ZnpPTFhrNGc2YnpJYmwyNDV1SUZGL0tuYUhsMk9BVDlZaVhBVHdDZ0kvNWJX?= =?utf-8?B?K1ByMmNFVGxuY3JuYUs3eDZqUzk2RGdsT1kwQVFGOGFTSDg2c0tuVGNMZXFE?= =?utf-8?Q?ygvLQ+CufXUncOdsx9N1u+Wbyw19ZwJG/rUeT?= X-OriginatorOrg: cornelisnetworks.com X-MS-Exchange-CrossTenant-Network-Message-Id: 55f4db38-92dd-4c2b-0651-08da13ecbb12 X-MS-Exchange-CrossTenant-AuthSource: PH0PR01MB6439.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Apr 2022 14:34:29.9482 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4dbdb7da-74ee-4b45-8747-ef5ce5ebe68a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9FGUCyr7TJZV6gmigW/VpUw7ZoQpTtiwyCrvUqozVeuLON6I3TBCVHEpON0DD+fDiu5319fnQCO3kjGYNaKjwz2/6eyx2Yr8FLEaILu0VuYXcIsNdWPSNjAAaNXNE8g4 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR01MB7042 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/31/22 6:45 PM, Jakob Koschel wrote: > When list_for_each_entry() completes the iteration over the whole list > without breaking the loop, the iterator value will be a bogus pointer > computed based on the head element. > > While it is safe to use the pointer to determine if it was computed > based on the head element, either with list_entry_is_head() or > &pos->member == head, using the iterator variable after the loop should > be avoided. > > In preparation to limit the scope of a list iterator to the list > traversal loop, use a dedicated pointer to point to the found element [1]. The code isn't searching the list. So there is no "found" element. It is walking a list of things and using each one it comes across. > > Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] > Signed-off-by: Jakob Koschel > --- > drivers/infiniband/hw/hfi1/tid_rdma.c | 16 +++++++++------- > 1 file changed, 9 insertions(+), 7 deletions(-) > > diff --git a/drivers/infiniband/hw/hfi1/tid_rdma.c b/drivers/infiniband/hw/hfi1/tid_rdma.c > index 2a7abf7a1f7f..b12abf83a91c 100644 > --- a/drivers/infiniband/hw/hfi1/tid_rdma.c > +++ b/drivers/infiniband/hw/hfi1/tid_rdma.c > @@ -1239,7 +1239,7 @@ static int kern_alloc_tids(struct tid_rdma_flow *flow) > struct hfi1_ctxtdata *rcd = flow->req->rcd; > struct hfi1_devdata *dd = rcd->dd; > u32 ngroups, pageidx = 0; > - struct tid_group *group = NULL, *used; > + struct tid_group *group = NULL, *used, *iter; > u8 use; > > flow->tnode_cnt = 0; > @@ -1248,13 +1248,15 @@ static int kern_alloc_tids(struct tid_rdma_flow *flow) > goto used_list; > > /* First look at complete groups */ > - list_for_each_entry(group, &rcd->tid_group_list.list, list) { > - kern_add_tid_node(flow, rcd, "complete groups", group, > - group->size); > + list_for_each_entry(iter, &rcd->tid_group_list.list, list) { > + kern_add_tid_node(flow, rcd, "complete groups", iter, > + iter->size); > > - pageidx += group->size; > - if (!--ngroups) > + pageidx += iter->size; > + if (!--ngroups) { > + group = iter; > break; > + } > } The original code's intention was that if group is NULL we never iterated the list. If group != NULL we either iterated the entire list and ran out or we had enough and hit the break. Under the proposed code, group is NULL if we never iterated the loop. It will also be NULL if we reach the end of the list. So the only time group != NULL is when we iterated the list and found all the groups we needed. > if (pageidx >= flow->npagesets) > @@ -1277,7 +1279,7 @@ static int kern_alloc_tids(struct tid_rdma_flow *flow) > * However, if we are at the head, we have reached the end of the > * complete groups list from the first loop above > */ > - if (group && &group->list == &rcd->tid_group_list.list) > + if (!group) So the problem here is group->list may point to gibberish if we iterated the entire loop? Perhaps instead of group, add a bool, call it "need_more" or something. Set it to True at init time. Then when/if we hit the break set it to False. Means we found enough groups. Then down here we check if (need_more).... At the very least if you want to keep the code as it is, fix up the comments to make sense and explain the situation. -Denny