Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6671773iob; Wed, 11 May 2022 02:49:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwb7arYin8EVorWqm64xjxegHQlY6i/toce6gXUG3Pe31G6z2cKE4w7kINhmhvBnyCqA5i X-Received: by 2002:a17:90b:194d:b0:1de:bc01:21b1 with SMTP id nk13-20020a17090b194d00b001debc0121b1mr4494908pjb.67.1652262554841; Wed, 11 May 2022 02:49:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1652262554; cv=pass; d=google.com; s=arc-20160816; b=IbtqIMbnFK7J742rgXoATAdMuqj0HXwXeO9RMzZ/a+Uee26BqdkR449pGa920wunyP aPVomi3Fi3VUSXZpOvVnAzmRBmYbrtxAV/AoSCZW00g5cdu1V9hZ4cCK5HYls4awYQhy 9n4f5CsPIiueZ9miYcgn4FmQyEqZ1Np4zdKSTZcYBPncSlh/d2bAuLDJWowr6BFFnQ5Y 8KYp3XKigWAB3fSCLW+wM2BFi00A6BFZprfIPb2Cek1U4rb3qZC8/DFSBJvmUqy9s+FA XkydnvUIQ31BAVsEnqUzRosLvfv73RkeO/yR4Tq0W+UTQ849BzM2jcb2y7LaZ2De38fM 2RVw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=E9svdHHg8y5jfdsixMh/oDs7XTRwYoOMtwZiFwLmQUY=; b=qM6MqcIK5P0vDmx7obKAxsK/jnUnm51ix0j+VtwiqZFzLO+S5lVAMDNOZ6APAzn/GN YiRqhQIjzD75wfWbvWMCCiPh+UMRWvUZbtcQtMjf7oZPWfvo9N0TTdyO/YmYXzuCFgZA hTd0Tt/SVPXMEfMOuZRePvx4zujQpWEHhnXwxxEkBfNooRYgtwE4LHV32d6K8N5EqiLp QrR9e5jGyf6yQYvwlcLPIjzUiCvv6a5zjjd7eBgfpaTRW0OjQ1436Ak+SfxGSVYN0OWN UYsd12Nro8jYbGjTD5Z4ExX3gv4+WZ3V/qjsaY1b/j3oWENuiVOgTvO+ogCdASBRCR/i Eb5Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=AAiDFbA+; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); 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=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j13-20020a17090a840d00b001dca4bd019esi5586964pjn.135.2022.05.11.02.49.03; Wed, 11 May 2022 02:49:14 -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=@Nvidia.com header.s=selector2 header.b=AAiDFbA+; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); 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=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233512AbiEKEcN (ORCPT + 99 others); Wed, 11 May 2022 00:32:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230518AbiEKEcK (ORCPT ); Wed, 11 May 2022 00:32:10 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2049.outbound.protection.outlook.com [40.107.220.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C91DB87A1F for ; Tue, 10 May 2022 21:32:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PJ6imAXoPoKRpTPX53V7Rjwq++cTEuSp3kT4OZNL4EVASft2mtSEg44h7sDl59zPiy07faIfCSonMLB5w+ekqcGagT0aClPlQ8pFkazv4HuSHYRJ4PDtOikTUtkMW/nw7Ego3OP3d5R5mzgDRlpMB92i6nDsJl5M7jJSHbIjcehjS3oP3niExrEAwxzSgz9iX+uVzIFJpVXoletsCwXHed9SVpqLuXV/oTOs5dbOHdgy3kNLWfmc4HonVv1eaaG6QbPxh3K3YeBk8l7k4Mf1CbGxNse/a2s07yYrwn/2JiaKtqpzQFbeg+/QIeTLakJ7NpdW7mMUmCI07KUAvEZ0kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=E9svdHHg8y5jfdsixMh/oDs7XTRwYoOMtwZiFwLmQUY=; b=YIvAwoLH6oeU1MizSWwwsyeMkhM82fYv8SQQTFdJmQyFDtxH8Z90vXhS9H+tzKPvQ71I/xFZ+GRchYfnfe1kfIdw2bR703o7x9ff3Bnc93sGZtPtgVRcET4dF2XH+zW2KdB3K8Cx9nbwv3Z51uvrmf6M0JDGovWCJ0cYdhtSnGjkYs9H8AvTXkvKd8joByqty2+EB0GsMtrGeivLcLHigHH8K9EV8Vx5gA194ORSKPNz8R9f/Ty1HJvhp0XMsdXjCDxCkUZxfQLhvIz0+B66DV93HNV1tz4CasfJvXBZzIUGRZ79YZi3rO6w2cJS38IBJE9mXV/0UUeJKy7YwFl7dg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=E9svdHHg8y5jfdsixMh/oDs7XTRwYoOMtwZiFwLmQUY=; b=AAiDFbA+1qgdjqv6wRTYAj4pLO3FmXCMIKx2L9dCvdApr2omM7FQIxLBCBBn3D3a6XSrqPvMIz4Hk7gT3mM7mnJWK2bF2aQRYchy5Wzo24XAP6vMsT8Vz470zRPX9VXGiBUCcV7LxaquRnwohkEogOy8qbqUn8dVZ+qkfrAC7ymTNl7+nrVAiHDgc9jeNXwRP9KmU7aQBIIeTFfgF4K3CYtfnrUbvKYzPR//vmvayKU3kEMEihhmjX1S0ceIao0JBAHqqK7BzgZ6ULt+HhUoOKHHLaFqOQ/xGKbLGeG5lE0EmuXg3xKdRJbWoXVB9IMAAGG0c+pW+mq5qFydmqHiKA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BY5PR12MB4130.namprd12.prod.outlook.com (2603:10b6:a03:20b::16) by CY4PR12MB1765.namprd12.prod.outlook.com (2603:10b6:903:120::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.23; Wed, 11 May 2022 04:32:07 +0000 Received: from BY5PR12MB4130.namprd12.prod.outlook.com ([fe80::15e3:d746:57e8:4de0]) by BY5PR12MB4130.namprd12.prod.outlook.com ([fe80::15e3:d746:57e8:4de0%7]) with mapi id 15.20.5227.023; Wed, 11 May 2022 04:32:07 +0000 Message-ID: <2ffa7670-04ea-bb28-28f8-93a9b9eea7e8@nvidia.com> Date: Tue, 10 May 2022 21:32:05 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v4] mm: fix is_pinnable_page against on cma page Content-Language: en-US To: Minchan Kim Cc: Andrew Morton , linux-mm , LKML , "Paul E . McKenney" , John Dias , David Hildenbrand References: <20220510211743.95831-1-minchan@kernel.org> <857d21da-5de2-fa3e-b1ce-41cc1cfb0191@nvidia.com> From: John Hubbard In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: BY3PR05CA0017.namprd05.prod.outlook.com (2603:10b6:a03:254::22) To BY5PR12MB4130.namprd12.prod.outlook.com (2603:10b6:a03:20b::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 901f9b20-e396-4881-8264-08da330734d2 X-MS-TrafficTypeDiagnostic: CY4PR12MB1765:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P9/ChZDmbupPi0IoyAmedTTnKaJZiL55inFqycrpzV04xC4cjnCJqXttrf6hQEyyLnvhQMzr+gjFQnHHy2MhJt93Zjm9YijKHKy8ER/z5VseI0tO+zGcHKQtQXvP8refFZ6fpwEM6/V3cqyFoO8n6pRXZcaPb7qXgGtrLe1Vlgq5u86FT76BshZpGEHDQEb+UlK410QRs+XXKQBqhqt9lh27AG/nE1Y4TCknK+bqx1IPJ9OufO7zcOrWlaMNiL+tA8TtBzDza0T80UgecIH45uhNKRyLWPw3yX3r8CIGVYaV0yoiWJkazAoMqhSxyFiwcP/fh/XwiLi6dshaD9X/2L6YgO7Hef18UDMXmscJ+kZTngIK88C+tdF9gBk0aFf3ehZcb4vfKtMnvBxEF81y1EfwwRpSH6hyLQIBYURcRmi7ym60emI7h1CNg11ALQ/92xFqL4luehUbgPLBUosCORMuHa7ZkAClOXGKrmXSV33N/P9hhKnDktNhmxvbaaZS9mzPbOiZCC1ADy6v+Gz1vN+lTh3FDMmAAN8Dmxq5+aQHVhG/1jWCYA4kvGN79bdw5W+H5n4eJywMVTxgNFqmSczlgO3te2MftaeoJpmNKgofcXd7r5vejpmKQzxNDpu4CGXbasOxzECB/C7FTrI6Qw7gGRBXi6pjPfylwMbGbbL9vSfwHDSUaoaGjr+wMTjUDTV6FDGGetbl7U9hFNb76coftBi+tC7IeOz0LnRjsOhub1qRgRV/+/JZRdKr5Kn8DQ+Yk074Wv0ifD96AMq2zcDPBo+uv9lIbj/Iub55NEJVqdfww6X4R3XG36/Jj7CnSHd8lXlrxJgd6fqYKvAjmQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR12MB4130.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(53546011)(2616005)(26005)(83380400001)(6506007)(31686004)(38100700002)(5660300002)(6512007)(8936002)(36756003)(2906002)(508600001)(66476007)(66556008)(66946007)(4326008)(8676002)(86362001)(31696002)(186003)(6916009)(966005)(6486002)(54906003)(316002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?amRGc2VXTytpbW95YnJSRkZ3aEg2aFVIZWMvb1J2dzAvTFgxRm1iR3U0aW00?= =?utf-8?B?UnhIZVpZUHMwYTdJZFRQMmMvTjUrNDBRYks2Vk1rRFVWSmFiMnhuNno5YTFM?= =?utf-8?B?SURSYldnTnliK3JyR21aVXFMNlliVWR0OGprQUtIVHphQWNHcGZQMEZkdE9K?= =?utf-8?B?VURhMFl2VTdXcmNsZWhlWlV2em8vUlVFTDhlazZLM1l5YkxpNlVpMWNWRzFB?= =?utf-8?B?RGM3VnBHQUFiRkpwZUdkNVNveE9jMWRMU3VWSzJmNWRuaHVFSGNCQmhrR3ZG?= =?utf-8?B?ZnJoZD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3IzcE5zYWxOaTdSMURDOTV5?= =?utf-8?B?c0psbkNZRzYvbWtkdnV0YlRrV1FnOHVUZTVDV0RLY3gzMnFUR0x4SjloNnpa?= =?utf-8?B?S2t4K29aK2RtRnRXcG1XZS80YzVRT3JoOCtsU1diVnJueVRQYmhOeWY5OWVa?= =?utf-8?B?RmQyaUhVdGRxbWdwMCtkUDJ1M3ljLytlZlMwTjkvakFMMHc2NkgrT3VtaDBh?= =?utf-8?B?dnR3dHdtcG9OUHUrSVZZOEkvRW9Od1lZYkliSTNaZFJDdk9pWmJvQWhpc3Ny?= =?utf-8?Q?nhanZ7V92/DkzXlA=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 901f9b20-e396-4881-8264-08da330734d2 X-MS-Exchange-CrossTenant-AuthSource: BY5PR12MB4130.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2022 04:32:07.2064 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uWfCs36sfmTfBRTwRmLqnVljetpOut2cIKat5FezH9qmXhEQ3UyMD9f4qJKg1NUbFtv0A7qLxilloKUOwzIoVg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1765 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 5/10/22 17:09, Minchan Kim wrote: > On Tue, May 10, 2022 at 04:58:13PM -0700, John Hubbard wrote: >> On 5/10/22 4:31 PM, Minchan Kim wrote: >>>>> + int __mt = get_pageblock_migratetype(page); >>>>> + int mt = __READ_ONCE(__mt); >>>> >>>> Although I saw the email discussion about this in v2, that discussion >>>> didn't go far enough. It started with "don't use volatile", and went >>>> on to "try __READ_ONCE() instead", but it should have continued on >>>> to "you don't need this at all". >>> >>> That's really what I want to hear from experts so wanted to learn >>> "Why". How could we prevent refetching of the mt if we don't use >>> __READ_ONCE or volatile there? >>> >>>> >>>> Because you don't. There is nothing you are racing with, and adding >>>> __READ_ONCE() in order to avoid a completely not-going-to-happen >>>> compiler re-invocation of a significant code block is just very wrong. >>>> >>>> So let's just let it go entirely. :) >>> >>> Yeah, once it's clear for everyone, I am happy to remove the >>> unnecessary lines. >>> >>>> >>>>> + >>>>> + if (mt == MIGRATE_CMA || mt == MIGRATE_ISOLATE) >>>> >> >> With or without __READ_ONCE() or volatile or anything else, >> this code will do what you want. Which is: loosely check >> for either of the above. >> >> What functional problem do you think you are preventing >> with __READ_ONCE()? Because I don't see one. > > I discussed the issue at v1 so please take a look. > > https://lore.kernel.org/all/YnFvmc+eMoXvLCWf@google.com/ I read that, but there was never any real justification there for needing to prevent a re-read of mt, just a preference: "I'd like to keep use the local variable mt's value in folloing conditions checks instead of refetching the value from get_pageblock_migratetype." But I don't believe that there is any combination of values of mt that will cause a problem here. I also think that once we pull in experts, they will tell us that the compiler is not going to re-run a non-trivial function to re-fetch a value, but I'm not one of those experts, so that's still arguable. But imagine what the kernel code would look like if every time we call a large function, we have to consider if it actually gets called some arbitrary number of times, due to (anti-) optimizations by the compiler. This seems like something that is not really happening. thanks, -- John Hubbard NVIDIA