From mboxrd@z Thu Jan 1 00:00:00 1970 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 F0791C43334 for ; Tue, 7 Jun 2022 18:33:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 43DD56B0074; Tue, 7 Jun 2022 14:33:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3ECF16B0075; Tue, 7 Jun 2022 14:33:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2B46A6B0078; Tue, 7 Jun 2022 14:33:00 -0400 (EDT) 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 18F8A6B0074 for ; Tue, 7 Jun 2022 14:33:00 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id DD45612095C for ; Tue, 7 Jun 2022 18:32:59 +0000 (UTC) X-FDA: 79552286478.10.32DA603 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id AB3C11C0003 for ; Tue, 7 Jun 2022 18:32:36 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 75AA861564; Tue, 7 Jun 2022 18:32:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23F75C385A5; Tue, 7 Jun 2022 18:32:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1654626778; bh=6EWeMUW4V3uJswyhJrlu4wS327ebt1gLFVtjQxZ6kwc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Pl0ITDp9k28djGN0qnztfygHz/ItO1iNYIxf2ZyNiMyFwJ2nWuUlWCIy6OpRtHl+d C1/GjByo284UIQ7QGt6iyzD0bB23lhLejK9IXqu3J8LrAVWvuU+fbuCAxL0wXRTrKC B5EmdlY3zLwNP+mHzd8A3GT74eASErBQfosc3fg0= Date: Tue, 7 Jun 2022 11:32:57 -0700 From: Andrew Morton To: Miaohe Lin Cc: , , Joao Martins Subject: Re: [PATCH] mm/page_alloc: make calling prep_compound_head more reliable Message-Id: <20220607113257.84b1bdd993f19be26b8c4944@linux-foundation.org> In-Reply-To: <20220607144157.36411-1-linmiaohe@huawei.com> References: <20220607144157.36411-1-linmiaohe@huawei.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: AB3C11C0003 X-Stat-Signature: x4qy1zaib3aq6xx6fnppmywngbuadqsr X-Rspam-User: Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=Pl0ITDp9; spf=pass (imf18.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-HE-Tag: 1654626756-400928 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: Let's cc Joao. On Tue, 7 Jun 2022 22:41:57 +0800 Miaohe Lin wrote: > compound_pincount_ptr is stored at first tail page instead of second tail > page now. "now"? Some identifiable commit did this? > And if it or some other field changes again in the future, data > overwritten might happen. Calling prep_compound_head() outside the loop > to prevent such possible issue. No functional change intended. > > ... > > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -6772,17 +6772,8 @@ static void __ref memmap_init_compound(struct page *head, > __init_zone_device_page(page, pfn, zone_idx, nid, pgmap); > prep_compound_tail(head, pfn - head_pfn); > set_page_count(page, 0); > - > - /* > - * The first tail page stores compound_mapcount_ptr() and > - * compound_order() and the second tail page stores > - * compound_pincount_ptr(). Call prep_compound_head() after > - * the first and second tail pages have been initialized to > - * not have the data overwritten. > - */ > - if (pfn == head_pfn + 2) > - prep_compound_head(head, order); > } > + prep_compound_head(head, order); > } > > void __ref memmap_init_zone_device(struct zone *zone,