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 A29B2C433EF for ; Thu, 12 May 2022 03:57:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 616858D0001; Wed, 11 May 2022 23:57:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 59E806B0078; Wed, 11 May 2022 23:57:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B3658D0001; Wed, 11 May 2022 23:57: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 3FE446B0075 for ; Wed, 11 May 2022 23:57:25 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 26432601D5 for ; Thu, 12 May 2022 03:57:25 +0000 (UTC) X-FDA: 79455731250.08.9528266 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf29.hostedemail.com (Postfix) with ESMTP id 9591E120003 for ; Thu, 12 May 2022 03:57:17 +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 9EB72619AC; Thu, 12 May 2022 03:57:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBCBFC385B8; Thu, 12 May 2022 03:57:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652327842; bh=53MI5L2TTsXVrR0+maeQDB6x59/snOKRo6bSDL9T59o=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=elZql7crJ753Qa6Q6fe8U2r0/+q0xdzvdkEGMgmS8yzt0Mf1Xn3FDsdZ7k3CuHXoo B09ww8MkDgFtXmnjAHxwUtw9LFqtL670fcLx+eI+PFKmg8Y/8fDUBTj8LAKL9lReAU vq7PO4mH3R3DtXwzjYVRjI4y3GLSXC6UGBXPttn3ttl4XhF49jaz8sq+uH1u2KK0Wa aSNN3rcVSE5cDvgXE5M7on4nTk8X7OlCFDKpmGu6PX6MTReOpC90ZhjfveqWvi+OT6 wy+zCBUTFvErK+dFxMez9HVDEYJ/6+CLjH7u/NbuQQyxGG7EJFmZpTnVynVfll0A6a Z/jvEkTiKMu8w== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 5FF835C05FC; Wed, 11 May 2022 20:57:22 -0700 (PDT) Date: Wed, 11 May 2022 20:57:22 -0700 From: "Paul E. McKenney" To: John Hubbard Cc: Minchan Kim , Andrew Morton , linux-mm , LKML , John Dias , David Hildenbrand Subject: Re: [PATCH v4] mm: fix is_pinnable_page against on cma page Message-ID: <20220512035722.GL1790663@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20220511234534.GG1790663@paulmck-ThinkPad-P17-Gen-1> <0d90390c-3624-4f93-f8bd-fb29e92237d3@nvidia.com> <20220512002207.GJ1790663@paulmck-ThinkPad-P17-Gen-1> <20220512004949.GK1790663@paulmck-ThinkPad-P17-Gen-1> <0accce46-fac6-cdfb-db7f-d08396bf9d35@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 9591E120003 X-Stat-Signature: f5rbzhuc5u8pwrkauoeqy95caedb47op Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=elZql7cr; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf29.hostedemail.com: domain of "SRS0=2I+2=VU=paulmck-ThinkPad-P17-Gen-1.home=paulmck@kernel.org" designates 139.178.84.217 as permitted sender) smtp.mailfrom="SRS0=2I+2=VU=paulmck-ThinkPad-P17-Gen-1.home=paulmck@kernel.org" X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1652327837-469332 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, May 11, 2022 at 07:18:56PM -0700, John Hubbard wrote: > On 5/11/22 18:08, John Hubbard wrote: > > On 5/11/22 18:03, Minchan Kim wrote: > > > > > > > > Or there might be some code path that really hates a READ_ONCE() in > > > > that place. > > > > > > My worry about chaning __get_pfnblock_flags_mask is it's called > > > multiple hot places in mm codes so I didn't want to add overhead > > > to them. > > > > ...unless it really does generate the same code as is already there, > > right? Let me check that real quick. > > > > It does change the generated code slightly. I don't know if this will > affect performance here or not. But just for completeness, here you go: > > free_one_page() originally has this (just showing the changed parts): > > mov 0x8(%rdx,%rax,8),%rbx > and $0x3f,%ecx > shr %cl,%rbx > and $0x7, > > > And after applying this diff: > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 0e42038382c1..df1f8e9a294f 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -482,7 +482,7 @@ unsigned long __get_pfnblock_flags_mask(const struct > page *page, > word_bitidx = bitidx / BITS_PER_LONG; > bitidx &= (BITS_PER_LONG-1); > > - word = bitmap[word_bitidx]; > + word = READ_ONCE(bitmap[word_bitidx]); > return (word >> bitidx) & mask; > } > > > ...it now does an extra memory dereference: > > lea 0x8(%rdx,%rax,8),%rax > and $0x3f,%ecx > mov (%rax),%rbx > shr %cl,%rbx > and $0x7,%ebx That could indeed be a bad thing on a fastpath. Thanx, Paul