From patchwork Mon Jan 13 13:16:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13937326 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 235C0C02180 for ; Mon, 13 Jan 2025 13:16:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B4BC26B0089; Mon, 13 Jan 2025 08:16:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AFBA66B008A; Mon, 13 Jan 2025 08:16:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 975A96B008C; Mon, 13 Jan 2025 08:16:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 757766B0089 for ; Mon, 13 Jan 2025 08:16:42 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 317B71C6D7E for ; Mon, 13 Jan 2025 13:16:42 +0000 (UTC) X-FDA: 83002478244.04.7B70C69 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf19.hostedemail.com (Postfix) with ESMTP id BA8251A0004 for ; Mon, 13 Jan 2025 13:16:39 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=M+nlahQl; spf=pass (imf19.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736774199; 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:in-reply-to:references:references:dkim-signature; bh=yqxlMuEwJ96RDEbbwPDjzSu+ESMvaexzxAdOoodpgX0=; b=nSri/iqBXYxJTXDCx53dXEthNWpAq/Bt+l5RVYT7kv/OZqpSyHLVW4spTUto6MPHFkmyEC 72QbpkNxREYDHCeTzHBv6FTBdJwQm2qprVhdeN/OktOoikHcGtAFhhOk4YYKajktpZXRcs CEY3PeXxQVbePz46v8CS2Z0iF9MxCXA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736774199; a=rsa-sha256; cv=none; b=7+wjKj8rg6hwvvlvgVYOaGyyM8H10FbaFwZrgnfgCPu0JDn6CEEjFvbdZD/mcUUy5bgwmK TuNlrFgJI4KwkGBivyDA0mmByAsCxv/LV93ZnvCb5CJ9qJgm+aakq0G+e/sFQz2h5Z0fmw zo4yxt21q7tdZrKHS8zeoQ1q1YcEGAw= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=M+nlahQl; spf=pass (imf19.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736774199; 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: in-reply-to:in-reply-to:references:references; bh=yqxlMuEwJ96RDEbbwPDjzSu+ESMvaexzxAdOoodpgX0=; b=M+nlahQlikF0D9V9H/xvnFiBNFM1qmFqlh++j1+yHALW8V/96oBF+3P2r1kHPSgonqEFlW PDwhhK7L8QFK9XanjNTuM5M+UufauvevUCHnpy9wRB3VaUFZ+KSt3oG2EGVV1YUouxjmn4 93k99qFgdoaO41yAiRUyDGoBVBCZVCk= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-571-TV_ijYTWNB2vmpGfuJPKrg-1; Mon, 13 Jan 2025 08:16:36 -0500 X-MC-Unique: TV_ijYTWNB2vmpGfuJPKrg-1 X-Mimecast-MFC-AGG-ID: TV_ijYTWNB2vmpGfuJPKrg Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-38634103b0dso2599062f8f.2 for ; Mon, 13 Jan 2025 05:16:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736774195; x=1737378995; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yqxlMuEwJ96RDEbbwPDjzSu+ESMvaexzxAdOoodpgX0=; b=hEuEehefj97ZLod5i1/xxwneE8PRu6HGqhOn03DKmLS7ropPWNAcWfwQho2cVxwXwq 6QVv4ESNMeX/Q4BmmmpE/h6Vb0yM4PU3GYB1bnHEMg/kQI+PM6dORVsnOItkFUOmEGnF 60GaRuPNTo8PCFr7SBWNV7J6+ofbTby530o/hutAK/W4kkZAz7Rn7Y+aWFHEnkYhKH2l GhtApckdQmn98yhd6vy06ky7S+chhTy5UOeY/daEZahFmXA58EDDhwB6oad6UPtZtIun CThDe9ejkdcnEruqV1+bMd19xjJ69Amw3TBWHo7fJaCOweq46xc/2HGcb1wDCRN0ovk+ X/Gg== X-Gm-Message-State: AOJu0Yx/LnrQodpRDK/2OW6/Q3imtpFGRaP3i3KDN82FISH1YtzrWF1+ Wqnnt74ckRDaP08xPI586sEV9Qv5V0m3O+fST4FcXr6OwS89w116XK0Wk9i1s3Zk+V3zjjYFPGM Ls4cw42TqLctx7ySt4lfeXhn+WeU5SzDP8oi+YNU3uiqt0O9n X-Gm-Gg: ASbGncvnZrKTt4hmga6v442d63LYW24iclKEhZ+7nhBqcC1FWBr7c8UITqY4zRPAKzI RpygEg/msDTcruJZ/+K8PCFngx6RYgDvqEWgr85IxxZBbdPl0YuEnUogfvzQ92dp8YGv2v8OXMe n8iWEiDK5BCRI/cyHrXIJGnTRrwLh/nTYtF2vtf7Zlj35AsjRafKTajs/BFL+6l/pgdE6S7hQr8 Pnx/I8aYbxs49S9jP4AhX2kR9KkytG1SEZivuZ9iaxqv8LeqHER X-Received: by 2002:a05:6000:4b0a:b0:385:fae2:f443 with SMTP id ffacd0b85a97d-38a87313975mr18780146f8f.34.1736774195625; Mon, 13 Jan 2025 05:16:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IFwBMYQqXPQxzZdc6FGJ8e2Lbj3PmWZBYhXw8lnFx0RiF7sjzN8pyjkFTORSuuscZKg5QTaCw== X-Received: by 2002:a05:6000:4b0a:b0:385:fae2:f443 with SMTP id ffacd0b85a97d-38a87313975mr18780120f8f.34.1736774195249; Mon, 13 Jan 2025 05:16:35 -0800 (PST) Received: from localhost ([2a09:80c0:192:0:5dac:bf3d:c41:c3e7]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-436e2e92dc4sm176071985e9.39.2025.01.13.05.16.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Jan 2025 05:16:33 -0800 (PST) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Muchun Song , "Matthew Wilcox (Oracle)" Subject: [PATCH v2 1/6] mm/huge_memory: convert has_hwpoisoned into a pure folio flag Date: Mon, 13 Jan 2025 14:16:06 +0100 Message-ID: <20250113131611.2554758-2-david@redhat.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250113131611.2554758-1-david@redhat.com> References: <20250113131611.2554758-1-david@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: c-8QIsegqIaL42Z-gONk1RzdgsSiFY0OHgUFSvL_DJA_1736774196 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: BA8251A0004 X-Stat-Signature: 939de58t8swxhsn47tp4gob6uszrudjk X-Rspam-User: X-HE-Tag: 1736774199-277887 X-HE-Meta: U2FsdGVkX189BFgXE/Xn9NpHpLnUyNQyh+oY660jGXjK4X2iQf09EJMO7xRikfpYi6PpzXis0n4wEpGMGeYHBC/DQLNkQrFzTWPwVvjiKhjxfOFUlgptqK81I1lAPu2qYxPrwza6QLHQiRSXz/SiGq3JP+mP6sYAcpfOi25eECurqceorUtbi1Ccb/kI9Dvb/i412JRLfL0/xK0fTyDp/1yZzj48oJwkhQq7swgsqXetE3trMM/sFdNv6JwzNN9AZ1CqfheQ5K1BHDbZnQQYxNDgKOsabd+8lSaKOQ8VhbGR+Lw2FnIOHmt2XDOINPwftrmLGI7W+Q+Kv8HQqZ4CXEirT3+5KE2wsMRtQxOKj6EmGxHcTy2Z6AkdZayMNOAkyhL2T7hpaZNUfw9ytvTsShPKz2lAY9H07YekS5WBVYmLop9GArJX1FzSVyFvP3SLoXr2CJ0MlatkMA1A5JKx81W/N2nf5DMQ1XJphK+sBdKf0ll7CoHPGxJknbjvKjriCGqZdxRzTFZMulSI8q0Kv2tP5KoFQlzrz7BM8+ni3R7OZt5oqf6o+n0z6Rs7FP4RvJqDCkhUAkicWu27WTEQXAViuISDDGSutqqBb9+g2aw2qLt3eC1h/W7v2ycvgCZiATGt1BbM4k50Jk7zgelbV7DGNsZCm4NtLHvqsAtl3+AE5kgEcZ+48chdBLvg+9CRzcSeQEVhrhco/Yws+wKxO5uWgui9S1yBdqk0Ny/2DH9mL778PSyuUwXSsQGgZDct+LafL+IzPSD9knT2Fl6Kym4NPRs60LbhynxdoLYiglcEfyLjJpZ3h3yHDuQjCuhJjVvFLfE0zGyNx1zhvlhoIX/IXBGdlIDrE/nbc8BZSYRzdSV2wfOD09vnJKXOq61IY2feah16e5VEfuVwKcXJKl4TVkQ9cnbYuJzNChcFpb7HUN7NJqun4zXIFcjq3JOk7q/kIqrhXlKfsaXiZAD AhWMpFwL rs0lhsq3qQ+o3BSSfyMAuPC1avhLdkKySFmlURQ061EI+beyGA450qRQndcd1GC4nK3wZqh+tFLbGMTKbM/Wcyi5bVkxtA2aOn6GSF4uxCNwL80Uz3IFOnmiOwguq+2s56QphmAVbowjzMsYjkZFZ45/Wkz6FQgw7cjgGjcRDoVMMqMo+HMyH9+ztXmv1jlM3XN/TBuGmsIqdcrhUw1JmLOX3GE90upZbXpuXE+HGjgRh13eNdxUhae2x0ZcVQmwXYNHNx0VDvPJLtgbjwnWk/UJZM8yfetUV4VRJLU0mBI7sp0dh2kDuvm7Y9NPsYXEW/3eMf24cjMKkVmPmDrSAm6OZnCgDy4ABL10CTItPX8YvHKLMxdZTTHD3zIRdJZp9WxHaJ3pjxn0cM/OwsHWhcda1wphn6fj2Vb9U4vQKi+RdMSE5kdDeihVTGrYlxyko5d72gMRcgvPq+k1wmhTExOvTlhUitn/m+N0vqnDEyXqPLtewOIhsC1Qm3yjDmtM3oYOe59PRhVc74K07H6EWczCWtOPTaY9JrFgoNIF+j5qZjlOTOhNChfVKaQ== 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: Let's stop setting it on pages, there is no need to anymore. Reviewed-by: Matthew Wilcox (Oracle) Signed-off-by: David Hildenbrand --- include/linux/page-flags.h | 6 ++---- mm/huge_memory.c | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 14226d6bd6f84..3f6a64ff968a7 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -948,11 +948,9 @@ TESTPAGEFLAG_FALSE(TransCompound, transcompound) * * This flag is set by hwpoison handler. Cleared by THP split or free page. */ -PAGEFLAG(HasHWPoisoned, has_hwpoisoned, PF_SECOND) - TESTSCFLAG(HasHWPoisoned, has_hwpoisoned, PF_SECOND) +FOLIO_FLAG(has_hwpoisoned, FOLIO_SECOND_PAGE) #else -PAGEFLAG_FALSE(HasHWPoisoned, has_hwpoisoned) - TESTSCFLAG_FALSE(HasHWPoisoned, has_hwpoisoned) +FOLIO_FLAG_FALSE(has_hwpoisoned) #endif /* diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 2654a95487499..3d3ebdc002d59 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3290,7 +3290,7 @@ static void __split_huge_page(struct page *page, struct list_head *list, /* lock lru list/PageCompound, ref frozen by page_ref_freeze */ lruvec = folio_lruvec_lock(folio); - ClearPageHasHWPoisoned(head); + folio_clear_has_hwpoisoned(folio); for (i = nr - new_nr; i >= new_nr; i -= new_nr) { struct folio *tail; From patchwork Mon Jan 13 13:16:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13937327 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 EEEECC02180 for ; Mon, 13 Jan 2025 13:16:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 72CE66B008C; Mon, 13 Jan 2025 08:16:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6DC8D6B0092; Mon, 13 Jan 2025 08:16:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 530426B0093; Mon, 13 Jan 2025 08:16:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 306DE6B008C for ; Mon, 13 Jan 2025 08:16:49 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D7ADC12020E for ; Mon, 13 Jan 2025 13:16:48 +0000 (UTC) X-FDA: 83002478496.22.66B954F 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 B1748C000F for ; Mon, 13 Jan 2025 13:16:46 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KLKEuQjU; spf=pass (imf28.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736774206; 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:in-reply-to:references:references:dkim-signature; bh=9usYI5DgNUlDmY6F4Dug4aGXBw+qPPqxLUrXzQ1Tmoo=; b=qBT6XfJlul9WO34ryv0svy3XkZDE5Gl/CxYJeNXxbTAnR5JkQHimtO6nU2AuIqEpBt2Tnk 7NjiRcvMVIeaSfTaTork3cnJ7PfCRGpq8tJqWmau7z53rJJnFqKL2frOmJbcLxjWHROAZ9 zP1cAMaG3VaG/gElBd4S36O58mph19w= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736774206; a=rsa-sha256; cv=none; b=vqGTSARtd42cCUBBXxL6fi4zinEMjyMWvuud4Tl2UEb78fCbJSwg49lG2KuZf89EFzxNGx /d77KGzhtr4IJTMffLVcasPmc2Wb61trjtmLXsDpceM3ohoW+ZoNpuyeiLWKtHxpePQSOt wFCjUHGAGW9AF1M1hijncDWHw/b1aCI= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KLKEuQjU; spf=pass (imf28.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736774206; 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: in-reply-to:in-reply-to:references:references; bh=9usYI5DgNUlDmY6F4Dug4aGXBw+qPPqxLUrXzQ1Tmoo=; b=KLKEuQjUQV7dtHFF9VH3L/jnBKvQEKN5lV9MSPCGYx7gS07OsTTMltn7zZWt7TZTqPR0Ma 58iFxHlkABFlx72F3WnQWnf2pw3L42AYwOavtsbjt3yUqGbMHEcsFikGQuMDIDQKbcXJ3A MZY/agMBlT4VZuUM94rz7ZZaJVK9dGs= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-686-0yMazMcoPSC2AX0fAJEcyQ-1; Mon, 13 Jan 2025 08:16:43 -0500 X-MC-Unique: 0yMazMcoPSC2AX0fAJEcyQ-1 X-Mimecast-MFC-AGG-ID: 0yMazMcoPSC2AX0fAJEcyQ Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4361c040ba8so24525115e9.1 for ; Mon, 13 Jan 2025 05:16:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736774202; x=1737379002; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9usYI5DgNUlDmY6F4Dug4aGXBw+qPPqxLUrXzQ1Tmoo=; b=YO5VyVivwk2R2uCQbqCmU2QW8o2w3RzD/Z4M5dq5g+9uIX9wIHT74kh6ZK3T1Hkqxg JZ9k71oH10kOa5w1UR5G+5WgK9M0Hdo5CFFzRVg1GlMnThmNGep7P5ErdmITQl1k40Rw eIn4NWUvMFcAJ1d1Zr0K4zuBq62kWX3E51Y4akZh1fGmFT5+r2wStYiNoR9Kf1GrfZNI DvxF8PlsAqznUUXA2OyMoW82IQjlKkGSkDleJqi+ErUA4d/BClh0mimKUUGfqE9KoEJR 1sIsgyZLOvyQ+zXgeCZ1LxqYJImRiowV/i3/AEleN1lDoduzznArMkACx+HBX2fcNuQL FAjA== X-Gm-Message-State: AOJu0Yyvkpn4J1X4/lJXoa8D6dl/HSPsnnbRZjlf2oPBZQiMF60YewK2 6eNf3TjNqPACLcedauuv77disojUvr6nRpU/K6C6agBUpYXmH4+mJFK4zoxXqcMkrpQuSZEKEB4 1VaWoyJInJgFcFUFpaNMNEz1WKot7a+AK2sjganZ2tJSKkvJw X-Gm-Gg: ASbGncu2z+w6xyMJQFTv8oEKXZrjTWXnjO/qF0EjWzPYYrczWTY2BmVwld76oHjCe9a 5GiRjRzWPvsly17cz8YE0e/VE5zERhTYQ7ruWFt/n7LXlixxYqFkIpESdm6TzWpo3aEA8BbEAH3 xKlExDPwKqp4ZezbOJHLCBNSx1AtR14EOiXIa8pdyBjy0jh4RoSS/gPQbV8xhjluRQHT4ddhe5S CmhL6cyauGke2s8ZHJCxn8I9FZ2VEUi2CdOncHu+Qo0uBTg2zNO X-Received: by 2002:a05:600c:314b:b0:436:5fc9:30ba with SMTP id 5b1f17b1804b1-436e26ebb6fmr73793205e9.29.1736774201719; Mon, 13 Jan 2025 05:16:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IF1QjX6fKScjtkrek3bHe4bgrZiW5f8BsOnYBHXEjoxDvqfSM2uADNbnmwxz9BF73D5jNf0aA== X-Received: by 2002:a05:600c:314b:b0:436:5fc9:30ba with SMTP id 5b1f17b1804b1-436e26ebb6fmr73792885e9.29.1736774201284; Mon, 13 Jan 2025 05:16:41 -0800 (PST) Received: from localhost ([2a09:80c0:192:0:5dac:bf3d:c41:c3e7]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-436e9e6263fsm146445655e9.39.2025.01.13.05.16.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Jan 2025 05:16:40 -0800 (PST) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Muchun Song , "Matthew Wilcox (Oracle)" , Baolin Wang Subject: [PATCH v2 2/6] mm/hugetlb: rename isolate_hugetlb() to folio_isolate_hugetlb() Date: Mon, 13 Jan 2025 14:16:07 +0100 Message-ID: <20250113131611.2554758-3-david@redhat.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250113131611.2554758-1-david@redhat.com> References: <20250113131611.2554758-1-david@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: V_XeOv-O_tOr7B5H6l30V8p6ns9-ALxdawTrQyFtbuE_1736774202 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspamd-Queue-Id: B1748C000F X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: 6ws5cczdh8xsop5mum55fhsxzanopu6z X-HE-Tag: 1736774206-579521 X-HE-Meta: U2FsdGVkX19G/Kbn5U4PXeEI4U5CjrxjI0mMRjUdPWscC2CzgvHidbVHuUbo3ZXz3M9/PY5jbrb91YsLFnfrPoxScUnn1Doudh365JOd80tms+Jm34A4u5asBqkcT65dyKcKTLxH4CcJryytNJaD0lzpmxJ7+G3da9eyXKcKYBsVo0Coz0o+SQA4E0WnkaBUaHugORH9vC6/lxpeQirk2A5sTPgKE7E+t2R0fDTP4uoG7FlNRler67p19Cv/7dSfbLr1WB5usW3vCTdFwMgIJ1aSmdt15u8paNlI5K+AYWBNMe0i76wFFX1nWebAbY9f0GEKHP4t0jdFbfUHY6ocWeZl3uBv1C6LHibxIDP6tkjZVs8hrLJH9ntR9IeeVTWklWkH9xz8ULNJT+l2+Tj+nk/uuvkvsD3AweamxtfNC1RsRAIHcnGIatdPpiHUbhF6p0v5ycfmog4w4KsJbp/Kja73k/zftwLQj+O6St15lThDoFc8RuXS5S9WimQ2RUql3ItCZ25axOL5HCuby9+g43leopz+D56rZ+n+Xphy/m09liv3SEGuA7L4IgWcz6W18Ax0QtmRy4SUFLZZxma2KATl56OQeYYHQIzFDECDQAaR53Oj1aMJyPW/W7YIj8ledHAaOOlyEr+ANWA756rpi4rFDNbiXxePVdIYEjV3Rg58DJvt7EyLSC6DzMDlhfb9iR7WFdI/TS/lc6uRS0L8hhq57eg2mQuwRE5+jBOt5brIU0undMICmyKQ6nFgwN1Gh25jlw4f7HKq21q+3aaaBT3NaLgJ795XMr/D8wLCldldIWwrlzU76K6dSl85LIbCRQyOSmO4RGI0G1qyypd2bxaUxpT98/qbzb+dhl4h8U2K59Xsv5fIGJbpmEMrgDTEDmDnooMNUvE60fXL3Z7nS2YDPQ3BB4WB1tkOJgo7qJVB2xXHuaTev/S9E3uoGGD9Cwfg4rrK1exFJQiTskS Obn0zu51 Fk1FGeDpDoIZUmP++d+geMweQ0AhbXiY55Dn+bolvMsI9mjQCB45DefCMOG+gkOSkjZfR6xIwbOW7wPcv2xEJHtvCaXqAakSOpig4TX0hZPMf3aHIYtA8v6qKMAnqWE/jkTVXWJG+3iHadDeQvFL+36PL7qlksfGqY3wyg2kcpawcC5vzdqq2ijii70bFfOYpb3/NiV0lHd/tpv0ZLAzgOy35jeNJpLjGA4fvnsMwAzv4zIxYbjw5ZP4qzdbnKNUl7yhQQZxjikXNaFtXHSWMOSrzcANPS4qS4d/9LuEIzBH3/2FCDNwVQclFB9Mx1Vw/1gGA05ipZia8sSyQy6w10MGq61pEo3Dahr5XU7Wl/6/19TmvgetwZY6LX1vTYzAbLZlxg2yc/6CcppG6hlnoDhhK7WV0U0qqvEe+LTg8saVZqvBwV0j77zx7XVzpfoRxd+Q8TPpkuoF6WLbAUSjJNl1bn/hKplu4HvdGFYAvz6IrsoXvxEj7qvsOipmtsEFbTBgm7GZ/HCOjiNTGvCwa3reeqTZYalap8KPFqpOqQp7p0AZ254/k0WXhoLVpcdsMMjmXpNZcBM7u5V8= 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: Let's make the function name match "folio_isolate_lru()", and add some kernel doc. Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Baolin Wang Signed-off-by: David Hildenbrand --- include/linux/hugetlb.h | 4 ++-- mm/gup.c | 2 +- mm/hugetlb.c | 23 ++++++++++++++++++++--- mm/mempolicy.c | 2 +- mm/migrate.c | 6 +++--- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 49ec2362ce926..c95ad5cd7894d 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -153,7 +153,7 @@ bool hugetlb_reserve_pages(struct inode *inode, long from, long to, vm_flags_t vm_flags); long hugetlb_unreserve_pages(struct inode *inode, long start, long end, long freed); -bool isolate_hugetlb(struct folio *folio, struct list_head *list); +bool folio_isolate_hugetlb(struct folio *folio, struct list_head *list); int get_hwpoison_hugetlb_folio(struct folio *folio, bool *hugetlb, bool unpoison); int get_huge_page_for_hwpoison(unsigned long pfn, int flags, bool *migratable_cleared); @@ -414,7 +414,7 @@ static inline pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr, return NULL; } -static inline bool isolate_hugetlb(struct folio *folio, struct list_head *list) +static inline bool folio_isolate_hugetlb(struct folio *folio, struct list_head *list) { return false; } diff --git a/mm/gup.c b/mm/gup.c index 00a1269cbee0a..2cc3a9d28e70e 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2344,7 +2344,7 @@ static unsigned long collect_longterm_unpinnable_folios( continue; if (folio_test_hugetlb(folio)) { - isolate_hugetlb(folio, movable_folio_list); + folio_isolate_hugetlb(folio, movable_folio_list); continue; } diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 9a5596022c4b3..a93b508bc0e0e 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -2808,7 +2808,7 @@ static int alloc_and_dissolve_hugetlb_folio(struct hstate *h, * Fail with -EBUSY if not possible. */ spin_unlock_irq(&hugetlb_lock); - isolated = isolate_hugetlb(old_folio, list); + isolated = folio_isolate_hugetlb(old_folio, list); ret = isolated ? 0 : -EBUSY; spin_lock_irq(&hugetlb_lock); goto free_new; @@ -2893,7 +2893,7 @@ int isolate_or_dissolve_huge_page(struct page *page, struct list_head *list) if (hstate_is_gigantic(h)) return -ENOMEM; - if (folio_ref_count(folio) && isolate_hugetlb(folio, list)) + if (folio_ref_count(folio) && folio_isolate_hugetlb(folio, list)) ret = 0; else if (!folio_ref_count(folio)) ret = alloc_and_dissolve_hugetlb_folio(h, folio, list); @@ -7417,7 +7417,24 @@ __weak unsigned long hugetlb_mask_last_page(struct hstate *h) #endif /* CONFIG_ARCH_WANT_GENERAL_HUGETLB */ -bool isolate_hugetlb(struct folio *folio, struct list_head *list) +/** + * folio_isolate_hugetlb - try to isolate an allocated hugetlb folio + * @folio: the folio to isolate + * @list: the list to add the folio to on success + * + * Isolate an allocated (refcount > 0) hugetlb folio, marking it as + * isolated/non-migratable, and moving it from the active list to the + * given list. + * + * Isolation will fail if @folio is not an allocated hugetlb folio, or if + * it is already isolated/non-migratable. + * + * On success, an additional folio reference is taken that must be dropped + * using folio_putback_active_hugetlb() to undo the isolation. + * + * Return: True if isolation worked, otherwise False. + */ +bool folio_isolate_hugetlb(struct folio *folio, struct list_head *list) { bool ret = true; diff --git a/mm/mempolicy.c b/mm/mempolicy.c index f83b73236ffe7..bbaadbeeb2919 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -647,7 +647,7 @@ static int queue_folios_hugetlb(pte_t *pte, unsigned long hmask, */ if ((flags & MPOL_MF_MOVE_ALL) || (!folio_likely_mapped_shared(folio) && !hugetlb_pmd_shared(pte))) - if (!isolate_hugetlb(folio, qp->pagelist)) + if (!folio_isolate_hugetlb(folio, qp->pagelist)) qp->nr_failed++; unlock: spin_unlock(ptl); diff --git a/mm/migrate.c b/mm/migrate.c index caadbe393aa21..80887cadb2774 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -128,7 +128,7 @@ static void putback_movable_folio(struct folio *folio) * * This function shall be used whenever the isolated pageset has been * built from lru, balloon, hugetlbfs page. See isolate_migratepages_range() - * and isolate_hugetlb(). + * and folio_isolate_hugetlb(). */ void putback_movable_pages(struct list_head *l) { @@ -169,7 +169,7 @@ bool isolate_folio_to_list(struct folio *folio, struct list_head *list) bool isolated, lru; if (folio_test_hugetlb(folio)) - return isolate_hugetlb(folio, list); + return folio_isolate_hugetlb(folio, list); lru = !__folio_test_movable(folio); if (lru) @@ -2203,7 +2203,7 @@ static int __add_folio_for_migration(struct folio *folio, int node, return -EACCES; if (folio_test_hugetlb(folio)) { - if (isolate_hugetlb(folio, pagelist)) + if (folio_isolate_hugetlb(folio, pagelist)) return 1; } else if (folio_isolate_lru(folio)) { list_add_tail(&folio->lru, pagelist); From patchwork Mon Jan 13 13:16:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13937328 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 BA3E2E7719F for ; Mon, 13 Jan 2025 13:16:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 495436B0092; Mon, 13 Jan 2025 08:16:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 445FB6B0093; Mon, 13 Jan 2025 08:16:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FC5A6B0096; Mon, 13 Jan 2025 08:16:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id E958D6B0092 for ; Mon, 13 Jan 2025 08:16:50 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id AD4A4C0285 for ; Mon, 13 Jan 2025 13:16:50 +0000 (UTC) X-FDA: 83002478580.13.A60BF32 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 7005B180012 for ; Mon, 13 Jan 2025 13:16:48 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=jETnr+ie; spf=pass (imf24.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736774208; 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:in-reply-to:references:references:dkim-signature; bh=cv8gcZXVG0aCvRchUy6M5ty//7bnFqYv0xGdrXbuesA=; b=TSNeA6BQ6xRdCD3TnepCoyB9+WwM4TmrizueRe5qk2wyT1MkqwOvxNtUBcfRMBatCsyoKN IUVbeXubkIo7gdAz8qdkklfrRwaY+mIlBDKT+miHz22rfmNIpaqV8li2PiGuS87rI3U4wU H4sw//PPRHrKomsCG6IrqjPuYOGwlHk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736774208; a=rsa-sha256; cv=none; b=wY5MSYzKXolStDhOcPL2cTJxi8RQUi2YUeFFqkhontUwd9LqTMAPjc9thC8gIDiOdhbAyc 9vbsGQU9j8/S2uuiHsokCXsogXAe2PMRZKe9LfH3L54AdXhALMGOEGAMfA93IUFSWtfjzf sueQ5Vykin7HOcjVS8OmwYbTp1IAxQ4= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=jETnr+ie; spf=pass (imf24.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736774207; 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: in-reply-to:in-reply-to:references:references; bh=cv8gcZXVG0aCvRchUy6M5ty//7bnFqYv0xGdrXbuesA=; b=jETnr+ieyEH313V+te4mgQzw726+zcCfBc6oM/eGVNUPWs+8TWldUkG9hQr3D/1GhLNV2V WLYKntJLSZ0d5ssZqT7SQj4sAKpcnRCxDzAaTMSdbVBDT+oUZ93fD/QFmQ4pFOftLNLDwu sp3ab4rzAj3Tsn5kjfV7wsnIZOtczJo= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-448-70L3ggJmMAyuhFhQqzgvrA-1; Mon, 13 Jan 2025 08:16:46 -0500 X-MC-Unique: 70L3ggJmMAyuhFhQqzgvrA-1 X-Mimecast-MFC-AGG-ID: 70L3ggJmMAyuhFhQqzgvrA Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-386321c8f4bso2704206f8f.0 for ; Mon, 13 Jan 2025 05:16:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736774205; x=1737379005; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cv8gcZXVG0aCvRchUy6M5ty//7bnFqYv0xGdrXbuesA=; b=JtMMbdpy38zWIc8NgZe8FwOyXvbO/c1duG/6TFqj1erIxTFXFvtsTT2koT2hyp9WgX eg38BmWXh/JhavvgbSkmUMD414jJPbCLqjNscqqhHTNLfNn8jZqpCMKKbt9nujQ7gtKf ux/6j0BkLI//aBDPfhFLYHM95tTDDK58RwYNBLFsZXBkW9a2+64Xmze2YJkz/ZXIXKeF SvwNFGKudHdIbvMjI1t20zRzbALacSl4YwmRs0pDQBbAxT5LM1TGXgk7i9+JnQd4NfJn Mx5nr+Mxl3+x22KlYPtBDnvoaAGFf5EVmLAc4EqZ0eHtCEk1oBH2ZHauE5sjA0StIfvA upWg== X-Gm-Message-State: AOJu0YzhvcWIR5aSz9jt6rYAYHgepkzNXAyjIUpwPiFDX6pUUjIaCMLs r+8C3eXmTE+RAJDBGrq3RMMqIlKki2vc0PJ9gbB6ij8x05b6tzyxoDIRG/SntApmzxl0qWlJm78 gZrV77H8f+sYZJ7Nd1Is5bewSx8BW6tMgjErCz1arUTdChM7X X-Gm-Gg: ASbGncvFYjcVOCPBwFznvSN1E0WPyA5Hn1tj89PHO9i6BxVFb3V6C1JWiQG283JsXfe CsMWQLPFzqPtn3UFrfdtwtDKE5vJLhMwi4zrK/u2Mf2hBjLWvIt2t+ByHr8TwU/jVSWS+2TUcsn A1tUSkP2Cw7O/KJI4qRg7vsYrmAnuzunllYqJLP1fIwBGXotP8Vo/T3oqmBtKqdH/0LeyJ+UvZ+ bHh/kQgm82n2Xh96Nl5WDvaD+9eZDqQ6itN9ssq1TA3zA6H0MZP X-Received: by 2002:a5d:47a1:0:b0:38a:a11e:7af6 with SMTP id ffacd0b85a97d-38aa11e7bbbmr5899252f8f.6.1736774205624; Mon, 13 Jan 2025 05:16:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IHQTPL422wYOOzjgEgIHFmJ3rDpDAPc/5y/ASBw+pb+O+L0PBYtTTxIRKUApv2sGAZ8bIk3sA== X-Received: by 2002:a5d:47a1:0:b0:38a:a11e:7af6 with SMTP id ffacd0b85a97d-38aa11e7bbbmr5899222f8f.6.1736774205221; Mon, 13 Jan 2025 05:16:45 -0800 (PST) Received: from localhost ([2a09:80c0:192:0:5dac:bf3d:c41:c3e7]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-436dcceb374sm165750165e9.0.2025.01.13.05.16.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Jan 2025 05:16:43 -0800 (PST) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Muchun Song , "Matthew Wilcox (Oracle)" , Baolin Wang Subject: [PATCH v2 3/6] mm/migrate: don't call folio_putback_active_hugetlb() on dst hugetlb folio Date: Mon, 13 Jan 2025 14:16:08 +0100 Message-ID: <20250113131611.2554758-4-david@redhat.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250113131611.2554758-1-david@redhat.com> References: <20250113131611.2554758-1-david@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 5sO7C5sJ8uM7PX2ftSNEDg8fo8UsXgq2-7kcri7HRck_1736774206 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspamd-Queue-Id: 7005B180012 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: x95c4ku1tu57zqoi4pjn6awwxtd4fkt5 X-HE-Tag: 1736774208-480125 X-HE-Meta: U2FsdGVkX1+VgIVmH1eCOKHnM0DqK1WcDpQDK9NGvgIhmRQ2PraVJ++Wkizme7Ga3JU965Jk85JckwtPHHwMzBzu9dMKEb1g55aMwLw45PwYDvTYFESRQi8sO/oiGvEA4ug2jv37GcKtfBoG3e5oVc+e+3c8tqgpl0Fbunnub2gXdocqtcQjCaLsraBGzlZ3I4KWHnUyaEuDIYBhjSIzeAGIjEf8ekwSbR4BRo11OologfV/QTpnDKYeeIf+MTJhBD1gmB8HM2b9bgf3rut6kRmMVEFxgOea+yrNyT96gs4ABMyhonaJYUwC8BK1gV2wZb+jCmXvyiuNBAGTjToFjkUgeth6IXXzSxPTkA8G+NdFPViuHWHMmcRJv3MZ44GAyg1ibTAEwGL+Nv0JIQls+WiwuBFmtVBCykJ/q9nhYAkClISdgqZFgwNMO/gY9su+gendJtWnFFzbzWGm2Mvr6cTSbUnjo+ddYpCfsqb55Bkg2bz4ojBzHQsx8nsI58iXkSaLzscZEcBr02k65szafa9YHLMXCJWHfSGYKdm74DoQJgi9S3Qk9DCsdRcJ05IF5rp5UG9B2UEzi8z7j8AkNewHMwcGtuS2X3+DagiwFVxJ6UU+cL4J/l9iYfyYiFxd8kwdCjl/5vnmA43GG3Itpr7pM+1gFrvUDt5DA0QgkUKFpgysXlZ8f2gJktJ20qYSChJ4HCbsFxu1kT1W4dRloQ8cJ+3H9Ok0MFgUrueNHKESWZUgCHwOr7qhpiOKvn+DfFF65lWSO+p5Mp6FPppQrv1unNsb2IRE1/MDbRo1DmVJoRTXbe4qSu50pOUwKBu24cPZ8zmWSeAnURsiMskgz6scryfyH7iiOb5CBisqXgyf253NA7H3S6nivb9d/Kz0Una5nGpDSo1xKnwwLBp9opAwPIl02LlW+veYhpAfv10woHOluVc9MDp32k31ZAxbLt0VNrJ54brLFAnVPXl zA3wjnV2 Qc170ZGMCFy7fSsbZEPXGF1sTBw3JsnTbPYdkha4j7S4rMApK59qRz+VJqBWYBLhL0rwILLTsLUwSopDIGEH7fvOOGU8i4IHRS0pKUmYP4147hB5vld5teuUAMugBTRjWLWJa06Ra+WdpDxNUTPja5uiS/oE1fQ9bWqQamlQfpNaPDUhBfqMLym3HGGlNlrJ94Yfi5kaARXgR3mk3Bv0vJ3UloAg1Z0oRRvAZLkIev1CL7U5zJRv92yCkqLwVm2Il7ZDs+ZlMmGy+CPDoko8Ytn8QXID9pqHU3x1wIAo3FYBsfGZdWWJ3e0zELGGxxRq0tX+axD6C5BmiQUJ0zOeG7zN0UVzkZVjZlrZYcd2MkoKBH6TtwhU2/i3Lf9/JlEdbkqUOyT2JX7j3QuRAAmhxG3Uw0loa+9bGPFfJzhN7HT+Tpfnro3pdZMHjBJDkPAjySxALkRw+F560VkA7reWODVrKLrHNiDbj7FArCd4Da7qhHVbrwTWOkbmf/ywdAUp7rNLbX05TWK8+t1suRoU1T4eYsw== 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: We replaced a simple put_page() by a putback_active_hugepage() call in commit 3aaa76e125c1 ("mm: migrate: hugetlb: putback destination hugepage to active list"), to set the "active" flag on the dst hugetlb folio. Nowadays, we decoupled the "active" list from the flag, by calling the flag "migratable". Calling "putback" on something that wasn't allocated is weird and not future proof, especially if we might reach that path when migration failed and we just want to free the freshly allocated hugetlb folio. Let's simply handle the migratable flag and the active list flag in move_hugetlb_state(), where we know that allocation succeeded and already handle the temporary flag; use a simple folio_put() to return our reference. Reviewed-by: Baolin Wang Signed-off-by: David Hildenbrand --- mm/hugetlb.c | 10 ++++++++++ mm/migrate.c | 8 ++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index a93b508bc0e0e..95579bd8c4fe0 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -7529,6 +7529,16 @@ void move_hugetlb_state(struct folio *old_folio, struct folio *new_folio, int re } spin_unlock_irq(&hugetlb_lock); } + + /* + * Our old folio is isolated and has "migratable" cleared until it + * is putback. As migration succeeded, set the new folio "migratable" + * and add it to the active list. + */ + spin_lock_irq(&hugetlb_lock); + folio_set_hugetlb_migratable(new_folio); + list_move_tail(&new_folio->lru, &(folio_hstate(new_folio))->hugepage_activelist); + spin_unlock_irq(&hugetlb_lock); } static void hugetlb_unshare_pmds(struct vm_area_struct *vma, diff --git a/mm/migrate.c b/mm/migrate.c index 80887cadb2774..7e23e78f1e57b 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1542,14 +1542,14 @@ static int unmap_and_move_huge_page(new_folio_t get_new_folio, list_move_tail(&src->lru, ret); /* - * If migration was not successful and there's a freeing callback, use - * it. Otherwise, put_page() will drop the reference grabbed during - * isolation. + * If migration was not successful and there's a freeing callback, + * return the folio to that special allocator. Otherwise, simply drop + * our additional reference. */ if (put_new_folio) put_new_folio(dst, private); else - folio_putback_active_hugetlb(dst); + folio_put(dst); return rc; } From patchwork Mon Jan 13 13:16:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13937329 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 783F6E7719F for ; Mon, 13 Jan 2025 13:16:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D22426B0093; Mon, 13 Jan 2025 08:16:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CA9986B0096; Mon, 13 Jan 2025 08:16:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A39566B0098; Mon, 13 Jan 2025 08:16:52 -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 82EA76B0093 for ; Mon, 13 Jan 2025 08:16:52 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 33626C0293 for ; Mon, 13 Jan 2025 13:16:52 +0000 (UTC) X-FDA: 83002478664.19.6AF9681 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf03.hostedemail.com (Postfix) with ESMTP id D35FA2000C for ; Mon, 13 Jan 2025 13:16:49 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fn+0UZ50; spf=pass (imf03.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736774209; 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:in-reply-to:references:references:dkim-signature; bh=Owz/t4LPLm8R10JBYoc8bZ8ehYgkHbNPd81HY1H1C4s=; b=LyslKVk8SsZofBS3FUgWPz5eJROXnK0WBzHHGEeokC4g40+QPN9Of4HTNq/nng63SMWLjZ dFMs/GIwAa60Ud+6F9Wa8pGo76WdJNXTDKsjndKUqWkGek9RddjR8m3D1U1Ug+mBlYZbrE D6HWy3b/njFg3pdAp+Ks5FQ5CoNxnlw= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fn+0UZ50; spf=pass (imf03.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736774209; a=rsa-sha256; cv=none; b=EKQtdUHkX1nfsiXqiKCwau3VNqWkw3QJLH3XOnmkMYPF4KtsZvGsaUxYGMx6A4wDEcxd0Z 4cRVNhAdvuH+VKrkOSAVjcByo4yblLORDRDRCA9Uv4faDSR5k+EBdx7W+uAcI6lcRTFnHT p5B2/2L6Nf4UL0rm5uqt1XRqA5Qe27I= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736774209; 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: in-reply-to:in-reply-to:references:references; bh=Owz/t4LPLm8R10JBYoc8bZ8ehYgkHbNPd81HY1H1C4s=; b=fn+0UZ50ndRIbqoNpG5LsUgeQmgvax/7Gq6vnys6bWva0zsmjX011ywsQ4Q/yfEuI1FfgV tkyVTNqSCQ8g08EWX2eXaK3AGkCxlNfG8bLBmsgKmQhLEgV/cjEcvfepWavUUCMm9bQ7tA vDRL25tokHYImsuIkh0QLQ3+R/LOtB0= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-671-A6ahor4vMX-osp6rY6p5wA-1; Mon, 13 Jan 2025 08:16:48 -0500 X-MC-Unique: A6ahor4vMX-osp6rY6p5wA-1 X-Mimecast-MFC-AGG-ID: A6ahor4vMX-osp6rY6p5wA Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3862b364578so2441205f8f.1 for ; Mon, 13 Jan 2025 05:16:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736774207; x=1737379007; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Owz/t4LPLm8R10JBYoc8bZ8ehYgkHbNPd81HY1H1C4s=; b=g6wecxcYtm22CBlqpJxVEPFyJxfNEOX3ovUvzTCrnM1BI8IXaqn5xJcInEfRTNq78w IpEri8HxBnW31RuSKXnM9gFLnUGXZNptDw4SRXuKFPkcHnbELKctNbwktrYpK5yXPgzF O+mclpS1zB80ZHEuX4Tu1CheU0m+XRPNP9dqwBmMvbu0d/xD9Qj0wxNQNzNykqX3SBTS /Y3BpdgIQgqRbaa4NlBR+/I56rX7jVT5DDrZY/UstMs7Wxs73jCfpEKUSQlMgk0fw6OB cfHs5HoB1ybf/tiRKOUiI/cTXF14Y13K7V9yqnClG59uTeFdF/xuZUGTdv2Lom7YC/ws dtyQ== X-Gm-Message-State: AOJu0Yz2wC6ptNH4okFqfzvMy8+O0UlqN4kXWv/Qyh/Pvz+SS+9xyh9t aSbhh+H5dcZQd3XRzHYi7gi0xewCtmv6D3804s9YvTwkk2Kz6Zy0umChRZA/tY30b4vuS1XewP/ V/Pvy0slgZJqTEN7HuWFdUJgz9CHq4d8Qkmmy3Kd8bPCU1ldb X-Gm-Gg: ASbGncuO4+tzqm9i0c6mv+OlXVK4vM9+LiGN1Hsxj/G9KMqftYHcbByvH+Ryr0YKcnE 6hcyaQvR2ifDdqFPeXViLkOyLrroOtiqvpFZYyQrbk2N8jgPanmpDMfS50z2jL7OH+QYQX/r/Fl QJmWzDt/xHJQlwmSQlWequtkXixMSaiS+0/zI5eG9KHicSQPyt5ndpZT5e9fENBZJKK5JH3r5Wb 8zwFGLK/x802QW2SRZwdaQnX8U24YohKkvEJf5Kwl8ACnPneYg+ X-Received: by 2002:a5d:5f42:0:b0:386:4570:ee3d with SMTP id ffacd0b85a97d-38a8b0f693emr14694191f8f.24.1736774206982; Mon, 13 Jan 2025 05:16:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IEmlNBWKTxitwUU8z3/x/DgIgt/PZq5l0prYnPmi8qWosnAo/rWsMNVPpJ+h/+u9EwIDLlc0A== X-Received: by 2002:a5d:5f42:0:b0:386:4570:ee3d with SMTP id ffacd0b85a97d-38a8b0f693emr14694155f8f.24.1736774206584; Mon, 13 Jan 2025 05:16:46 -0800 (PST) Received: from localhost ([2a09:80c0:192:0:5dac:bf3d:c41:c3e7]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-38a8e383965sm12339069f8f.31.2025.01.13.05.16.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Jan 2025 05:16:46 -0800 (PST) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Muchun Song , "Matthew Wilcox (Oracle)" , Baolin Wang Subject: [PATCH v2 4/6] mm/hugetlb: rename folio_putback_active_hugetlb() to folio_putback_hugetlb() Date: Mon, 13 Jan 2025 14:16:09 +0100 Message-ID: <20250113131611.2554758-5-david@redhat.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250113131611.2554758-1-david@redhat.com> References: <20250113131611.2554758-1-david@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ecXvIR64Sw3UHAfjDfljt18OfS-GC3D5nYyJBmIAfnU_1736774207 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspamd-Queue-Id: D35FA2000C X-Stat-Signature: m9dhekt9n3erejzpoyyz1dhm1x4oqi89 X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1736774209-801990 X-HE-Meta: U2FsdGVkX1+v7EnpNzyEiCcmH0z0qgQ0JF2GczAiLeoD4dTwTpvOj4rsjpoClDd/KO9i/O0AnQykyIZL8oZPJAc3Z1Kcudbg45QQMBQyy6o2DFt3xrZJS1ekI6X5SBmCnArjdyduho2G/e/ryruRmw1e64dmQmTGsti/zoDxB7MveJ1gu9lu4RLlNOu2KLi5Cb/jMJkNyyik+jSjD4jiMkE/ZLz2/gi6nF/IWvGQFtZox3ZZqiRyQwXuho17evytkgn69aWETtzmTdf55YTK5eqCBUuf9XR09grVDkuDr6oy0HMDICFcngFv8A/muFXdjNPjqNa0RfcKUf4fCB0x2Ghhwl8YCNTu6BKlNbc0kXHqLL0pdf6WtkR5fpoJDnyaWdzWa1bIxKGFgy2GZNcf+YGlQ0PCcPJxEYJWtU6ScK+3IQb5/ufdSzR//8s3UvFVhgKfvBqHjDozwtJUDNyw88o+3M2h0Oex3kDV8RRjWhEYRng7U6Lew4XC0sroea452eT5+sIFaCFR2eTXuoNpu+vtHa6bGPiN4JDJNhJY6+yCgWvAAIKoomx43bPHfLznbJhP/R5RvEZLIYYxD7wWC0kOY9D9xKiX6Nz3UewE/o0hCSfADiaI+cq9gssifQZCpnjQmttHniOIZQ1sKN5PNcjRErKdFZtRRZGh5CTnMtFMbWIb5T4A4apYfr3cDl3P1xjFwI0Ax3gqoYfeB2ngcGyNQa7UEVzskeKx6xFK+mJ2ycbLPo/YvqFjgJe7j2SSXOAhRaVW5kPiknVAjT1I8g2BFUtWG8zXrlzwviUMT0i92dbqP68frUBBE9LQEla1y3zW5/E+sS1TgnLo1X8Pc/BRf7DDxZvTJX3LzhZJiBpYUFdSv7mfwujchR7D2SX4iB2IyrWxEN4zMVj+Ya2T8C5ARAJxTIw5hvFLektdoN29aXOOqDBiulygNiAhdiu4faXtlHX18Na8n+8aPPa HTY6LWOg 7Qu9XrdHF7JSK9SF3tMhhK5Rxsrbl9CEd0RrPkq00aexPqpksv5rshnN8DqOyvEL54Yz/6if5eDttI859IhEyA9QUC7iXIBY8WvjeRQ6psJQrsAeGZzcmLSYQwNg4UH4ZnuhqCdsgskqpOhZDPx7xlTcmv+diPXKu3i7U9YZso7Uuc7OBoIBBgcn3puSrY5WIA6YQuN7hadeYbVMshGxB2mhw6BhYeqX5LsO5nFUyZR25R9Yvw4/j2U1MA/UW31TyNt0DpBgfRbxW3WbJJXJVyVDAkPmrcNHcoBdUiy5dnU5d1fr46X+MmyegBHGCwllkJxWZJ0EA1lgTjTzCeZBuIQ1o9UneNUmZ9TOrgFdrKjI3+FgOq9rASOZVFHvumXrnLDrgt04/iitmFUxKSzLrer0BVNO2GIIfw1fRFJMb8JrUWdW1oUR6i0Xp1oRKSRICbgpeEGdNku52cuwJMN2LiNpN7cvYthTaFlZJWArxA20PEXf4OXEfM81+trerQFPQ4OjDKgWM/tp4PISDjC6jVknotA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000037, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Now that folio_putback_hugetlb() is only called on folios that were previously isolated through folio_isolate_hugetlb(), let's rename it to match folio_putback_lru(). Add some kernel doc to clarify how this function is supposed to be used. Reviewed-by: Baolin Wang Signed-off-by: David Hildenbrand --- include/linux/hugetlb.h | 4 ++-- mm/hugetlb.c | 15 +++++++++++++-- mm/migrate.c | 6 +++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index c95ad5cd7894d..ec8c0ccc8f959 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -157,7 +157,7 @@ bool folio_isolate_hugetlb(struct folio *folio, struct list_head *list); int get_hwpoison_hugetlb_folio(struct folio *folio, bool *hugetlb, bool unpoison); int get_huge_page_for_hwpoison(unsigned long pfn, int flags, bool *migratable_cleared); -void folio_putback_active_hugetlb(struct folio *folio); +void folio_putback_hugetlb(struct folio *folio); void move_hugetlb_state(struct folio *old_folio, struct folio *new_folio, int reason); void hugetlb_fix_reserve_counts(struct inode *inode); extern struct mutex *hugetlb_fault_mutex_table; @@ -430,7 +430,7 @@ static inline int get_huge_page_for_hwpoison(unsigned long pfn, int flags, return 0; } -static inline void folio_putback_active_hugetlb(struct folio *folio) +static inline void folio_putback_hugetlb(struct folio *folio) { } diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 95579bd8c4fe0..bc4ab45d9b93b 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -7430,7 +7430,7 @@ __weak unsigned long hugetlb_mask_last_page(struct hstate *h) * it is already isolated/non-migratable. * * On success, an additional folio reference is taken that must be dropped - * using folio_putback_active_hugetlb() to undo the isolation. + * using folio_putback_hugetlb() to undo the isolation. * * Return: True if isolation worked, otherwise False. */ @@ -7482,7 +7482,18 @@ int get_huge_page_for_hwpoison(unsigned long pfn, int flags, return ret; } -void folio_putback_active_hugetlb(struct folio *folio) +/** + * folio_putback_hugetlb - unisolate a hugetlb folio + * @folio: the isolated hugetlb folio + * + * Putback/un-isolate the hugetlb folio that was previous isolated using + * folio_isolate_hugetlb(): marking it non-isolated/migratable and putting it + * back onto the active list. + * + * Will drop the additional folio reference obtained through + * folio_isolate_hugetlb(). + */ +void folio_putback_hugetlb(struct folio *folio) { spin_lock_irq(&hugetlb_lock); folio_set_hugetlb_migratable(folio); diff --git a/mm/migrate.c b/mm/migrate.c index 7e23e78f1e57b..be9e3b48cd622 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -137,7 +137,7 @@ void putback_movable_pages(struct list_head *l) list_for_each_entry_safe(folio, folio2, l, lru) { if (unlikely(folio_test_hugetlb(folio))) { - folio_putback_active_hugetlb(folio); + folio_putback_hugetlb(folio); continue; } list_del(&folio->lru); @@ -1454,7 +1454,7 @@ static int unmap_and_move_huge_page(new_folio_t get_new_folio, if (folio_ref_count(src) == 1) { /* page was freed from under us. So we are done. */ - folio_putback_active_hugetlb(src); + folio_putback_hugetlb(src); return MIGRATEPAGE_SUCCESS; } @@ -1537,7 +1537,7 @@ static int unmap_and_move_huge_page(new_folio_t get_new_folio, folio_unlock(src); out: if (rc == MIGRATEPAGE_SUCCESS) - folio_putback_active_hugetlb(src); + folio_putback_hugetlb(src); else if (rc != -EAGAIN) list_move_tail(&src->lru, ret); From patchwork Mon Jan 13 13:16:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13937330 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 3B9F0C02180 for ; Mon, 13 Jan 2025 13:17:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE93E6B0099; Mon, 13 Jan 2025 08:16:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B98966B009A; Mon, 13 Jan 2025 08:16:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A14406B009B; Mon, 13 Jan 2025 08:16:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 7D17A6B0099 for ; Mon, 13 Jan 2025 08:16:59 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 26A48801B7 for ; Mon, 13 Jan 2025 13:16:59 +0000 (UTC) X-FDA: 83002478958.01.E69DF17 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf10.hostedemail.com (Postfix) with ESMTP id EC608C0003 for ; Mon, 13 Jan 2025 13:16:56 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XVeM09GP; spf=pass (imf10.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736774217; a=rsa-sha256; cv=none; b=4/mg1EcbTbzVSR0FDWr41uBGdOQ6LxtU8KAxdyx8VRXgZAe8OxL48gKh01LrwCLLTBRWPa f9vFin3Y4F4oybzjodj50SX2N+opU7iZZaoHdLB4gl9HjkBpG++FQJX2rbJp+DSKp8+eRS yWVaJe+4Lo4RuuFAbiqzSSDkJ6RJGRk= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XVeM09GP; spf=pass (imf10.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736774217; 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:in-reply-to:references:references:dkim-signature; bh=HRNEOcGf3GTMgcl4QTjKb5jV93l50oLMkY3MdRla6Ho=; b=hAMZ0jlXqk7Ig4EMt8bsKEpnsujUxFLd37vfkbrDwhXCITWqhfA1Rqqvdl3IP8R72FlRVr JDeFJR9TkyqihZddQPvUT8zbTPOq/bnOzsSHzQmVVd5SH39W+YukTN5XrT9F78BssXnBhg 2gpi2CdjTA2Q5b+2ciidexamivo+vlo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736774216; 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: in-reply-to:in-reply-to:references:references; bh=HRNEOcGf3GTMgcl4QTjKb5jV93l50oLMkY3MdRla6Ho=; b=XVeM09GPiVryyKNkNUnLgx4h+AEsRyObm+C+1Y9lFNP3BuiOpGUc0wlPTrmH5EfPyBYyCK gIy+LjqkIQAD59gbO/b+WWEhXO+zHsX/OTGhi9ma9Jx6ipBkWizorz9oS51Rz9D90DzBna CFMV9oQFSAeDat7pGY1evTtNOHs7NKg= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-107-hFd_s03JM-ajGMRAkKQrAA-1; Mon, 13 Jan 2025 08:16:55 -0500 X-MC-Unique: hFd_s03JM-ajGMRAkKQrAA-1 X-Mimecast-MFC-AGG-ID: hFd_s03JM-ajGMRAkKQrAA Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4362552ce62so23356625e9.0 for ; Mon, 13 Jan 2025 05:16:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736774214; x=1737379014; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HRNEOcGf3GTMgcl4QTjKb5jV93l50oLMkY3MdRla6Ho=; b=th7tyyiDyJQB0jCNM2tXixwaDk2NBnnQLgEsp+uMqvGHOHvuT8XYeMtyDP+3MGkXq/ 5yEUnP63UKxaGjbFyvPVeZRRJaEbVrp/+MqXAi+PWvZhx2c+2K2ipivM3ej0yLXtaLBx QQlh+c2uGCATytb2+F8Pl6Dnx8zztx/wPqrCtlmRhuVSaRK7OnfzeFVwft6jwepBLC9Q cBeMK7t2iFunWuBVBplecAZ0I2HiLxHvCVHlX3kUxalRCwv+6v7fcTArt1RXfYMj8ZIq 47ikFFQGh/dhriOON8bm4Himw6xrohGUy6EKY1L0R95Qbmsu2KEDQ8gmu/T+kBQr6p/u 19Pw== X-Gm-Message-State: AOJu0YxgFtSDf7/sJK8/O3CuBc2rnA/mb09cT2ELUlwmGvhfZMJs5pQK 73GjPMkT8FQ1XqXpKr1IqqRJfA2mROdjONcZVlqz9cbAtNfd6nEkLT3qJ6eoacWfV36Org74G1Z oQkWhEQTD7ExdDzqI06eo+SnHNO8XeewmBCMUt+wS8tBaOxiN X-Gm-Gg: ASbGncsR1+BBWJLkOYxC/rc2Po4JAMHELWvD8K8QXzt7cAvxmoNqOrSy2a/p08LTOVo ABUYK7l+OOhQ+w+xq5ym2af2T+x+aQQqnnrPB1h+sYBfX7LougK+pGfET5kprwM0V8hs7RSNcuS vroM0V4FlT46XvdABA3codlZ4jCuz67bOeOaxlFeO8RhMTFpK1Pe1PzNcptL+KZbwKGbmEz84eJ VQEEqFjSnmnS5oJZDZgymXkrxj2s7rnDhJ5vsnKuLSyEjVcpEQ1 X-Received: by 2002:a05:600c:3543:b0:434:f767:68ea with SMTP id 5b1f17b1804b1-436e2677c7dmr207456055e9.5.1736774213922; Mon, 13 Jan 2025 05:16:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IFKTq+E4NJrcYvXWDYuu54JFXgVM2MwdOi9Ma73C8Zz4ZeGeNjp6vUj/uympH2bo3v62O1gRA== X-Received: by 2002:a05:600c:3543:b0:434:f767:68ea with SMTP id 5b1f17b1804b1-436e2677c7dmr207455755e9.5.1736774213570; Mon, 13 Jan 2025 05:16:53 -0800 (PST) Received: from localhost ([2a09:80c0:192:0:5dac:bf3d:c41:c3e7]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-436e2da66d9sm179456795e9.1.2025.01.13.05.16.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Jan 2025 05:16:52 -0800 (PST) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Muchun Song , "Matthew Wilcox (Oracle)" Subject: [PATCH v2 5/6] mm/hugetlb-cgroup: convert hugetlb_cgroup_css_offline() to work on folios Date: Mon, 13 Jan 2025 14:16:10 +0100 Message-ID: <20250113131611.2554758-6-david@redhat.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250113131611.2554758-1-david@redhat.com> References: <20250113131611.2554758-1-david@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: qL6NW2CP1ozZj_6981OoB2j1-QKinL8T6sIPL4u9N_U_1736774214 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspamd-Queue-Id: EC608C0003 X-Stat-Signature: rijy6cyyjura3cx7cxk6937431493yim X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1736774216-348683 X-HE-Meta: U2FsdGVkX19KFe5/NNzP/4VwauQA1Hk3xgYr5EN6KoZ64MtpIQFO4HtReygPMWnvEyjzzzAlvE3YI74U+6c4qpQFROsRLaDw4616cTZ3gdVGTTD0VJGc6FHvoOdMo9hO8OVSRLTrOEn7vJUSK5EqSr/Bp/XW+VHjfFuHsUExlzblvknBEIxG8FPfLXXLDCZs5wH4JnczqrM3B0CRtXX89uqvbKnK2Cxq13yi6W1Eb9yX4w39XRqwJERU9tlqDHjkP0S2z231U412kuBHRLZu2xXGW3EuRRWZM3KAMjXqKnxgEDP87m6vGWtRfdXJ3E3zsUBaGuhUcFJ60zCgy8PzxFpA7UJ7Rmn1SdhXi2rQvsH80fAss5lZA9GvgGo4omCTp2TY5ssaQArOv1BJrNFxWOh7WdygMNOVYpp90MhUyMuAI3+AxACqvrSsCdXMLqeuiQu5zyxhTNQ024xXQk8Ru959lTUMrbjDShCsCFO5n/JJs3T+/3u4ex+ys+OydnN8OrEtaOqa4JRH9Dlf51qCOmkbYsiU05Vb4Zr4rOzzfxRfiZQYaWknPVE+HA27SFqREtY9zSxoYhV4reOTnSMpCHONXh2aH/W4bL1B4YUUAB+vZfCmwji2izw93x4nZ18YUJj6yrzqxkoi3zbDAGhCP60uNZiXCb6x/QX1Ch2LwyQR5XRvI8BBjmmn4bxBJE+fVNkfNv/8l3jsFcBrgnr3rt3Q37xrXRzWgoDgSbJxM6XS+R4tUbwFKIipKJDzm3bGEfvXX6Han8286hw3PPMUp3ap24mBaQAeVdh4XeO+mWpH+Uk6gOpuB4Vd3lRqSIJynH78sP12IcDc1AhCDVsTSIMHss+7ZlGW0CAwL0x3W+NYTpZ+rb2Y0xCvMWVGUKI9AM6oIfN+5rzkq51PNcOaJ79dvepNdUWFAcqaEtJEqbfZZBWJZeI0Dge4gWL5PMsa3AmldcivOeRIG4j76Wb Skag+mc2 3Iivq77sr17neQDAYI9EeAoGgtNwEpUVnHowEyWC3V4lXNIjrlEXkUXSU9/lFQqMmlHurQE988P7GjdfnIPocmIw/f+QYuf8osUir22CJy9rj0bFFR2uYsTxhOPmSnwD3CUu5lman0UfOxS+lOwhBtAJggWAwucRs98MMkeDG68Fz07WaE1u8gIzt7P0SxZz0WU+32iJJTeMkZxmgCOoIUTNlBvM0PeTHlAzu87TsoPQNfeWPQj99Fr2yXoS/MSof4zIiVhVRLbAfpGAGXiphDbVjL3CyqH/LCfh1k+5eSGeai85K03A5N2Pz8r8PqN4DVNqmq4v+/n5w6A5Xz4d1B4LF3u6T4cNei0jMbeL6q2up/Or0R+38HbvZ7FbNH+o2tFWfOHIAlPfbjfXNIEPwb5VfEzkp7TMQMD+QloPtIe8Jk4WyVtZBa7NVRB8/KNhpi+CzQJsFhaAFW3e4BoQABe3jnSlPOmIDpcS7YXFyoQ6LWeputnq7HzJkSG3g9un48K0Gq4FrKD+cAvYkFIn6b+Cs5EE6b0EgQI6o25/UCTNKzf6zOWOFCzWvNwdCUnUDJEBxXIfdIL/G9Uz4e94xpi/3SC3pHapXtszUWsT+cC3kLCk= 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: Let's convert hugetlb_cgroup_css_offline() and hugetlb_cgroup_move_parent() to work on folios. hugepage_activelist contains folios, not pages. While at it, rename page_hcg simply to hcg, removing most of the "page" terminology. This removes an unnecessary call to compound_head(). Reviewed-by: Matthew Wilcox (Oracle) Signed-off-by: David Hildenbrand --- mm/hugetlb_cgroup.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c index 89a8ad45a533d..bb9578bd99f98 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c @@ -195,24 +195,23 @@ static void hugetlb_cgroup_css_free(struct cgroup_subsys_state *css) * cannot fail. */ static void hugetlb_cgroup_move_parent(int idx, struct hugetlb_cgroup *h_cg, - struct page *page) + struct folio *folio) { unsigned int nr_pages; struct page_counter *counter; - struct hugetlb_cgroup *page_hcg; + struct hugetlb_cgroup *hcg; struct hugetlb_cgroup *parent = parent_hugetlb_cgroup(h_cg); - struct folio *folio = page_folio(page); - page_hcg = hugetlb_cgroup_from_folio(folio); + hcg = hugetlb_cgroup_from_folio(folio); /* * We can have pages in active list without any cgroup * ie, hugepage with less than 3 pages. We can safely * ignore those pages. */ - if (!page_hcg || page_hcg != h_cg) + if (!hcg || hcg != h_cg) goto out; - nr_pages = compound_nr(page); + nr_pages = folio_nr_pages(folio); if (!parent) { parent = root_h_cgroup; /* root has no limit */ @@ -235,13 +234,13 @@ static void hugetlb_cgroup_css_offline(struct cgroup_subsys_state *css) { struct hugetlb_cgroup *h_cg = hugetlb_cgroup_from_css(css); struct hstate *h; - struct page *page; + struct folio *folio; do { for_each_hstate(h) { spin_lock_irq(&hugetlb_lock); - list_for_each_entry(page, &h->hugepage_activelist, lru) - hugetlb_cgroup_move_parent(hstate_index(h), h_cg, page); + list_for_each_entry(folio, &h->hugepage_activelist, lru) + hugetlb_cgroup_move_parent(hstate_index(h), h_cg, folio); spin_unlock_irq(&hugetlb_lock); } From patchwork Mon Jan 13 13:16:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13937331 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 3096EE7719F for ; Mon, 13 Jan 2025 13:17:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BEAC76B009A; Mon, 13 Jan 2025 08:17:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B98B56B009B; Mon, 13 Jan 2025 08:17:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9EB616B009C; Mon, 13 Jan 2025 08:17:01 -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 7D9396B009A for ; Mon, 13 Jan 2025 08:17:01 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 39EC81C719F for ; Mon, 13 Jan 2025 13:17:01 +0000 (UTC) X-FDA: 83002479042.19.5670E3A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 20CF320004 for ; Mon, 13 Jan 2025 13:16:58 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="N9UyI/F+"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736774219; a=rsa-sha256; cv=none; b=vi8q1hOrQO72jklkxf6G12WvPhBlkWGLc6Ai3CRqufJse8FOUmyXZ4yfAmmIRfYoXJBmi4 hseWsyf86uN1nnOAkb0YXTWupgY3PV3e7R2xEDgSN4cdJXGUPVR5RAVsEJLGibgA1rR7o4 4bAjyLvD5svDySIV20BhdiR2Qp3ikE8= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="N9UyI/F+"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736774219; 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:in-reply-to:references:references:dkim-signature; bh=1WieYHqvNwLPc2kQdBClwQ4rx8s3Wr6RxbLoIHjGUPM=; b=c+OYcaIRi4KHOjXSVlq4WKWuDeAR5Pg4xxBPTV7tcY0xpvNYhuwd/LQ2+wHAO9ht8P4PZW qE+eFz0/fCi1ydzpgN9J2JC0FiXz+/fTTdN9ksmqiS2pRapmWX9mzbIB55kbSn9BdukChD IeFUHCaDlZyZn/wsQ8X5+P7tksKy1JE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736774218; 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: in-reply-to:in-reply-to:references:references; bh=1WieYHqvNwLPc2kQdBClwQ4rx8s3Wr6RxbLoIHjGUPM=; b=N9UyI/F+zKstNdCoqqt2T68B5u6D5Z4No681k7Cwi69RVmoF6Upmyc//RCkrRk+JvjwDE0 i8SNBW5ApJucRK9YDr48JLwN+E+sAvxtKv08NJsqtc01VzPGoOO60yyRfEzEQo+e2EHT2l FuNEljtwdNhQLIbw3TTCFfdvqpJ0C/g= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-18-Ico5UsdiNk2XK8rKeOdOng-1; Mon, 13 Jan 2025 08:16:57 -0500 X-MC-Unique: Ico5UsdiNk2XK8rKeOdOng-1 X-Mimecast-MFC-AGG-ID: Ico5UsdiNk2XK8rKeOdOng Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-385d52591d6so1868563f8f.1 for ; Mon, 13 Jan 2025 05:16:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736774216; x=1737379016; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1WieYHqvNwLPc2kQdBClwQ4rx8s3Wr6RxbLoIHjGUPM=; b=FYopN84g1JqKDwdmQwv6R7Ad235n7xssGzzO8nsYreJoRTn3FXKqEfac2yCu8Rjqmx ztBC8QX7peLKIHWITQTWV+0VOm9GFzRmZietJB7fiSP2bLs+ggwGBMP20V9gvrum4cFa VOXxZ0YEbcSbTxjSvMciEdciogdsevh8gisLA3yQ2VV5SE9G5ZfNFV/sDZsS7uZIOj0F qdQ1ekDUJzAXCYZA1abkKOUnK4t8wXY1fBCKh1yvdt8K52KuvpFPkraNx197+N89vUYd BSpx/Vm2xv7VAHsZIEk6sK41bCti6lzTzMlNZW2+ysvFJnuyujbs+vTqNxbgFFF6Yp7X zpJA== X-Gm-Message-State: AOJu0Yzf5Trr9C3zw3xZAfhLpeIfbEAc2wKRgoZ5LuIeKmPFOpf6rZUo 8vnBIYR5EbJMKLrkr8jqyLyWFgeZy/sqzi576preL/0056hUETcIo+4Q0MWxMzEJznRjYn/ZWKx uceZ4NHUwIo0eFprwdlQ0Ky56mkUiu6TgOEcxA+eOd6o9nzMF X-Gm-Gg: ASbGncuhoWp/EAmI902KSLiS96MMZT8tUUuiEIomiRxcYkDT4OSp7Zq8LrWkh7PSFX7 BT+roDaXZQM7AWWL0RT0l1mOjdY5CX6CuTH6LHR9eWeYI7nfUOgPz0a0+cEXLW6s6v6bgGU7Hdi mZrwEsUYKMUxsA0c6oYeJl6rNLM019iI3F9T57JSVxIs/H49pAFe5+ngNqQHcOj/Xt0bGcghI1S 49yzSTfYhk67qW3NhrnFXhV1sqsARuhU+pgqAbKTGRvWW0c8DZZ X-Received: by 2002:a5d:6daf:0:b0:385:f64e:f177 with SMTP id ffacd0b85a97d-38a8b0dafa2mr13358485f8f.11.1736774216037; Mon, 13 Jan 2025 05:16:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IHM8kqPNMvs4k+lMVb/1YEEDh2vMU1tnG15WGDH/BJuRUJ2BI9n6kMTuyVCDUkmDxXKO6pcnA== X-Received: by 2002:a5d:6daf:0:b0:385:f64e:f177 with SMTP id ffacd0b85a97d-38a8b0dafa2mr13358454f8f.11.1736774215697; Mon, 13 Jan 2025 05:16:55 -0800 (PST) Received: from localhost ([2a09:80c0:192:0:5dac:bf3d:c41:c3e7]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-38a8e37d0casm12226917f8f.11.2025.01.13.05.16.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Jan 2025 05:16:55 -0800 (PST) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Muchun Song , "Matthew Wilcox (Oracle)" Subject: [PATCH v2 6/6] mm/hugetlb: use folio->lru int demote_free_hugetlb_folios() Date: Mon, 13 Jan 2025 14:16:11 +0100 Message-ID: <20250113131611.2554758-7-david@redhat.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250113131611.2554758-1-david@redhat.com> References: <20250113131611.2554758-1-david@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: mgCK2gXd2AK1Q1_napO4yE_67l-VIG7OV55Yux1rUU0_1736774216 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 20CF320004 X-Stat-Signature: pd3uiurs46jbhgjqynzz59brxpzqz8h1 X-Rspam-User: X-HE-Tag: 1736774218-651669 X-HE-Meta: U2FsdGVkX1+61kwl5OctXOKr8j5m36QLbADLG+OVxbNu+vFeYf37G4U/ElO49f7SK+LguV2yNONGNGTVqpdiyXiRsR4LGDBywTSGUTzNoRPT3ppr4p0dBRuCLJSxJWwio4NuBr5+k+JRLivrvCaIBnFOpoltphYBmf4YpKbGbO3omwq5+2ko0w/owfsJ/Wbg4P0HhGODaWDlzaPxlHUIvwcDY+7JSoe75nneDxlMKLzsl4tMSyV8w9PG3LNokLvjY33veNrPmca8jqGTXDWyeuQ8Nz8AogcXkku2QbRlzvxdhkolpXgVbneQHFxH7TL747Q0+W8rv7SACdh72mGRuInpA92owaF5Ycag8vQTPXLiItmveyu7FktuNLxEbE0DFSalqGEorbd+HggNlXfst5/dG8zlZzoMd3TG1+cD6kCDSkhsPnlx1syQOTxAaLzAgJA2CGMmRbenNxIouc9uNrpLF7g3gbzwHlUUJ3grJT1O3epVbGu6w5eSRhythEd/qREzvHw7avt1NgucVL91uR+Z6XP1usGhvg0a1cAalCv80dUtix2iaX3rbTrd1VWFWWKeG978TEL3F+MadUwwITCNfVy3vJwijw8FqUPg5p0A1By/Z16iKlQ+w2onbv8D8SvuDKiAZUzBNF1rJYvHbBYtrnqv/ualR9bQ845CErxkG37AuafEDmMXSbEsKuEzsWGmH6W20fSpoywewm/MP6uURneZiGD8HJUY4wYa2h0s8MGSmb9a757smrThqtvZ0vFJ8vhBij/xTS2VBOTu/W/EdSRC5fCyPZEyL234PibselwntGJaYlZLcGIlrbCfHl9MfKY6R0FUtAzrj4J5vjVnyfmU+uB8yooPflvPax0a0Q5InNEKpOqrM1LniMmw4wLdrLjrL57mh7s/YxT+z1CWsRlQZJ9aySI+nQHYm7JBruWZBiH8PiCOWXs7Wsb6AMZoRpzJtkStFRxJuVo ZpV/zln+ IfRgU5ei05XZTvCxOqjSAZ+IASszOtaDbOE4cUOloug16ryFmtDPspM6pyePj5nYoyiNZ75oCRj7zrX/TNrEqGoC8+Nnt19AlGDiiJmegpm9/mQwXcyySTq4uHBTu8eigb4buT0UXPlc5t307FD0NdgsfHzozvv4KL20zI23esM2TGhaCis4+ztPsC7fI+YhHV2f05kELkPSJ+0bVN3M0f2ubVGAj43xbQGmEEtjeI7vVazuSgpLBba81Bvf0tCGPCvr5Fjr0OJv3p76ylpdluhboG5SZ+v0wY/aof2cMmTC06HWU9SOEFaFnK40ol3ny5CWr/u+9Nf89TxKuhEp4R+u+ODxezCT2MjR3jCn6dOVDVaS293vq9FRibuXeCwxDxqNguFy5136uEJpxo333OcMXRSQyBYppzWAh60Vk2OFUY6zVhHUND08qvIJ8nt3ISPwTcFt5DoqBpLUt9/QBHCn6JXpZOn7ZDzOVC9nsN+mRB73xYtBpa64GmBbuC7rvTx6eN0kP4CaJwV7mtyhig5PQ/mjwiwW/agBq X-Bogosity: Ham, tests=bogofilter, spamicity=0.000007, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: We are demoting hugetlb folios to smaller hugetlb folios; let's avoid messing with pages where avoidable and handle it more similar to __split_huge_page_tail(). Signed-off-by: David Hildenbrand Reviewed-by: Sidhartha Kumar --- mm/hugetlb.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index bc4ab45d9b93b..a94d52dd53728 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3822,13 +3822,15 @@ static long demote_free_hugetlb_folios(struct hstate *src, struct hstate *dst, for (i = 0; i < pages_per_huge_page(src); i += pages_per_huge_page(dst)) { struct page *page = folio_page(folio, i); + /* Careful: see __split_huge_page_tail() */ + struct folio *new_folio = (struct folio *)page; - page->mapping = NULL; clear_compound_head(page); prep_compound_page(page, dst->order); - init_new_hugetlb_folio(dst, page_folio(page)); - list_add(&page->lru, &dst_list); + new_folio->mapping = NULL; + init_new_hugetlb_folio(dst, new_folio); + list_add(&new_folio->lru, &dst_list); } }