From patchwork Fri Apr 12 11:48:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barry Song <21cnbao@gmail.com> X-Patchwork-Id: 13627658 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 67926C4345F for ; Fri, 12 Apr 2024 11:49:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F05526B008C; Fri, 12 Apr 2024 07:49:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E8D4E6B0093; Fri, 12 Apr 2024 07:49:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D2E7B6B0095; Fri, 12 Apr 2024 07:49:26 -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 B05D16B008C for ; Fri, 12 Apr 2024 07:49:26 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 81511A0E61 for ; Fri, 12 Apr 2024 11:49:26 +0000 (UTC) X-FDA: 82000709532.12.E34D3E9 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by imf11.hostedemail.com (Postfix) with ESMTP id AFA1840007 for ; Fri, 12 Apr 2024 11:49:24 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=fn1dpIG+; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712922564; a=rsa-sha256; cv=none; b=71erSTAZqX846uo6zkYgM/CL8OsOHmnuO0ly90mBFTs2MKsb6hb6cVEXb+MMaduuLSI75d Ef5lzqmaCbpAqAKejvG5Kb/yjXHh/nDDUcQK7F2fQ8/5gMcwYmlWcLMcCkPd3Qtja+qb1B J/HP/EhzFoeDID3tLvxbBOGv1Wv+EmE= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=fn1dpIG+; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712922564; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=rsGNE4XVP3pLkOAKr41E6LqkIK87UvM+YC6wxpcMFv8=; b=7Y+j8Iokcoku5OQhxoUKMh4ndKlGg0s891L2dXwc6uZ7LelpfazEN8Mo0BlYLyeWOvly2Y Z+lvzp2ED9jqykUbBTgVSwktGc4Zx/yUETYs7z+0mWgeoBTaS3zlDRa9sYZqy+4OCRKCLI go8rsYQsoUnZSf1gJKOmQ65WF+0YqPU= Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6ecf8ebff50so567750b3a.1 for ; Fri, 12 Apr 2024 04:49:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712922563; x=1713527363; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rsGNE4XVP3pLkOAKr41E6LqkIK87UvM+YC6wxpcMFv8=; b=fn1dpIG+P/GTzZVvVEv++4xFq4GJzIDza8JAHMrva86D2XCHEGvJHOQpJQOQFzy/AU Fg3gBLhMo5BwWTP+xOcQ5p2vFehElDECLQfkcqcwXUFdArzzkfE2HK0EdzMFzAdlP69p UzO1Wbh7vz0kzwgSswV4B9rHHbiAI2FQulFRZf7gMXHSURiA/y6YUkGL86fjsZ/8ySHE 9ZkzJoX4bmNyFdBeSHsS8WBoipc+KK2qBf1KogjqWKITwMGtY+6GETWbm7tktArvfPI8 aZPyz3EVBFJNVoKA/5lHBcdlYN0Z7YYbYJZBvRPamqnm5iKyuMJGJ+Varygz0Grbw5SN D8+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712922563; x=1713527363; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rsGNE4XVP3pLkOAKr41E6LqkIK87UvM+YC6wxpcMFv8=; b=AkmG/c4yaQ+h8K/9Rr1dr53aQQwr3qE54ulazWMFel7putw+rZesMweyVCRA3exlOe Wr9l/rv0adYEx9/qi+BgBiCiJDhXBtCaJVFsn9pJ6gZ8MDVeAVBO2aWrMhJIL4e/Xu5p nJkZButv40vPPZKc3SFmmTVd6XfWKgKs4+9+Wb9Ccz6OANYuX+Fs6XdrnlPitXLRUqtZ a9APSABXpgydDBQnCA2+cfGnKF9424uTq0krSx2u8D4bEqtVbVj7X2ML7bJgQQ58+B2B NWGHu+n7vUlGG6FRW63Cl2vBymBVSCOsLiUQgoyG8QU4uucSzLsQ6cdUe0S1JqnMLWVr SjRw== X-Forwarded-Encrypted: i=1; AJvYcCXvAbrRQDR3QyOJslny8w06YxAclvfHzwRKUQU+7NvJN7janHMIOIAnKDPSS/ymy7ZkRYThjoBKCv6GQk7kJn7c91s= X-Gm-Message-State: AOJu0YwFsLQZV+Gcv/nA9GhrExqFBcFKH76alhsPq7dIrf1spkMwdTUc hD31S8nTc0yTqfRFxy/WqXNLJ1Dbww+GSjHylGHtraxoMxwXZwNj X-Google-Smtp-Source: AGHT+IGT5HsRUdIKeuS97P1LcQaXZ4m6uHGIP6/+AXNUFnrOjD3L9oLUEEO5s/R9jaTkOrY3eJcOCw== X-Received: by 2002:a05:6a00:10c7:b0:6ed:825b:30c0 with SMTP id d7-20020a056a0010c700b006ed825b30c0mr7228196pfu.15.1712922563594; Fri, 12 Apr 2024 04:49:23 -0700 (PDT) Received: from localhost.localdomain ([2407:7000:8942:5500:aaa1:59ff:fe57:eb97]) by smtp.gmail.com with ESMTPSA id q1-20020a634301000000b005e43cce33f8sm2541048pga.88.2024.04.12.04.49.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 04:49:23 -0700 (PDT) From: Barry Song <21cnbao@gmail.com> To: akpm@linux-foundation.org, linux-mm@kvack.org Cc: cerasuolodomenico@gmail.com, chrisl@kernel.org, david@redhat.com, kasong@tencent.com, linux-kernel@vger.kernel.org, peterx@redhat.com, ryan.roberts@arm.com, surenb@google.com, v-songbaohua@oppo.com, willy@infradead.org, yosryahmed@google.com, yuzhao@google.com, corbet@lwn.net Subject: [PATCH v6 2/4] mm: add per-order mTHP anon_swpout and anon_swpout_fallback counters Date: Fri, 12 Apr 2024 23:48:56 +1200 Message-Id: <20240412114858.407208-3-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412114858.407208-1-21cnbao@gmail.com> References: <20240412114858.407208-1-21cnbao@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: AFA1840007 X-Stat-Signature: 5tohhzxboziwbuuf5tr191q9szk9c3x9 X-HE-Tag: 1712922564-800296 X-HE-Meta: U2FsdGVkX18ozebbXdLdCtT1PeAYFDPzIEwXuL4MIQLJwR6XSkWJl+XZQaKP/fu5RJEHoFqH6g17CFszNvy2E3fYMPwS962AUHhLH2waSkWq+zAHVJ8RL9tVrRGPw2d39ZdQ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ZUUaOdJXNSlgvVAzdQJ3Bl6NFA0pOEnJHwCz4bpGztBs4gSVFbtKC3K8jvJdMSvEdNQsTaFGa5PssDcZ+julLj8Lp6xyBDSJyGxtsyZUCJw4k6xhSxv0zTWEFYL/B68LvUsIkLZyGmsOwHYHxZMWD3Ax7WnMt7XUY+3EEVIiljiJKyTkLxutP3jJqVgXfGODjzyzw6WI5oGI77f/RbvsbsQuAzQAwe7oyC0YOI28bEnWeszPIxT7xY0n56gAULe+3bcvBAnEmyvIX6pBuhiE9NNDkCKZnFOXSqVu1l4fBpE91MIz8zODNSt2Rj7autku8W6xfpWeJdQ7K0Z43Y3WkzJhCO4VP5Lt1fkV1VlViNCj0Hrk/Seny7SfCtYdzAFCulm/zoDObNBBFOnEPeNtOTCw/MJnUeYpKb2kELNh7Ny0q+58UD2BQt8BT4zFVtEI2eO43nmt8cYqQ04ufRtMfZjPRuIsvUrmls2Lz9xnVv8Aq/ErOfwbH7uVvH9B4TQJhjHL4cIkOOM81qwq/mvCcYs12UZlAqgaQtXZMLnIhmoW2A6DjcKcv4ehRCRsmRraWSJSyj3Wi90FET/RbhF8UvfmZ2dIC+ApS8vmksY54ttWv304VkiA== 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: From: Barry Song This helps to display the fragmentation situation of the swapfile, knowing the proportion of how much we haven't split large folios. So far, we only support non-split swapout for anon memory, with the possibility of expanding to shmem in the future. So, we add the "anon" prefix to the counter names. Signed-off-by: Barry Song Reviewed-by: Ryan Roberts Cc: Chris Li Cc: David Hildenbrand Cc: Domenico Cerasuolo Cc: Kairui Song Cc: Matthew Wilcox (Oracle) Cc: Peter Xu Cc: Ryan Roberts Cc: Suren Baghdasaryan Cc: Yosry Ahmed Cc: Yu Zhao Acked-by: David Hildenbrand --- include/linux/huge_mm.h | 2 ++ mm/huge_memory.c | 4 ++++ mm/page_io.c | 1 + mm/vmscan.c | 3 +++ 4 files changed, 10 insertions(+) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index d4fdb2641070..7cd07b83a3d0 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -268,6 +268,8 @@ enum mthp_stat_item { MTHP_STAT_ANON_FAULT_ALLOC, MTHP_STAT_ANON_FAULT_FALLBACK, MTHP_STAT_ANON_FAULT_FALLBACK_CHARGE, + MTHP_STAT_ANON_SWPOUT, + MTHP_STAT_ANON_SWPOUT_FALLBACK, __MTHP_STAT_COUNT }; diff --git a/mm/huge_memory.c b/mm/huge_memory.c index dfc38cc83a04..58f2c4745d80 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -555,11 +555,15 @@ static struct kobj_attribute _name##_attr = __ATTR_RO(_name) DEFINE_MTHP_STAT_ATTR(anon_fault_alloc, MTHP_STAT_ANON_FAULT_ALLOC); DEFINE_MTHP_STAT_ATTR(anon_fault_fallback, MTHP_STAT_ANON_FAULT_FALLBACK); DEFINE_MTHP_STAT_ATTR(anon_fault_fallback_charge, MTHP_STAT_ANON_FAULT_FALLBACK_CHARGE); +DEFINE_MTHP_STAT_ATTR(anon_swpout, MTHP_STAT_ANON_SWPOUT); +DEFINE_MTHP_STAT_ATTR(anon_swpout_fallback, MTHP_STAT_ANON_SWPOUT_FALLBACK); static struct attribute *stats_attrs[] = { &anon_fault_alloc_attr.attr, &anon_fault_fallback_attr.attr, &anon_fault_fallback_charge_attr.attr, + &anon_swpout_attr.attr, + &anon_swpout_fallback_attr.attr, NULL, }; diff --git a/mm/page_io.c b/mm/page_io.c index a9a7c236aecc..46c603dddf04 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -217,6 +217,7 @@ static inline void count_swpout_vm_event(struct folio *folio) count_memcg_folio_events(folio, THP_SWPOUT, 1); count_vm_event(THP_SWPOUT); } + count_mthp_stat(folio_order(folio), MTHP_STAT_ANON_SWPOUT); #endif count_vm_events(PSWPOUT, folio_nr_pages(folio)); } diff --git a/mm/vmscan.c b/mm/vmscan.c index bca2d9981c95..49bd94423961 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1231,6 +1231,8 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, goto activate_locked; } if (!add_to_swap(folio)) { + int __maybe_unused order = folio_order(folio); + if (!folio_test_large(folio)) goto activate_locked_split; /* Fallback to swap normal pages */ @@ -1242,6 +1244,7 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, THP_SWPOUT_FALLBACK, 1); count_vm_event(THP_SWPOUT_FALLBACK); } + count_mthp_stat(order, MTHP_STAT_ANON_SWPOUT_FALLBACK); #endif if (!add_to_swap(folio)) goto activate_locked_split;