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 77949C433EF for ; Tue, 14 Jun 2022 13:13:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0D9E26B007D; Tue, 14 Jun 2022 09:13:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 063046B0080; Tue, 14 Jun 2022 09:13:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E45856B0081; Tue, 14 Jun 2022 09:13:25 -0400 (EDT) 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 CF1836B007D for ; Tue, 14 Jun 2022 09:13:25 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A8F9F20844 for ; Tue, 14 Jun 2022 13:13:25 +0000 (UTC) X-FDA: 79576882770.29.7401BF9 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf29.hostedemail.com (Postfix) with ESMTP id 3E6FF120089 for ; Tue, 14 Jun 2022 13:13:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=BtkNA8bnFXUJxG1GIdprNfyVDGg3vDC4/9ZoY+WLPSM=; b=Z2ye09vqFR1lmMOiossGHXii+D 1wF8QAsAmmHJj97pPcgWinAavHDonjKZM6REYxB3Fe2if2x9jCl0cbMyAPGBYqfkQdhOlutpC4EPT WEqg+GhmvFzyu+30/QaPmJaNJtPBFG5EzWD9U4QNP2LnnnsHhWyP0wrX4axmyrpPhMpMcQfUTJXJ+ g6SHnuQTwJ/3xY7ux3tdAvN4Do2w/i7fj/me18UCKVYbYwSU4s5uSb2YOwhQOFDzLmYOEgAB7we3G fI9tpreRaRNLkklkScS2+JOmvG1hcfm7nr64LdAbhh7BZLLoncG6LGypsiNLogMp1cj1+2+PCHib4 ZiajdU0g==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1o16M4-000BS0-J6; Tue, 14 Jun 2022 13:13:12 +0000 Date: Tue, 14 Jun 2022 14:13:12 +0100 From: Matthew Wilcox To: Miaohe Lin Cc: Joao Martins , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Dan Williams Subject: Re: [PATCH] mm/page_alloc: make calling prep_compound_head more reliable Message-ID: References: <20220607144157.36411-1-linmiaohe@huawei.com> <20220607113257.84b1bdd993f19be26b8c4944@linux-foundation.org> <65e5da9c-32d1-17d7-d8c6-96cbfac23fec@oracle.com> <4a30f026-789a-9235-2fbd-f553e4d7b45d@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4a30f026-789a-9235-2fbd-f553e4d7b45d@huawei.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655212405; a=rsa-sha256; cv=none; b=ZfvpoxsBRouOy7TA/lKY6SqkPTlKmZv9OENKuNEkPhDevV3VzCYZO1PHqXzs+gKMvkKmnR bKyC8PgUwwZq7CVDNP85WdJ90NfnRy6wjCI5rxuJj1XCIXqzxSNieowbMDhLIafAodeKE/ fF0pR71VoYzgJUUemsMWv2aRTm22RQ4= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Z2ye09vq; dmarc=none; spf=none (imf29.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655212405; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=BtkNA8bnFXUJxG1GIdprNfyVDGg3vDC4/9ZoY+WLPSM=; b=xi4om3PuEF/zEXaplg1fVfVa7n54UfAk+7WoAB80vWL/xV/HZXqHtVIeVpwHLhs1vnaJmC JiFxX+JM2S3+iSfs+JCXW6YCY619/LxGYSPp/s+6qKTwJiEVrRd83yNv0fJf+Cz/aETyjT INkUaUShWaaiWAjyy+YDrYjkH/2sDYo= X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 3E6FF120089 X-Stat-Signature: kyr6t7izomcngzu8jy69dwas3qpq5equ Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Z2ye09vq; dmarc=none; spf=none (imf29.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspam-User: X-HE-Tag: 1655212405-535015 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: On Wed, Jun 08, 2022 at 08:17:35PM +0800, Miaohe Lin wrote: > +++ b/mm/page_alloc.c > @@ -6771,13 +6771,18 @@ static void __ref memmap_init_compound(struct page *head, > 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. > + * The first tail page stores compound_mapcount_ptr(), > + * compound_order() and compound_pincount_ptr(). Call > + * prep_compound_head() after the first tail page have > + * been initialized to not have the data overwritten. > + * > + * Note the idea to make this right after we initialize > + * the offending tail pages is trying to take advantage > + * of the likelihood of those tail struct pages being > + * cached given that we will read them right after in > + * prep_compound_head(). It's not that we'll read them again, it's that the cacheline will still be in cache, and therefore dirty. Honestly, I don't think we need this extra explanation in a comment. Just change the first paragraph to reflect reality and leave it at that. > */ > - if (pfn == head_pfn + 2) > + if (unlikely(pfn == head_pfn + 1)) We definitely don't need the unlikely here. > prep_compound_head(head, order); > } > } > > Or am I miss something? > > Thanks! > > > . > > >