From patchwork Thu Jul 4 04:31:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13723197 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 10858C3271F for ; Thu, 4 Jul 2024 04:32:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0DF536B00A8; Thu, 4 Jul 2024 00:32:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 044326B00AA; Thu, 4 Jul 2024 00:32:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D61446B00AB; Thu, 4 Jul 2024 00:32:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id AD7716B00A8 for ; Thu, 4 Jul 2024 00:32:17 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 677BC80B20 for ; Thu, 4 Jul 2024 04:32:17 +0000 (UTC) X-FDA: 82300798314.26.555F185 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf25.hostedemail.com (Postfix) with ESMTP id 47084A0002 for ; Thu, 4 Jul 2024 04:32:15 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=j2uGj66F; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=aF1AIMEQ; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=j2uGj66F; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=aF1AIMEQ; spf=pass (imf25.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=1720067511; 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=wUAXkDKulvUPvsNZqyUfVRpX873YTDqHqTEgZWFzyt4=; b=GcDTbsZWALaTRmMC40WIDM5kvGWj6+XeHBnFe+5lvHW+uuOHpYD+YWRHorTp3RZ/AEokq/ q5pSo7F5mGDpxwIeg2a9PXLne4aZ42sIj3bJ0sND0n/2us+SFyolOpeanRv2dXtq52u5Uv aDEpIxyqpklUmucL0NWGp7CyMX2weIU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720067511; a=rsa-sha256; cv=none; b=XZ5wYpJzBWBR4OVNvRN8lfPQ6cO2/xFPiOYBD1qIFug+UhPMFQqpPPIkzmjd4LDUXfq1AA fWLf+a2mRCVCD4YmClMYoaRuI1noSDkUUQWYRUHAnwbqx7aIAIEEcpn2LPhrpy7ZgWs7Nd O7sObQhHXxYTiWDGF2fwXzQi3W0RmRM= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=j2uGj66F; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=aF1AIMEQ; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=j2uGj66F; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=aF1AIMEQ; spf=pass (imf25.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 053031FCFC; Thu, 4 Jul 2024 04:32:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720067534; 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=wUAXkDKulvUPvsNZqyUfVRpX873YTDqHqTEgZWFzyt4=; b=j2uGj66FrtGxFBiwFctbDQ4OTG+w9M73dH62olOmsLGZIhnPfy8i6BSi1M1uU7Z995dm0M rDy3fOSDZiLRMBRFvYSwMC3MWiBIZt60dh4cyu70ITZlu4RYz92tsp3lGRkhC2d9EZ2fgM G1/oiZiEwG0JggCZhXJlACHwMP0ZVFI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720067534; 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=wUAXkDKulvUPvsNZqyUfVRpX873YTDqHqTEgZWFzyt4=; b=aF1AIMEQj6zRqtFUbpMf5dtjXnB1Crkf8BYEYuKhtpIYT+dX14+NYfft0LEejATVkvxiN5 /oB961ArpbntQiAw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720067534; 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=wUAXkDKulvUPvsNZqyUfVRpX873YTDqHqTEgZWFzyt4=; b=j2uGj66FrtGxFBiwFctbDQ4OTG+w9M73dH62olOmsLGZIhnPfy8i6BSi1M1uU7Z995dm0M rDy3fOSDZiLRMBRFvYSwMC3MWiBIZt60dh4cyu70ITZlu4RYz92tsp3lGRkhC2d9EZ2fgM G1/oiZiEwG0JggCZhXJlACHwMP0ZVFI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720067534; 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=wUAXkDKulvUPvsNZqyUfVRpX873YTDqHqTEgZWFzyt4=; b=aF1AIMEQj6zRqtFUbpMf5dtjXnB1Crkf8BYEYuKhtpIYT+dX14+NYfft0LEejATVkvxiN5 /oB961ArpbntQiAw== 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 DD98813889; Thu, 4 Jul 2024 04:32:12 +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 WFxbMcwlhmbnDAAAD6G6ig (envelope-from ); Thu, 04 Jul 2024 04:32:12 +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 19/45] fs/proc: Enable gather_pte_stats to handle hugetlb vmas Date: Thu, 4 Jul 2024 06:31:06 +0200 Message-ID: <20240704043132.28501-20-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: 47084A0002 X-Stat-Signature: ae4n74oxouqpjmg9y18by9qk7gzjf3su X-HE-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ITRcjyErVhZO8yWG1UZm8rdTm1E7Pc2f69YdxL1WCIlyYb5dhGYCowzPKG4lmGaMxVvXUBRrweAFz7UjRQ6YJ27icsC8dzw+sJ5+BScNPp5kIjzIYdAzxbPELCtEVbRLRVEYej5F/nufTpsMqMnJkifRUCrlym9iHuIgzGGvT/YU9d+rcxp5fhaUbozZCIqGd4ulPRzP55fykSed4hHJziP4iEcw5 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 gather_pte_stats. Add the required code so it knows how to handle those there. Signed-off-by: Oscar Salvador --- fs/proc/task_mmu.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 3785a44b97fa..e13754d3246e 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -3141,7 +3141,7 @@ static struct page *can_gather_numa_stats(pte_t pte, struct vm_area_struct *vma, return page; } -#ifdef CONFIG_TRANSPARENT_HUGEPAGE +#ifdef CONFIG_PGTABLE_HAS_HUGE_LEAVES static struct page *can_gather_numa_stats_pmd(pmd_t pmd, struct vm_area_struct *vma, unsigned long addr) @@ -3176,15 +3176,21 @@ static int gather_pte_stats(pmd_t *pmd, unsigned long addr, pte_t *orig_pte; pte_t *pte; -#ifdef CONFIG_TRANSPARENT_HUGEPAGE - ptl = pmd_trans_huge_lock(pmd, vma); +#ifdef CONFIG_PGTABLE_HAS_HUGE_LEAVES + ptl = pmd_huge_lock(pmd, vma); if (ptl) { + unsigned long nr_pages; struct page *page; + if (is_vm_hugetlb_page(vma)) + nr_pages = 1; + else + nr_pages = HPAGE_PMD_SIZE / PAGE_SIZE; + page = can_gather_numa_stats_pmd(*pmd, vma, addr); if (page) gather_stats(page, md, pmd_dirty(*pmd), - HPAGE_PMD_SIZE/PAGE_SIZE); + nr_pages); spin_unlock(ptl); return 0; }