From patchwork Thu Jul 4 04:31:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13723204 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 CF2DBC3065C for ; Thu, 4 Jul 2024 04:33:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D68926B00B3; Thu, 4 Jul 2024 00:32:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CECD76B00B4; Thu, 4 Jul 2024 00:32:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B15556B00B5; Thu, 4 Jul 2024 00:32:26 -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 85A776B00B3 for ; Thu, 4 Jul 2024 00:32:26 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 43DC8120F9D for ; Thu, 4 Jul 2024 04:32:26 +0000 (UTC) X-FDA: 82300798692.27.EB7ECE0 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf19.hostedemail.com (Postfix) with ESMTP id 39EA71A0012 for ; Thu, 4 Jul 2024 04:32:23 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf19.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.130 as permitted sender) smtp.mailfrom=osalvador@suse.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720067524; a=rsa-sha256; cv=none; b=xr6eacKwf94RI04/LfLT52jntjjawC6lU/mfG1ULNonU6D/60GwS8CFj/goECKiMn6c+n4 epQ3PocC8AfRKoDpnsWKD6M0oBEz8hEDELouBSHjDuV7zjIVpTrZ2kDy/8n03xKW+Lzu7V E4H8bzyAdBZpTjvdYVrismR6O32P5sg= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf19.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.130 as permitted sender) smtp.mailfrom=osalvador@suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720067524; 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=tDyxny4TknAwVCp4MGOFy70tk6Ey0sbLgqgCHwZ91s4=; b=UzXeMvcLXy/EYGDg2YB3SaqrHZV/2vrzJ9/4RR+L7ZslTMGO3hwWx58qAvIjTt5kr9J8tg BX/L21y7y0LRsuNZazmlHxQXO64Hw4GUmKeC7u5Pk5qqe0shDcRH88hhkA1Dm7mot8XAhb eyd2EBGJ7qg30YeTc8VdSyCEV3gVKTI= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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-out1.suse.de (Postfix) with ESMTPS id 09ECD21180; Thu, 4 Jul 2024 04:32:23 +0000 (UTC) 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 CD1EE13889; Thu, 4 Jul 2024 04:32:21 +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 UADILdUlhmbnDAAAD6G6ig (envelope-from ); Thu, 04 Jul 2024 04:32:21 +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 26/45] mm/damon: Enable damon_young_pmd_entry to handle hugetlb vmas Date: Thu, 4 Jul 2024 06:31:13 +0200 Message-ID: <20240704043132.28501-27-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-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 39EA71A0012 X-Stat-Signature: 5t93gg5ii793omi8mtkypay6eq7mboq6 X-Rspam-User: X-HE-Tag: 1720067543-717720 X-HE-Meta: U2FsdGVkX1+5XcqRjTWriFiiAeP3vSjGZWzJeE3QImevPIGYlRtsTaxwT/3WKHQqlbIe1/AXKB4cGjH029fYxHt5ZLhH1UDy2Lg8aAHPgpTPFiytQgljIlVPmTREujJK9L9qWpPr0hS7arNgADImYM6swoDUibsnnY10gjOCTAtOhShZsZ/hWIelllCqYTp+tW/acOE+RuJgxeidoc87O74QUHWKXBwOjAYMSWae9BoIFRsBYEl6sW+nIiXBDrE2Q1hPjGVjWO1E9vrnVI8OTuEpsL9eIdCFZzGibYkamiS+fiKu9xatHDKSD9umGinVFUzVzg769g+bPKaOOKP4uIT8URZibN3AThQ6pc1JOSIu078AQpqp3e30kqgM9mfZGr+/WT+LSsklfytNUdhZZdQRPVyllIPE6kitI3CmBFX9dnoyO5SxW26Vf5Rh7UBDmiQcCxD6XKciKh6wKA5mNqu/nkWLlwCv1TRR+w/rtm7zKNO5Nzrh1DiIqSVJt3CQCRGxfd8TzcuWmEuqrWyP17J541hcTdhRKadtu4A/nTlF/fZ1WYJIiMd3/vUlvU+m5ZGwTrGa2J/yhj4UDMX/xyaDt/137XLFb94S+7RNo9p8fdN5IeZAsyRQC8UP3dzm4JoegBcWyB/dpmODpHJFbzPC3woIlCrnxzFqir/OkwLGekGExiFQj58oOhgnYMjVhgFYfrM5r2G9xaXoLFpHT4gEZPLfjXSla9KzfoWQVHZcmZuNjPZj8dmv+9Z/nqGvlqyuXxsLYqfb1QDd+thCa7XbeS04M78j9eP0MpnNqyVres0DwsJw+/mCwuKKqMzPlZcJwRKKPG4AOaMzQ1KX68cofI53sr1svgbXgXBp3Hht+EgUnQOEbDwOjYgsesS7t6W/3XWGlF6ULnJcmZgWN10NTDi9JWcLx8F49vaTyrLNqaAn93fORnHLY3e982eNC/GnIKnuQuyxO8LrauD ONgCcMmf MKfZbwFKBJzbk0/5ucO906LD7swPhzBJB3PfEp3A5T6eSe1S/X8MmhWx7qU2GMTquHiec4m13VqXghsHI3Yo2QFGAudL8GBxXRPRzQx2t2vI22oc9606t9Al6FMZdtk9kQ2Y4yQPxPW7ciJLB0t9KY0S1KS3Rax79/aZq7uwjug0AV7A= 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 damon_young_pmd_entry. Add the required code so it knows how to handle those there. Signed-off-by: Oscar Salvador --- mm/damon/vaddr.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index 58829baf8b5d..00d32beffe38 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -443,30 +443,35 @@ static int damon_young_pmd_entry(pmd_t *pmd, unsigned long addr, struct folio *folio; struct damon_young_walk_private *priv = walk->private; -#ifdef CONFIG_TRANSPARENT_HUGEPAGE - if (pmd_trans_huge(pmdp_get(pmd))) { - pmd_t pmde; - - ptl = pmd_lock(walk->mm, pmd); - pmde = pmdp_get(pmd); +#ifdef CONFIG_PGTABLE_HAS_HUGE_LEAVES + ptl = pmd_huge_lock(vma, pmd); + if (ptl) { + unsigned long pfn; - if (!pmd_present(pmde)) { + if (!pmd_present(*pmd)) { spin_unlock(ptl); return 0; } - if (!pmd_trans_huge(pmde)) { - spin_unlock(ptl); - goto regular_page; + pfn = pmd_pfn(*pmd); + if (is_vm_hugetlb_page(walk->vma)) { + folio = pfn_folio(pfn); + if (folio) + folio_get(folio); + } else { + folio = damon_get_folio(pfn); } - folio = damon_get_folio(pmd_pfn(pmde)); if (!folio) goto huge_out; if (pmd_young(pmde) || !folio_test_idle(folio) || mmu_notifier_test_young(walk->mm, addr)) priv->young = true; - *priv->folio_sz = HPAGE_PMD_SIZE; + + if (is_vm_hugetlb_page(walk->vma)) + *priv->folio_sz = huge_page_size(h); + else + *priv->folio_sz = HPAGE_PMD_SIZE; folio_put(folio); huge_out: spin_unlock(ptl); @@ -474,7 +479,7 @@ static int damon_young_pmd_entry(pmd_t *pmd, unsigned long addr, } regular_page: -#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ +#endif /* CONFIG_PGTABLE_HAS_HUGE_LEAVES */ pte = pte_offset_map_lock(walk->mm, pmd, addr, &ptl); if (!pte) {