Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp763934iob; Thu, 12 May 2022 04:16:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxlH/FgmXKK+3tOpWapfQgPS1IpHfVv5PeoB3Sb1pog8jqkrEbb9DCKK+v5G96leHkDHKN X-Received: by 2002:a05:6a00:2444:b0:4fd:db81:cbdd with SMTP id d4-20020a056a00244400b004fddb81cbddmr29261386pfj.32.1652354213952; Thu, 12 May 2022 04:16:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652354213; cv=none; d=google.com; s=arc-20160816; b=lMrnHaGFq4uFSLElNs94c2JWHn8/qpulpaWJmU141dVurHA5WhzeMkP6C0wBlBNXvl 2VsEtXjl0+Py9CEgLNZdNqTSOjg9pqLwg4oFhwjvLikP6iTnaGbiixUNXIYYOgCDyVWi OOAIeLyibB3lbyiDXPwl6GYu9SbF6+MC5rynINO1+NryJOFuh//48VYbpVIJ2gmSkiFw rZLDJYh5BRGq7JBmQdSCb1LsvYE9p5fSkigVSMPL3notiq2a+vatfyaqnNBzDdjMkI4a UQp039Z+5Xb/NOqduSu8xW1n1FKJcftLFUnglmzVjB0bsyrSmuoMhW8Nlt/Kn1DGVsIt /suA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=WS0DbLZONXbA0qlsoFzcwV+1Vi1nadOcsbXwV/JeJTs=; b=QFZ+tqLS1TppF0ENBDP+SBXgqS4/OBzsB05Bi/fbFXjOW1OgvX8Fgn0Aa3BTbJD17J YfTvA6Q77lkbJaHVvZQHNQme29QG7G3864t+JacObb+NwG0WWakkXdPOLzLVt0Je6fgm 1MV4uR+rYo3Ii7uEQc0wGHN4GVp7Hmt68Q973UDAr+FZgIYjzJ/OwLmgIPTErXOOSIpK hBdPNjNtvGgsQR+qzMqWGrTLQ4ZL1HkIHk7+stPwQ1uBxWXaFjNgqjkxXljyaEnrm2II L7cAZMOYRP7Vj527h4ZphNi19xNrGhEJk0BZvxojD4u2GRMP+CVcS6ts1A7KbsgWsrju TQtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Mnk3xql1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e17-20020a17090301d100b0015ebccf1e98si6637022plh.563.2022.05.12.04.16.40; Thu, 12 May 2022 04:16:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Mnk3xql1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349162AbiELAf5 (ORCPT + 99 others); Wed, 11 May 2022 20:35:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349693AbiELAfs (ORCPT ); Wed, 11 May 2022 20:35:48 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14537634B for ; Wed, 11 May 2022 17:35:46 -0700 (PDT) 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 sin.source.kernel.org (Postfix) with ESMTPS id 61AC6CE27A9 for ; Thu, 12 May 2022 00:35:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2014C340EE; Thu, 12 May 2022 00:35:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652315743; bh=uxmwQjcc5w9P8/ZBtZYbLtOFtxd71WhJTlltZhYOd+o=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=Mnk3xql1gcp07bHdLvrpCMUuhXH1uzi5OBQb+Ul+Gju38PpV9Y9QfvVmg8X53hmkf xZK1XipMLOOxaPj2zRKkLwVa3rWxEttVmx/Z1L3f7ggdRZKtjKTHf0NvTpBNIPbTA8 /+MuO0uL63+Xi1RTZ6x27WSsI+MAv+VE+PByM/myRwRmMI+PHF/TBqCdf5APdGgjeu NRrR5Evrc11ZO5ciIRFFNsALEGtWhTN30wVyUwQ/ltdKtE1XNM1foL8JoOa/GI9nsS CVyXwHeMxvoRDJy10+1dAaNCbrUQyYu5/nDVQQ7Df58Sl2wIN07XLne07HLmWohXmc B4pH4yEejGq7Q== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 356825C05FC; Wed, 11 May 2022 17:35:43 -0700 (PDT) Date: Wed, 11 May 2022 17:35:43 -0700 From: "Paul E. McKenney" To: Minchan Kim Cc: John Hubbard , Andrew Morton , linux-mm , LKML , John Dias , David Hildenbrand Subject: Re: [PATCH v4] mm: fix is_pinnable_page against on cma page Message-ID: <20220512003543.GA2043693@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <54b5d177-f2f4-cef2-3a68-cd3b0b276f86@nvidia.com> <8f083802-7ab0-15ec-b37d-bc9471eea0b1@nvidia.com> <20220511234534.GG1790663@paulmck-ThinkPad-P17-Gen-1> <0d90390c-3624-4f93-f8bd-fb29e92237d3@nvidia.com> <20220512002207.GJ1790663@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 11, 2022 at 05:26:55PM -0700, Minchan Kim wrote: > On Wed, May 11, 2022 at 05:22:07PM -0700, Paul E. McKenney wrote: > > On Wed, May 11, 2022 at 05:12:32PM -0700, John Hubbard wrote: > > > On 5/11/22 16:57, 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? :) > > > > > > > > > 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? > > > > > > > > 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. > > > > > > > > thanks, > > > > > > Let me try to say this more clearly: I don't think that the following > > > __READ_ONCE() statement can actually help anything, given that > > > get_pageblock_migratetype() is non-inlined: > > > > > > + int __mt = get_pageblock_migratetype(page); > > > + int mt = __READ_ONCE(__mt); > > > + > > > + if (mt & (MIGRATE_CMA | MIGRATE_ISOLATE)) > > > + return false; > > > > > > > > > Am I missing anything here? > > > > In the absence of future aggression from link-time optimizations (LTO), > > you are missing nothing. > > A thing I want to note is Android kernel uses LTO full mode. I doubt that current LTO can do this sort of optimized inlining, at least, not yet. Thanx, Paul