Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2937366lqo; Tue, 14 May 2024 14:14:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWzBg6FHPjuVcR3XyxXaJe80cnzCO7r3/33yDYEh2SSf1415qQWHwhQ+2s9jtuNlC0CPQ2777rssPlfwR4sOhN/f7R40nPD1NXjnWbYow== X-Google-Smtp-Source: AGHT+IHACdCUvFpN3te5oLvuXvHtFeTRoi9PorN5BpNCyoyFw2CKnSkSbHHEjyH//7pRQc/We7wp X-Received: by 2002:a2e:8010:0:b0:2e6:f1f6:7dc5 with SMTP id 38308e7fff4ca-2e6f1f68028mr6985101fa.39.1715721288278; Tue, 14 May 2024 14:14:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715721288; cv=pass; d=google.com; s=arc-20160816; b=P7XxTTeZa/YHRxzI8X4Z+YD4YfeBqJ/hmXTbNwkVNWv/NFVNu8cs0FWKt2HYVi1EBq COwAcdMy4/XM3gyRfLageQuvb/wpMEhknVHQ3qZxRV7CHTgza34dTTiDYK6cr82+Q6Ny ToGxikeJtnhGQ8QWTO1w0WQkA9BpPqntb8lW1BV5MQta1VFoVTAE6rbgiwx4ieQtxQ+c GK4kZdzrlEps/lf0vl7Utbl9xZed3Gml8FhqkA+eR2wNi+6gTPb2NGujIjJbdUuvwpVW tf2YlvhGrNkWoKY76V8InMUvRLeENQNE3rSig/KA3rAsqXmxdSPdqBQkhOiCcLGi+s/2 aQaQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=MCYxMqHlXfwZDOft8FR/g9E5omranZHw8AUMVIKKvp0=; fh=R142QkvnqRGUzZcY/di7yG+uIyDSnv2W2Umv0A9ZlKM=; b=bcMXQ6q5tIXe4Z5sNy7qC6E5Zxsp+sc4Jy8FnhiGP9GSosz6uDmKmEnkgPBJDelZ/2 dZQJmuUW95eHENddgHmio4GJHt5qdhriISjFjeINvRoOF4WSSqArnz647WoswvsPGVyU S20yxV9od55Plk3HpIsauESxOMOGMW0JF36zSxFhNU17nZQqygeJMGJJsLRe/FIH2bGf F2qm+twH+r4WU3j0w5Vqh5HdhnYJmxlUdB4DgmZg65zv1YxliK8zwUG2cGHspXEZM+sl IfjlEWTaDs1nL6HjcRqIn4pyW2ZHA84KNtisrKmoGKBp7E3VyHYuhup/3CDWr2ELyfmu YT9A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=SxFKmuF+; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-179177-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179177-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-574d3fc502asi2064378a12.47.2024.05.14.14.14.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 14:14:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179177-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=SxFKmuF+; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-179177-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179177-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D87801F22BB3 for ; Tue, 14 May 2024 21:14:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 06A99181B98; Tue, 14 May 2024 21:14:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="SxFKmuF+" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 03E501E491 for ; Tue, 14 May 2024 21:14:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715721281; cv=none; b=TeAgp5kMr+ONBnb8bKA3vOcgmjbr6zMP4fq6Q4TG6g6DtYGiIjgzD7AVB2GhIwDvslbyNbAa1f1R4g7+CGxITMU/8pZlQz6MXfOQAO+wCQJgUslXM+lXf0EK2YvR7SvB4dQK+ui9MQE0aihslW1WquxTbu+Zlze4tk60WevFNbY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715721281; c=relaxed/simple; bh=+78pNISfXCXpQc/XQQZsCUs23dG3BM2mGKmH6j0NNjk=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=a5/mkMGu5K/lwc7r+ECXgB5yPg2GjQ26kL7XAEjWrTGXthvvVYEGJQxxXKnIIdjgmlB6m9gUI1Jy5R/nRE//pAww4n8tS6B9UOBxJh/Epu7YJ11a6GpRohHIa5vFzdB3BG3f9pqD8Gx1f3x1HhFKJsjyQdmEIuAIsCUI3Fppd9A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=SxFKmuF+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32221C2BD10; Tue, 14 May 2024 21:14:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1715721280; bh=+78pNISfXCXpQc/XQQZsCUs23dG3BM2mGKmH6j0NNjk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=SxFKmuF+sG0UZJmAeOxtF9ZMQb8akcIRfMvgc4391rbSl8yD8FT5GFt6CEIaj2pUF BSxBbwuptHGht6iv9I0uFiD44IZkm+fk/dycCHQ5+BDlhFO9ETq0+SDZpTDiJQ74Kb W9KNmasRY5erD9X5YWKD0cYUdg/rHHrCSmPBDM2Y= Date: Tue, 14 May 2024 14:14:39 -0700 From: Andrew Morton To: Miaohe Lin Cc: , , , , Subject: Re: [PATCH -rc7] mm/huge_memory: mark huge_zero_page reserved Message-Id: <20240514141439.55fba39c81c1af55c9a100e1@linux-foundation.org> In-Reply-To: <20240511035435.1477004-1-linmiaohe@huawei.com> References: <20240511035435.1477004-1-linmiaohe@huawei.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sat, 11 May 2024 11:54:35 +0800 Miaohe Lin wrote: > When I did memory failure tests recently, below panic occurs: > > kernel BUG at include/linux/mm.h:1135! > invalid opcode: 0000 [#1] PREEMPT SMP NOPTI > CPU: 9 PID: 137 Comm: kswapd1 Not tainted 6.9.0-rc4-00491-gd5ce28f156fe-dirty #14 > > ... > > --- a/mm/huge_memory.c > +++ b/mm/huge_memory.c > @@ -208,6 +208,7 @@ static bool get_huge_zero_page(void) > __free_pages(zero_page, compound_order(zero_page)); > goto retry; > } > + __SetPageReserved(zero_page); > WRITE_ONCE(huge_zero_pfn, page_to_pfn(zero_page)); > > /* We take additional reference here. It will be put back by shrinker */ > @@ -260,6 +261,7 @@ static unsigned long shrink_huge_zero_page_scan(struct shrinker *shrink, > struct page *zero_page = xchg(&huge_zero_page, NULL); > BUG_ON(zero_page == NULL); > WRITE_ONCE(huge_zero_pfn, ~0UL); > + __ClearPageReserved(zero_page); > __free_pages(zero_page, compound_order(zero_page)); > return HPAGE_PMD_NR; > } This causes a bit of a mess when staged ahead of mm-stable. So to avoid disruption I staged it behind mm-stable. This means that when the -stable maintainers try to merge it, they will ask for a fixed up version for older kernels so you can please just send them this version. To facilitate this I added the below adjustment: (btw, shouldn't get_huge_zero_page() and shrink_huge_zero_page_scan() be renamed to *_folio_*?) From: Andrew Morton Subject: mm-huge_memory-mark-huge_zero_page-reserved-fix Date: Tue May 14 01:53:37 PM PDT 2024 Update it for 5691753d73a2 ("mm: convert huge_zero_page to huge_zero_folio") Cc: Matthew Wilcox (Oracle) Cc: David Hildenbrand Cc: Miaohe Lin Cc: Naoya Horiguchi Cc: Xu Yu Cc: Yang Shi Signed-off-by: Andrew Morton --- mm/huge_memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/mm/huge_memory.c~mm-huge_memory-mark-huge_zero_page-reserved-fix +++ a/mm/huge_memory.c @@ -212,7 +212,7 @@ retry: folio_put(zero_folio); goto retry; } - __SetPageReserved(zero_page); + __folio_set_reserved(zero_folio); WRITE_ONCE(huge_zero_pfn, folio_pfn(zero_folio)); /* We take additional reference here. It will be put back by shrinker */ @@ -265,7 +265,7 @@ static unsigned long shrink_huge_zero_pa struct folio *zero_folio = xchg(&huge_zero_folio, NULL); BUG_ON(zero_folio == NULL); WRITE_ONCE(huge_zero_pfn, ~0UL); - __ClearPageReserved(zero_page); + __folio_clear_reserved(zero_folio); folio_put(zero_folio); return HPAGE_PMD_NR; } _