Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1710105pxb; Wed, 10 Feb 2021 15:04:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJyEGtkYWX9YLmF5w/tFswohDA9PMMwsWXZHqZdEYN1SCUyEQGZi64qBzj1IIZhCL2LDj3zt X-Received: by 2002:a17:906:7d09:: with SMTP id u9mr5105349ejo.380.1612998283188; Wed, 10 Feb 2021 15:04:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612998283; cv=none; d=google.com; s=arc-20160816; b=MTfXdRsEOwDXTz1juoyFBVQczXf2g2g8TMsVZ3LHKA95eoEugEgQAPgpLxgy8dY/7E klEae0qW2E3X3PUrPvs3/7pvcbyC4oly3OCTJcyHPs2TYf+qBfCdSfYOAVXr18MIJgq1 I7vGnunv+9hMPbN6jrYIvvbYXvpri2ds8af/LiGgJ9BtX+DRegcB7eBvIORB47hSnXND BCyqkbFGAlgxW1WKx5MATGDJW91chSJaSOq0owB+FNuwRtlvTcVMtBzW8qa5aoV/eOm2 pHaYTHrNGbPqbBfPBSFOjS9ZKmmoQjqe+rLhuJ4GyamSKY4rrc3W/sRPp/kgq1aCcn62 aKxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=xrTlzAySlcJTUXRnlEJkf0lrI9Iuz7zvICLmzyym/xM=; b=G+RRk2OrVKRct7h8z3OT3letJZb482LtVrGl8OK4phpzpaebgQvTRRboJlxLeNErBZ T4Wku37jzr5ovqWxYSeVgsg++554+MqEyRjvbvpOwVUQilb56LRcjdLtHKuX19KOGuRI DeNOubOX683uyQItYOE86NJ83jNbtUrWgnH+R4WatlHWedU7jPZcVAKV1Fr/JS9hxLpD QwQyAqNPyU7nGkHqzESjszCJoUvoqNtp9TurabxsmGYjw1qtAaJcIk2QT2uTfXIcXj6e KU7s3+TblexqgaKa6iD9kigLXy6Ttzwxu0D96axhXlUqRAYKSbxdyyinObzKFGpB5PMt Zkvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=eMT+HrSp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gv6si2164060ejc.302.2021.02.10.15.03.49; Wed, 10 Feb 2021 15:04:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=eMT+HrSp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S232164AbhBJXA2 (ORCPT + 99 others); Wed, 10 Feb 2021 18:00:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231897AbhBJXAZ (ORCPT ); Wed, 10 Feb 2021 18:00:25 -0500 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BCF0C06174A for ; Wed, 10 Feb 2021 14:59:45 -0800 (PST) Received: by mail-lf1-x131.google.com with SMTP id f23so5370445lfk.9 for ; Wed, 10 Feb 2021 14:59:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xrTlzAySlcJTUXRnlEJkf0lrI9Iuz7zvICLmzyym/xM=; b=eMT+HrSpUk67s7D9Fb/wYqRRhLhygRRnmrKjid5+dGjRRdcWnl+Coe1Hmivi013BcD vM7qrpbntHPGYw3ZR2mT73sG3gTPW+Ae1qRtuLiiI+dqqOKuimFiDxcTK8abjY31E3rf Fmq+1ScDwhhI6jHG7o9mVfPDf1sBmPRQsQLW79d/E3O3s4IGItRepiKnHYMt1D30bRmR MM+t2zmasxETxauJwuE6V8yQF8vBKu/UNkNA0RFX4nCUyjeyCijXg0fMI7T9wwjnhnNQ 0u4Vr+WykIzPW6B+1Kw9DctVhRNP42iVTrRSwiizbnXzW/vUetxSQ8bVn1+17zIlc7Ni ft3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xrTlzAySlcJTUXRnlEJkf0lrI9Iuz7zvICLmzyym/xM=; b=G2BFE7Sn0OQ1umrhXxnu/xbSz7LmjhBr+9woyvXUm4lcNRwJRYZDgZM18WkY1gy2Md i/3PLVJuDrxS7N1hFQjdzU7gYLsiXarlSSEr3Kou/gnwc8rSMnuE34EgwVdUC5ku69RH cYuAxljPXO4jvRFMJfWPtHCdB/IaGk3PKqDD/ft/Jp6QxAyuj0OpH+ngic5zg9XeqsuW iNUaPtOPbj7g7Id3AFt2fNzcDphjTxJJA6QI+PP9gCdTEm5++c4gvjDrG+h1CjdUbp2U OaehlUsGIQdfyilWv8ypW6mmEv2dJbK+tNiJ0rHX6FwYFI4mPVXiIN8n2rJsKH7qZ2kW iyxA== X-Gm-Message-State: AOAM533DyIh7EhpwdurWg7z196wrLBA62Sq+dBqFQvKWF8cGVPl6hxVd Lu91Tft7Q86BNE9zHKGRpmPW0Ir9ATgSh9qucybWpQ== X-Received: by 2002:a19:4cc2:: with SMTP id z185mr2657923lfa.83.1612997983406; Wed, 10 Feb 2021 14:59:43 -0800 (PST) MIME-Version: 1.0 References: <20210209214543.112655-1-hannes@cmpxchg.org> In-Reply-To: From: Shakeel Butt Date: Wed, 10 Feb 2021 14:59:32 -0800 Message-ID: Subject: Re: [PATCH v2] mm: page-writeback: simplify memcg handling in test_clear_page_writeback() To: Johannes Weiner Cc: Hugh Dickins , Andrew Morton , Michal Hocko , Roman Gushchin , Linux MM , Cgroups , LKML , Kernel Team , Arjun Roy Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 10, 2021 at 9:44 AM Johannes Weiner wrote: > > On Wed, Feb 10, 2021 at 08:22:00AM -0800, Hugh Dickins wrote: > > On Tue, 9 Feb 2021, Hugh Dickins wrote: > > > On Tue, 9 Feb 2021, Johannes Weiner wrote: > > > > > > > Page writeback doesn't hold a page reference, which allows truncate to > > > > free a page the second PageWriteback is cleared. This used to require > > > > special attention in test_clear_page_writeback(), where we had to be > > > > careful not to rely on the unstable page->memcg binding and look up > > > > all the necessary information before clearing the writeback flag. > > > > > > > > Since commit 073861ed77b6 ("mm: fix VM_BUG_ON(PageTail) and > > > > BUG_ON(PageWriteback)") test_clear_page_writeback() is called with an > > > > explicit reference on the page, and this dance is no longer needed. > > > > > > > > Use unlock_page_memcg() and dec_lruvec_page_stat() directly. > > > > > > s/stat()/state()/ > > > > > > This is a nice cleanup: I hadn't seen that connection at all. > > > > > > But I think you should take it further: > > > __unlock_page_memcg() can then be static in mm/memcontrol.c, > > > and its declarations deleted from include/linux/memcontrol.h? > > > > And further: void lock_page_memcg(page), not returning memcg. > > You're right on all counts! > > > > And further: delete __dec_lruvec_state() and dec_lruvec_state() > > > from include/linux/vmstat.h - unless you feel that every "inc" > > > ought to be matched by a "dec", even when unused. > > Hey look, there isn't a user for the __inc, either :) There is one for > inc, but I don't insist on having symmetry there. > > > > > Signed-off-by: Johannes Weiner > > > > > > Acked-by: Hugh Dickins > > Thanks for the review and good feedback. > > How about this v2? > > --- > > From 5bcc0f468460aa2670c40318bb657e8b08ef96d5 Mon Sep 17 00:00:00 2001 > From: Johannes Weiner > Date: Tue, 9 Feb 2021 16:22:42 -0500 > Subject: [PATCH] mm: page-writeback: simplify memcg handling in > test_clear_page_writeback() > > Page writeback doesn't hold a page reference, which allows truncate to > free a page the second PageWriteback is cleared. This used to require > special attention in test_clear_page_writeback(), where we had to be > careful not to rely on the unstable page->memcg binding and look up > all the necessary information before clearing the writeback flag. > > Since commit 073861ed77b6 ("mm: fix VM_BUG_ON(PageTail) and > BUG_ON(PageWriteback)") test_clear_page_writeback() is called with an > explicit reference on the page, and this dance is no longer needed. > > Use unlock_page_memcg() and dec_lruvec_page_state() directly. > > This removes the last user of the lock_page_memcg() return value, > change it to void. Touch up the comments in there as well. This also > removes the last extern user of __unlock_page_memcg(), make it > static. Further, it removes the last user of dec_lruvec_state(), > delete it, along with a few other unused helpers. > > Signed-off-by: Johannes Weiner > Acked-by: Hugh Dickins > Reviewed-by: Shakeel Butt The patch looks fine. I don't want to spoil the fun but just wanted to call out that I might bring back __unlock_page_memcg() for the memcg accounting of zero copy TCP memory work where we are uncharging the page in page_remove_rmap().