Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp5605047pxb; Mon, 28 Mar 2022 14:52:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz707djh6advEw2hb1DSktQHo0EyLz4b9HJWJ3kpLyeNZmSoPGvqSspP9diDTOxBEJddu/z X-Received: by 2002:a05:6122:2229:b0:32d:1642:b58b with SMTP id bb41-20020a056122222900b0032d1642b58bmr14030233vkb.27.1648504335377; Mon, 28 Mar 2022 14:52:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648504335; cv=none; d=google.com; s=arc-20160816; b=D23gm6PE5PnNFF5Q/dsTxQ1pAJI1BFcLXk4/AB2jG+WeTTWGrhBZsQT1nSMP6r5b0J JfA2w+zeev4huGT5aMEe+KWbfjH1UvsLJlyDuTA2pfRNskHKoNybc2w38gvp5kLXsdSc TaquGC5wuclQX+VsCezmCBQOSOtPJadd6Vye4Msoai+vcCgXyNYiy1ioOFIaDspi4+Oe M+tzPBrSgOfq+2LSMFblkbDTI3cuMJdE3KW6i3jfrggbqMd/+t8X1ZMe7e27E0yPFYc7 7HHkczeijYYOcqPUBYeZ60xm3zhzaMyvmVzv/IaD4eykTMQQu+keC20z9Q6IB4qx6CC0 QUhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1iRsvsVzGXiBsSi/m3Dky7HVs1UayhjXllJjlzde6TE=; b=D/qNublYkvK4AQEdM0JMaT4SJ3bGM+tizOrmBukJWkrF/LaKUvmaHICckba+uap4hV ow7JrlmxGEQEOQe88m5L6eqbAbFuXec8X6jxm4TYxdSvzXC0Zt3RTENsIYYjoAy7qsR1 1t1h3/Ikwe8uG7Np8CfFLfP7b+K2IPnDHVaQjj9LDU7e5/5pjWTEK24OsOqdqls4BBE6 1eqVdjk24/IbN2vhyaf1B9P9JXum2QJgoamJQeYAwpnoizgDXVqm19lGpaZg+I9FSLvN zkpHzcXvqEZbs/5wLvs+GDPFTCM/Yvyd1EjRC+hr85nUrD3fWAtSjPZmzlIoBefOjV25 VhUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PBhbaW+f; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id p23-20020a67e957000000b00324e7674063si2920827vso.436.2022.03.28.14.52.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 14:52:15 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PBhbaW+f; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0D96A137F75; Mon, 28 Mar 2022 14:23:04 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241984AbiC1LxI (ORCPT + 99 others); Mon, 28 Mar 2022 07:53:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241897AbiC1Lrn (ORCPT ); Mon, 28 Mar 2022 07:47:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 747D7B07 for ; Mon, 28 Mar 2022 04:42:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0FCC4611D6 for ; Mon, 28 Mar 2022 11:42:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03361C004DD; Mon, 28 Mar 2022 11:42:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648467774; bh=jMaunHAXMlJ+DWdKZ1J2mPlg8iRfvDMvaDW/Gbm28E4=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=PBhbaW+fD1BPQ93FjKM7at0JOtBDEhoYmRbtWUb2T3cyhmQJsvDADFuvCGHqzfQoW y/tlW4i31COh9bIQ+E999BDp/LVsEp0s7r2TUa8cDTI9hGfWoYZWEoEKugAFgtJY3R 3lR0v/4KDIgaxlsIVwdcimmR5o7MS13N3FYc8IyeyAzTDYE8FH8Fsj5HmsoPmf7sO/ 3koCjiH8vDU+nzQPg++KQfjrg7gWo9nwTk/T6FibfbGGawm7Pl27aQZCwsvEVS2uln +oxPDvHCFmh+2SQBDZEynsjkgYErnpDYW+fVhFpyq482heuGlQFXOo88AdiDCSvNhn I2A11bHfvRDug== From: sj@kernel.org To: Xiaomeng Tong Cc: sj@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] damon: vaddr-test: tweak code to make the logic clearer Date: Mon, 28 Mar 2022 11:42:51 +0000 Message-Id: <20220328114251.31851-1-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220328112930.31229-1-xiam0nd.tong@gmail.com> X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, 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 Mon, 28 Mar 2022 19:29:30 +0800 Xiaomeng Tong wrote: > Move these two lines into the damon_for_each_region loop, it is always > for testing the last region. And also avoid to use a list iterator 'r' > outside the loop which is considered harmful[1]. > > [1]: https://lkml.org/lkml/2022/2/17/1032 Let's have one empty line here[1]. [1] https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html#the-canonical-patch-format > Signed-off-by: Xiaomeng Tong Other than the above trivial nit, Reviewed-by: SeongJae Park Thanks, SJ > --- > mm/damon/vaddr-test.h | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/mm/damon/vaddr-test.h b/mm/damon/vaddr-test.h > index 6a1b9272ea12..98b7a9f54b35 100644 > --- a/mm/damon/vaddr-test.h > +++ b/mm/damon/vaddr-test.h > @@ -281,14 +281,16 @@ static void damon_test_split_evenly_succ(struct kunit *test, > KUNIT_EXPECT_EQ(test, damon_nr_regions(t), nr_pieces); > > damon_for_each_region(r, t) { > - if (i == nr_pieces - 1) > + if (i == nr_pieces - 1) { > + KUNIT_EXPECT_EQ(test, > + r->ar.start, start + i * expected_width); > + KUNIT_EXPECT_EQ(test, r->ar.end, end); > break; > + } > KUNIT_EXPECT_EQ(test, > r->ar.start, start + i++ * expected_width); > KUNIT_EXPECT_EQ(test, r->ar.end, start + i * expected_width); > } > - KUNIT_EXPECT_EQ(test, r->ar.start, start + i * expected_width); > - KUNIT_EXPECT_EQ(test, r->ar.end, end); > damon_free_target(t); > } > > -- > 2.17.1