Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1044148iob; Fri, 13 May 2022 20:52:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeE1ErGxGEmqqKpnTPK3WgAqfPjiIaK8iCojT2G/6z9YpysEF7mM50H8j32d6fyq8AvIdt X-Received: by 2002:a7b:c5d0:0:b0:389:fe85:3d79 with SMTP id n16-20020a7bc5d0000000b00389fe853d79mr17764088wmk.77.1652500329225; Fri, 13 May 2022 20:52:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652500329; cv=none; d=google.com; s=arc-20160816; b=Y4X7SviyXjPX5pMhWs7IFnRcjWwPVV9T18RXQx0lXExRFN+WFTo9XV9mUFqbLpcPQ7 kaWKzvcGMumc3z12dXcTK+yu8ah0fWJCsQfJOmD929DmnAyOiDiLUNyB24b/EHZbVrxi voJsblgcUOqGCeDPcK0UqxM8NopCzdpPkBlfua15AU6EUZzoH4dTOHh+siUA//nZwoG8 xcAvzxPMdCyyFWFRbg/gQiY3tS2iInN5PZm6Kj4YL2iV4VdNPe8WLvKfuHwhAJeH5rI6 jHd3GXX2Ia6eQ1rbjRm3nSqBHZDCNZBh/IN+u8eXAe7a3ftpbEcep7SYWjkD1yhcuCxI Fvhw== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=YzFXSZxGmGSXKrpoxhKMarCqVBVEsKmErajixcy/MMU=; b=b+E7hRpY/ENTkjyJ9i/enqRApwT1/Q2UQto9Fhh9XE46NBj7SqBFDjNBOfrv/sqxoS jMfOusDNgjRY02Po9yXFZTDZ4Gma4XJmU61YzJB9JEOKWvg07yIzkrjIZc3RXtsRtFAN XlX+aWJnVF+G18laauAWytLvm/nhg3HqowiYVqaVjx7gtuUCA8BY7ffC0PePKDG1qH/Y CVz5OA8C7wdUcn2/mswEuWN3tyWiAo5Z8KMDJnnJfVvhopmXk31Yxy9l8sooUNx42+Z1 KoCkGz90m7Bnnq1jNmBHnt3hqtkQWHxnocNTX2fRhNRTT+QrhiWLPStgpze0nzHvM0Oe 6jFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Z7Xz3sS2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id g5-20020a1c4e05000000b003943f8ff692si3792983wmh.48.2022.05.13.20.52.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 20:52:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Z7Xz3sS2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 207CF47DEB4; Fri, 13 May 2022 17:24:49 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349782AbiELBEA (ORCPT + 99 others); Wed, 11 May 2022 21:04:00 -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-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: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no 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: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.