From patchwork Thu Dec 7 03:09:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yu X-Patchwork-Id: 13482642 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 31934C4167B for ; Thu, 7 Dec 2023 03:10:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BA1EE6B0087; Wed, 6 Dec 2023 22:09:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B51C36B0088; Wed, 6 Dec 2023 22:09:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A40B86B0089; Wed, 6 Dec 2023 22:09:59 -0500 (EST) 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 92A406B0087 for ; Wed, 6 Dec 2023 22:09:59 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 69822401CB for ; Thu, 7 Dec 2023 03:09:59 +0000 (UTC) X-FDA: 81538542918.11.7565451 Received: from out30-118.freemail.mail.aliyun.com (out30-118.freemail.mail.aliyun.com [115.124.30.118]) by imf25.hostedemail.com (Postfix) with ESMTP id EC174A0017 for ; Thu, 7 Dec 2023 03:09:55 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf25.hostedemail.com: domain of xuyu@linux.alibaba.com designates 115.124.30.118 as permitted sender) smtp.mailfrom=xuyu@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701918597; 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; bh=q14Cm+aRClhek9NyJWf0suZBIurTLzWU4itQeAmkk3s=; b=ACmkZlAzEgL8Ok4ARNgBdl67JjJ6vJM9WSEMF4pjVhPkyZGTWgn7A7q2YEtQ4c5teYYk9Z xL3vhefOr4uZOmXzt+5bIWdJL7lc34aitnMN48vus5Y90jXGaYvc0QgTshxpbKT2HRktdP im+QR4tppNbkEtoiUNHmytJhg2NHVgs= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf25.hostedemail.com: domain of xuyu@linux.alibaba.com designates 115.124.30.118 as permitted sender) smtp.mailfrom=xuyu@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701918597; a=rsa-sha256; cv=none; b=3BohY1WCEwOkUt5paqQ8y3d0DAYyGTzyt2/L3O2txnxgNPj6wm0fsgEUo9D6uO4MkH1fXX WT/gKKU9/FcLPQnGltEsO3wKj+7AIPMSnbUu6wurKm+aTnRhUrgVKEkFjLqSXTfPI5COAL kDy2BH5hMIyDgZIvvzwJ9C/M+GdFSGw= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R151e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=xuyu@linux.alibaba.com;NM=1;PH=DS;RN=2;SR=0;TI=SMTPD_---0Vy-ETCI_1701918591; Received: from localhost(mailfrom:xuyu@linux.alibaba.com fp:SMTPD_---0Vy-ETCI_1701918591) by smtp.aliyun-inc.com; Thu, 07 Dec 2023 11:09:51 +0800 From: Xu Yu To: linux-mm@kvack.org Cc: david@redhat.com Subject: [PATCH v2 0/2] attempt to map anonymous pte-mapped THPs by pmds Date: Thu, 7 Dec 2023 11:09:44 +0800 Message-Id: X-Mailer: git-send-email 2.37.1 In-Reply-To: References: MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: wrugidhdq3km9gmehjqfk5iaxb6u53rs X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: EC174A0017 X-HE-Tag: 1701918595-619554 X-HE-Meta: U2FsdGVkX1+bsP4+2/o7OBohh4jdFoiKP4vwCKXF5Tz+ii3ye+w4GNBMS3yMZ0qz7WK3HmJIaTc73krrs8ZqGdhlmHtLolFLpipQigoFR9moQKDXBXMjypcJwS3PLGI80Oj5nGmscxwfAnD9hRmVKAI//oypYLa21i6X4Ihf0Ml9QOI5PefxoZvw75gy3xwh93LLLpRyc/6HFIZqbUwsavVl59vhs87r82S+exI0VBORG4RG+t8ZDlzISFXNA0wH68KOYmbIZC+OQ++PkoeeVj4RxN9fcLOIOzALOsOXy0XfEnbqWYgrIcymF83iN+xV9xzFS8gccbPGqeoJkqfYMqbQB3dFdlimQGrr5kMr6enTBQrKqGq8imRfBlqkn/XcoEnVx+kTk9FWRfKGD7jJ0WeQ25utyLJsr+Bco822Mp4xgL9PC97wHepBdD2ogrqmcr9Fnzj1QqAxYKO/S6ifcx16Sf0eVzGlsYLAxyUDt8Wul2UZcoC8VuwBwbAFs7cZmsCFQ+WlQiMGUotnxTMUSvD/BjPO/awMzMPEwR4xq0ZGA0nfEXjimKYXkL/DkqMtz/aoP6bxXQW94uwQ2lz56R/4DZkNCAZokd9ujE02N7bSURXbhgw/IePsjfWQ5Gm/xx4FPPLpys0mIrj2kIg6q2ChmQ5VYqb1k9RGe0RT7oJ39oO6qpvW1PSzxXjKxUaMvoJzGBV8agY7wKQDYXS1ETa14jnlusNX605+0u256wtG+1VlDGAtC3jKe0hZxDYXzmaLCqPvR8jiwCeUwKlTb1nylT5h8gCYLK8pt+tsnow6cfpb+2k2AtkC35JheIb5OLJ4b0IBmpRVJtzwL6wPyde1Q7NDhEoBB7fGbFh8prrsnqlADCMQkgLSYHgk8xseSviwUNZbFQaaoPGo5ER49znaDNl0JqBSu8oVgo/tVpX2W41Z24tPm7kdk5A7NEInedZZeenN5/cLGb9FQfs M0qYjO8z dU+k/oOU/8YXyzc/V+0ZAaktXTaqy1JYNi4wRS046oMtEWhNHJLg5QXNOww== 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: Result of tools/testing/selftests/mm/cow.c tests: # [RUN] Basic COW after fork() when collapsing before fork() ok 145 No leak from parent into child # [RUN] Basic COW after fork() when collapsing after fork() (fully shared) ok 146 No leak from parent into child # [RUN] Basic COW after fork() when collapsing after fork() (lower shared) ok 147 No leak from parent into child # [RUN] Basic COW after fork() when collapsing after fork() (upper shared) ok 148 No leak from parent into child Debug messages (simply with printk, will add tracepoints later) show that THP in case 145 and 146 is remapped with pmd in place. To be honest, I'm not sure some of the conditions are handled properly, such as pin and uffd. And I send out this workable patchset to get more comments. Many thanks! Changes since v1: - Deal with PageAnonExclusive properly, as suggested by David. Xu Yu (2): mm/khugepaged: attempt to map anonymous pte-mapped THPs by pmds mm/khugepaged: add case for mapping anonymous pte-mapped THPs by pmds mm/khugepaged.c | 231 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 231 insertions(+)