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 B703AC433FE for ; Tue, 22 Nov 2022 16:31:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 57F446B0071; Tue, 22 Nov 2022 11:31:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5093A8E0002; Tue, 22 Nov 2022 11:31:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D0018E0001; Tue, 22 Nov 2022 11:31:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 2E0E66B0071 for ; Tue, 22 Nov 2022 11:31:00 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 023C01A10D1 for ; Tue, 22 Nov 2022 16:30:59 +0000 (UTC) X-FDA: 80161617480.02.079B3EB Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) by imf01.hostedemail.com (Postfix) with ESMTP id 3A43A4003B for ; Tue, 22 Nov 2022 16:30:57 +0000 (UTC) Received: by mail-pf1-f202.google.com with SMTP id bq9-20020a056a000e0900b00571802a2eaaso9709546pfb.22 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=7sGvyESWh3UrFaUUEXcWJSj2mB6P9RYrioT2PgPGCULu7zTbfsantnS67QtjQ+UbK3 mJeeEsDdzmxudOdbLKNAGz/aWuP2mfR22F7LiKMxM+zPh2bqQTUTJ/mtFUr0oPjVlmDi 2504mRY0nN/vloCf3bor+4fMMRMCDonwQ8ClJ9s8LnnXUnBGOkMQbHLWW1NI8FWbMmy8 R045EypCeY4PUvnallkSI8dTKYthhml/Y85+/nXK64hXroAwW3C1u2iYcBs0FVus2kVD Wikkdf0ufTLMkZ6iBw8blWGWICGtO5OkMIdD4suRViuMmkJ8N5W1xoUZA6l4h6I6ulJi A7MQ== X-Gm-Message-State: ANoB5pnIXDCYIrvbSZvxYLQrWZC4IWfRbd2Z9w+FdHiOy22yykm/Ifhr b4ao9Jr0dME4RqcP8zxuTqVwTLOFi+QQWA== X-Google-Smtp-Source: AA0mqf6psx92ZT/st1c7JFGzjLbYxXaAUphXGERJq21OYZf+61cRy9bY1cYqYRj1EfZdazcQiZXiMalJgigTvA== 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" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669134657; a=rsa-sha256; cv=none; b=iy4VqoGLpFyzXJfyWw0cjmtkar6Z261FtP61fN8XQu8ead/vgX5MyMruSiG9Yl91dODSlU fMuiHVN+4PLC4L0oMyrhp5Ht/UYtgvfxRYAtfMCSO4BsE8sUMLn0J7y3K6txz5FLw4wAci eYZrHLCGLenrU5n6+s13eCL2psdk2/8= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="MC7t/RjN"; spf=pass (imf01.hostedemail.com: domain of 3P_l8YwgKCEg2rkuoovlqyyqvo.mywvsx47-wwu5kmu.y1q@flex--shakeelb.bounces.google.com designates 209.85.210.202 as permitted sender) smtp.mailfrom=3P_l8YwgKCEg2rkuoovlqyyqvo.mywvsx47-wwu5kmu.y1q@flex--shakeelb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669134657; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=D+tKnyn/Cyv5SBwG1da8cKfhKhoYcRDt75vGeaxs9fk=; b=VLhD5mgTpelxvtbNAIfeDS18C/tfzhDf6FkegX3Od5laHjQWWIeJMvJAZiETlTXbJIKXE+ oXN5rqjvKVuNUUSguzA/fTecmVo4R/bayYu4GUh5BlxqQzZNFiflaK+v1twLrB89mU5ZWV B1owP5dJy3y3/jI3WxVcNahT+9WE4xc= X-Rspam-User: X-Rspamd-Queue-Id: 3A43A4003B Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="MC7t/RjN"; spf=pass (imf01.hostedemail.com: domain of 3P_l8YwgKCEg2rkuoovlqyyqvo.mywvsx47-wwu5kmu.y1q@flex--shakeelb.bounces.google.com designates 209.85.210.202 as permitted sender) smtp.mailfrom=3P_l8YwgKCEg2rkuoovlqyyqvo.mywvsx47-wwu5kmu.y1q@flex--shakeelb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: 8njhaji38twcs96aqpaoysr5iekii4hr X-Rspamd-Server: rspam10 X-HE-Tag: 1669134657-385541 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 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.