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=-13.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL 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 EA06DC433E0 for ; Fri, 5 Feb 2021 15:59:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5620C64DEB for ; Fri, 5 Feb 2021 15:59:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5620C64DEB Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B9B3D6B007B; Fri, 5 Feb 2021 10:59:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B21496B007D; Fri, 5 Feb 2021 10:59:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99F3A6B007E; Fri, 5 Feb 2021 10:59:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0203.hostedemail.com [216.40.44.203]) by kanga.kvack.org (Postfix) with ESMTP id 7CE296B007B for ; Fri, 5 Feb 2021 10:59:20 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 4B38C824999B for ; Fri, 5 Feb 2021 15:59:20 +0000 (UTC) X-FDA: 77784673680.15.bag60_160131f275e6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 0AFAE1814B0C1 for ; Fri, 5 Feb 2021 15:59:20 +0000 (UTC) X-HE-Tag: bag60_160131f275e6 X-Filterd-Recvd-Size: 4395 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Fri, 5 Feb 2021 15:59:19 +0000 (UTC) Received: by mail-lf1-f49.google.com with SMTP id h7so10569857lfc.6 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=fGQQMO2RowaVqSFpP7CO4ZryXrhVPui1fHoj+OYu3yRWzsP7cSdPM6oyR2z3gnwsMn TEaCZLs3YOxFjXDS4G882IBAre0+cKWFhfhSRRiW7VGw2PbfRqEnHyh/DwVeh7fgTv2N 4o5+A7xCC3yMisLHS1CyVll4/9JOUsUhe8KU7bJZ69t4vI8lVv8CqvX4thkt2rnJ0Qnf 8AuLdandLvwNiSxVK3VFZHOVIamv5P/mPqBQH/j/B25HrBk84/9mqQe/k7KWCAYSAdXi blNVekTPohJPrz7FoPrFVLUDvKBydoUNqQTT3FGvG7I4uWtPM0LfBynMuS3pxLL95350 wv7A== X-Gm-Message-State: AOAM530QrNOyKqUlBIh7HShhEr+PVKB3kLB5QIzIB8bqzNJGhP3SRPoH us/LSGX1xiyeRaqweDBrVEIOa3xGVqBkLH4F4lUymw== X-Google-Smtp-Source: ABdhPJynHravulos9kvEdqamWTrNiSmYhNidO9oViyVVCdPE2tLwU/SEvGYCabUTT73f1QcoYRDQDCmbc0htVFMoh9Y= 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" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: +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/