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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9685FA3741 for ; Mon, 31 Oct 2022 17:33:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 585E76B007D; Mon, 31 Oct 2022 13:33:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5362C8E0002; Mon, 31 Oct 2022 13:33:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3FDB48E0001; Mon, 31 Oct 2022 13:33:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 31F6E6B007D for ; Mon, 31 Oct 2022 13:33:12 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id F11BF80134 for ; Mon, 31 Oct 2022 17:33:11 +0000 (UTC) X-FDA: 80081940582.16.397C50F Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) by imf17.hostedemail.com (Postfix) with ESMTP id 830BF40006 for ; Mon, 31 Oct 2022 17:33:11 +0000 (UTC) Received: by mail-qk1-f179.google.com with SMTP id g10so1490376qkl.6 for ; Mon, 31 Oct 2022 10:33:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=wO1aXGez9nOhy2a+Zn5RD+RAHyQUNPFJqnfXakKdh28=; b=f5ptxWlLLcXdghefXYE0GvwEBlSe2liMn3DrOmZMCY7LFSlAbtO0iLErEaZVfejg/Y Kx/GBuhsRS3JG5bobpj9w6WcYfAH9TsouB6zoEn9T6kaOeTfZxIHJB9lag9lVgkmsAN2 M/FvOPQtTrbDWHeQVYWxfpFrLN57Pme71gDxo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wO1aXGez9nOhy2a+Zn5RD+RAHyQUNPFJqnfXakKdh28=; b=ezpGYIHz4TqONTKkU6k0r4wVVe7oMimmunFNiNzx8Rty2gYjNAY8kMB7+rRYJ7qlqU shnPjFsQgGtOXJXkj2vomjyAiW2LG4ijCKqKa9uFqFEVNto9t7rrMOYNF3N+BmlHWe/e mbymjCrkEwKNSMfqmB5RSFLUAGwbq3ajUirmwuG2AHz3E7LFUTm1bOElFIGv7BztMRuZ 9SwdoEZCz5sN70iO7IEYvpGpoc8xbd7NmMvEig5/yEh8OrUz2rXf7H6TFVZZRt2KzGcr 2DBAwKeNEbwAw8gxf0p+c8vWdwh6Jw5RCf//2jCJyzwAru6z6xBgUaLCLiuRy2NHn0Fl MoRg== X-Gm-Message-State: ACrzQf0ll+A4AzfbOCND2ri+9w8P2IeYcPs/Yoql0r1yl8OtA5Tzkll5 VFgUptC22HH7zUfObpkpbZSaobCuVSYd7w== X-Google-Smtp-Source: AMsMyM63FlraupuW6pml6/XEmw9G1xLpmI8zsLKrgegcZWHj0FPJUgVp/ke39eRnFScHiPV93oAeEw== X-Received: by 2002:a05:620a:3dc:b0:6fa:2161:84c3 with SMTP id r28-20020a05620a03dc00b006fa216184c3mr6396149qkm.400.1667237590611; Mon, 31 Oct 2022 10:33:10 -0700 (PDT) Received: from mail-yb1-f170.google.com (mail-yb1-f170.google.com. [209.85.219.170]) by smtp.gmail.com with ESMTPSA id r17-20020a05620a03d100b006eee3a09ff3sm4964510qkm.69.2022.10.31.10.33.09 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 31 Oct 2022 10:33:09 -0700 (PDT) Received: by mail-yb1-f170.google.com with SMTP id j2so1360529ybb.6 for ; Mon, 31 Oct 2022 10:33:09 -0700 (PDT) X-Received: by 2002:a05:6902:124f:b0:66e:e3da:487e with SMTP id t15-20020a056902124f00b0066ee3da487emr14959950ybu.310.1667237588682; Mon, 31 Oct 2022 10:33:08 -0700 (PDT) MIME-Version: 1.0 References: <20221022111403.531902164@infradead.org> <20221022114424.515572025@infradead.org> <2c800ed1-d17a-def4-39e1-09281ee78d05@nvidia.com> <6C548A9A-3AF3-4EC1-B1E5-47A7FFBEB761@gmail.com> <47678198-C502-47E1-B7C8-8A12352CDA95@gmail.com> <140B437E-B994-45B7-8DAC-E9B66885BEEF@gmail.com> <0E3DDDE4-FD20-40ED-A418-222AAA546596@gmail.com> In-Reply-To: <0E3DDDE4-FD20-40ED-A418-222AAA546596@gmail.com> From: Linus Torvalds Date: Mon, 31 Oct 2022 10:32:52 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 01/13] mm: Update ptep_get_lockless()s comment To: Nadav Amit Cc: Peter Zijlstra , Jann Horn , John Hubbard , X86 ML , Matthew Wilcox , Andrew Morton , kernel list , Linux-MM , Andrea Arcangeli , "Kirill A . Shutemov" , jroedel@suse.de, ubizjak@gmail.com, Alistair Popple Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667237591; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wO1aXGez9nOhy2a+Zn5RD+RAHyQUNPFJqnfXakKdh28=; b=lsC2+FkecUDah274a9VCTSkfOr7TP1nS3c1ESS8HhQIAnU6yx4QZCHvShbi6XctlbDGadb IgTcpMsOmfzZvuxYWBRYTto/omAcxvuCoTmmVNKw6lvG4Mo1YWuDPB1T/zwIAR3mSm5I3h DhsZi8S8GYFXEYJDkIbUrjgw+vZPIgQ= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=f5ptxWlL; dmarc=none; spf=pass (imf17.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.222.179 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667237591; a=rsa-sha256; cv=none; b=jb0NkDselBqorT3otIQMwP2ZaoFMih8GfMDJx/DyqaJKDZm3kDl6Ajo5KC1NAO/s8grocR 2wo6LvcM8LZnts2d9xrNvX+T+wNYTfSZBFxrjQ3ol37vrRrcVYvZO3DbFeY4wauOU5bo6o R35YTai9PfygLPiedGkWTJNHPYeQIqo= X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 830BF40006 Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=f5ptxWlL; dmarc=none; spf=pass (imf17.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.222.179 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org X-Stat-Signature: 1r68muhd7ygsy3p68ywx5ogsz7yzz13n X-Rspam-User: X-HE-Tag: 1667237591-975273 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Oct 31, 2022 at 8:43 AM Nadav Amit wrote: > > On Oct 30, 2022, at 10:00 PM, Linus Torvalds wrote: > > > So the current ordering rules are basically that we need to do > > set_page_dirty() *and* we need to flush the TLB's before dropping the > > page table lock. That's what gets us serialized with "mkclean=E2=80=9D. > > I understand. I am still not sure whether ordering the set_page_dirty() a= nd > dropping the mapcount reference cannot suffice for the reclaim logic not = to > free the buffers if the page is dirtied. Ahh, ok. > According to the code, shrink_page_list() first checks for folio_mapped() > and then for folio_test_dirty() to check whether pageout() is necessary. > IIUC, the buffers are not dropped up to this point and set_page_dirty() > would always set the page-struct dirty bit. > > IOW: In shrink_page_list(), when we decide on whether to pageout(), we > should see whether the page is dirty (give or take smp_rmb()). > > But this is an optimization and I do not know all the cases in which buff= ers > might be dropped. My intuition says that they cannot be dropped while > mapcount !=3D 0, but I need to further explore it. Yes, the above sounds like one fairly good way out of the whole forced TLB flushing for dirty pages, while still keeping the filesystem code happy. But at this point it's an independent issue. And I really would like any fix like that to also fix the whole issue with GUP too, which seems related. Linus