From patchwork Tue Aug 20 09:49:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13769791 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 CC8CDC5320E for ; Tue, 20 Aug 2024 09:49:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 61C246B008A; Tue, 20 Aug 2024 05:49:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5CC8D6B008C; Tue, 20 Aug 2024 05:49:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4BAA16B0092; Tue, 20 Aug 2024 05:49:47 -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 2E9B66B008A for ; Tue, 20 Aug 2024 05:49:47 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 967521619BC for ; Tue, 20 Aug 2024 09:49:46 +0000 (UTC) X-FDA: 82472151972.29.6C2A931 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by imf13.hostedemail.com (Postfix) with ESMTP id B63402000F for ; Tue, 20 Aug 2024 09:49:43 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=E04d0UFW; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf13.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724147369; a=rsa-sha256; cv=none; b=I+5DSb5o+eQ2QxY8Cd6wx995YzCXMBeNIPyTXuYO+DW6rpHbfUZPyeCb1XW+QQyNtW7d/K 5lLk9tquDKTpgF7Gj8/KkZE7x01Fgf907wyVflF3vfbULVbXPbDK9y+A0ckXBD70bW/Gqn DUWMJAIIMfM07h+iI6yhzypOsJiEXO0= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=E04d0UFW; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf13.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724147369; 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:references:dkim-signature; bh=3wTFA0rLCCOfQFYiLlDDLZ/CL/lY+xV11hE2CPpQNZs=; b=OWc80rq7dqZSU76T4dHPI9wX6/nokidqYVdz1oP5sGgvfTuiM6QzAi910SdywQLa5PIC4g RHoXtNshscqIe/gSPKliRyduJ+lGLtu072RV7FVbaf06DbJLVYi+qWAa68WADc/oUHi38s H2f9RTnmj4OsfpeTAyU3iDG04KzRPA0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1724147380; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=3wTFA0rLCCOfQFYiLlDDLZ/CL/lY+xV11hE2CPpQNZs=; b=E04d0UFWjdLWeS6aHoXbTQvlMbFLUdfPSUcbtRJtwFyj2UjiD5NT3dPurrUfGkBlEP375TlXfVrLuVZDwb0dl3HU2C0YN0fluHE3P6gR+luU6VFY1/Dc9tCY0mwzDjliq9DmMYWxvlabJECQjsMnBOIYzylga2D6HDc6FJhTo0w= Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WDIEwhX_1724147379) by smtp.aliyun-inc.com; Tue, 20 Aug 2024 17:49:40 +0800 From: Baolin Wang To: akpm@linux-foundation.org Cc: hughd@google.com, willy@infradead.org, david@redhat.com, 21cnbao@gmail.com, ryan.roberts@arm.com, shy828301@gmail.com, ziy@nvidia.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 0/5] support shmem mTHP collapse Date: Tue, 20 Aug 2024 17:49:12 +0800 Message-Id: X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: B63402000F X-Rspamd-Server: rspam01 X-Stat-Signature: nn3hwer8nr45o31u6h9e4i4x6xm8fgpk X-HE-Tag: 1724147383-470111 X-HE-Meta: U2FsdGVkX1+8X9wGtxd44dUrkm31BreON/NlO7SNypBlJiS+IyYd4ciSW+/3g8Z8QNu+gHDsD6srQiaJBU+pFX48eYUDu8VQnOvboK0Jku0jnyOJqw5LrC9ioD/2qGD5NwFN1XZIJfS58raa2pmNGTpr2Zz1LJ6iHfTkMLh0oxWoijFehuH6bYiQNpFg1XEyCyrrnOXWKuYCo0PP8a1Dg2fZJszfRfFLnjaJLJTvqGDKJxWqvdCfHOXeJuPujvy0087CsFFH4AmXguA8Hqt/GCUdCJgY8xbIl3gk9sddg+vKywLAbVkwnitNxy/FNOPXgZxCxB/WM7ThlQlo1H5hANdnshdHLWTGiwR2JkebNPHlpi8jezuyikdiKMQkdpeeOvcJZZ0SJBnlELNDVs9xk8RLWqhu/Hca3ci8OUXdhNOqpt1CGiiBdhWwQc/6YGgOlrjBtGyhsWyi7F9GUvkViukwRIQNoOZFImLHxN+h4QFbT0D1K9ERDXJTR3Qh3oyPAnBS2kb1HyRfIgAXzUeMTemXV2KwRBEwu2eUpRrmhIK+wKxFKQH/tWpoZbckyGAvDFPdSr8GoBPvtLiVm67iyvmaNaS5qEpfMESDa7h7tQH7eshXIdgCF8TdHKtLCSDXFfiDXEIEKClXRVywqTtpi3L1YfGsb343ERAxgfR4WprgiW2RGlwoGFkCGyU2VEpUG2M+CNOLLI9psJbN8x/JTXBZFaLmYWdehJIgH08oSs2oc8gTXIIhqxt7Oxu2MTx6Cbz5aFS7LWU9FWPFHA80cCo2FeG9gAE/9R+kztxApPreFm3zMUd34tgG4kbAlhi209GiUJsK9NgSB7UVAShphaZYkoqab1EZltrkXaxxV/V4t847XY1cxzDngKrT3HQGlTQgOoQUuEYJ53jkZt7TXjATj/4qUUM+1HIq8Z/IalT5msHACm4Y+h0kv0lZ4VSZr/6PQwnl6hpI+9iQpXV Leh8FVDj JDRuiloRj1e4Jpd6hyf5AN52/aSz/VUoxvYt3sV2uWdGXOwobzcmYikSyH5gXowYNeO8avGO0dkXbx2b3mEAhTBYIMsMadDn9HJ16/TNGLVkaaOp8avuhWHT+c5EiaJ29mumGOIkh08ws6U3QTXfH6yuW2j9X/uEZQ4nPUlnZQqUpPtLOW1PIOY38Q3eBqRAc5qmNoru0dzn3ASAE6IDm8e+R7uch3IsphZVAvIYoJ1eHptgyOfy762GABkCv72xtJ+OmJ3Z2PmPKEc0eqZsLqEOWHf+7BSqs8ofh 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: Hi, Shmem already supports mTHP allocation[1], and this patch set adds support for shmem mTHP collapse, as well as adding relevant test cases. Please help to review. Thanks. Note: all khugepaged selftests have passed. [1] https://lore.kernel.org/all/cover.1718090413.git.baolin.wang@linux.alibaba.com/T/#m4bd7e701c7b5f36f712055e4360cad593a22b3bf Changes from v1: - Simplify is_refcount_suitable(), per David. - Add reviewed tag from David. Thanks. - Update some comments. Baolin Wang (5): mm: khugepaged: expand the is_refcount_suitable() to support file folios mm: khugepaged: use the number of pages in the folio to check the reference count mm: khugepaged: support shmem mTHP copy mm: khugepaged: support shmem mTHP collapse selftests: mm: support shmem mTHP collapse testing mm/khugepaged.c | 62 +++++++++++------------ tools/testing/selftests/mm/khugepaged.c | 4 +- tools/testing/selftests/mm/thp_settings.c | 46 ++++++++++++++--- tools/testing/selftests/mm/thp_settings.h | 9 +++- 4 files changed, 82 insertions(+), 39 deletions(-)