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 0A628C2BA1A for ; Fri, 21 Jun 2024 08:50:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8DC696B0430; Fri, 21 Jun 2024 04:50:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 88CC96B0431; Fri, 21 Jun 2024 04:50:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 72D3C6B0432; Fri, 21 Jun 2024 04:50:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 49D876B0430 for ; Fri, 21 Jun 2024 04:50:52 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id EB8F3C0BA7 for ; Fri, 21 Jun 2024 08:50:51 +0000 (UTC) X-FDA: 82254275502.15.254E6ED Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf10.hostedemail.com (Postfix) with ESMTP id E2E3DC0005 for ; Fri, 21 Jun 2024 08:50:49 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=U4ytXGOm; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf10.hostedemail.com: domain of chrisl@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=chrisl@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718959842; a=rsa-sha256; cv=none; b=2YPPPIDgqDd6DuV65xdGXS9NYkFQLCtj0IfYla+9xbBZ8nWR5lFxBZIH9dMoZIPZoT8p/c I5UhCCazsZxyTg8EOKamHbvqpZnHwfyBoYL3+YoFzBdB2w4KBL+6W6NNCxKZ20qAS6Y/LT G+4Jl5wH8KE/1HQ1BywXwAOrvHRR3Kk= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=U4ytXGOm; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf10.hostedemail.com: domain of chrisl@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=chrisl@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718959842; h=from:from:sender: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=PZK+y9IrBmfcyL/NEma5WNE67KPzT5Vfy29QsNFdLTE=; b=8Fq9yq2Ae1inRVdvzoCGKHa+eoJP78aFxFclxmAi4IYh3DjYHdY4MBybXNufD0PlZy81Vo +C1iRQexfbJleeK6LLCMWN3qIsdO3B8RKTZw9yyEI2j3cyXLlA5iRtuzQg+WfA97wJlHz+ cdZcL0BOKOPmxl7eF8eA3eezNQI+UFU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id F3531624AB for ; Fri, 21 Jun 2024 08:50:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 689E9C4AF0F for ; Fri, 21 Jun 2024 08:50:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718959848; bh=PZK+y9IrBmfcyL/NEma5WNE67KPzT5Vfy29QsNFdLTE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=U4ytXGOm45qB6KIjZ1kb557AnaG6CYKw4iJZwhRN0/L74mmUZXeywYHZ/AVwB+55N tGIq5ELrXS7axJAxf+P7O/l7HE7C8QI5k4MlmGrtOYG97kz7h8v3zs/N7Agrh4MhJw a0Ff6Ycgod9u2V5kApL8zxmXiZkVlnXIqJoDiy3QuhHV6chZuz5Sw0atQ24p07u2eG ErYl9ctHE0kc1UET2GhksU1SMOACACqFjx/L6B1euo6XXxRNTLIcHsFEOfe7V18vl/ TeNeAnBs77pAt4zSWNQ8ZqAMKp7j6/oZRkcPJqX91iliPIcFI5CKbeAPPnvwxkFkJ8 o8T4A7rZt33Ew== Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-52cdb0d8107so54837e87.1 for ; Fri, 21 Jun 2024 01:50:48 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCWM7IItEnEx5Nv4dHCwFzWJDGsCYTobaBMx0W8gbGi/LwnYDjHq+D9uOUE2Ew9W0bjtoBR3C4X/Ix5xQ1jOgWK9rBs= X-Gm-Message-State: AOJu0YzDWg2uS4U0R972jHdkRljE3GKlhxgByNvOkQYFkwxz6lJEtXdP I06BpbQuhrvJKKp1PmCfq0/KjMskBebHsjS8rLAW9RZ1kMGJuWqos/EnMhlHEAz82PDm+/i3RTe RoPoUNAQ1sd8Dja1uvilnAa9XeQ== X-Google-Smtp-Source: AGHT+IGZ4e8uRVE52VeLsDYoPWEaG0mJ9iQuxHimYcfx3rr7/xXSmVv+Q+yczg1q7bSKqw5UBCj0KNWaAQ0+bKY18+8= X-Received: by 2002:a19:4347:0:b0:52c:8318:dc14 with SMTP id 2adb3069b0e04-52ccaa5dc33mr4448995e87.25.1718959846994; Fri, 21 Jun 2024 01:50:46 -0700 (PDT) MIME-Version: 1.0 References: <20240620002648.75204-1-21cnbao@gmail.com> In-Reply-To: From: Chris Li Date: Fri, 21 Jun 2024 01:50:35 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] selftests/mm: Introduce a test program to assess swap entry allocation for thp_swapout To: Barry Song <21cnbao@gmail.com> Cc: Ryan Roberts , David Hildenbrand , akpm@linux-foundation.org, shuah@kernel.org, linux-mm@kvack.org, hughd@google.com, kaleshsingh@google.com, kasong@tencent.com, linux-kernel@vger.kernel.org, ying.huang@intel.com, linux-kselftest@vger.kernel.org, Barry Song Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: E2E3DC0005 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: dpimksohuheeyqnjfewzgjke9c456qe7 X-HE-Tag: 1718959849-82057 X-HE-Meta: U2FsdGVkX19dffdlNxjqa58agnoyHA/vVGjw485F6j15FszIOJwT3uwgW3H2NdN0TN4RfGEkICMep0GIL+doIYZltcEDdPprJsHo2QbahPSBJU9Xp4aXbpVZw+cDlqzVk9KWm3nzdqZ1GzAxJZft80yqeE8dX/8b2yzhQPHpyejmQ7ZQ0hFFA8X2EV6GO8WMjuhxGcRN3quZj/mUqjghHgSik28EV/ME21RvcZ4I6TC2GW+lB8y94arn4j4qrUTqI69Cj15y2OP5i75CYXzDy2M0TDkEfJDfcTWMtZc/14upQYvVylMExvvi4AnfS6lOwvhLItOWLjBzjkxM/UoBs+StJg+JT4PyiO3kr+1AgtV9wNQmuvvIfd+nATb5nNNEE8v418HDfNVd3DVQBJovpK42k/u3bY1y/ZG+tmPclUaxwOJnPtT90m4RzFOYDa6iKw4P9v70n71b6NJ1GPsxENLE1DiXsggysLQ3wFpCq8OgvKa0/zYBfJ2MwtRUUfWS7k1kDw7fmSGymswadGfvFOFCMA5Feed6FJnF2KBDHnT/yYviLkC7K+k8jdunam3885rZEi6GsfswfkprTcELHgceBfKug36PPDm21rGmcwi5yYu5yyVlQ+q6Vd3tHI4cZA30Admal6Ylr4uNF+WQeetSex8K8RxBBDNdES9e4EmGLdLRhQn/CNAdc9ThVtWK3qylkSYO5/uNmfnO0qunLSeRXi1lzm2dumsnwHQis+RXTuFidB/mmxkuwVZ5VPqNrsmrken5N+ryk0TftTjDF879vy7PtPnDnJE+wkuLMQTGHMKKrY/tMCfd2uB7rJpKJLYIsyYGbZeMmzTkzwOJhj98AAYPL7cBEzUnjtRqLWW65jbVvaGizvKuYGXSSWovH0PO8ZaJEpXDnE90Oez1UOJnyuAtLz4StwqojvefAnCTkXcJNVg2IYEt4/xfIWsnLN44/690iH+8u6hRiGt Lh0stlI0 jBUQ14opAoa9Kmq8T7wo8ATV7Zx7seQx21a6aNZj63+GozW9lEI2ks0Lcee6iEXLQziT/NxiK6MCnE7kMhxxi97YmE9IhGTXnunPo+/Gtiy0+tIWovAayvpodugUsY7NBKXOIj3rvazUHWEcBf1Eg04ObnP2p1x66aqEt2YByV0EKTixVm5/Q9iVFc11duJsvximZlvXq3aPJ2eZkIJm6U8lOx/K+Z3OfCjHrdYptKhFg8Ckm0oXL1F8Gos3pTIWzNshkLNXLLzxFtYHXATGxyn/cs7LTu7Snuz1kN7fxERkM3QVnm5KEXGeWzO8oSlUSruwuyyTHKi0/fAmy7ROCJSZ0U82DqHnMExBL/0TYWs6wYvnMNVFdV6xWRaGlb7DhvjHeCRjmEbSA+e3H/KgOsVKWM0H8GhuWzhn4p2r3hb/6I7eeIwVJ7JPRlEdcVtJvXSR8 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 Fri, Jun 21, 2024 at 12:47=E2=80=AFAM Barry Song <21cnbao@gmail.com> wro= te: > > On Fri, Jun 21, 2024 at 7:25=E2=80=AFPM Ryan Roberts wrote: > > > > On 20/06/2024 12:34, David Hildenbrand wrote: > > > On 20.06.24 11:04, Ryan Roberts wrote: > > >> On 20/06/2024 01:26, Barry Song wrote: > > >>> From: Barry Song > > >>> > > >>> Both Ryan and Chris have been utilizing the small test program to a= id > > >>> in debugging and identifying issues with swap entry allocation. Whi= le > > >>> a real or intricate workload might be more suitable for assessing t= he > > >>> correctness and effectiveness of the swap allocation policy, a smal= l > > >>> test program presents a simpler means of understanding the problem = and > > >>> initially verifying the improvements being made. > > >>> > > >>> Let's endeavor to integrate it into the self-test suite. Although i= t > > >>> presently only accommodates 64KB and 4KB, I'm optimistic that we ca= n > > >>> expand its capabilities to support multiple sizes and simulate more > > >>> complex systems in the future as required. > > >> > > >> I'll try to summarize the thread with Huang Ying by suggesting this = test program > > >> is "neccessary but not sufficient" to exhaustively test the mTHP swa= p-out path. > > >> I've certainly found it useful and think it would be a valuable addi= tion to the > > >> tree. > > >> > > >> That said, I'm not convinced it is a selftest; IMO a selftest should= provide a > > >> clear pass/fail result against some criteria and must be able to be = run > > >> automatically by (e.g.) a CI system. > > > > > > Likely we should then consider moving other such performance-related = thingies > > > out of the selftests? > > > > Yes, that would get my vote. But of the 4 tests you mentioned that use > > clock_gettime(), it looks like transhuge-stress is the only one that do= esn't > > have a pass/fail result, so is probably the only candidate for moving. > > > > The others either use the times as a timeout and determines failure if = the > > action didn't occur within the timeout (e.g. ksm_tests.c) or use it to = add some > > supplemental performance information to an otherwise functionality-orie= nted test. > > Thank you very much, Ryan. I think you've found a better home for this > tool . I will > send v2, relocating it to tools/mm and adding a function to swap in > either the whole > mTHPs or a portion of mTHPs by "-a"(aligned swapin). > > So basically, we will have > > 1. Use MADV_PAGEPUT for rapid swap-out, putting the swap allocation code = under > high exercise in a short time. > > 2. Use MADV_DONTNEED to simulate the behavior of libc and Java heap in fr= eeing > memory, as well as for munmap, app exits, or OOM killer scenarios. This e= nsures > new mTHP is always generated, released or swapped out, similar to the beh= avior > on a PC or Android phone where many applications are frequently started a= nd > terminated. Will this cover the case that the ratio of order 0 and order 4 swap requests change during LMK, and swapfile is almost full? If not, please add that :-) > 3. Swap in with or without the "-a" option to observe how fragments > due to swap-in > and the incoming swap-in of large folios will impact swap-out fallback. > > And many thanks to Chris for the suggestion on improving it within > selftest, though I > prefer to place it in tools/mm. I am perfectly fine with that. Looking forward to your V2. Chris