Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp109199rwb; Tue, 6 Dec 2022 18:04:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf6MIv/Ryp7v5mcxAoUvCSg4vokknMcCP3afFx5MHAzIDEa/2qrHLDMwRLfUaFOBQsD+OPlw X-Received: by 2002:aa7:8054:0:b0:56c:4303:a93d with SMTP id y20-20020aa78054000000b0056c4303a93dmr76021563pfm.73.1670378676896; Tue, 06 Dec 2022 18:04:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670378676; cv=none; d=google.com; s=arc-20160816; b=FtTvueFaGDzONSpjVZ7OvDvVWHgf7DgdQxIpgaa6MCDTeIuAYyy4v2lsVfBV9ZoemF dJTs/tsklslRYUOLHP+WvKq6iJ0Yd2xye3VKsJ8fM0yVt7m+QG6Q9V9GD2CJGXEgv+8B r2SywDteoI9kIqF77qb36NjXy2pPhh4CuU9DeT4QynWQIzxJ2M17SKBQYkConpDZOSSO h2sqGI8m2dp+ATTmD5lzWvEUJ4wVWhJH3eEfp1DoQUXlOmzn9Xobo0TKxZkrRRTpIFaN txcFY00ROGwT9QVTaLLVYlTTQojunWbe3HE1Nycc4fCRuRKsA4646LAY6qnASwwz7CC2 61ng== 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=b2g4EnU2Zj/9WIHBvH/VdPM01QEtKqmAnMzJgcZ6VHQ=; b=ToA3eVc+jE/caB7KnyLmshW93omeGGZLLWfNlGqstPaX4Wz0glpJXnLHebHnpnr6iN wZAKMN69yXdfHzX9hzoRrkf70ptKEeXdm8/XncrxA10Yava1QON2S4d80H4LnL5EJYr1 aMjvtuwZMRHWe7Ak8n7LXMqaQucjMl7HPXodqvPpdoSzIOPl1CHg6FtCa7X4nYqHiLjM XHXh1SLp9XnEH/BIa2o0WzvwOISfupbJnfGjS4SorKOEZ7X6yH7C/8+Se9q9OPitUs7Y jeVNvyhv3HHOfAv54PB8WGzfc6nSpFy5L81+s6sF2U38+lJPe3lSjbKt+zGuz4ThfyCe IAyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=qApXaWmI; 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 g19-20020a170902d1d300b00189d56098b3si6519243plb.113.2022.12.06.18.04.27; Tue, 06 Dec 2022 18:04:36 -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=qApXaWmI; 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 S230015AbiLGByX (ORCPT + 77 others); Tue, 6 Dec 2022 20:54:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230011AbiLGBx4 (ORCPT ); Tue, 6 Dec 2022 20:53:56 -0500 Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86AC42ED for ; Tue, 6 Dec 2022 17:52:33 -0800 (PST) Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-1447c7aa004so11539417fac.11 for ; Tue, 06 Dec 2022 17:52:33 -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=b2g4EnU2Zj/9WIHBvH/VdPM01QEtKqmAnMzJgcZ6VHQ=; b=qApXaWmIPSsbt1t37N/UXspIRY2YX9G+lCexd6I3+q6DAhcxsVtC5HiGEtNK+yKsla fR5UsohH8fXItmA4XTxpP+SWfNUOP6XeF7COYuJhZ2CCNwm6hOTCPy8fm6TzWBrx1cOC tYSILyxmygDVz91nN0ryG2YtYMT7+JzTDgNBIBbZb+WOJsypItnaG1ncTsMp2zqGaZMm feEYFcfotDSARSmqNRvtE4qiibFVHHWf5vwwoy0DFxFgN+j5ExbVRoG6P9Qpu5OD2dhD Bd8sp/0CuRHT2nZ8/5uuq9OOF9Dgh8lToFyOEbRhV+EDLbRGT4zlvs4W7ik63KUpAUU+ sKrg== 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=b2g4EnU2Zj/9WIHBvH/VdPM01QEtKqmAnMzJgcZ6VHQ=; b=x5GiafwdsNOylfDKIjU/7rfrsnytACqNK/EENO9dvLxBCKL6y6N4UB3bJtL4vHDvgz oPRtDYUoHGMX9xrn32C0xl/YWJDaiPZXC9vuki2FmH/znnZo9NbVAV7hM8mbvCdMRlQY WGAlBYHbGsolgyC1l8Dk+q2AN09VIlW7oa9LDX57ft/kT6r5kOEjywx0XnrfA53/NV/W VPvnvdQlk2653QcFYA4S6pLJUTb96vNR9NejOOWG8ykC5kRAJEM+qrOz4Hk8SnCONeA/ N/5owHsxIGDUQDsmIvk8c+8387pbx189XKsXWkiULA6JP6zG9pNSJNQpscI4jdWKRdbp TaTg== X-Gm-Message-State: ANoB5ply7XDrQHLvTjfWhuZVhla2cOv0pl419OVEV/us448b2qBvuGjv qupD5TdtWmcwYeka71tefZ5hug== X-Received: by 2002:a05:6870:638f:b0:144:cbb4:7fd4 with SMTP id t15-20020a056870638f00b00144cbb47fd4mr2395995oap.136.1670377952773; Tue, 06 Dec 2022 17:52:32 -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 b24-20020a9d5d18000000b0066da36d2c45sm9763064oti.22.2022.12.06.17.52.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 17:52:32 -0800 (PST) Date: Tue, 6 Dec 2022 17:52:30 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Johannes Weiner cc: Andrew Morton , Linus Torvalds , Hugh Dickins , Shakeel Butt , Michal Hocko , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] mm: rmap: remove lock_page_memcg() In-Reply-To: <20221206171340.139790-3-hannes@cmpxchg.org> Message-ID: <424a805a-28b8-afe1-ad61-f4fdc42aaa8@google.com> References: <20221206171340.139790-1-hannes@cmpxchg.org> <20221206171340.139790-3-hannes@cmpxchg.org> 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, 6 Dec 2022, Johannes Weiner wrote: > The previous patch made sure charge moving only touches pages for > which page_mapped() is stable. lock_page_memcg() is no longer needed. > > Signed-off-by: Johannes Weiner Acked-by: Hugh Dickins > --- > mm/rmap.c | 26 ++++++++------------------ > 1 file changed, 8 insertions(+), 18 deletions(-) > > diff --git a/mm/rmap.c b/mm/rmap.c > index b616870a09be..32e48b1c5847 100644 > --- a/mm/rmap.c > +++ b/mm/rmap.c > @@ -1222,9 +1222,6 @@ void page_add_anon_rmap(struct page *page, > bool compound = flags & RMAP_COMPOUND; > bool first = true; > > - if (unlikely(PageKsm(page))) > - lock_page_memcg(page); > - > /* Is page being mapped by PTE? Is this its first map to be added? */ > if (likely(!compound)) { > first = atomic_inc_and_test(&page->_mapcount); > @@ -1262,15 +1259,14 @@ void page_add_anon_rmap(struct page *page, > if (nr) > __mod_lruvec_page_state(page, NR_ANON_MAPPED, nr); > > - if (unlikely(PageKsm(page))) > - unlock_page_memcg(page); > - > - /* address might be in next vma when migration races vma_adjust */ > - else if (first) > - __page_set_anon_rmap(page, vma, address, > - !!(flags & RMAP_EXCLUSIVE)); > - else > - __page_check_anon_rmap(page, vma, address); > + if (likely(!PageKsm(page))) { > + /* address might be in next vma when migration races vma_adjust */ > + if (first) > + __page_set_anon_rmap(page, vma, address, > + !!(flags & RMAP_EXCLUSIVE)); > + else > + __page_check_anon_rmap(page, vma, address); > + } > > mlock_vma_page(page, vma, compound); > } > @@ -1329,7 +1325,6 @@ void page_add_file_rmap(struct page *page, > bool first; > > VM_BUG_ON_PAGE(compound && !PageTransHuge(page), page); > - lock_page_memcg(page); > > /* Is page being mapped by PTE? Is this its first map to be added? */ > if (likely(!compound)) { > @@ -1365,7 +1360,6 @@ void page_add_file_rmap(struct page *page, > NR_SHMEM_PMDMAPPED : NR_FILE_PMDMAPPED, nr_pmdmapped); > if (nr) > __mod_lruvec_page_state(page, NR_FILE_MAPPED, nr); > - unlock_page_memcg(page); > > mlock_vma_page(page, vma, compound); > } > @@ -1394,8 +1388,6 @@ void page_remove_rmap(struct page *page, > return; > } > > - lock_page_memcg(page); > - > /* Is page being unmapped by PTE? Is this its last map to be removed? */ > if (likely(!compound)) { > last = atomic_add_negative(-1, &page->_mapcount); > @@ -1451,8 +1443,6 @@ void page_remove_rmap(struct page *page, > * and remember that it's only reliable while mapped. > */ > > - unlock_page_memcg(page); > - > munlock_vma_page(page, vma, compound); > } > > -- > 2.38.1 > >