Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp68361rwo; Fri, 21 Jul 2023 08:37:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlG84UPP8RvpuptrkAhO0ueavvQ2T1rPt5w74hybKaJieFvrb8iNHdapGxyzLwISdOvHUIGq X-Received: by 2002:a05:6402:1382:b0:51e:26dc:b35e with SMTP id b2-20020a056402138200b0051e26dcb35emr1751170edv.21.1689953824884; Fri, 21 Jul 2023 08:37:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689953824; cv=none; d=google.com; s=arc-20160816; b=jMc8gNYo/19tgPc5yqghJyVbKzJeHkEeOHxEYm5RRsjPTv6F7nS+Hcrzp76P1yJzzz fR2DpLknftFiXQRZrpgFonh9yLcCcu/vPfoThMFzJ1g0DwN0IMlpMG1NIOobjKRPZztD hTmQiWGgjZ+ZwqstBO3rJLfsshzCDnT87Bt5NsIboqbmlwE6CrbQdojVGgAd9IKXI5hJ wywfHnC9m60gYtgy+EkEmFqtbcq0bcFrWGIJ8YHWdqbyd/PiQ7qVHQixOAQPVdIBqJS8 QL4GpJgYNOuQE1wvNMAXDcprFZvcNbtly6HGUILtj0bcPS0uEEmHfebPNsqDyP98qe4t ubVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:subject:cc:to:from:message-id:date :dkim-signature; bh=WIUnonEuz9s/GXG9WtFQfFvEvlsTMFF0HTxFInJ1mG0=; fh=h1ghZINZiFLLlrt4p1llC4IfVINLt2KICwBfPlwm7kM=; b=yZCN1TkhIepSuRPQ5qWp1JdYqBSm9lr685B9y13+5WUWGd2/9OjlVO/7WJM1TbKLVE EHUUn0ReQgYUvAQh3aqZpQkox3KIVcYcQnKEHkPbfoz0dQoWwJRwu94fZnsU4s6toI98 5S9oKqh3pRxhpcPuv3H3fIbf6wZK4Tz/QbLPb3fWthe9wIrpTjxo11/FxIVsnYEt78MM pfb6J/01KD4xSzn9U7VD3usuTVcV6zqUtmVC1DC2PNNBg7ASoz6HRiQ6Vf+V/h57ZGBy MY7URPiPyzptaeZE0IDJIiSBXR7m8gJadbvd0L57H2jvtmyIhmWkyyTyVg/goEDt8RE9 uIog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=fJ4PUmtX; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bf10-20020a0564021a4a00b00521e784bbbesi1111363edb.15.2023.07.21.08.36.39; Fri, 21 Jul 2023 08:37:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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; dkim=pass header.i=@gmail.com header.s=20221208 header.b=fJ4PUmtX; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230112AbjGUPcE (ORCPT + 99 others); Fri, 21 Jul 2023 11:32:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229801AbjGUPcD (ORCPT ); Fri, 21 Jul 2023 11:32:03 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3F532D47; Fri, 21 Jul 2023 08:32:02 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-262e839647eso1185223a91.2; Fri, 21 Jul 2023 08:32:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689953522; x=1690558322; h=in-reply-to:subject:cc:to:from:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=WIUnonEuz9s/GXG9WtFQfFvEvlsTMFF0HTxFInJ1mG0=; b=fJ4PUmtXNPGf0B0fr09V6fdwEJoTM9bq4O5PnJchACO0/MHwAJkBgzsCRUfyTSD22V D/0cLhvcSjVciOcvfpbGfZOEKKqdYANcmZY4pyxZ5To2nlyMoh21lMU4yAozTgqXpdZN zTsqUxrgau3vrU/GiqAlU3Y4cHAqkcAgKCySJ3r2jSGkQdS25nNLPZjskOx5+OOGH/g4 LMWUu3Bnq6TeJ9uCTletrZ3LalufheQtxLRONEEjIo4Gvn2g0lRf636U579xSC/qbjvH 92eioK0u3tHTPX2NjPhgbXongKpIWiZ+ROHRH/qffQQbMAD+edWziytCS174ICgEASfF 9aug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689953522; x=1690558322; h=in-reply-to:subject:cc:to:from:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=WIUnonEuz9s/GXG9WtFQfFvEvlsTMFF0HTxFInJ1mG0=; b=CZz7GB5OsgzKV4AmDxbeZOyq4dalgorYMo6HT7mncpPcnV0Tmc+V+CL2bUS1Hc1Q47 4Ut0qXg+vtCImK0EOsNK3gzJFKsnlJXXk24eXl/McEwqmB62dezH+i/T33Joff99sRF+ 3EXpcgbqowOvUHjeg1AJ/LYKuhd8c2cVj+x/dOkwwEEi1hFg/b1K4SYEY7JIhNArjQvi sIlxxDrIGqORHQOL1xPmXL5nhVHrXrt02tYT+aagxte6K1QTv5t8G5xyoctCh6h/MAdR l1DSeVNbEGRYjrj23aJPH2SE9Gqn6Avsui+4t7QD945FBWn+rofGozt33G+5P/Zu+CNl QIuA== X-Gm-Message-State: ABy/qLZWLz2liUsy6AIFsa9Y10qPJa+aJHLxRQ7l0H2699PXAoPm06xs joU6iOxacaLEumo6Ofg0/UU= X-Received: by 2002:a17:90b:3887:b0:267:9767:d1a6 with SMTP id mu7-20020a17090b388700b002679767d1a6mr1949400pjb.3.1689953522182; Fri, 21 Jul 2023 08:32:02 -0700 (PDT) Received: from dw-tp ([49.207.232.207]) by smtp.gmail.com with ESMTPSA id n20-20020a17090ade9400b0024e4f169931sm4327647pjv.2.2023.07.21.08.31.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 08:32:01 -0700 (PDT) Date: Fri, 21 Jul 2023 21:01:58 +0530 Message-Id: <87cz0ll1qp.fsf@doe.com> From: Ritesh Harjani (IBM) To: Kemeng Shi , tytso@mit.edu, adilger.kernel@dilger.ca, ojaswin@linux.ibm.com, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Cc: shikemeng@huaweicloud.com Subject: Re: [PATCH 03/10] ext4: return found group directly in ext4_mb_choose_next_group_p2_aligned In-Reply-To: <20230721171007.2065423-4-shikemeng@huaweicloud.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,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-ext4@vger.kernel.org Kemeng Shi writes: > Return good group when it's found in loop to remove unnecessary NULL > initialization of grp and futher check if good group is found after loop. > > Signed-off-by: Kemeng Shi > --- > fs/ext4/mballoc.c | 21 +++++++-------------- > 1 file changed, 7 insertions(+), 14 deletions(-) Makes it simpler. Thanks for the cleanup. Feel free to add: Reviewed-by: Ritesh Harjani (IBM) -ritesh > > diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c > index 33ee3991f62c..4031f8e2a660 100644 > --- a/fs/ext4/mballoc.c > +++ b/fs/ext4/mballoc.c > @@ -875,7 +875,7 @@ static void ext4_mb_choose_next_group_p2_aligned(struct ext4_allocation_context > enum criteria *new_cr, ext4_group_t *group, ext4_group_t ngroups) > { > struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb); > - struct ext4_group_info *iter, *grp; > + struct ext4_group_info *iter; > int i; > > if (ac->ac_status == AC_STATUS_FOUND) > @@ -884,7 +884,6 @@ static void ext4_mb_choose_next_group_p2_aligned(struct ext4_allocation_context > if (unlikely(sbi->s_mb_stats && ac->ac_flags & EXT4_MB_CR_POWER2_ALIGNED_OPTIMIZED)) > atomic_inc(&sbi->s_bal_p2_aligned_bad_suggestions); > > - grp = NULL; > for (i = ac->ac_2order; i < MB_NUM_ORDERS(ac->ac_sb); i++) { > if (list_empty(&sbi->s_mb_largest_free_orders[i])) > continue; > @@ -893,28 +892,22 @@ static void ext4_mb_choose_next_group_p2_aligned(struct ext4_allocation_context > read_unlock(&sbi->s_mb_largest_free_orders_locks[i]); > continue; > } > - grp = NULL; > list_for_each_entry(iter, &sbi->s_mb_largest_free_orders[i], > bb_largest_free_order_node) { > if (sbi->s_mb_stats) > atomic64_inc(&sbi->s_bal_cX_groups_considered[CR_POWER2_ALIGNED]); > if (likely(ext4_mb_good_group(ac, iter->bb_group, CR_POWER2_ALIGNED))) { > - grp = iter; > - break; > + *group = iter->bb_group; > + ac->ac_flags |= EXT4_MB_CR_POWER2_ALIGNED_OPTIMIZED; > + read_unlock(&sbi->s_mb_largest_free_orders_locks[i]); > + return; > } > } > read_unlock(&sbi->s_mb_largest_free_orders_locks[i]); > - if (grp) > - break; > } > > - if (!grp) { > - /* Increment cr and search again */ > - *new_cr = CR_GOAL_LEN_FAST; > - } else { > - *group = grp->bb_group; > - ac->ac_flags |= EXT4_MB_CR_POWER2_ALIGNED_OPTIMIZED; > - } > + /* Increment cr and search again if no group is found */ > + *new_cr = CR_GOAL_LEN_FAST; > } > > /* > -- > 2.30.0