From patchwork Mon Mar 18 20:03:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13595760 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 72957C54E5D for ; Mon, 18 Mar 2024 20:04:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B1B796B007B; Mon, 18 Mar 2024 16:04:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ACB596B0082; Mon, 18 Mar 2024 16:04:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 96D336B0083; Mon, 18 Mar 2024 16:04:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 874246B007B for ; Mon, 18 Mar 2024 16:04:13 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0FE551C0BD0 for ; Mon, 18 Mar 2024 20:04:13 +0000 (UTC) X-FDA: 81911236386.23.779B48E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf28.hostedemail.com (Postfix) with ESMTP id E931FC001F for ; Mon, 18 Mar 2024 20:04:09 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=InxVHWpS; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710792250; 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: references:dkim-signature; bh=j5cONy39WPTChmBWXZo5a/mjWSs5JnDb/U3l3IKfJB0=; b=VpBehsH1ez4+KpCUG249sv99Ro/XCGHYd/sz+qPb39i9+mOnmPA9VBf4tbJrNsF4fSTovo AVFQDhQN9rDUA69aWWHriMy4H2Fz5rE/mAhVvOEt2QS+F6kv8hg8HPEvazoskP9+Jn4/HZ 7y0zNW3703dcFEMcnD3U8dTKflMOQ70= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=InxVHWpS; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710792250; a=rsa-sha256; cv=none; b=3XJ/iyl8dokvvAahlOlK9Cp3kV7cFxgb24LdSpOi/X+TM1e9kPch5+G4VI7vBVYyIti2nW 2zUCwBq15K+ePNMIMAkbjQO1IpcH3wnfmoSIM+2sMm2GWYibtVv27uaAZHr43TbtVcg0ND pdiNVhcVTu7Y+QaN87MFSItM2Etm5zo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710792249; h=from:from: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; bh=j5cONy39WPTChmBWXZo5a/mjWSs5JnDb/U3l3IKfJB0=; b=InxVHWpSgzQYn8fmIygDW65nFhl7yfRlR6+iXjYiqPdZwLTAw5iJKlzHhkGOjIg4Y0Q0oJ 6EK+XpRRBMsJWfu+QeqIi5S6cBl4+p/vr7hi7FCOROAmBC1ytCQf9r+0Eu31sJcYrPQf3e EbcoFelezV5gzKFeOXvuEdT10b4QOjI= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-182-pPCp_VPHPqiD37b4Gzb0wg-1; Mon, 18 Mar 2024 16:04:07 -0400 X-MC-Unique: pPCp_VPHPqiD37b4Gzb0wg-1 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-430c9bbe925so2098031cf.0 for ; Mon, 18 Mar 2024 13:04:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710792247; x=1711397047; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=j5cONy39WPTChmBWXZo5a/mjWSs5JnDb/U3l3IKfJB0=; b=DzpKqgNv12fVEK27JzY5wiUxc7ReSXWn5XLQibZiD6Guh/v++VNDgkyfHKeuRfJKer ByDE+vVXpiTGnK2850uj68Uu/92orfXkwzVicCHHlc5pMW2haGEqvCxlzQhFQicM2Yie aSTMFSrTebEpwHtPyMzmxi5fFbxdFeBftJtp1UXB4318ETWEfsAGf5DD3YtZOarTGeC8 BWA532z1i3hBPt9n+wADw3Vbrrm/q5jMT/GudUzJYgQNkZ9C7zsB4kbNybIPgaX+mQBo rgtJBDT6dTq6CaRPddpMqpjN4GlBHBWylOM+NIw1Gbp0SRaV2fCoaVSSWM8MXC1iWrTk sQ0A== X-Forwarded-Encrypted: i=1; AJvYcCWG27g0WTBEf0yn8ux08B6nK+nHC8VCp9aLpUT08mv/z67J+5DGl2ZFAmD3F206PTIzFsOv/Qq2ReABLbqafujCgXg= X-Gm-Message-State: AOJu0YyNIjMJyEfwNS9mwgYNJdbz0IBH2lv8XV2MC/QaVp4TkmCzsoIe 8lGiE5ztIQdMLivs+LSraY49wN5VvhimMsgiiWdW61HZ2VJmnoGCZg87It9p7q75ArCWgtZgI56 XgG6aIXAPExdnfWaMWUdUcEJLVJaREec/QytGui7UO7pDr1xk X-Received: by 2002:ac8:7c98:0:b0:430:ace8:980c with SMTP id y24-20020ac87c98000000b00430ace8980cmr316482qtv.1.1710792246957; Mon, 18 Mar 2024 13:04:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGo9BloGRl/c/yuy7ygQZyZX9tfR07zN6D3r4pfcwUlCUAvWyqq6nKAa5eHOp/ysbaQ7B4Kng== X-Received: by 2002:ac8:7c98:0:b0:430:ace8:980c with SMTP id y24-20020ac87c98000000b00430ace8980cmr316449qtv.1.1710792246399; Mon, 18 Mar 2024 13:04:06 -0700 (PDT) Received: from x1n.. ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id hj10-20020a05622a620a00b0042ebbc1196fsm3484491qtb.87.2024.03.18.13.04.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 13:04:06 -0700 (PDT) From: peterx@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Andrew Morton , x86@kernel.org, Muchun Song , Mike Rapoport , Matthew Wilcox , sparclinux@vger.kernel.org, Jason Gunthorpe , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , linux-arm-kernel@lists.infradead.org, peterx@redhat.com Subject: [PATCH v2 00/14] mm/treewide: Remove pXd_huge() API Date: Mon, 18 Mar 2024 16:03:50 -0400 Message-ID: <20240318200404.448346-1-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Queue-Id: E931FC001F X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: a8cgestwqyhkou94413n74jt3e1mpngd X-HE-Tag: 1710792249-424230 X-HE-Meta: U2FsdGVkX1+E2xZGL8YgeEYXmbmK5IVbXRbtHlY8M2xvfk1IdQjzSF/vlMsTG2rGFtg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MFCeOhcINRBRVP/qkCL19Fw+wJnqINTJRkMugMjlBJ+jJv0+mqRA7SDExz4ZN9Vk1GPeOLwjaalty1Akfgs7/9VoVU7ueLQTehTEVGOMGHNXWwDHQ2JTJRG3Ek1f9MHHNbQfBN4Ka6KTM+TYIy8o3hRR6xBOslqVd4ujVd/SAXYhNVqjgVFb4V0QUPDpV0D3AhrXnoGu4J9QNNsyoaW2n7S3RafyUqBUzACNRGmJKL62Qkvl4hn7HKYk5ynz7HbpycZyEGrLeCM41OV+N9aJb/9uG441RoFBPx14gCUsN4tn2wyegJaSUnhBGakD4HZCe9CL+v7xa23Ar7dtGL9LdsvgA== 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: Peter Xu [based on akpm/mm-unstable commit b66d4391d8fe, March 18th] v2: - Add a patch to cleanup ARM's pmd_thp_or_huge [Christophe] - Enhance commit message for PowerPC patch on hugepd [Christophe] v1: https://lore.kernel.org/r/20240313214719.253873-1-peterx@redhat.com In previous work [1], we removed the pXd_large() API, which is arch specific. This patchset further removes the hugetlb pXd_huge() API. Hugetlb was never special on creating huge mappings when compared with other huge mappings. Having a standalone API just to detect such pgtable entries is more or less redundant, especially after the pXd_leaf() API set is introduced with/without CONFIG_HUGETLB_PAGE. When looking at this problem, a few issues are also exposed that we don't have a clear definition of the *_huge() variance API. This patchset started by cleaning these issues first, then replace all *_huge() users to use *_leaf(), then drop all *_huge() code. On x86/sparc, swap entries will be reported "true" in pXd_huge(), while for all the rest archs they're reported "false" instead. This part is done in patch 1-5, in which I suspect patch 1 can be seen as a bug fix, but I'll leave that to hmm experts to decide. Besides, there are three archs (arm, arm64, powerpc) that have slightly different definitions between the *_huge() v.s. *_leaf() variances. I tackled them separately so that it'll be easier for arch experts to chim in when necessary. This part is done in patch 6-9. The final patches 10-14 do the rest on the final removal, since *_leaf() will be the ultimate API in the future, and we seem to have quite some confusions on how *_huge() APIs can be defined, provide a rich comment for *_leaf() API set to define them properly to avoid future misuse, and hopefully that'll also help new archs to start support huge mappings and avoid traps (like either swap entries, or PROT_NONE entry checks). The whole series is lightly tested on x86 and arm64. [1] https://lore.kernel.org/r/20240305043750.93762-1-peterx@redhat.com Peter Xu (14): mm/hmm: Process pud swap entry without pud_huge() mm/gup: Cache p4d in follow_p4d_mask() mm/gup: Check p4d presence before going on mm/x86: Change pXd_huge() behavior to exclude swap entries mm/sparc: Change pXd_huge() behavior to exclude swap entries mm/arm: Use macros to define pmd/pud helpers mm/arm: Redefine pmd_huge() with pmd_leaf() mm/arm64: Merge pXd_huge() and pXd_leaf() definitions mm/powerpc: Redefine pXd_huge() with pXd_leaf() mm/gup: Merge pXd huge mapping checks mm/treewide: Replace pXd_huge() with pXd_leaf() mm/treewide: Remove pXd_huge() mm/arm: Remove pmd_thp_or_huge() mm: Document pXd_leaf() API arch/arm/include/asm/pgtable-2level.h | 5 ++- arch/arm/include/asm/pgtable-3level-hwdef.h | 1 + arch/arm/include/asm/pgtable-3level.h | 5 ++- arch/arm/lib/uaccess_with_memcpy.c | 4 +-- arch/arm/mm/Makefile | 1 - arch/arm/mm/hugetlbpage.c | 34 ------------------- arch/arm64/include/asm/pgtable.h | 6 ++-- arch/arm64/mm/hugetlbpage.c | 18 ++-------- arch/loongarch/mm/hugetlbpage.c | 12 +------ arch/mips/include/asm/pgtable-32.h | 2 +- arch/mips/include/asm/pgtable-64.h | 2 +- arch/mips/mm/hugetlbpage.c | 10 ------ arch/mips/mm/tlb-r4k.c | 2 +- arch/parisc/mm/hugetlbpage.c | 11 ------ .../include/asm/book3s/64/pgtable-4k.h | 20 ----------- .../include/asm/book3s/64/pgtable-64k.h | 25 -------------- arch/powerpc/include/asm/book3s/64/pgtable.h | 27 +++++++-------- arch/powerpc/include/asm/nohash/pgtable.h | 10 ------ arch/powerpc/mm/pgtable_64.c | 6 ++-- arch/riscv/mm/hugetlbpage.c | 10 ------ arch/s390/mm/hugetlbpage.c | 10 ------ arch/sh/mm/hugetlbpage.c | 10 ------ arch/sparc/mm/hugetlbpage.c | 12 ------- arch/x86/mm/hugetlbpage.c | 26 -------------- arch/x86/mm/pgtable.c | 4 +-- include/linux/hugetlb.h | 24 ------------- include/linux/pgtable.h | 24 ++++++++++--- mm/gup.c | 24 ++++++------- mm/hmm.c | 9 ++--- mm/memory.c | 2 +- 30 files changed, 68 insertions(+), 288 deletions(-) delete mode 100644 arch/arm/mm/hugetlbpage.c