From patchwork Thu Jul 4 04:30:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13723190 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 51FFAC30653 for ; Thu, 4 Jul 2024 04:32:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E4F636B009F; Thu, 4 Jul 2024 00:32:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D61FE6B00A0; Thu, 4 Jul 2024 00:32:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B63BC6B00A1; Thu, 4 Jul 2024 00:32:08 -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 8E09E6B009F for ; Thu, 4 Jul 2024 00:32:08 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 568D81A105C for ; Thu, 4 Jul 2024 04:32:08 +0000 (UTC) X-FDA: 82300797936.19.4E48F6D Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf15.hostedemail.com (Postfix) with ESMTP id 242C9A000C for ; Thu, 4 Jul 2024 04:32:05 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=RIxxEKxG; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=qELKKw+j; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=RIxxEKxG; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=qELKKw+j; spf=pass (imf15.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.131 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720067501; 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=TzRTJDegzctm0o/zod38K6uM5eCrhph5+Nc4qITcL0E=; b=ZzeIgmsVEdFpPNlHjF41LmO6FGurxnQ4NW1pfhdlsDWnQKotVYl+kGFQrKcvp1tOB7keJG T7uDcIauYz+aS/sffFygiiCTzRD6aAnAbYbMcMe4nhSFWa64Lp8m3nbBIf3uy4VmWzBF6f 9iUOMuIlEQ9KIc1DCWvFkuo0njfDCWQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720067501; a=rsa-sha256; cv=none; b=pKIu+fYS45FVn5THTDlm0qFhlVx8vPfoZybZudf1ABdXVnPO1oezfEzHLsglrUGGSfJgxg +R+7+h8y43Ljj7jNvv7SkX0vqfebC/BtqKehfhmBp2/Ufuv09kcmZWgoc2XcRrPnlXQfbq 450USWlaK6AD3gbEdQylqX0I3WlyMXM= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=RIxxEKxG; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=qELKKw+j; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=RIxxEKxG; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=qELKKw+j; spf=pass (imf15.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.131 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C84641FCFC; Thu, 4 Jul 2024 04:32:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720067524; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TzRTJDegzctm0o/zod38K6uM5eCrhph5+Nc4qITcL0E=; b=RIxxEKxG5cR+JdvOXGvScHx2quxv+jhuEkgOckg4pFfPpwOj9VOZl1vh5qJmR4/JuTNxQ4 D/UknVe0GOar65hwsjkxTWr72/C44FARudhSihdPho6fBNUUoiPDaqE3fz2zwhDes4iDuP OItI5Fg3f+Kf/XMNa7u2ylOqzbGXysA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720067524; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TzRTJDegzctm0o/zod38K6uM5eCrhph5+Nc4qITcL0E=; b=qELKKw+j6f1vh0ZBQrKxzDcNKdWTqCngnE0ElYT6ZMBZDJuWGRwB7g2w0Ut5FIQYasv9A8 JRnzseqZKYp7iOAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720067524; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TzRTJDegzctm0o/zod38K6uM5eCrhph5+Nc4qITcL0E=; b=RIxxEKxG5cR+JdvOXGvScHx2quxv+jhuEkgOckg4pFfPpwOj9VOZl1vh5qJmR4/JuTNxQ4 D/UknVe0GOar65hwsjkxTWr72/C44FARudhSihdPho6fBNUUoiPDaqE3fz2zwhDes4iDuP OItI5Fg3f+Kf/XMNa7u2ylOqzbGXysA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720067524; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TzRTJDegzctm0o/zod38K6uM5eCrhph5+Nc4qITcL0E=; b=qELKKw+j6f1vh0ZBQrKxzDcNKdWTqCngnE0ElYT6ZMBZDJuWGRwB7g2w0Ut5FIQYasv9A8 JRnzseqZKYp7iOAQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 9BDC913889; Thu, 4 Jul 2024 04:32:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id SDs9IcMlhmbnDAAAD6G6ig (envelope-from ); Thu, 04 Jul 2024 04:32:03 +0000 From: Oscar Salvador To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Peter Xu , Muchun Song , David Hildenbrand , SeongJae Park , Miaohe Lin , Michal Hocko , Matthew Wilcox , Christophe Leroy , Oscar Salvador Subject: [PATCH 12/45] fs/proc: Enable pagemap_pmd_range to handle hugetlb vmas Date: Thu, 4 Jul 2024 06:30:59 +0200 Message-ID: <20240704043132.28501-13-osalvador@suse.de> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240704043132.28501-1-osalvador@suse.de> References: <20240704043132.28501-1-osalvador@suse.de> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 242C9A000C X-Stat-Signature: fa8o94xzb7ogayjmj87db369r3o6yoij X-HE-Tag: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OELfNawEQMvUHycbD0PskP93oQ3BBQIjCFn5n+661b3fENyKIxnHuZliHaEI3yEhA/WYwDFyNSFaqA8NlyEtBzi0mhgBaDX4D/DCbP0brhEdpD5FTgFMGw+H0YwPAmg1Bhe9tiPonauMHC+owpG8EqImh4uYvJDiaC+058AxZn6KAhdvHxo9BoZf//tGOwc+ldZER9X8L1nd1yD1G7G+Iclt/u4g== 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: PMD-mapped hugetlb vmas will also reach pagemap_pmd_range. Add the required code so it knows how to handle those there. Signed-off-by: Oscar Salvador --- fs/proc/task_mmu.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 4d94b6ce58dd..ec429d82b921 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1824,9 +1824,9 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end, spinlock_t *ptl; pte_t *pte, *orig_pte; int err = 0; -#ifdef CONFIG_TRANSPARENT_HUGEPAGE +#ifdef CONFIG_PGTABLE_HAS_HUGE_LEAVES - ptl = pmd_trans_huge_lock(pmdp, vma); + ptl = pmd_huge_lock(pmdp, vma); if (ptl) { unsigned int idx = (addr & ~PMD_MASK) >> PAGE_SHIFT; u64 flags = 0, frame = 0; @@ -1848,7 +1848,6 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end, if (pm->show_pfn) frame = pmd_pfn(pmd) + idx; } -#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION else if (is_swap_pmd(pmd)) { swp_entry_t entry = pmd_to_swp_entry(pmd); unsigned long offset; @@ -1861,7 +1860,8 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end, frame = swp_type(entry) | (offset << MAX_SWAPFILES_SHIFT); } - flags |= PM_SWAP; + if (!is_vm_hugetlb_page(vma)) + flags |= PM_SWAP; if (pmd_swp_soft_dirty(pmd)) flags |= PM_SOFT_DIRTY; if (pmd_swp_uffd_wp(pmd)) @@ -1869,7 +1869,6 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end, VM_BUG_ON(!is_pmd_migration_entry(pmd)); page = pfn_swap_entry_to_page(entry); } -#endif if (page) { folio = page_folio(page); @@ -1899,7 +1898,7 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end, spin_unlock(ptl); return err; } -#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ +#endif /* CONFIG_PGTABLE_HAS_HUGE_LEAVES */ /* * We can assume that @vma always points to a valid one and @end never