From nobody Fri Dec 19 07:43:42 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD7A61F94A for ; Mon, 13 Jan 2025 13:17:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736774224; cv=none; b=JBspWW62djoCZpuohQK0N06XXMgWvMZgpVHeWtpfT1m3duqhHKvfX8c5aJsb+BqqIwwnz2obtp0KQkUn4RDbxw7bjp6PvQIYGf8nI5ma5wkRDUS3JNXGUbR2OYaWrd5nTvVQK5MXxQ6TF/OdxXUEdPKr3ynN3qZRFeGIIDxmXWM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736774224; c=relaxed/simple; bh=ZO1hSVqmhl+b3CMSxqEoN4E0FWwDIHc0yaZyGGttpug=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bIDPaSuJiOtSP+JvYA4HNY3N39XW1zTeeU3jsOYpXCD2WHMwPh18nSH04v0ZPhJpfbM5zrT0I4TytNsPpnsbirjReq8prR1mcltP8OzBCstWFVNG+5OOnO7FQ/9CrnFSWhC13yIkPIb/XGjY7nHngxGB9f/urIthzH7wZqPetLg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=FB3a2qU4; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="FB3a2qU4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736774220; h=from:from:reply-to:subject:subject: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=1WieYHqvNwLPc2kQdBClwQ4rx8s3Wr6RxbLoIHjGUPM=; b=FB3a2qU4GiijLeuTW5b+6NeaBiGGAaRYBGSo3ZjCV5jUv1ZFo2vAmxofBl2bZwt+qeOc0M BDuxl5OCf+4Qdg4YADuuYHMT50M+A6vaQWgOgkRO1zUmiYx5Zl/Gd2y0f17xHJUpaCq+1Z MEcTvJTjoQvYHRhUYhCg5LhkTG9hESg= 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-247-HagaH-8CM6SnRTc7TSGgvw-1; Mon, 13 Jan 2025 08:16:57 -0500 X-MC-Unique: HagaH-8CM6SnRTc7TSGgvw-1 X-Mimecast-MFC-AGG-ID: HagaH-8CM6SnRTc7TSGgvw Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-38a891d2aa5so2159559f8f.0 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=eKOzOPKMySQ2caegCuoIbj9N+i2BQOwnjO+ZPdUwOL3vWmy4C471/8hlzToOyEveyp sLvIOa42sUGUk+WZIBep7afy0qr1JoVrXFql+rKE5HTGS3SHE4rWn0eDIwTCoRJ/mT54 cJFpjx1ElozrGrg6TeUPPmXKNCp9rOoZLRx0xEejmewRXk5FP8NtEQheWMRJdH4iKwy4 1jBFgcadc3ZMzZlsAVWMZtWCH+YRfWBtfDVL+XbQ5hul8mSWrsUVlm8cbEuI6QZtD7QM InLIh7svhsFPeF55oPDy+oIWN4RcacmQ4EQIhLwwn0rUNdhfsdfvQxp9iLDs/GjWJ2/q 9gqA== X-Gm-Message-State: AOJu0Yy02rFCrIO9iHbuxehyeMRZ3pjLqfKD1sjZdLmhNR3bUOR7Zlmf SizN8gVZ6ZPxfiY4sRiFgQ50RjTymCGqkb3KAwfvWH0aGzd1rSMwrMuhdMyw2lrAsHmngQi02l6 QerY9FqZzMDvptcSVWB00Mb0mSpgZ5dBPVyxeVLNfRv2gzlfMreV4dd3FEGDiOufiR0QCiUxuOf 8PdHiKIvJa/b0DOX9Xgwmi5MxkHTzIhlznl6eTLNrLGukO X-Gm-Gg: ASbGncuC/FpTQtqb4ei/Gbq0jvn/AfUYPhElKaN4xVNAtLKymLrLnGPzNTiBrRWh0bW tt8LLWItbIaKi2NN8gyFpGcqkLclzJdVrYFv0OGlu7/SVeQyzxdjHPm+345DNrNcogbKzIx+ikR oPokOPUIUpsD83GI7dS5odmSxsTJ+U/gBa1X0lW5heAyKEDGi2XnALD0L7I7ibXcymjg3Bb09Xl Gmup01z7K0Nd9oYed8u0HD+sX6jv8NTeCcwknMaPcNU/KiZp4mB X-Received: by 2002:a5d:6daf:0:b0:385:f64e:f177 with SMTP id ffacd0b85a97d-38a8b0dafa2mr13358489f8f.11.1736774216091; 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 hstat= e *src, struct hstate *dst, =20 for (i =3D 0; i < pages_per_huge_page(src); i +=3D pages_per_huge_page(d= st)) { struct page *page =3D folio_page(folio, i); + /* Careful: see __split_huge_page_tail() */ + struct folio *new_folio =3D (struct folio *)page; =20 - page->mapping =3D NULL; clear_compound_head(page); prep_compound_page(page, dst->order); =20 - init_new_hugetlb_folio(dst, page_folio(page)); - list_add(&page->lru, &dst_list); + new_folio->mapping =3D NULL; + init_new_hugetlb_folio(dst, new_folio); + list_add(&new_folio->lru, &dst_list); } } =20 --=20 2.47.1