Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6137992rwb; Tue, 22 Nov 2022 09:12:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf7+rLZruumuyi/Y+Ku6icLpUWeAqfvgZ1PkyjA/7ofG71vsBMz0efpu8vAxM5FZK41PKHYA X-Received: by 2002:a17:907:774e:b0:7ae:39b4:7208 with SMTP id kx14-20020a170907774e00b007ae39b47208mr4774240ejc.766.1669137158579; Tue, 22 Nov 2022 09:12:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669137158; cv=none; d=google.com; s=arc-20160816; b=KY57gYJrlNCdm2wASvQ/dW0ievgCzdB6f1OroYD3ri2qnrPaTFuyTeGA+/LmWl/dNk JC0008XyYuK1vA6zif4bSepNYR8ui9orBvnOpkn7Ji0/L/bwd8p8baP+OMGcK7zjDxKZ u2cYcfytcxgRR4RboIgtxq0xX2HXt82fGWKQknzCIpTzPKXy8hIRFVcnQuXJZ/Lgp3bL mpSclzjz4CXqZVewdVa0bhP7pcILq7pKfJ8x62lZIjpKCbzWOu4FM+1VjaAbuMmz6KrJ oIyW6G9pECGiLQyelykIUJSLm3TCkMIayF4OUIuhHw1SL+RsF9GjeoOBoZn5C1ZQu0Ax HcSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=D+tKnyn/Cyv5SBwG1da8cKfhKhoYcRDt75vGeaxs9fk=; b=SmC2wStqHnR6GY4IN0oBE52f5FfRZebFesPUpVBDzfWDn57R4C6lglYvw6jQ0Z+Ap4 TR3XRXAS6yoBl6MFvS5bzG02TPcUIc9cdEcRbqh2KZtCWVhCZ8yHYwL4R9T3YT/B98YF Hg2LP6jBgkB6C0td9VyoiBPzNrUeRYvLQiivVUcwnOeaRvJnsr4QUfghHg0yZybAFTBq cuHpgkrcLnc3T+7/JFT/78tW1XTIoXlVYTed9drxHMMrdds74s6xFbUNlLzFmGSXzjPZ ueVgJHSRjqp/A8bepuORSB6CNl4LwUkiVyv4+nicafgjXUDR4MMyCiZ5EjPRChDnh/aU UbVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="MC7t/RjN"; 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=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b22-20020a170906491600b007ada030c2e9si10652101ejq.944.2022.11.22.09.12.06; Tue, 22 Nov 2022 09:12:38 -0800 (PST) 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=@google.com header.s=20210112 header.b="MC7t/RjN"; 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=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233379AbiKVQbA (ORCPT + 90 others); Tue, 22 Nov 2022 11:31:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232370AbiKVQa5 (ORCPT ); Tue, 22 Nov 2022 11:30:57 -0500 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 756932BB09 for ; Tue, 22 Nov 2022 08:30:56 -0800 (PST) Received: by mail-pg1-x54a.google.com with SMTP id 11-20020a63000b000000b004776fe2eebfso3489056pga.9 for ; Tue, 22 Nov 2022 08:30:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=D+tKnyn/Cyv5SBwG1da8cKfhKhoYcRDt75vGeaxs9fk=; b=MC7t/RjNxF4M05cdJCqZ+z9kLUErLG05/Djm9rojrB4WW9Xkf692T2wUv8dGxivXXK f7lr2XG4p5fgwMoQuxeXhTTF+2JZv/6Cyoc0QvXtBf93MJ2LWULf42migXRaFcNniedh FDceLzA9AXfL2F7RaJAEZJdmFSMPtExdpmAKEI94/qNrfcr4yJ5J3ddqsFEyijARrAmS vEbQdBSiCB1ojNp1hgLKm0BYtCjRNun9LWEXlVfX2JoqPmT6ZOT33oa46K+keLIt9ZL3 hJPtQQdNUqc8gGZ5bkn3HkK0RBb5NeI3pCM710eufIFflGILZhd8KgqEL/H0lAFRA0fi /Yug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=D+tKnyn/Cyv5SBwG1da8cKfhKhoYcRDt75vGeaxs9fk=; b=zys5yjD8blrV89p70wdINEB09+yVKYnO4qtPbebGKMD/G8Vbzccb9tjVavZWcxNktF leq+TETh4CeMGVhf8RAiE/SaW9HvFkBVzAw2Lu3v7nkB8KHn6lJOOoR3F3IaOknA25My NT0FblaADCMDkbwf+pp4MoEBwQlbhVqpjr5CZWjPy+mbKzBM09P4RhVpOqT9ni1ySFoU pdPsEiC0njC10fuxHUfBpy68KR0ODfDftdGcaJdJ+nh55haOOIdxKdTlax4q4MbKlwza fjQX95VvDwlfa9/rejTaXkJ74rMKasS93MW2NOncNvU4uTd/Nh2Nn8xRpWBBDa/apuJN GdYA== X-Gm-Message-State: ANoB5pmAjn4MXS68HP/xgPHY0YM9o3vuYAj9M1zXYAx5UN3cGibLvroo jZKlxO1nGtvkrjjuGHFH+IOsucEz+IVp7A== X-Received: from shakeelb.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:262e]) (user=shakeelb job=sendgmr) by 2002:a17:90a:df8c:b0:20a:fee1:8f69 with SMTP id p12-20020a17090adf8c00b0020afee18f69mr2340761pjv.0.1669134655640; Tue, 22 Nov 2022 08:30:55 -0800 (PST) Date: Tue, 22 Nov 2022 16:30:53 +0000 In-Reply-To: Mime-Version: 1.0 References: <5f52de70-975-e94f-f141-543765736181@google.com> <20221121165938.oid3pemsfkaeq3ws@google.com> Message-ID: <20221122163053.gngosdbd3stksk6c@google.com> Subject: Re: [PATCH 0/3] mm,thp,rmap: rework the use of subpages_mapcount From: Shakeel Butt To: Johannes Weiner Cc: Matthew Wilcox , Hugh Dickins , Andrew Morton , Linus Torvalds , "Kirill A. Shutemov" , David Hildenbrand , Vlastimil Babka , Peter Xu , Yang Shi , John Hubbard , Mike Kravetz , Sidhartha Kumar , Muchun Song , Miaohe Lin , Naoya Horiguchi , Mina Almasry , James Houghton , "Zach O'Keefe" , linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 Tue, Nov 22, 2022 at 01:55:39AM -0500, Johannes Weiner wrote: > On Tue, Nov 22, 2022 at 05:57:42AM +0000, Matthew Wilcox wrote: > > On Mon, Nov 21, 2022 at 01:52:23PM -0500, Johannes Weiner wrote: > > > That leaves clearing writeback. This can't hold the page lock due to > > > the atomic context, so currently we need to take lock_page_memcg() as > > > the lock of last resort. > > > > > > I wonder if we can have cgroup take the xalock instead: writeback > > > ending on file pages always acquires the xarray lock. Swap writeback > > > currently doesn't, but we could make it so (swap_address_space). > > > > > > The only thing that gives me pause is the !mapping check in > > > __folio_end_writeback. File and swapcache pages usually have mappings, > > > and truncation waits for writeback to finish before axing > > > page->mapping. So AFAICS this can only happen if we call end_writeback > > > on something that isn't under writeback - in which case the test_clear > > > will fail and we don't update the stats anyway. But I want to be sure. > > > > > > Does anybody know from the top of their heads if a page under > > > writeback could be without a mapping in some weird cornercase? > > > > I can't think of such a corner case. We should always wait for > > writeback to finish before removing the page from the page cache; > > the writeback bit used to be (and kind of still is) an implicit > > reference to the page, which means that we can't remove the page > > cache's reference to the page without waiting for writeback. > > Great, thanks! > > > > If we could ensure that the NR_WRITEBACK decs are always protected by > > > the xalock, we could grab it from mem_cgroup_move_account(), and then > > > kill lock_page_memcg() altogether. > > > > I'm not thrilled by this idea, but I'm not going to veto it. > > Ok, I'm also happy to drop this one. > > Certainly, the rmap one is the lowest-hanging fruit. I have the patch > rebased against Hugh's series in mm-unstable; I'll wait for that to > settle down, and then send an updated version to Andrew. I am planning to initiate the deprecation of the move charge functionality of v1. So I would say let's go with low hanging fruit for now and let slow process of deprecation remove the remaining cases.