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); } }