Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4304728rdb; Thu, 14 Sep 2023 19:53:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGM646/sSdG5NNBnm6bTCcmmIvLsbiM7gG0nGaYS7/5acSt4k/VBiP8xijFdPefV5vSbqUj X-Received: by 2002:a17:902:eaca:b0:1c3:a4f2:7c84 with SMTP id p10-20020a170902eaca00b001c3a4f27c84mr441772pld.60.1694746400617; Thu, 14 Sep 2023 19:53:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694746400; cv=none; d=google.com; s=arc-20160816; b=mgk/jg6223wCUn97PGhM7oQbKnOAMnZ9Llpdj7X8A/iqfg474B+tGKUmV30cp+wPVw OwT8ZoBc7VXHkbq+TtowPji9yvcBRCSQU6KuLZ58lYM45QbX+BFLYkmrtOwHGh7goxUF mPKBNJxcB1awieUeOQjXrS8jBsiAJOEHvzRJP90gTaFYZLdiJYUIh/IR6/YFfW2l+z5o ryjfIQZv6X9DT8rAWMKVmcWRpo4z4+oiEBNz2Vp6fUxPBNzDcvuLRIkY5qDYotw0JV3V iJBrnjtCABQ57bmYvcALSt6qZ6wdCCUHoPBAusI1Wlqm4ea4tKv/2Q1Bc2QHmbUWG0ko hYnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=s9CCrAW2k5JfZmWyxspFJIvVkuWytxqxD9bxjnqhVns=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=MH2VpnQZvS9YkZWBD8VGUa/fqrTjETfVE1PhrT8tcH1xgq667HQslXDvHGKFqmYZCb HAXoKjvS/fCAocXj9ZIq+p4EOnNJC5xQDsFbFmHaFb7PJObTePSdLNWU/pz+LRpeG2Ox xb9TOvoZl92GFxByIW5fWeNoBCQ7z1oDx2rzQAyQCbfN/Y5SO0c85x3bhl7jtioQ9JLh IhIWD/0GgJ35VB9MRHX3mOH+d9toD1TTHl7hmU+FcO4AtkwdAHgBoYIYV3acpxvsVI7h jtk1ubJ+V0e1cOdAdkSjJBg4fQ8axqPsbI2ncVlf7mbrT7KBLgMnAC5hHhp/5teXMZ9z ld6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EyWd6QeH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id j4-20020a170903028400b001bb0fdbfdc1si2641643plr.199.2023.09.14.19.53.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 19:53:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EyWd6QeH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 19F208381623; Thu, 14 Sep 2023 19:53:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231755AbjIOCxM (ORCPT + 99 others); Thu, 14 Sep 2023 22:53:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231648AbjIOCxI (ORCPT ); Thu, 14 Sep 2023 22:53:08 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F6322701 for ; Thu, 14 Sep 2023 19:53:04 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68B15C433CA; Fri, 15 Sep 2023 02:53:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694746383; bh=i00VYLhoAf7cwF/8O1Xi88bbaOl2lSsV4k5ng0qJ0ek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EyWd6QeH+I+otwhxDe5iLd5XAOviRv5NU62+pG7wOYSt1RxJd562R/9kRGV/14S6k wqwgK3S/aoyzhC6ERZqSSiw7JvU7BAbifNwCKIe6Ic1N++Fm4YodPXqekKh7wy5E4c frf4PtL+Dv7zzGaMntbeugmrQFPZnEwcCuwZ6MVTdQMvr7clAKApk58dlqzx4D9XB7 gFmgUFdVfZXcHnVsiUAYX4nj2eQscAJwIuXzXjzAOvHwZF0ZRQvEYWdpSJfowFNMuu CkJENgkBPYUg94GulS9lebSqQJdp3mZ2b0vLC1KWqzgCeo/tyq22w10Ies9ncnlHit 8JGVkX6Fe/OWA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/8] mm/damon/vaddr: call damon_update_region_access_rate() always Date: Fri, 15 Sep 2023 02:52:45 +0000 Message-Id: <20230915025251.72816-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915025251.72816-1-sj@kernel.org> References: <20230915025251.72816-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 14 Sep 2023 19:53:17 -0700 (PDT) X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email When getting mm_struct of the monitoring target process fails, there wil be no need to increase the access rate counter (nr_accesses) of the regions for the process. Hence, damon_va_check_accesses() skips calling damon_update_region_access_rate() in the case. This breaks the assumption that damon_update_region_access_rate() is called for every region, for every sampling interval. Call the function for every region even in the case. This might increase the overhead in some cases, but such case would not be frequent, so no significant impact is really expected. Signed-off-by: SeongJae Park --- mm/damon/vaddr.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index 7fc0bda73b4c..e36303271f9d 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -563,6 +563,11 @@ static void __damon_va_check_access(struct mm_struct *mm, static unsigned long last_folio_sz = PAGE_SIZE; static bool last_accessed; + if (!mm) { + damon_update_region_access_rate(r, false); + return; + } + /* If the region is in the last checked page, reuse the result */ if (same_target && (ALIGN_DOWN(last_addr, last_folio_sz) == ALIGN_DOWN(r->sampling_addr, last_folio_sz))) { @@ -586,15 +591,14 @@ static unsigned int damon_va_check_accesses(struct damon_ctx *ctx) damon_for_each_target(t, ctx) { mm = damon_get_mm(t); - if (!mm) - continue; same_target = false; damon_for_each_region(r, t) { __damon_va_check_access(mm, r, same_target); max_nr_accesses = max(r->nr_accesses, max_nr_accesses); same_target = true; } - mmput(mm); + if (mm) + mmput(mm); } return max_nr_accesses; -- 2.25.1