From nobody Thu Apr 2 03:22:50 2026 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [160.30.148.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 19F19344DBD for ; Thu, 12 Feb 2026 11:29:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=160.30.148.35 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770895788; cv=none; b=AwY10HApYE5HbueqTvbCBdxTeqRqWJZyPzo9Q0jSWfDmFdalwOBbDGsKIWDqSulwOEgCUAAraiTavf94Y9c1vIac898wr9hcLxPNvEX9Azyat/lGMOzgxaCNrLTXKgDiQXqBTkV5BrIUIIs7s0kuD/wQKDMo70xT4sXV493/zF0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770895788; c=relaxed/simple; bh=TWjv1WZu3xMhZybeWnfCye+0DXnlsEW0wyXbrAqYOmo=; h=Message-ID:In-Reply-To:References:Date:Mime-Version:From:To:Cc: Subject:Content-Type; b=Jtix8Yg1cQ1QzKKbDaW76O30C7UQA5aQQ2bgTD1nCXqjEJlyX8H7H3n+YgJOW0unYHkfHnJ7S0iBIfYIYZrLPvZJQzuLzpnrzMg6LY+zaTfwcX5tJ/xEn4oekCEfKG8EUSuK6V0qxAW2Jio3Nkrv9gVAmI7shCbzHROJkn0oJGg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zte.com.cn; spf=pass smtp.mailfrom=zte.com.cn; arc=none smtp.client-ip=160.30.148.35 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zte.com.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zte.com.cn Received: from mse-fl1.zte.com.cn (unknown [10.5.228.132]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4fBY432Nsqz8Xs6w; Thu, 12 Feb 2026 19:29:39 +0800 (CST) Received: from xaxapp01.zte.com.cn ([10.88.99.176]) by mse-fl1.zte.com.cn with SMTP id 61CBTTM7085942; Thu, 12 Feb 2026 19:29:30 +0800 (+08) (envelope-from xu.xin16@zte.com.cn) Received: from mapi (xaxapp01[null]) by mapi (Zmail) with MAPI id mid32; Thu, 12 Feb 2026 19:29:32 +0800 (CST) X-Zmail-TransId: 2af9698db99c623-3d550 X-Mailer: Zmail v1.0 Message-ID: <20260212192932941MSsJEAyoRW4YdLBN7_myn@zte.com.cn> In-Reply-To: <20260212192820223O_r2NQzSEPG_C56cs-z4l@zte.com.cn> References: 20260212192820223O_r2NQzSEPG_C56cs-z4l@zte.com.cn Date: Thu, 12 Feb 2026 19:29:32 +0800 (CST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 From: To: , Cc: , , , , , Subject: =?UTF-8?B?W1BBVENIIHYzIDEvMl0ga3NtOiBJbml0aWFsaXplIHRoZSBhZGRyIG9ubHkgb25jZSBpbiBybWFwX3dhbGtfa3Nt?= Content-Type: text/plain; charset="utf-8" X-MAIL: mse-fl1.zte.com.cn 61CBTTM7085942 X-TLS: YES X-SPF-DOMAIN: zte.com.cn X-ENVELOPE-SENDER: xu.xin16@zte.com.cn X-SPF: None X-SOURCE-IP: 10.5.228.132 unknown Thu, 12 Feb 2026 19:29:39 +0800 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 698DB9A3.000/4fBY432Nsqz8Xs6w Content-Transfer-Encoding: quoted-printable From: xu xin This is a minor performance optimization, especially when there are many for-loop iterations, because the addr variable doesn=E2=80=99t change across iterations. Therefore, it only needs to be initialized once before the loop. Signed-off-by: xu xin Acked-by: David Hildenbrand (Arm) --- mm/ksm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index 2d89a7c8b4eb..950e122bcbf4 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -3168,6 +3168,8 @@ void rmap_walk_ksm(struct folio *folio, struct rmap_w= alk_control *rwc) return; again: hlist_for_each_entry(rmap_item, &stable_node->hlist, hlist) { + /* Ignore the stable/unstable/sqnr flags */ + const unsigned long addr =3D rmap_item->address & PAGE_MASK; struct anon_vma *anon_vma =3D rmap_item->anon_vma; struct anon_vma_chain *vmac; struct vm_area_struct *vma; @@ -3180,16 +3182,13 @@ void rmap_walk_ksm(struct folio *folio, struct rmap= _walk_control *rwc) } anon_vma_lock_read(anon_vma); } + anon_vma_interval_tree_foreach(vmac, &anon_vma->rb_root, 0, ULONG_MAX) { - unsigned long addr; cond_resched(); vma =3D vmac->vma; - /* Ignore the stable/unstable/sqnr flags */ - addr =3D rmap_item->address & PAGE_MASK; - if (addr < vma->vm_start || addr >=3D vma->vm_end) continue; /* --=20 2.25.1