From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pz2-f1.google.com (mail-pz2-f1.google.com [74.125.228.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EE68495510 for ; Wed, 22 Jul 2026 09:58:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.228.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784714298; cv=none; b=S7gthnx5aNXTh9feNpnoWOF/eSP1twM9k9Ud+cVvhuzOm3oTM7hyU/ptp5R8TmJLyKbB+M/bNNSmd5Tth/WALoDXwcq3mOowI/jwZ9ViHL1HDEq2nx9MT+a+bil0f7aUn/Law3y3gW3jCDqIQyzG/L9aWBFPvclwW1DpUny4wjc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784714298; c=relaxed/simple; bh=akDU7xYh0IgyGRFadM1zLtDJvjoGFRPfM3elobo9fME=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=jlFwYlJpicvFvUmorSilA4uzEwd5759xpb0uBpbK/4g5lP6ZmxTAoskLNoR12r3vCOwsbu1L/z77W0t1/U9vdrgAq3DerdZB9pIFAh7RN8PsojZPQgsIYNnzt+8j7qa6y627C2dS/m1PxrY72YNV2EnZ1vbuv1AkG8kSxVRXHi4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JeUtFaBI; arc=none smtp.client-ip=74.125.228.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JeUtFaBI" Received: by mail-pz2-f1.google.com with SMTP id 41be03b00d2f7-cbb818e57c9so897334a12.0 for ; Wed, 22 Jul 2026 02:58:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784714296; x=1785319096; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Ijy/gLpb1NwFXbgR00G1evfvLl/4vAA++YOqxk207ZE=; b=JeUtFaBIjK/Zxm7YniW0ZoW4x/1vuNH26eGK15X0gw8M3j/Atr2xx8FKpwsUqGOLE1 CbUbgG+Vfx3j9w4jwtZz7eOKcQ41lxd/j3vlmttq6zVwb5er8bPwxqgnWZ5VJUQWHDs2 cH/70vzh510NKbVKuKrnRrgnkaTzLCOBacaP7ZPymrU5kHeqnj4Vhl8eoUCD/SJpHKM7 wduAQVXvAj/3erZsoKvltTV07OR4L0kUzFhFKr1Km3tHcMMd/O3caqs9otR9Xv0+rq7s n6ct89b1zPhnX5AW2H/gxgsE+o1srorr+1FQbzp18IfkDiNG+ZcmJa1JGozRQrG9LoY4 samQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784714296; x=1785319096; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Ijy/gLpb1NwFXbgR00G1evfvLl/4vAA++YOqxk207ZE=; b=Ge9Q4y/RT+X/0RELyj5ZWCW9G7BNGeU7C3Tpx2qidMAAdMYGJtTKnemjSZYRodau8g Jvh/Vgi/nFIF+RQ7BYEfHVt21GEfpQslbd46IZrkI0JYwELlVvbr071OPzsXWDSt4K2r RKNhFk4QwZrGOCmhH8EfRf5FqEczHVpXAvTtge74hlFNT3nHoLEnvEHjHlmFNrGiDpZa ntTK8ZU5AAdSualyo4FQmHf7LiKb/2zngEDizx7KpTRXx3fdI0yB2yIlv4d2ZyE4J7kB z9nY0ZvbAbk2c1KRfg7W49to3UKJZaY/XRYKQz/TsVcViL8bEKA1rmLK9dIRlps/s5bP NREw== X-Forwarded-Encrypted: i=1; AHgh+RqbAy2GmrwPbPx5krlfeMg1b7ahJSoGnKJOX6vjxXamzUEtBcx9jiauqtzBzDFnSWu8egKubxJVmyDbvHE=@vger.kernel.org X-Gm-Message-State: AOJu0Yx9Bov5m3CpDB+1mP9ldyZG+OMxYGYtpvyWH44fTKEwagacc/h8 xG/2kwiI/+w6zxSxWJYCmvRPv7URxqmJyVbolsuHsSK3nOdmucai2aVi X-Gm-Gg: AR+sD13WrXxGwrxyHA0nK82YtvapvdEXCDccCSTDWmjoTUWpaFQ4vl65YnEv7C5AgUI 8Lr44ZtKLjEGKzTukJNNA7JgS5kgLDY8OoopMlQLI6wmD5fTQVkpRSuFp1fS73ozApiEcawscT5 G8r/7BYfmr5eKc4T+FWbmVUm59Md4TuJ79jJbP9aavkYHVETlQnfv1CsHbupFffiwvFpCtq+w9O 3RJe1lhhuHyiHwgmpxKg5pgo2N9r3pVfKnXqgBAqnfExqnUR6wCPgTVPSxgTH/4TPwF8ILx/Ngv HLNX9J3wTJGuoewHuKzVPIjXmpDktgG3mgJU9c5FJ0UaMPOTdB8aUyuLEOe5LXTN9pTeBXyzw2M Y/qzZ8LwZLKAn3zhraGhylkC/KaJYHJjyIbHJn9v47nlkFUbOMBeyZi8kAXZ3kBIN/X8Y+TuhVF +G75iIw7ylsw== X-Received: by 2002:a05:6a00:23d5:b0:848:4754:28e5 with SMTP id d2e1a72fcca58-84c292393e8mr21888359b3a.16.1784714296477; Wed, 22 Jul 2026 02:58:16 -0700 (PDT) Received: from [10.125.112.20] ([210.184.73.204]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84e172862d3sm1045545b3a.22.2026.07.22.02.58.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Jul 2026 02:58:15 -0700 (PDT) Message-ID: <2e9902e7-3f40-49d5-afb0-e710fb01ab39@gmail.com> Date: Wed, 22 Jul 2026 17:58:00 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 4/4] mm/mlock: migrate folios out of CMA when mlocking a range To: Sebastian Andrzej Siewior , "David Hildenbrand (Arm)" Cc: vbabka@kernel.org, rostedt@goodmis.org, mhiramat@kernel.org, Alexander.Krabler@kuka.com, hughd@google.com, fvdl@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, akpm@linux-foundation.org, surenb@google.com, mhocko@suse.com, jackmanb@google.com, hannes@cmpxchg.org, ziy@nvidia.com, ljs@kernel.org, riel@surriel.com, liam@infradead.org, harry@kernel.org, jannh@google.com, lance.yang@linux.dev, mathieu.desnoyers@efficios.com, matthew.brost@intel.com, joshua.hahnjy@gmail.com, rakie.kim@sk.com, byungchul@sk.com, gourry@gourry.net, ying.huang@linux.alibaba.com, apopple@nvidia.com, pfalcato@suse.de References: <20260707125925.3725177-1-chenwandun1@gmail.com> <20260707125925.3725177-5-chenwandun1@gmail.com> <9b227263-56d9-41d5-ba8e-c969d8d68785@kernel.org> <20260709131509.iIPP2VBh@linutronix.de> Content-Language: en-US From: Wandun In-Reply-To: <20260709131509.iIPP2VBh@linutronix.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi Sebastian, David, Sorry for the long delay in getting back to this, and thanks a lot for the review. On 7/9/26 21:15, Sebastian Andrzej Siewior wrote: > On 2026-07-09 12:04:33 [+0200], David Hildenbrand (Arm) wrote: >> On 7/7/26 14:59, Wandun Chen wrote: >>> From: Wandun Chen >>> >>> The region covered by mlock[all] may contain CMA pages. cma_alloc installs >> >> What about ZONE_MOVABLE where memory is supposed to be migratable? > > Would it be bad if the pages would not be movable anymore? Does this > effect just memory-hotplug or something else, too? ZONE_MOVABLE does not need the same treatment as CMA. 1. On RT compact_unevictable_allowed is 0 by default, pages in ZONE_MOVABLE are never migrated by compaction, so no latency spike, no problem. 2. For the scenario of memory offlining within ZONE_MOVABLE, because of offline is an explicit administrator action. Any jitter/latency is expected and acceptable, the operator chose to offline memory and would not do so during an RT-critical phase. 3. cma_alloc() runs at runtime, triggered by drivers as part of normal operation, and isolation path hardcodes ISOLATE_UNEVICTABLE, so it migrates the mlocked pages and installs migration entries. The fault-and-wait latency hits the RT task unpredictably during normal operation, which is not expected, and is exactly the spike this patch targets. > >> Also, what about drivers that mmap() CMA memory to user space, and >> __mm_populate()->populate_vma_page_range() would actually try mlocking them, and >> they actually must remain on CMA areas? > > It should be safe to skip those. They belong to device and they > shouldn't be affected by anything including getting swapped out. Agreed. Only LRU folios are ever isolated for migration here (isolate_folio_to_list() -> folio_isolate_lru()), and device-owned CMA buffers are not on the LRU, so they are left in place. I'll double-check the mmap paths and make sure this holds, and state it explicitly in v3. Best regards, Wandun > > Sebastian