Received: by 2002:a05:6358:795:b0:dc:4c66:fc3e with SMTP id n21csp931737rwj; Sat, 29 Oct 2022 13:28:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM42x+xktq2PVWe1hlW2xOWhaHX9b+zWkZl7zKdsefC5a+kXiRaEC5p7IxaR6l5lZxbSzffi X-Received: by 2002:a17:907:9625:b0:78d:bb06:9072 with SMTP id gb37-20020a170907962500b0078dbb069072mr5260305ejc.472.1667075333870; Sat, 29 Oct 2022 13:28:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1667075333; cv=pass; d=google.com; s=arc-20160816; b=F/LW+19xGoGgTNC4VIkblSvj8z5MYx7TmlyDyehJ0wt6ZaLjXG/GUkNH0tCaDYvsKu RW0Y1TOdda0x8h0TaHis83SGXO9WDNbviXAuAQ9ZoayDNWR75SW4pH1JpMIHnSJnkTfm lf+y7otIY4/nvJJXOgkhKOak5khHJxnXw/dI7NsWMvekLjo8Rhc8T8mkhYjspmzxTkND 35RGboVZWU2TchAuliVSVCsuNHYaqGZj/mW6e2LiRSMQISwkSF858/EpPlgg3T3vJM5I Dd079c+hBf2f2xjN4JxwzK8CrwR6wIYOkDdjwdBABLsyuD1NeiRIQW6uYF2MnpeCnmTV fHNg== 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=sS7b82Q5p4Xh/hZi0hOqWOcn2AlSZ1bur0ielNcXNgQ=; b=0fdkiC0fxYrYMbZJIDtF5hLu/IYaFtjLicQ9TN8HHmrqs/gbIfognRllsILfYY94gj QrD0PSrTlPsYf89mKo+NicOMRUcqD1N8OZ5S8QMquCKf7iHog8R9It6vscUd+vQqKwoa C4IF+85/I0v614vA9yVQHTnTvFmeIw5N7Wc8BH8C1U3BlBGZ/9S4Rq/qWexfrdtgh712 GEPLcVpNoejS4a0RiJwdGTvwKoA49YBUW6eN2d6gqwOIrsjSMHnyD5HrgFoTfUhvXdOr ld5ITItkoXlI+EUcgku/vlcOkDKc3IlQ3MfC7NoTNMOdz8hEAT8ZN/646/BwRuffqSnN d6Vw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=TcngGANs; 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 hv18-20020a17090760d200b007919fc02ce8si2648832ejc.971.2022.10.29.13.28.29; Sat, 29 Oct 2022 13:28: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=@Nvidia.com header.s=selector2 header.b=TcngGANs; 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 S229678AbiJ2Tjk (ORCPT + 99 others); Sat, 29 Oct 2022 15:39:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229602AbiJ2Tjh (ORCPT ); Sat, 29 Oct 2022 15:39:37 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2042.outbound.protection.outlook.com [40.107.223.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0CA05F4E for ; Sat, 29 Oct 2022 12:39:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oOuypOhx4rd5Xv5LYED2k7knd5ulqmmm1ZtFpLLN6AX/9+d7qMn2pB+ZH9o4lOFseiRpwpYGgiyW/u4usKL/ITbPuQFB4F0Qjjs7H1x4QOMcbPkEQnngOuc8elBA7awu2k5lS3Wcz3fC9CjDpmIxwNgZ1A1pNxYCyLnmAJKIWdl9hdJmDxFjrADfh+hG51LaAhT7zTZ+AJJt//xptfOC1Nla2k46bp7YZmHE3dP5VGHgT2R8Cj8Gd7wUDQXWrARecLwVfCjDXcoB7XSBhrWHr1JYnbJU8NmUmjcw6VEdU9gOI1d1JqIqDCyaiWaoZoh3JHUsL8EkbxZDi1Ub2X0+yQ== 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=sS7b82Q5p4Xh/hZi0hOqWOcn2AlSZ1bur0ielNcXNgQ=; b=UmJotYWu3lTTSOk3GgujIqbdNoNM34JKjvKt6y8HQuzLR/BK3RAL+4js6m1cyDr+Tw0VMY8h98KuvH8MUbJO4l99KLI8GVHIHwh9qKZtp3Sm2aoKZFR5OxNw7feIipXjRDlVrykpQTRMaM3MIOlCVh57WnlSfl4hiHMciYy4M8n4aDrOYNAnGLj+44GY7bQ/sqaKh/LzWd07SL9HKnTACSIcimZgkVks9MuTbbhiZ8v652rdXU9oZeJT2RKgXLUqlfxZMokpm5CcXBQc1M5OV5wrzKPpc7AGDCXKhyGhBqjnG/5dWoHSsQRAs95VXZ9EAHCBs77XzUlVL59jvFaSsQ== 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=sS7b82Q5p4Xh/hZi0hOqWOcn2AlSZ1bur0ielNcXNgQ=; b=TcngGANslKkve9cZK/4GhVUXXR7gzi5YXb2Q6+9oDjH/4irUKlvm/HMUtkoI6I4+uKZjcROZCt12fQq04iLuTwiPktUfwPs+l+bwovUrNXMpViOQO5MRkGqSPOBid+kUvy+Aj6lJJsm8MX7TvAO/Zxy967qgTMq0bR8DDrCUe0YfdRojsAyqeMQYBIsqVAI/fXw8/kXOa9MHL6FS9m1YMnhggemKFyDMFqYFO6xr3c5IVX12fo1YqE1BmXwJag51wd9r5r7WAWps9yigRjefrfIrhie1BLose2Myi8mjpWAuBJGzDvYmkTAPLPvCFOGDQ8VWG1IvDBHDLo2zohZ+6Q== 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 SN7PR12MB6958.namprd12.prod.outlook.com (2603:10b6:806:262::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.15; Sat, 29 Oct 2022 19:39:32 +0000 Received: from BY5PR12MB4130.namprd12.prod.outlook.com ([fe80::fbce:3eb5:b646:6e3f]) by BY5PR12MB4130.namprd12.prod.outlook.com ([fe80::fbce:3eb5:b646:6e3f%3]) with mapi id 15.20.5769.016; Sat, 29 Oct 2022 19:39:32 +0000 Message-ID: <3a57cfc5-5db4-bdc9-1ddf-5305a37ffa62@nvidia.com> Date: Sat, 29 Oct 2022 12:39:29 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH 01/13] mm: Update ptep_get_lockless()s comment Content-Language: en-US To: Linus Torvalds , Nadav Amit Cc: Peter Zijlstra , Jann Horn , X86 ML , Matthew Wilcox , Andrew Morton , kernel list , Linux-MM , Andrea Arcangeli , "Kirill A . Shutemov" , jroedel@suse.de, ubizjak@gmail.com, Alistair Popple References: <20221022111403.531902164@infradead.org> <2c800ed1-d17a-def4-39e1-09281ee78d05@nvidia.com> <6C548A9A-3AF3-4EC1-B1E5-47A7FFBEB761@gmail.com> <47678198-C502-47E1-B7C8-8A12352CDA95@gmail.com> From: John Hubbard In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: BY5PR17CA0039.namprd17.prod.outlook.com (2603:10b6:a03:167::16) To BY5PR12MB4130.namprd12.prod.outlook.com (2603:10b6:a03:20b::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR12MB4130:EE_|SN7PR12MB6958:EE_ X-MS-Office365-Filtering-Correlation-Id: 5d602b02-a252-4c44-1e89-08dab9e54d2a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xFUV7UA4tUzNcOcprIggOZWnM5bUyadmOB3P0Pk57FNP7U+sbpz71HFWOLmn/i8w5zpo5c9Anlr8JAxfCQd0Hr1DfBzcBg/eBfxFElMcplvYuaPR9BqUUhJ+UZNbEsukLAPqIEryaE7cntvTDY4nVFpLzYpKLnAc8C+Mh0dSpt017niM9SkXAacmyEw/9sxe1JYMmVjggAS8ruCqDitVqFKDBi6cLlnLqgVEWeDmINN+szzhBRRgKKCxzaDM0lNO2LuzRgCVGHrdDRmJ2wUS890xIPkkYafCFmA7EyLhuOVJIFcdBLMRYWacvXdbsT4Mpyys4Q8Cqu7gs0ZmBDQp6nnCTzHnrRJFEk09959qshuGfq1AoZJ0TYaZFAOEwLaY27+3tieIIDJlStpyCtC+4H73RHjqn27QrwLFSQQxZOfxfMeX2+Cyryvw5Qb3eR0CDFmgFVFboUtNJThuM7f7BJgo+CNHVQLznP3wsQ4UokDhZacn1cfN7HqdhvWCuQvzeVv2kXsgI/tk3ZqcyAFnOh573v7pZ5M8/XnZUCp0imm+lSeqwajiNuIPODICRuTrKQ2+ByAknyTfPm31CAwNRyNcrtQrOoXM7pszWV45SrewxEwgl0DXHsfrrx/t8VUICb4fOZk9izcv+4UyKQcGPmkLhn21IA/HVdaNz/YyJAFcTfW+v2SMwV4q3uwO5b7IzYSxbD3t2zljEnFEmr3t6F+t9S2L4q02HpelpLCsZUDWwdRlGu9xDRvAoLROrhq0bPGFerzKNS8ck6nMP48sYE/BZU9NNV6nxtR2LiVL2ROBQYmBekN/t1BIXSYl//4HYdozXyH2j2rUUWrt5p5YiHZIjHtiLeZprFk2FicNl1FbdlbTBpqlXfabkE5Z79N+ 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:(13230022)(4636009)(376002)(346002)(136003)(366004)(39860400002)(396003)(451199015)(2616005)(6512007)(478600001)(53546011)(6506007)(6666004)(107886003)(26005)(186003)(83380400001)(2906002)(316002)(54906003)(6486002)(966005)(110136005)(8936002)(66476007)(7416002)(4326008)(5660300002)(8676002)(66556008)(66946007)(41300700001)(31696002)(86362001)(36756003)(38100700002)(31686004)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?VGxmc0lCbE9RUHkyWHVDQ0JlNzFPUTBkMU5PcG92SXorSWdGL1hOQnd3VktN?= =?utf-8?B?QlBoYXI3TkVkUzM4TmRxTzZZeTE0REg0Ql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VY1VEtSS3l3VHg4VGtiN2NuWGFJOFpzeTVwcmpoWTFNMWNZbFBER2lnMlBZ?= =?utf-8?B?NkRtci95bG9kaWRsL0lZOHh1dUxDdGRXUU1nN1MxWGFxREhiemlORlVuNmtn?= =?utf-8?B?SklBaERRSGNVUTh4MlRKcWNQTnJEbE1yRUViZmtvOFhNWmRydUp3b0lOZDlH?= =?utf-8?B?cUJCWVI1SzAvZ21YN3AyazNlYzN0NHo3Ui9LVnZNbGp5RlBHMDNQU2ZsZk1m?= =?utf-8?Q?h2wO++xtx5n4sQXHId/10VCuJ?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d602b02-a252-4c44-1e89-08dab9e54d2a X-MS-Exchange-CrossTenant-AuthSource: BY5PR12MB4130.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2022 19:39:32.1544 (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: TEi4X+PR3+QkYBfmkhex+Mn6WpnwoQsZgdRBmQ3IZnJUqPQWtFSNnKbhAofaKzmooO5CIpgF382iDv22j2Ectw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6958 X-Spam-Status: No, score=-1.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 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 10/29/22 11:36, Linus Torvalds wrote: >> In such a case, shrink_page_list() would consider the page clean, and would >> indeed keep the page (since __remove_mapping() would find elevated page >> refcount), which appears to give us a chance to mark the page as dirty >> later. > > Right. That is not different to any other function (like "write()" > having looked up the page. > >> However, IIUC, in this case shrink_page_list() might still call >> filemap_release_folio() and release the buffers, so calling set_page_dirty() >> afterwards - after the actual TLB invalidation took place - would fail. > > I'm not seeing why. > > That would imply that any "look up page, do set_page_dirty()" is > broken. They don't have rmap either. And we have a number of them all > over (eg think "GUP users" etc). Yes, we do have a bunch of "look up page, do set_page_dirty()" cases. And I think that many (most?) of them are in fact broken! Because: the dirtiness of a page is something that the filesystem believes that it is managing, and so filesystem coordination is, in general, required in order to mark a page as dirty. Jan Kara's 2018 analysis [1] (which launched the pin_user_pages() effort) shows a nice clear example. And since then, I've come to believe that most of the gup/pup call sites have it wrong: a) pin_user_pages() b) /* access page contents */ c) set_page_dirty() or set_page_dirty_lock() // PROBLEM HERE d) unpin_user_page() ext4 has since papered over the problem, by soldiering on if it finds a page without writeback buffers when it expected to be able to writeback a dirty page. But you get the idea. And I think that applies beyond the gup/pup situation. [1] https://lore.kernel.org/linux-mm/20180103100430.GE4911@quack2.suse.cz/T/#u thanks, -- John Hubbard NVIDIA