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 DC108C2BB85 for ; Fri, 21 Jun 2024 07:47:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 508978D0142; Fri, 21 Jun 2024 03:47:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4B8DB8D0138; Fri, 21 Jun 2024 03:47:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 35A648D0142; Fri, 21 Jun 2024 03:47:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 178EE8D0138 for ; Fri, 21 Jun 2024 03:47:18 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A93A9140A17 for ; Fri, 21 Jun 2024 07:47:17 +0000 (UTC) X-FDA: 82254115314.10.0197910 Received: from mail-vs1-f51.google.com (mail-vs1-f51.google.com [209.85.217.51]) by imf29.hostedemail.com (Postfix) with ESMTP id E7600120014 for ; Fri, 21 Jun 2024 07:47:15 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Phl9wYy8; spf=pass (imf29.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.217.51 as permitted sender) smtp.mailfrom=21cnbao@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=1718956026; 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=hb2Fy9ZwHI1dYIHOgnUy42pdbjf6n2Bld7IZk3B0d8I=; b=JypDLREmPN7EO7Q8sMqpi54KGDCVtuuS50SRwR2NwzWuxvWvZ3gvvzc1Jp51onJaTi8MCw K8+Oy1eBEjs8/QYFWCO7Q7HdU8nvykG+y5ndS+PlK1dVpXm6S0ft0Awsjgkvy4xKwUYDtF fkiMQYxCFGKwzMXlBX1/WOOl1nMIIHs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718956026; a=rsa-sha256; cv=none; b=xNoeigtnnF53wtdj3ORkzZMGz0hRkqembhVxiVe/5+WiGVnLnuJbUU/up2N9notAXFQFmT pGrrsTT4HJIftKn2UvS0ilYeOtDtlE7BHqRh71j3EiTC9ssIUOb1aprMXz+W14s4ukCL03 f+AQ6aFwTGL1NDpbvRPcwPj50qTr8g8= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Phl9wYy8; spf=pass (imf29.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.217.51 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-vs1-f51.google.com with SMTP id ada2fe7eead31-48ee7668cc6so563288137.1 for ; Fri, 21 Jun 2024 00:47:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718956035; x=1719560835; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=hb2Fy9ZwHI1dYIHOgnUy42pdbjf6n2Bld7IZk3B0d8I=; b=Phl9wYy88cpTq0qjx0pmugafQACuPYFvczrGI7rgY42lMoPgNeCVImIMVXr3O1m+BT gPSfjHrL5tfPBe6Y6hSp4uGk+sKP9cgdaTNyQD1ChphDakNMMVxMA1QILBrPCs0RevK/ 8pKELlTMfjRnct+KiaaeiyTakYTeKaneLm8vI3t3AOA2429r1Q4/BEUZRLxCiRvampdG uGYsF6DTTjiDXXR9TZ5IUsakECEvNF+GcgVlU9SI3g3wZoyDbqNS/fqijron1JLkujAL ojpjB4OCUh7qWHaEu2s6oniI4Ekx1zD7gXLtFj6++hjTiMwyUeT1hWZtdFEqXNvIcj1h BnDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718956035; x=1719560835; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hb2Fy9ZwHI1dYIHOgnUy42pdbjf6n2Bld7IZk3B0d8I=; b=lv2kGtX2vbJSNuAq0lpJd38HWngR1h/F0TvZpBF8OrN/YiKfP9QxKe6xsXpeMRHekw qBvIDyaX/cCRXOteCBj6cWXknxhHXaz9b+thtW5hqmhQUcqXrxcOvGDMge2EDfeSdDEt vRwuvmOqjOta4Hg2AG4+XCoKi0l6uM3pRBfXKx1zU89Epf+kBNDeBvnUHc2gvVkTA7zN cRt1qdzUS4AqSdHhDJ5LqgcLkbLriyHgOO6MWgLPa5kTqoK4oDkvQD/sw0W+XMUPCt8n tSkGkkWjJ+drppwMXhFVNQxhf2/YozkPzJ5nSy8ZpbeHnxWUzPxwLiT5raVQ+pjeDSnn ShVw== X-Forwarded-Encrypted: i=1; AJvYcCX2i9KeG+TenIMJCHIiLn6GDAwC+cmNEatb3v2GE4mKW6QySBHo70hFI0D1g0znv4p4L42Q1fvWln40dlNeTugszhw= X-Gm-Message-State: AOJu0YxMDf/Pn2J91jdpHFz+NK20DhRI1XN+uTv9oryI36i3SiReL6Z7 2LdlA45I5UlsCwTXdpRLvfUewtPOBDKzp0mzDSzqFbOPcYTF+vMFwLXL9nKzJaXF41ViXXRurke 2NhshSvwiJOidyTzSv8Yjhd8iypg= X-Google-Smtp-Source: AGHT+IENxJpB3fR9O1qG5MmYWU2eUwfRE0yy8BBUjnzGd+z9Xs2T3ZKskBIctY2so5qNjGrbh91CJEO2hUli5f90diw= X-Received: by 2002:a67:f505:0:b0:48f:30cd:d94c with SMTP id ada2fe7eead31-48f30cde5f3mr2014409137.6.1718956034943; Fri, 21 Jun 2024 00:47:14 -0700 (PDT) MIME-Version: 1.0 References: <20240620002648.75204-1-21cnbao@gmail.com> In-Reply-To: From: Barry Song <21cnbao@gmail.com> Date: Fri, 21 Jun 2024 19:47:02 +1200 Message-ID: Subject: Re: [PATCH] selftests/mm: Introduce a test program to assess swap entry allocation for thp_swapout To: Ryan Roberts Cc: David Hildenbrand , akpm@linux-foundation.org, shuah@kernel.org, linux-mm@kvack.org, chrisl@kernel.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: E7600120014 X-Stat-Signature: o9kh8hk4jhh4zqjha5c6mcwcfhunjbd9 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1718956035-505263 X-HE-Meta: U2FsdGVkX1+/QHgYN16aNjvjAAJz4Vn3xMIC2UAeJKIzZ2khqN/VpirYHkeW+reU8RoXHW515YpQwLv6Tftkpo7l76yjz6I/HircauROI+vrJca5LT42HXDuTgbkOcjxn8SJv5afjqEV6KbLZLD4FsBmd7oZwGfXveXSggYsayp7j582Kyu7Jce76pUj4P+qXVJ5cYcHaU6A2sh96v4nmmpFkwBGJyOcHyTvLDaN6OZe6A16X3TOlr6EtF7LCk6iwIuk9vJVdRCiHXKUaBY9mkZUJrUiYp02RoT9TvgwqLsmN3fXT9a445CBjjgCryBAdnaUIa+YamUnDjFePRu6yCz+iT8e6rht1TWt2Xlx/L3AwJu68QK5RflLJ8zYtJPd6qOrTH8ES4o46BgP7WD1mukSICoGgvqS9Sps7jTnQlOSkuKgfBijG9jnrEpAN2GNuVl861gau9gnwePUdq6t1+SyEneTERosMHDC7sAxlcgjlGsasUPV7NzUm/elsSAmxUIHs93g9ksv6gv6/rmu83zmuXKwpxToChHyEBp/6EN3tM4jmROUW+1eagWQCT65PVjSJdTD1fZ5XZLPfvbLD94uPFhKTkG7GfFaNhoUl38vkD2/kRbzJ2EAF0O1ivfOhLIGqZuBKdsF2g2ydm/w2WyYRlDMZX56tBQ5TIG7AreZmu82NcH93UPq848HSpn7LCfe8ewDiG/SPRWlTDk7mRnCpMonppyHfmMHNDZshjnCtUWQI0cZN2zqmQ/tm6lTFiDo1OFgNJhdnen7tqKRr/q/0rRFBcfOSnq0mYIELodBywy6CQJpS435DgL4SLFF3P77xd4ZbypoZYRe8BZVajRj+QkzyZAzh1o+5WFNNeZX1OlT8L7kNh3eFu7zlgJIbBG+oUchQjDlcimV7wv4HqLd41sWuJEOBc99sMrewW5XGZAWAqP/sEMWv/he3NTLYvoOCb1CG1gVk+uEju7 OAQUVcVM ObilX0VnOrFyuNJcQkUkhsTQmeJ6C+a8ZqYDCefzbeG6Z/DMC6T30XEWtBsGCqtAEZmkAxBI5E1A48GZjGQARFOvcER3FqOeHnb8JJ7OVmT25UAfsqVS0lCVUUu+I9BIKstZvPRn1NWOgJglKnDxxTbeAAdoOcMmBpeXCvwDx7DZr/pHmDRjws0DoJFgip6igpd3RG5iBND6rIwvYMrfOgCcfjXLrcOjnJfUKmL/8r97544Mmp/6LiKY+5+CeKU+fRH/fcqfRYNHHjC15daKcNP+v4F5bPgG/zj47bQITTSDf2OF80eLGyDLMwre+P0H+BTqaipjVnWlfT/pW4Qo9LqeQk/CVKPGbjNgmNwaGaZZm6f99vlPwsQPpBKPOKdCzk2SkiCORbo8wjbssCeGmWImSNxyCZMspbmtnxUSTeN6yzEqLl59LLm1OfqhZ9k+F8LltzBld/Jj6F2iTmge1G0iTaw== 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 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 aid > >>> in debugging and identifying issues with swap entry allocation. While > >>> a real or intricate workload might be more suitable for assessing the > >>> correctness and effectiveness of the swap allocation policy, a small > >>> test program presents a simpler means of understanding the problem an= d > >>> initially verifying the improvements being made. > >>> > >>> Let's endeavor to integrate it into the self-test suite. Although it > >>> presently only accommodates 64KB and 4KB, I'm optimistic that we can > >>> 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 te= st program > >> is "neccessary but not sufficient" to exhaustively test the mTHP swap-= out path. > >> I've certainly found it useful and think it would be a valuable additi= on to the > >> tree. > >> > >> That said, I'm not convinced it is a selftest; IMO a selftest should p= rovide a > >> clear pass/fail result against some criteria and must be able to be ru= n > >> automatically by (e.g.) a CI system. > > > > Likely we should then consider moving other such performance-related th= ingies > > 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 does= n'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 th= e > action didn't occur within the timeout (e.g. ksm_tests.c) or use it to ad= d some > supplemental performance information to an otherwise functionality-orient= ed 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 un= der high exercise in a short time. 2. Use MADV_DONTNEED to simulate the behavior of libc and Java heap in free= ing memory, as well as for munmap, app exits, or OOM killer scenarios. This ens= ures new mTHP is always generated, released or swapped out, similar to the behav= ior on a PC or Android phone where many applications are frequently started and terminated. 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. Thanks Barry