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 9463FC433EF for ; Thu, 12 May 2022 00:12:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 226F06B0075; Wed, 11 May 2022 20:12:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1D6D16B0078; Wed, 11 May 2022 20:12:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C4706B007B; Wed, 11 May 2022 20:12:09 -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 F02B16B0075 for ; Wed, 11 May 2022 20:12:08 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D05C631471 for ; Thu, 12 May 2022 00:12:08 +0000 (UTC) X-FDA: 79455163536.10.BB92F98 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf17.hostedemail.com (Postfix) with ESMTP id 29D22400AB for ; Thu, 12 May 2022 00:11:48 +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 ams.source.kernel.org (Postfix) with ESMTPS id 61738B82676; Thu, 12 May 2022 00:12:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08C12C340EE; Thu, 12 May 2022 00:12:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652314325; bh=x80aVd3yLVAjF6xWo0HCUHHYskzQhdBCwzdwrac0c50=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=p7uG09Kv5Zco88w6Cr+BU70V05hjAQwEtq/8uZC0+esSxgDCADpYtuFNPVQ/ZcH28 /IZIb3noao/oVzU6Z/omNe8fdh/Dpxzjw0fCtlEQgt06K/+V+1dqwl6jn+Qn7r2Bp6 b24tKjpdx4AhKTA76FJuLqg773eYWOQ200a57d0BvWpPRFp6FCmI3HQU1WBtggk96d AJfnWNGYK/VL3i7mam+KsSN0F2NfIDEk2gYVe4U2kt+HqYkpZx6er4GMYUFSVQFDIH qnDt3CIiAAj9CYP6MVQjDIsoH4Ji2X3METgQgx6MGMDKOmGPLMr7LotgBizYYaB8S8 j+0UFsBpDb8vA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 940605C05FC; Wed, 11 May 2022 17:12:04 -0700 (PDT) Date: Wed, 11 May 2022 17:12:04 -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: <20220512001204.GI1790663@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <2ffa7670-04ea-bb28-28f8-93a9b9eea7e8@nvidia.com> <54b5d177-f2f4-cef2-3a68-cd3b0b276f86@nvidia.com> <8f083802-7ab0-15ec-b37d-bc9471eea0b1@nvidia.com> <20220511234534.GG1790663@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 29D22400AB X-Stat-Signature: dwos6pz77rqbywymqq4iw9wbcrf7kk73 X-Rspam-User: Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=p7uG09Kv; spf=pass (imf17.hostedemail.com: domain of "SRS0=2I+2=VU=paulmck-ThinkPad-P17-Gen-1.home=paulmck@kernel.org" designates 145.40.68.75 as permitted sender) smtp.mailfrom="SRS0=2I+2=VU=paulmck-ThinkPad-P17-Gen-1.home=paulmck@kernel.org"; dmarc=pass (policy=none) header.from=kernel.org X-HE-Tag: 1652314308-379776 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000006, 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 04:57:04PM -0700, John Hubbard wrote: > On 5/11/22 16:45, Paul E. McKenney wrote: > > > > > > Well no, because the "&" operation is a single operation on the CPU, and > > > isn't going to get split up like that. > > > > Chiming in a bit late... > > Much appreciated! > > > The usual way that this sort of thing causes trouble is if there is a > > single store instruction that changes the value from MIGRATE_ISOLATE > > to MIGRATE_CMA, and if the compiler decides to fetch twice, AND twice, > > Doing an AND twice for "x & constant" this definitely blows my mind. Is > nothing sacred? :) Apparently there is not much sacred to compiler writers in search of additional optimizations. :-/ > > and then combine the results. This could give a zero outcome where the > > underlying variable never had the value zero. > > > > Is this sort of thing low probability? > > > > Definitely. > > > > Isn't this sort of thing prohibited? > > > > Definitely not. > > > > So what you have will likely work for at least a while longer, but it > > is not guaranteed and it forces you to think a lot harder about what > > the current implementations of the compiler can and cannot do to you. > > > > The following LWN article goes through some of the possible optimizations > > (vandalisms?) in this area: https://lwn.net/Articles/793253/ > > hmm, I don't think we hit any of those cases, do we? Because here, the > "write" side is via a non-inline function that I just don't believe the > compiler is allowed to call twice. Or is it? Not yet. But if link-time optimizations (LTO) continue their march, I wouldn't feel safe ruling it out... > Minchan's earlier summary: > > CPU 0 CPU1 > > > set_pageblock_migratetype(MIGRATE_ISOLATE) > > if (get_pageblock_migrate(page) & MIGRATE_CMA) > > set_pageblock_migratetype(MIGRATE_CMA) > > if (get_pageblock_migrate(page) & MIGRATE_ISOLATE) > > ...where set_pageblock_migratetype() is not inline. ...especially if the code is reorganized for whatever reason. > thanks, > -- > John Hubbard > NVIDIA But again: > > In the end, it is your code, so you get to decide how much you would > > like to keep track of what compilers get up to over time. ;-) Thanx, Paul