Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5442331rwb; Mon, 21 Nov 2022 23:19:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf6McjRq0Z16LoDEbs20Qjs0aQ/I8jOmqCIdu1MSxQ4FrUFoDIXTj2RG/tCV56X/zyX1/q7N X-Received: by 2002:a17:902:b493:b0:176:a6fb:801a with SMTP id y19-20020a170902b49300b00176a6fb801amr3071881plr.97.1669101546638; Mon, 21 Nov 2022 23:19:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669101546; cv=none; d=google.com; s=arc-20160816; b=kWNXQz33VvGLHQR7dPReOIdhCeJlE4RVedtm94UCx/LWKfVGJxgTKmTpO0QC9dN5sr b5N0QnKQhft62JojtHJOmRcx71k/kLNI4lqHy+qrig0nQjkGSAk+F/FMDFx1kTqR/AZo HI0ATrgoAQVd8VAnP1Lw20DghzgOxfbYNbpg9m54a1Mp6OQpCHOEyX2vtJ8yrmVXV5R7 NAVzDkOSV4nYdZENHwqw/fFuZTz1tBNpo+MCMhiTDDxdo4W8z4kcAwiFxzovXdnwDcO/ X/jzjyAnY54nn9WLhgYrQf7uFpcp9OOT3ga0tWssyfmF1e96Uo6FEW15oC2YypZJ9cSB C4fw== 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:dkim-signature; bh=mYAqDDk/54FmeYnzSCfE4ubLGzPeGRlE3OkG0R3fi1g=; b=ya2qG+bNFZWbKKByWJr+pRe6G3wyUNT3RNF76Zct/vbhYkFBl4+yROfdHJ4xzR8Ior 59p8gJ+rnLOBsvZmi2gyTJRgKvAzZpDwd0CrqJqD+gbYg1Z3AlAKLDeHeDufgIhP7Jut M58LhPDoV0vQkc/FhrI07d2jQsLs8j0sRIchpEqool3XHOvReAKjYQYGgN+9Dqz4VSpJ rlvWULafSSdHM9MyNOHzC7sSgHfqselFcOHfhdrvRT7xgEAIUXIsJwo8QSb/ft2qOQCc eUOcD0GgNc3cSMu7bV4iyalmzWNmtzU6OdwoCTobj5jOXhPfmO70xKTgJ2OaAVPUHSTQ zuuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=0RLPsjsq; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p30-20020a63741e000000b0046fcbcb1015si13072734pgc.331.2022.11.21.23.18.52; Mon, 21 Nov 2022 23:19:06 -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=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=0RLPsjsq; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232195AbiKVGzS (ORCPT + 91 others); Tue, 22 Nov 2022 01:55:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229553AbiKVGzQ (ORCPT ); Tue, 22 Nov 2022 01:55:16 -0500 Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0838F2018C for ; Mon, 21 Nov 2022 22:55:15 -0800 (PST) Received: by mail-qt1-x82d.google.com with SMTP id fz10so8757877qtb.3 for ; Mon, 21 Nov 2022 22:55:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=mYAqDDk/54FmeYnzSCfE4ubLGzPeGRlE3OkG0R3fi1g=; b=0RLPsjsq8XFYFsbBP31qFJbsIjbs3BM99Hd75XBgqLbKxUqoZYlpPLWpIu4K7iAZsv KDQoslmgNXaijNZMlDhzaIxhg47IL8/8frC1xBQcmS2HqfZH/6IaGb43LzLTqw0U8OoH tlFJX/1st+DaU+CjYO3toBQqOhCyPMaYaI5dXW00F76nvY2xK4jIhi4AjA4EhPVnBIwY 6RorVI7v7SFsbixEWrgw7ilExM8XtSYriWyNCAlCdPrvWXVNadIoKpTqi+mGhP1qGPen AL1uX7jTAc2Hd2OGYxYua2oCEhkSy+bPWR8kLdIrt/yhJp1pW/PX1my5Ob+oJbw2gr6x QWjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=mYAqDDk/54FmeYnzSCfE4ubLGzPeGRlE3OkG0R3fi1g=; b=qzuWkIK5ngDd9Sbe5aLiKuy30GKY66DxWPHJrFV9RbeWtlzhirgZ67lxrTrUgFm6Zr o+j8hZOC8IOZJoEXbc/6+BsfRs35VIoYWs5V1J5CELc6Hdhivj2knYZHpGCvwTIQ5TIy 20aoT/pDLeDJ3SHSV08AFRIaEKsrxZyr1qfLvmsqdbp9WPz6hyisvk6VBT7hgP8oPehS 2W1dAhUp9Ov55QbtRFSF+2oz5oQ2PTp5ydFmSNC7YmDNd5AZm/8iW95F8Uhz2+gkBlK+ Anqvk474dtdl9XtgInP4PlAqN5Gn+NqkB1A83GP6fNzI3agIvYIvjRwSDQyUJ4aOiCX9 GCSA== X-Gm-Message-State: ANoB5pmWHvOWWG9dRcgd3lPzrrriWY0ZKI22d8MDhfJsuDQOmAoX9IN3 n5rFAwjwMGYO54SXzz2j6ecUiw== X-Received: by 2002:a05:622a:5a96:b0:3a6:3b3a:e8cc with SMTP id fz22-20020a05622a5a9600b003a63b3ae8ccmr11975315qtb.373.1669100114196; Mon, 21 Nov 2022 22:55:14 -0800 (PST) Received: from localhost ([2620:10d:c091:480::1:bc4]) by smtp.gmail.com with ESMTPSA id bl9-20020a05622a244900b0038b684a1642sm7888922qtb.32.2022.11.21.22.55.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 22:55:13 -0800 (PST) Date: Tue, 22 Nov 2022 01:55:39 -0500 From: Johannes Weiner To: Matthew Wilcox Cc: Shakeel Butt , 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 Subject: Re: [PATCH 0/3] mm,thp,rmap: rework the use of subpages_mapcount Message-ID: References: <5f52de70-975-e94f-f141-543765736181@google.com> <20221121165938.oid3pemsfkaeq3ws@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 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.