From mboxrd@z Thu Jan 1 00:00:00 1970 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 1BE99C54F30 for ; Tue, 27 May 2025 06:34:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A5CEC6B008C; Tue, 27 May 2025 02:34:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A0D306B0092; Tue, 27 May 2025 02:34:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 949BF6B0093; Tue, 27 May 2025 02:34:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 761486B008C for ; Tue, 27 May 2025 02:34:33 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1FE76140110 for ; Tue, 27 May 2025 06:34:33 +0000 (UTC) X-FDA: 83487724026.01.ACFB2AF Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) by imf16.hostedemail.com (Postfix) with ESMTP id 190C1180008 for ; Tue, 27 May 2025 06:34:30 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=mSRwbl6R; spf=pass (imf16.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.50 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1748327671; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=UwZWHVEBP19vCrdAF3+T5zX3xH9X9oRl91m4sOfd/T0=; b=4zTxh/n5Ox741rOR2+zVn7wPj/FvtF3dQzSY4+p+aWuVNgQPASzYgfo2+kVvWmDI4LjgGT fT3P0KV40W1CUVLgy7nIPk8j9MrSyt593fRULEgyuX8zIgkUf6gJNG7gmkwZPkWT3T+Aru kgKLzkX3x865YvWZvp4KrKF04awOxSE= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=mSRwbl6R; spf=pass (imf16.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.50 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1748327671; a=rsa-sha256; cv=none; b=jtJ4z+vvm9+RMXLd5hER2FqG0XIzY9sfRcrgK9EHeOw0lWKYWYaG4SMggfHO57vyfOrMoV us8edMR6hEhWc3HMy/ITwkNSnIwmm/Z2EdaSyz88dX1x/gugdcRwBqoyVbLLbrK8c+NKew UuaP70i+gzS+0ozJmPkhr516AnV9AQs= Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-ad564b7aea9so793294066b.1 for ; Mon, 26 May 2025 23:34:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748327669; x=1748932469; darn=kvack.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=UwZWHVEBP19vCrdAF3+T5zX3xH9X9oRl91m4sOfd/T0=; b=mSRwbl6R6hlBKbjcTVcnjRW2rEVh3s7kpLsRPTpdsnTP6FRC3AyJ+1lr3vNwnhouJo YjjLnLGnTB2P5ITymeXkdx2vUOcXEXT8W3abLg3yjcbgu+PNAW8mWCfcFx3tR4Qw+XRH 3u9Z+KFDfeMmngEhrzcfHGGKsQh8DQpmTCaMA2Ac+xQjKq9pfommhrNFKUAPieidfZ2u 7TbJSJms8I4TcCUSdYNp3ZpQ+TEAK/RIJuZtmX7mOZHrqIJ4qzE3NDvG4orCTzODUWwj QThEp7sKriqkUZ0yMj80eX0uTZDLSQCl0DdJE4l5M4R67xG6Z6xYcyhz+A0341veU7mo ePfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748327669; x=1748932469; h=user-agent:in-reply-to:content-disposition:mime-version:references :reply-to:message-id:subject:cc:to:from:date:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=UwZWHVEBP19vCrdAF3+T5zX3xH9X9oRl91m4sOfd/T0=; b=r43dNtoFOAyBDzMf2CJ+SL1k8J9MakpYkM1prRRTUwT/9G4hRXzYa/P8Q5GouzqvbT dL2L6rFoypDEE+jBUCw8fmUdfz5Vudbtz1ZsOqhUTB7ld6r95T8yjEZFVMHUfipWQRCe +qa+SvYG9lSRPOZn6odEgtzTyvSUpkqVi5qTwN4YKZD9EhJJGIM7V3G0qxnVwEt8+dTV +iIYFOhOcqKDQri2JOFTfpv2rBGOQ8npYtT6XVSWKOC6XusHbUfQtNtG+zJX7IcAsEJ9 54SlxpLTDRicHxOu+fSJUUUQqX3BRET+e9TttbVS1f5E5F5bFvLlCGQZeCx8TvXwMKQi SkNg== X-Forwarded-Encrypted: i=1; AJvYcCXto6KgYNqOTTK9hHax4y6sEQNTFnDtZuTSkD3x+pY8gP66S7rpU+//nexTJOkwmX6y56+3jfonuA==@kvack.org X-Gm-Message-State: AOJu0YyQ04Spd6mJesQjAlyLNeEOjPVkWiUG+lj2L9PGxwGjNpI4LCRd 7i9yTFpWALMDdkeTRxTeRrNbP8v2YdFqPr3PmAHEEeSEgG6TDXpJCyPN X-Gm-Gg: ASbGncudZ/l+b6RkTQ1DjT81hSN9nDKfQ/F5jbnUu76D16f07BiIK4pF3m16S5siVv/ 1BXszyjx6CeK37kabhlMC3ts7FIp/RwW1D8KissKjRVs2JuKutpI77KolkV9/WtjbxNtSvLJMNn 0Oa1oGTTMaO4OXs5HgBW6p/Rez8LXNlfb+S6wCuB9CE2N68LMBIrekvnypdsN4tcCMaOBZF4pIM pvhJDDXXgZnYPWkADgDohGrE3nVKNDo8IxKdHG1owGirr0ceFnndVXSrn5oYoS9hmL2MSD0mhGZ v98BgHhtfIA9ER3au/EaLwjr1S/ch5G1uArCORcSiw8NZ07AVxoKmlSroUn/zA== X-Google-Smtp-Source: AGHT+IGTLHqoBpkkve1ug4gaVKUx4T1D3AS5WGvgPW9rywOPI46CFUrLmtd4j6MXJ42rGpjIKvOC3w== X-Received: by 2002:a17:907:980c:b0:ad5:6a52:ea41 with SMTP id a640c23a62f3a-ad63f982570mr1276843366b.1.1748327669133; Mon, 26 May 2025 23:34:29 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ad89497343dsm10544166b.42.2025.05.26.23.34.28 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 May 2025 23:34:28 -0700 (PDT) Date: Tue, 27 May 2025 06:34:28 +0000 From: Wei Yang To: Wei Yang Cc: David Hildenbrand , Lorenzo Stoakes , akpm@linux-foundation.org, riel@surriel.com, vbabka@suse.cz, harry.yoo@oracle.com, jannh@google.com, baohua@kernel.org, linux-mm@kvack.org Subject: Re: [RFC Patch 0/5] Make anon_vma operations testable Message-ID: <20250527063428.4ykrdtive2hfnqdp@master> Reply-To: Wei Yang References: <20250429090639.784-1-richard.weiyang@gmail.com> <8c268ece-71a7-470a-bf8b-71d3e4920977@redhat.com> <20250429235608.yvbcxybkfsmp6ow5@master> <20250514012318.2impqotf65p4ihsc@master> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250514012318.2impqotf65p4ihsc@master> User-Agent: NeoMutt/20170113 (1.7.2) X-Rspamd-Queue-Id: 190C1180008 X-Stat-Signature: ihrpqkh6ejhspudwuqui15zg7u8oaxcr X-Rspam-User: X-Rspamd-Server: rspam07 X-HE-Tag: 1748327670-5290 X-HE-Meta: U2FsdGVkX1/QqdfSs4BgIWvo6SP6j6lja7XZ77bcHrfGrnHW003dFr97tb1WL2DS+6Qt0m3o24kJ363BmtbFhtwc545ORnFrK4nafLECkrbr0JI9GVfGC6zgHRGyhc6QAaelF8vGc+OacNpOLNDTvRzAnTh5WobWt8FYMY8U9StKae4TCKoMMKjZw9dUXCewv2KRZI09ZeQz0yVR2EcS3XazsOLd60gwmOuCliCrgLItpbDOKRAXGsoH5mwIUllc2HqLZKroC2A43u9AogFu0SoyT24oHZCsxkLVH/HWc24erQZrH31Wj4zi4ABaIdl8RHiFUaaIdHgb3tjHgwDEvg+vZlJJz2RBeXT4oV4iHpEbJZ3Qhw5XqrmokI+634rxE+1rgvuH5t+nM8GS+KjvrRhngetAieFWTZV5BBgiTA2OsagtX3BKqTfcPEaLmLcqiOjE/mxee9QF43y+7mif9/d+L6exESnI4mkOuQLNC7KW9dGGsDG5DcQhHHwJMcHCt2lz0M0lOg6INrD2kK7Jl8RubWAOOQgTeWUA8jVqSgcMiCBErYebWHsJngkIfoR937nmfUW6BuzkyWXEFUkph27Gibby5MfclLuAwYvTBxC5GdSTqe/QhnrqTpW/rv5EnGTI7eWVrWCSste1V4dU5Ms9EW/gM2OzGd0/Mvj7OouKwY1IV7Wqs13EQ+Wcr8d9AVfQjt9H4GPIxqgr414gt4lqxFm91jKHHbqZNs8EEFbdenq8Zm1AkWCmhskA7y8PRFy0Qcda1+jk/56tO1xfPqRVEaYcaifOMhiEpEi+nPbXaLf55WINfn8ztY2mYNg6qxkPpg8FM042UPJxuZdJl3Tvv8786SgAyvpjknic9k30C1ikgMqlqfmm6CieLlkR8PYhCLVbRiMpqsdDdkNDsiLtqV+C3o2O8X/ba5ZIVd8GCLBXSAff/0IZ4vMRlN9xfvPGigA8yHQbe0c7oKi /jP/6LRY aXRC3LejlaZnZm2x5P/tiT8lD5cqjSUsm9d56+MEgD4QHwFpHfq97sOanq3zAyr0ZEHSpwrFIkhTJ7eydcP3OE25/XkHg7ptVPslBexVOfibLWQcU1ru8oMURoYfa3lhO5VKXXkAFOUHk7AjOwFH80e+/wfkN6W8GOE106vc9PhxZkwywEvMqpccW+Gv5Fmhftl+m39cuRQjCVzdlK8UHQivDQNExWeLmYtfH9P92Eus6dnHl3Av4TQP8vYiZQZ3EbHeRFUoiHwk2IAKEjyFgME4t7ilWtFk8YfWmFOQIsP4iwWKytyDKq4AiFhDTZFjza/UzFECtnEm8f2llYxrBTD4RIOCVX9cPwfcEI4rf8bC6gEOCaF0/GQenJLt5dK78YU2P/uX15H18SpOvDPBQ/R2iBOb09KUOpqEh1KGHGdhfmSFMC7Rt6gpLAtnCoupL0wA+c7BQdqGVqasf1G6Pqnc6ko7UohuabK/6FVowUT1cpCWxQFNqsNJvlqHHOlqqXnvsodI5L3soVkWIUoFzO8lm762wR4gD+vuldSMOtS5W5TGogcJuMJFebHzNx/WpGxcCHBRQj8qXeZw0q756Nw8mS2bFI9RN9PYvlEy3mmzb8Bikblsaqv+7WPoUUq0m5qOj86+RbX3G/xTIfcqZ/JiiJMtTniiTTT6Z1Um/nMXNiiahcIgNUiuwfwclY/eEMcH8qUCrtFWphErdnRWeIHpbMA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, May 14, 2025 at 01:23:18AM +0000, Wei Yang wrote: >On Wed, Apr 30, 2025 at 09:47:16AM +0200, David Hildenbrand wrote: >[...] >>> > > Agreed, skimming over the tests there are some nice diagrams and cases. >>> > > >>> > > But I would hope that for most of these cases we could test on a higher >>> > > level: test our expectations when running real programs that we want to >>> > > check, especially when performing internal changes on how we handle anon >>> > > memory + rmap. >>> > > >>> > > E.g., do fork(), then test if we can successfully perform rmap >>> > > lookups/updates (e.g., migrate folio to a different numa node etc). >>> > > >>> > >>> > That's a great point! Wei - if you could look at making some self-tests >>> > (i.e. that live in tools/testing/selftests/mm) that try to recreate _real_ >>> > scenarios that use the rmap like this and assert correct behaviour there, >>> > that could be a positive way of moving forward with this. >>> > >>> Ping >>> I am trying to understand what scenarios you want. >> > >Sorry for the late reply, I handled other things a while. > >>That is exactly the task to figure out: how can we actually test our rmap >>implementation from a higher level. The example regarding fork and migration >>is possibly a low-hanging fruit. > >If my understanding is correct, you suggested two high level way: > >1. fork + migrate (move_pages) > >> >>We might already have the functionality to achieve it, *maybe* we'd even want >>some extensions to make it all even easier to test. >> >>For example, MADV_PAGEOUT is refused on folios that are mapped into multiple >>processes. Maybe we'd want the option to *still* page it out, just like >>MPOL_MF_MOVE_ALL allows with CAP_SYS_NICE to *still* migrate a folio that is >>mapped into multiple processes. >> > >2. madvise(MADV_PAGEOUT) > >Not fully get it here. You mean fork + madvise(MADV_PAGEOUT) + migrate ? > >But we need to enable pageout in this way first. > >I am not sure why this one is easier way to test. Would you mind sharing more >idea on this? > >>Some rmap tests could make sense for both, anon and pagecache folios. >> >>> >>> Something like below? >>> >>> * fork and migrate a range in child >>> * fork/unmap in parent and migrate a range in child >>> >>> If the operation is successful, then we are good, right? >> >>Yes. And one can come up with a bunch of similar rmap test cases, like doing >>a partial mremap() of a THP, then testing if the rmap walk still works as >>expected, pairing the whole thing with for etc. >> > >For both way, we could arrange all those scenarios and also do partial >mremap() during it. > >>One "problem" here is that even with MPOL_MF_MOVE_ALL, >>move_pages() will not move a folio if it already resides on the target node. >>So one always needs two NUMA nodes, which is a bit suboptimal for testing >>purposes. >> >>For testing purposes, it could have been helpful a couple of times already to >>just have a way of migrating a folio even if it already resides on the >>expected node. >> > >This looks we need a new flag for it? > >Here is my plan if my understanding is correct. > >1. Add test cases for fork + migrate. We may limit it only works on machine > with 2 NUMA nodes. >2. Enable move_pages() on local node, then remove the test limitation >3. Enable madvise(MADV_PAGEOUT) with multiple mapping, then add related cases >4. Add mremap() or other cases > >In general, to verify rmap dose the work correctly, my idea is to > > * mmap(MAP_SHARED) > * write some initial data before fork > * after fork and migrate, we write some different data to it > * if each process do see the new data, rmap is good. > >Does it sound good to you? > >>-- >>Cheers, >> >>David / dhildenb > >-- >Wei Yang >Help you, Help me -- Wei Yang Help you, Help me