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 X-Spam-Level: X-Spam-Status: No, score=-5.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1625CC433E9 for ; Fri, 5 Feb 2021 23:13:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DF3F264FF6 for ; Fri, 5 Feb 2021 23:13:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232301AbhBEXNU (ORCPT ); Fri, 5 Feb 2021 18:13:20 -0500 Received: from mx2.suse.de ([195.135.220.15]:50472 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232625AbhBEO2U (ORCPT ); Fri, 5 Feb 2021 09:28:20 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1612541179; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=X0eNZnPZ2yvNSsohyfO18yi1he4bt+Z9BswCbs9pY3o=; b=YTiJoqhqHI2WHfc/9NOnQxXomFQnQCUwdI5oE5KBAXc1O9bZPxV2+A/3GrVxmdvJKCbIc8 9ChcfYP2M7iEcMltkcdxKxBeP+1W6fktGOqgAaFVj4vBCU4AuFA1sVBIwma+QHOIqOGPkd HlvyEvn0XK+Z44oQX8eZCi+9KntjaFw= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 560A9B0BF; Fri, 5 Feb 2021 16:06:19 +0000 (UTC) Date: Fri, 5 Feb 2021 17:06:18 +0100 From: Michal Hocko To: Shakeel Butt Cc: Roman Gushchin , Muchun Song , Johannes Weiner , Vladimir Davydov , Andrew Morton , Cgroups , Linux Memory Management List , LKML Subject: Re: [External] Re: [PATCH] mm: memcontrol: remove rcu_read_lock from get_mem_cgroup_from_page Message-ID: References: <20210205062719.74431-1-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 05-02-21 07:59:06, Shakeel Butt wrote: > +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. Yeah, I would like to not have very special locking requirements here. Definitely not page_lock as that one is too overloaded already. > > [1] https://lore.kernel.org/linux-mm/CALvZod5pAv=u8L2Tgk0hDY7XAiiF2dvjC1omQ5BSfzFu_2zSXA@mail.gmail.com/ -- Michal Hocko SUSE Labs