Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2339120pxb; Fri, 5 Feb 2021 15:38:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwSPLaqpLOYeS713cEjrrIhnqHLkJdz4qlttC3PDUxhZAU+OJCg9NusoxIsDNB2Z5VxAMwl X-Received: by 2002:a17:906:6791:: with SMTP id q17mr6343067ejp.116.1612568318038; Fri, 05 Feb 2021 15:38:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612568318; cv=none; d=google.com; s=arc-20160816; b=yeUZuNWPDuGzXRJKFXowV98xCUgcsqz2KtSCTyfbI6GpgjghfTjQ37XAuj1tbYgr/Y 15t/8aKQ/I/WxL/opaonLCkUxLkLcGc3AGCQZ3PwY8AVlpZKV0+1JWVBlKsltVd1+6sm G7aySaMujTQgc5F9AYIjgvZH+Dq8ImMW7lrneZL/MYtlxuwgXpA1KwO6CgC8whFX643q paJOQWilmM72/KLXhd6pJ+zYyK6Zx2o4unRxwZtBwNGeQbR7AgDhef9E4ahJTDPefIte 9Y0ctIcYFgvETl15vtwiMFgir+dyXsLdOXM+QXV//Dmi83ade0IEJl7JA/fi5PYSMupp Dd2A== 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=jHFnyH790m7nlnJSVskIB0W5pLoFkbMx9bIb16KHmNs=; b=Z92OdKFI2y5TF2VvLw23VQA6UVLBpmdBbd4vYCBoZnZgWHx5ySv36CA/dMrEPAth1A iOzmFlU8FgvdUkLRye+YH91BTlIh1/uTSgDgtT6M8jZcbZiyCS3aaZSsK3Qk8f+XmQQr ISB9TB4xeXAaO05+kfBYdT7ioUAgoATYIzGAgEHp6jYjtbPxSmzcmEVfCVVeNuUUDSzA ZPtFWvUWHO8aqLRcCSv4pJlTSHzqnQ7u8PZEmEYIL8swFQBEm14cn2JT3Z71M+eSsPcd +eM50ZZKkpylWX2yxk4kOpbEbZnMVnjrV6G6rozAFUcLTYiZdy0PZFaNUA8YLbBei6ty 1rtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Y1n3cckx; 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 n9si6145389edv.123.2021.02.05.15.38.14; Fri, 05 Feb 2021 15:38:38 -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=Y1n3cckx; 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 S230245AbhBEXew (ORCPT + 99 others); Fri, 5 Feb 2021 18:34:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232313AbhBEOV5 (ORCPT ); Fri, 5 Feb 2021 09:21:57 -0500 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91938C0617AB for ; Fri, 5 Feb 2021 07:59:19 -0800 (PST) Received: by mail-lf1-x12b.google.com with SMTP id p21so10522085lfu.11 for ; Fri, 05 Feb 2021 07:59:19 -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=jHFnyH790m7nlnJSVskIB0W5pLoFkbMx9bIb16KHmNs=; b=Y1n3cckxp8Sv26Yg2Kxgb2craA8eH4oamlcKNyGu6Cq1ETKGeIjpz1wSLG34yCwBx9 8jCz4hYbdEzrAX0HgzdJIOZAxBXC75We1qql4WXxrna9TC7NdTBJ4AQonUGKLBiKsjI4 K7eE3O2fHwXc9MFhnrN0WYaNbqDRD0jwhifUYAb0N4UDEKiIlSTtsc4gAJogahjk9yU4 H2yVdG7mMrcZ+vdTepWBHEqEjQs47HZ21dfvcgETV8ovaJ59vY1rQbi4dzKp+swccwCE yoKNg1vQ7f8haUoV7EPCiMm4JXjqOzywrdWE8hRgawdHbFgXUy6MoznmNBJSqTLnnPlU qETg== 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=jHFnyH790m7nlnJSVskIB0W5pLoFkbMx9bIb16KHmNs=; b=Rv+/O1qL3ZeideIDULq0f8B12DTN5VzKRKf2PbsA+KyZ1lx0Wca5zqRerr4IY2MJ+1 Fk9pFb7Xp+3eBFWJ9cPGVvrDAjMM5KQVCaTL3xIh2neoh1IhU6IZ3Cz2uAPIJiMnPnKe zxdmaKAfR6Pks907g2d1vc7lcvTVZ3FkGpe2Zf+hDoFy2Cy18zgvgWli35G45vpluISX TkIVjPRONo93MMNJnMubSnUdNicz93CgiCuP0V5f6M2YsSOSmi/MAPnrRILARtkWfw4Q m0fSY2Q7ijPWv4vPlRSeB0jvD3I0dbbD93xegUTip10U97h7U8fb44GAsFMYgcqAN70N GW/g== X-Gm-Message-State: AOAM533rY5WmBe3A/x2Hp1rza8Pr7AE2x9okusIZITnCrHthAM5+xhSu eUG9lN9VdzDDAfU+2S2+3bHyyCIszSCdFoLzdoVdBw== X-Received: by 2002:ac2:5a41:: with SMTP id r1mr2870906lfn.117.1612540757833; Fri, 05 Feb 2021 07:59:17 -0800 (PST) MIME-Version: 1.0 References: <20210205062719.74431-1-songmuchun@bytedance.com> In-Reply-To: From: Shakeel Butt Date: Fri, 5 Feb 2021 07:59:06 -0800 Message-ID: Subject: Re: [External] Re: [PATCH] mm: memcontrol: remove rcu_read_lock from get_mem_cgroup_from_page To: Michal Hocko , Roman Gushchin Cc: Muchun Song , Johannes Weiner , Vladimir Davydov , Andrew Morton , Cgroups , Linux Memory Management List , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +Cc Roman On Fri, Feb 5, 2021 at 2:49 AM Michal Hocko wrote: > [snip] > > > > Also, css_get is enough because page > > > > has a reference to the memcg. > > > > > > tryget used to be there to guard against offlined memcg but we have > > > concluded this is impossible in this path. tryget stayed there to catch > > > some unexpected cases IIRC. > > > > Yeah, it can catch some unexpected cases. But why is this path > > special so that we need a tryget? > > I do not remember details and the changelog of that change is not > explicit but I suspect it was just because this one could trigger as > there are external callers to memcg. Is this protection needed? I am not > sure, this is for you to justify if you want to remove it. > It used to be css_tryget_online() which was changed to css_tryget() and from the discussion at [1], it seemed css_get() would be enough but we took a safer route. Anyways, I think we can either take the page_memcg_rcu() route or put explicit restrictions with page lock or lock_page_memcg() to guarantee page and memcg binding. I don't have a strong opinion either way but I think removing restrictions in future for new use-cases will be much harder, so, page_memcg_rcu() approach seems more appropriate at least for now. [1] https://lore.kernel.org/linux-mm/CALvZod5pAv=u8L2Tgk0hDY7XAiiF2dvjC1omQ5BSfzFu_2zSXA@mail.gmail.com/