Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1978625rwb; Wed, 30 Nov 2022 00:05:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf44mrJIahxFF50YWv70IhnChFC4uS+SyMWkNmsjJoaSki6b5kJ/hAooZa++FwjZ2Elg1suD X-Received: by 2002:a17:906:65c4:b0:7ad:d250:b907 with SMTP id z4-20020a17090665c400b007add250b907mr50509702ejn.737.1669795501667; Wed, 30 Nov 2022 00:05:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669795501; cv=none; d=google.com; s=arc-20160816; b=ke4YiN7weK9i2eNatkhV99dmLlI5br6hZDUzHLj54CGNaQm+TDCqa/48o3rUsI8R5x 6rkSltXoP/pSDYXngKIlxr1y4B0X6lRTgXs2XBKc+CzZIHw0HPOfOujSc7hYMHQNq2vH MSzxZ0di0VsVu4SakoO8T2bDxNPenWxUQPphIFgzbJsvT4S9qmE8p2CCUtUV0SAtZDVX zttCbhTIHn4ayyUTzAgWi4ciMgJ4jDsJmimDzxeZwcYwjUDKQloSsjDFcOXIFZ5yettf tdSkwi9RuvAJHflrfLV4zhyjxW514sgzH0tUkimjzHN2mYwKXwd+/lE6tGERc1g8pmZr kCVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=5AgzOj8U3caSyuY1WKQWxWsXylIKB3XS8A98MNnMeTI=; b=IFHlbzN77mMqwyvibXnAVyJ8eZcX3TzCthClU9QmJgSYNlmlIUqBw95qIAKm+RfshN /dmW6sz56A9PHrneDWUfEQlnrAQ3Qp1rN3/w9YzdZb/kP62tCfBGhqJGxrRPApM1o31w KBmGWZ6zmfbuBrNqFDyQnzDtAyXx+gT5Hj5zTN+2SV/8lpgM/bylkrIYMKiRcI29koBc tu2Q6HTpsHhn00wSGbla44AnKICDepIFRrwsbLINUrGDpdvBza7cQ/HN/MTcelRprSC1 IFSOpqwOdQrJNHyl+h7Z6pLulkkBdTpmB5H9/OBG27oH3dHjZqoa7caLzFBJTwaaRnna qhwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=lq99lhtW; 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 b18-20020a056402279200b0045ad02bb8fbsi870646ede.290.2022.11.30.00.04.40; Wed, 30 Nov 2022 00:05:01 -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=lq99lhtW; 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 S234036AbiK3Hd3 (ORCPT + 84 others); Wed, 30 Nov 2022 02:33:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233394AbiK3Hd1 (ORCPT ); Wed, 30 Nov 2022 02:33:27 -0500 Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E431A5B5A5 for ; Tue, 29 Nov 2022 23:33:24 -0800 (PST) Received: by mail-ot1-x334.google.com with SMTP id g51-20020a9d12b6000000b0066dbea0d203so10672852otg.6 for ; Tue, 29 Nov 2022 23:33:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=5AgzOj8U3caSyuY1WKQWxWsXylIKB3XS8A98MNnMeTI=; b=lq99lhtWYhivFicKBQg0Prv5DJ+v/2lt7NSJFbq3rAUCzXgv+KNkTw/xhiyUZyKfqu uMf2C6OYW5swfdUEuSNfmToqqQCvapyvBEvoLa9I53Ndv6qYYJWQY1NpXdK/DMep/mGR 7L8Hl0Jzaihv1Ny3msUYGt7QI5CzigbfwEtDso150EN9K4k5WTZ9i+5r39ViwHjdPomi 1qHBXQNIab2fmYZH+82qfFqdeSinNLbxsAAnnMs/3YJ53sHZ4wwReZDqH1eYS1Phyuy+ zs+pAc+bZtQT8h0FP0tZDi452jQmcPX/LjIw/UdtMpkH4O4GqO+i6KRtz8XtJ1Ob46e0 h35w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5AgzOj8U3caSyuY1WKQWxWsXylIKB3XS8A98MNnMeTI=; b=kreCw8bWxe952zs8Lz5VIHtO8/+Ycl4Bb8Bu99/Gm58qSQR4tSVvPbQxg5acF0OUTZ iPlEGd4DE5IqC/YcbejOvG2im+eI4S5E5McSokWHbDnJEvTRtF996Zf24o0/mEM9v1kX GI62v3XRVrUI+ja1wsy9jVolQGXteZqMVGFADcyfqczDXzAcGwMH/D0GB06guY6WBbh6 qB9rEc8ST8XEE34pBCVNAz0E+oMAiNAsaRVK+xMyFdaVAkZBkXRe2guQfPHtgb/S9Ti1 FJWiPoGnKwMeDW5Ctcs7fv537scWWT21EY2DPr3OwkeVNzUtA+6XY/iKsUnEtFo7yoRB m6QA== X-Gm-Message-State: ANoB5pnsxIBqytcvtYxWsUkkxYFXcJ1CSjJlxBUG223p9cMGPJPJzvLv kDEg5LvKpSXdZcAW/ecTBYiGEw== X-Received: by 2002:a9d:6294:0:b0:66c:5ad5:325e with SMTP id x20-20020a9d6294000000b0066c5ad5325emr21143324otk.116.1669793604101; Tue, 29 Nov 2022 23:33:24 -0800 (PST) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id m1-20020a4ae3c1000000b004a002884426sm451137oov.18.2022.11.29.23.33.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 23:33:23 -0800 (PST) Date: Tue, 29 Nov 2022 23:33:14 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Johannes Weiner cc: Hugh Dickins , Andrew Morton , Linus Torvalds , Shakeel Butt , Michal Hocko , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: remove lock_page_memcg() from rmap In-Reply-To: Message-ID: <3659bbe0-ccf2-7feb-5465-b287593aa421@google.com> References: <20221123181838.1373440-1-hannes@cmpxchg.org> <16dd09c-bb6c-6058-2b3-7559b5aefe9@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_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, 29 Nov 2022, Johannes Weiner wrote: > On Mon, Nov 28, 2022 at 11:59:53AM -0500, Johannes Weiner wrote: > > On Wed, Nov 23, 2022 at 10:03:00PM -0800, Hugh Dickins wrote: > > The swapcache/pagecache bit was a brainfart. We acquire the folio lock > > in move_account(), which would lock out concurrent faults. If it's not > > mapped, I don't see how it could become mapped behind our backs. But > > we do need to be prepared for it to be unmapped. > > Welp, that doesn't protect us from the inverse, where the page is > mapped elsewhere and the other ptes are going away. So this won't be > enough, unfortunately. > > > > Does that mean that we just have to reinstate the folio_mapped() checks > > > in mm/memcontrol.c i.e. revert all mm/memcontrol.c changes from the > > > commit? Or does it invalidate the whole project to remove > > > lock_page_memcg() from mm/rmap.c? > > Short of further restricting the pages that can be moved, I don't see > how we can get rid of the cgroup locks in rmap after all. :( > > We can try limiting move candidates to present ptes. But maybe it's > indeed time to deprecate the legacy charge moving altogether, and get > rid of the entire complication. > > Hugh, Shakeel, Michal, what do you think? I'm certainly not against deprecating it - it's a largish body of odd code, which poses signficant problems, yet is very seldom used; but I feel that we'd all like to see it gone from rmap quicker that it can be fully deprecated out of existence. I do wonder if any user would notice, if we quietly removed its operation on non-present ptes; certainly there *might* be users relying on that behaviour, but I doubt that many would. Alternatively (although I think Linus's objection to it in rmap is on both aesthetic and performance grounds, and retaining any trace of it in rmap.c still fails the aesthetic), can there be some static-keying done, to eliminate (un)lock_page_memcg() overhead for all but those few who actually indulge in moving memcg charge at immigrate? (But I think you would have already done that if it were possible.) Hugh