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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 940D1C433EF for ; Thu, 12 May 2022 01:04:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349784AbiELBEB (ORCPT ); Wed, 11 May 2022 21:04:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244841AbiELBD7 (ORCPT ); Wed, 11 May 2022 21:03:59 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A42F6FD14 for ; Wed, 11 May 2022 18:03:57 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id 31so3208446pgp.8 for ; Wed, 11 May 2022 18:03:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=YzFXSZxGmGSXKrpoxhKMarCqVBVEsKmErajixcy/MMU=; b=Z7Xz3sS26Xj8FvLqt4cX8EjKc0XNm1zZohZUe5c0G358Yb5n36jVW9H0RikEXRgfxS 54x9k3rizbf+Wv3uutl5yQ86B5MkjRAU4fIZx1Mmg+Rw2+KYHew3fHP3sym8mAyx+W6m 30I2o5JO2MpJM7aESRASihDhdo3IThm4mHp+iRAZBqGKIymsgGQL+R77ih+IOTmIRKRM bXFCUsNM7/kVSM5XCwavx2BQSomZh2Newf5/921cIfRu93hptHITn3rWbXXfLj7JQPut IA96QUXBhIPM+nHPK5ED2tYLm0ImajXx2YzpNVERrbrMJHQjY5jsmW4S0YCuA3YHw2Cs O1LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=YzFXSZxGmGSXKrpoxhKMarCqVBVEsKmErajixcy/MMU=; b=SjfdXMuyaU++dT7EFyjNwblFRD92/CYlIJDmL+pjOnPUfjr3gKBN9vfD+S0gGYmJUG Jo4KLLJsEFTomCGbXFg3QkUo+C1VygHfVt0VYCE16912bMLKjPUWWH9BM+ixWoPhM3Ui 4RgeQmZXDg/ZKAuQ1rdlHuMfRMt8yWom1mZsEzq77XAvLDK1vb/PleOw/V1o+d7wSbiT lHc8f5m687gyd6asp2YB6EOuWu/ik21+QXRlaecZafz5DPQ+BilTbVEoSPrbq1NSDyGF RfvMpffY4R/lpV8IlIwmFKIgdHW926PrkVSPl+OmaYz/VTMy3ZYYQy5hD6aWxnh+8qUS xZLQ== X-Gm-Message-State: AOAM530O4sPCGu/fY1D2kSo0jyihs18FOs3gAVMcXjk2j+j/Moxq8Q// ksCFJlms+Zyd9KgX1RimdXI= X-Google-Smtp-Source: ABdhPJyY6dSsLzH3mjIMEuwXY4gMz4p+SK5XnFgWDsWYY31BI0/Qk36ETSD4JGyoQkWaK2KW7J69ww== X-Received: by 2002:a63:834a:0:b0:3db:5307:6115 with SMTP id h71-20020a63834a000000b003db53076115mr1963000pge.134.1652317437032; Wed, 11 May 2022 18:03:57 -0700 (PDT) Received: from google.com ([2620:15c:211:201:69ef:9c87:7816:4f74]) by smtp.gmail.com with ESMTPSA id c5-20020a170902b68500b0015f0dcd1579sm2578305pls.9.2022.05.11.18.03.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 18:03:56 -0700 (PDT) Sender: Minchan Kim Date: Wed, 11 May 2022 18:03:54 -0700 From: Minchan Kim To: John Hubbard Cc: "Paul E. McKenney" , Andrew Morton , linux-mm , LKML , John Dias , David Hildenbrand Subject: Re: [PATCH v4] mm: fix is_pinnable_page against on cma page Message-ID: References: <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=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 11, 2022 at 05:34:52PM -0700, John Hubbard wrote: > On 5/11/22 17:26, Minchan Kim wrote: > > > > 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. > > Thanks Paul for explaining the state of things. > > Minchan, how about something like very close to your original draft, > then, but with a little note, and the "&" as well: > > int __mt = get_pageblock_migratetype(page); > > /* > * Defend against future compiler LTO features, or code refactoring > * that inlines the above function, by forcing a single read. Because, this > * routine races with set_pageblock_migratetype(), and we want to avoid > * reading zero, when actually one or the other flags was set. > */ > int mt = __READ_ONCE(__mt); > > if (mt & (MIGRATE_CMA | MIGRATE_ISOLATE)) > return false; > > > ...which should make everyone comfortable and protected from the > future sins of the compiler and linker teams? :) Will take. Thanks.