From patchwork Mon Mar 28 11:29:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaomeng Tong X-Patchwork-Id: 12793413 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17A59C433EF for ; Mon, 28 Mar 2022 11:29:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 704AF8D0002; Mon, 28 Mar 2022 07:29:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 68D5B8D0001; Mon, 28 Mar 2022 07:29:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 52E1D8D0002; Mon, 28 Mar 2022 07:29:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 3C3258D0001 for ; Mon, 28 Mar 2022 07:29:41 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E390923809 for ; Mon, 28 Mar 2022 11:29:40 +0000 (UTC) X-FDA: 79293574920.05.F98A60F Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by imf06.hostedemail.com (Postfix) with ESMTP id 79ADB180016 for ; Mon, 28 Mar 2022 11:29:40 +0000 (UTC) Received: by mail-pj1-f41.google.com with SMTP id p4-20020a17090ad30400b001c7ca87c05bso9639305pju.1 for ; Mon, 28 Mar 2022 04:29:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id; bh=K1GDc+QJWhYEe9B5KwJciqzvBoL8N5FOvcNlONWFAIU=; b=RubwMEPDFLu856QooxU8gVDiQIA2hT1b620J4DxI9O8yZdT5Q3ZmepeXh/LsHlKr9Q ga31VSpBvCU2kgCkEQo57UWND6TOscCSI2C9+kKt9ik3dLiG1217Yr1XaAGzeMAnedpF w3V/Neo4elRASPM4JWEA6uuNkXjAHyqDvTuyZMZlv7BVMKdZriYyhu6t+zlpXAbxPvfl tne8ytdGQXMFroeRM47d1y71A4hIgxsRpdyDbyCh3lZaFtmUMBo3jV8hGSfv789g0uE9 wAhydDl29xGGcoxRL/JI7969bFs7NE/WQ+C30E8I9/UA33RexHtMBBWYmbbqX0EXlL4a 3l5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=K1GDc+QJWhYEe9B5KwJciqzvBoL8N5FOvcNlONWFAIU=; b=RpcAY9ngMPc5v+aluYBSEV4ExC5LHBZep1aQkS/NnK5E7JwH/+U1CucKqjTT+UXL+L a7ydRfs3n7JcDbob6ObBwHOdMDZ4p+u7gQ8cKAeYqSsHbxVzuOJBtcia1XrEfgnjd1SW Du4G+xJm23fAm3hXi3/FLtLnxnT6uub5f0fJt4u+pZjvJdnURf6yA2qxw3tg7d8w8QNm E0XAhkiYL+RMH+IOm7M9vPaXVmeloU3KA/TA/Sag1n208SHpNfMn44h30MU1a7btFQpe GEy9Tvy/z0Z7sci8uuoSocbCrSeDJ6bwLXh/oWOj7pjvUyCmZyenKk1sSU/c7+GFHUPu EEQA== X-Gm-Message-State: AOAM531FpLyGC1JvzBr7JgXoU+vgM1ZNswnMDDb/y1TMg8U1kprfkTrk X5Q4yLuy0t179idXJLjh4ZsCOJC73LFBVw== X-Google-Smtp-Source: ABdhPJyCMbkOGpR1KCqR5Kq4MYgOKdA4gGy4GsZX0tn++dQ86W4p49spqRifXX6uFwSAN3xYFK6+SA== X-Received: by 2002:a17:902:d2ce:b0:154:7271:9c0f with SMTP id n14-20020a170902d2ce00b0015472719c0fmr25690548plc.85.1648466979418; Mon, 28 Mar 2022 04:29:39 -0700 (PDT) Received: from ubuntu.huawei.com ([119.3.119.18]) by smtp.googlemail.com with ESMTPSA id c69-20020a633548000000b0038554192b91sm13064338pga.38.2022.03.28.04.29.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 04:29:38 -0700 (PDT) From: Xiaomeng Tong To: sj@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Xiaomeng Tong Subject: [PATCH] damon: vaddr-test: tweak code to make the logic clearer Date: Mon, 28 Mar 2022 19:29:30 +0800 Message-Id: <20220328112930.31229-1-xiam0nd.tong@gmail.com> X-Mailer: git-send-email 2.17.1 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 79ADB180016 X-Stat-Signature: zwj5ho1rff7gjxkbbrgt7edbs5gde6pz Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=RubwMEPD; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of xiam0nd.tong@gmail.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=xiam0nd.tong@gmail.com X-Rspam-User: X-HE-Tag: 1648466980-890110 X-Bogosity: Ham, tests=bogofilter, spamicity=0.131508, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Signed-off-by: Xiaomeng Tong Reviewed-by: SeongJae Park --- 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); }