Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp14410137rwd; Sat, 24 Jun 2023 19:34:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7mtX69d09jVn899pM2+jYK38ByVj1yi9pX4ZJXUfSb+8R/RV5n2GAxWi4JCYrEjNrnOvCc X-Received: by 2002:a05:6359:5a0:b0:133:307:d6c4 with SMTP id ee32-20020a05635905a000b001330307d6c4mr252138rwb.9.1687660494754; Sat, 24 Jun 2023 19:34:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687660494; cv=none; d=google.com; s=arc-20160816; b=U/eqntVshfSeftfeUnUWcRx0tzs9rE/xBtIEzejAB+0JNYAwhB2BiN/8QVSLaLHPDD Vmkto3GZvfNgRDL9wgjwPul6howNoWOBFTxY8UikE3HxLpmMh2kbZtzGWNj6LOLw2F1B BzK+M7mUPcISyF15X5aeBBzb4QIYra5ATEFbOD1en+zd+Iso7gCagBI+mKY6U9uui0lW schlYlP1/PVoHY+dw6nPQOF7D+7pWkQb4UbCdPzWeMs/WrEY3i5N0epE01x/KtjGd3dz um3yGTJ9MAv8A8ndpc0XDn13khdk6BQzYz+w/ZHaj2+bLeMRrcLedHpYSexYf9ZHRVXp 5DqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=OqNYmzivUmNc7c9G7YuXYqHmCYFrw/OQcMvbEkMtNtU=; fh=N0oCjPxtju8cGXdy4swt0gfNp+Qkn1Qt/BjR+AEaoac=; b=M/lNZdtsdEXIKntzC8Asef3B9unu61YdJU55vWfs+eBdBlGl0NzK5NtYbBZV7TZ/Ht SrdAyMWUcRPDtO0GLMKGlo3XD+CJsp8LxF9OdAc+2aD08vgHg9wOyt4MaKmJA9hoIGbr 6W5zvY2mQIvwmvaa+Kk3aSN+k1ryBnWe3odSV3soQqCBBTwI5voZwbzzEt2nStcyvz9T kZTd0T8FhPT1WGqtk4kDXqMMXadnsJad3B3K7eqQrNzHoaAqqu48eLMeSkD/yGsxhqJm xN42jc0r6H/RYMLeItWnB4jnoOqU7u2l/zYyn9ahGPTQfQe22b2HJRuu6GAlGs3WRXV/ n+fA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i10-20020a17090332ca00b001b7d0b2af9bsi2675712plr.34.2023.06.24.19.34.43; Sat, 24 Jun 2023 19:34:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230369AbjFYB7m (ORCPT + 99 others); Sat, 24 Jun 2023 21:59:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230309AbjFYB7k (ORCPT ); Sat, 24 Jun 2023 21:59:40 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61FCE10C9 for ; Sat, 24 Jun 2023 18:59:39 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4QpZ0X47y9zqV2P; Sun, 25 Jun 2023 09:59:24 +0800 (CST) Received: from [10.174.151.185] (10.174.151.185) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Sun, 25 Jun 2023 09:59:36 +0800 Subject: Re: [PATCH] sched/topology: remove unneeded do while loop in cpu_attach_domain() To: Ricardo Neri CC: Peter Zijlstra , , , , , , , , , , , , References: <20230617081926.2035113-1-linmiaohe@huawei.com> <20230620141120.GA2016469@hirez.programming.kicks-ass.net> <53a9ec35-8332-755c-40ed-54315ffb0d78@huawei.com> <20230621131159.GA23663@ranerica-svr.sc.intel.com> <20230621185749.GA24063@ranerica-svr.sc.intel.com> From: Miaohe Lin Message-ID: <268d9d61-ce17-cda6-7a21-148b518ac323@huawei.com> Date: Sun, 25 Jun 2023 09:59:36 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20230621185749.GA24063@ranerica-svr.sc.intel.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 2023/6/22 2:57, Ricardo Neri wrote: > On Wed, Jun 21, 2023 at 06:11:59AM -0700, Ricardo Neri wrote: >> On Wed, Jun 21, 2023 at 10:53:57AM +0800, Miaohe Lin wrote: >>> On 2023/6/20 22:11, Peter Zijlstra wrote: >>>> On Sat, Jun 17, 2023 at 04:19:26PM +0800, Miaohe Lin wrote: >>>>> When sg != sd->groups, the do while loop would cause deadloop here. But >>>>> that won't occur because sg is always equal to sd->groups now. Remove >>>>> this unneeded do while loop. >>>> >>>> This Changelog makes no sense to me.. Yes, as is the do {} while loop is >>>> dead code, but it *should* have read like: >>>> >>>> do { >>>> sg->flags = 0; >>>> sg = sg->next; >>>> } while (sg != sd->groups); >> >> Yes, I agree that this is the correct solution. > > I take this back. I think we should do this: > > @@ -758,19 +758,14 @@ cpu_attach_domain(struct sched_domain *sd, struct root_domain *rd, int cpu) > sd = sd->parent; > destroy_sched_domain(tmp); > if (sd) { > - struct sched_group *sg = sd->groups; > - > /* > * sched groups hold the flags of the child sched > * domain for convenience. Clear such flags since > * the child is being destroyed. > */ > - do { > - sg->flags = 0; > - } while (sg != sd->groups); > + sd->groups->flags = 0; > > sd->child = NULL; > - } > } > > sched_domain_debug(sd, cpu); > > A comment from Chenyu made got me thinking that we should only clear the > flags of the local group as viewed from the parent domain. This is because > the domain being degenerated defines the flags of such group only. This looks better to my patch. Thanks.