From patchwork Fri Sep 15 02:52:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 140040 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp765624vqi; Thu, 14 Sep 2023 19:53:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFrUAFfnFQS45LnGkxgVxHAsn5IQDyIAIUEbfQeqx/T5xHsP/TZTE9/+9ZAOKpdH+CS5PAV X-Received: by 2002:a17:903:48f:b0:1c3:76c4:7246 with SMTP id jj15-20020a170903048f00b001c376c47246mr398992plb.9.1694746424359; Thu, 14 Sep 2023 19:53:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694746424; cv=none; d=google.com; s=arc-20160816; b=DlxgsenMtcCoEhEYXsheHeDvXrI74xUQf2JNxNplvfs+xRC8dkuKHEDEtPACozGqgQ soDQF++b5Zvcppb0wyzWu4SGkeoG0sikim7vIC+SItVVWJUa1DOKwYbv1rvs2nFeCS8A LmuwOtHPd94Fd6k5SeYwFiDzejyJftAK4AG7K9+bwamn1oNTGS6k5I0HcjEp3LRLW8Ze 7oWozDk9sxKpE4Rxr6Y4WEPmLqGAKHgFOO3SpLSRhfQVAyCNW2nDhbk2cof435LWmFVg NTE9RimO3QZTc031JNauGJlE0z7K5pDhCERESxorwAKaMUXAgeqGrD5ZHq4YeLeMF0Zc XVyw== 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 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id e15-20020a17090301cf00b001c3a05b0b67si2706268plh.566.2023.09.14.19.53.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 19:53:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; 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 2620:137:e000::3:5 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 AA44C83669CB; Thu, 14 Sep 2023 19:53:40 -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 S231691AbjIOCxM (ORCPT + 33 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 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:40 -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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777070426974987364 X-GMAIL-MSGID: 1777070426974987364 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;