Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp304411pxb; Wed, 14 Apr 2021 16:09:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+1KzM+QxzlL60ABWFquOUS3lENp5LoSL3u/xEy0YVq+Ol19g09g86t7G+W5ccLzzpIj/N X-Received: by 2002:aa7:cd51:: with SMTP id v17mr649032edw.137.1618441790791; Wed, 14 Apr 2021 16:09:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618441790; cv=none; d=google.com; s=arc-20160816; b=gCbOlpYRob/x2lVq/xpvqCHO6qIZQlq+ZeGTGsN0gUuJxw5myVclKL6+Zb5B63y0RE AXcHLiQx6FEq1/Iq3c4EHd7eoyWvQzRoew2j3UZNcySb1WaYQ3aeZ9q8u4zPyhbzyQQU lwziCyKFSDghUYQZFMB2xV8o7Djxfr/GXnK9CioOAbNRhGjZt9UR8j0xk+cl8R2+0FTK Z1Zik4l70ieHQIz4qUTUat9sCrqaEmt0KrAdxpHnkv4BS0/L+Jg3ZdsmSTXidshF77Wt wY+CUWS1liV5J0tLMTE00S214PGlQvJbDnxSMv+qbQnyqNOra8dT9PGH09+JoXkpMMP2 OGEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=e6wKF//P88U/M+zDwsZ3xJTgPUSQgjspEx6v7dGglkw=; b=MbQ45KP79m+ITg/JxQ3BW3ORddLC4VUTAW36kT79jjDYNERFY9rOx5ZiF/FX5CuGA3 18YTQecJsfffyDPMBCbF7un54PK0/R+IBxz0dD/AmYEMt4k/Uu028zoELMZJZYP5q/67 Uq0huWUxbJ6PdGrNHy9vVWeh+cMI2KVIdf9C0EPzvB3ozo4QQxdnSuBQqVfZm23947q7 JuHZ55mXAqfnxGbIbXMmFgvYbQeHKu96NTYgvPTQOLDnC/zCmLNWTZU+kIcRUoQvzLRi onLQlnUMj/W9LPJ7EGehNfex4aXSFqgpPhXQ2q8/gnzgVbD/pSXf+OxCvgM3lFkZdNeb QpuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=XixLXnku; 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=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k7si770180edx.440.2021.04.14.16.09.27; Wed, 14 Apr 2021 16:09:50 -0700 (PDT) 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=@suse.com header.s=susede1 header.b=XixLXnku; 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=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232908AbhDNKQG (ORCPT + 99 others); Wed, 14 Apr 2021 06:16:06 -0400 Received: from mx2.suse.de ([195.135.220.15]:57884 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232032AbhDNKQE (ORCPT ); Wed, 14 Apr 2021 06:16:04 -0400 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=1618395342; 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=e6wKF//P88U/M+zDwsZ3xJTgPUSQgjspEx6v7dGglkw=; b=XixLXnku8keACsrXdywnzaLMPxitUWW1MLzpGkLuHry2mV4ONud24MzYd5uB9jGT5g4crA PLg3P0NDpplSNVmjWSGBluS2VEspTZBk8K8hs5ue6yPgvuJJBehN6DpNUPg0MMq1ZDZRd9 WWWPyYawUhyJQ5vKR5Ep41hOxAMG+X0= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 3DA79AF4F; Wed, 14 Apr 2021 10:15:42 +0000 (UTC) Date: Wed, 14 Apr 2021 12:15:40 +0200 From: Michal Hocko To: Muchun Song Cc: guro@fb.com, hannes@cmpxchg.org, akpm@linux-foundation.org, shakeelb@google.com, vdavydov.dev@gmail.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, duanxiongchun@bytedance.com, fam.zheng@bytedance.com Subject: Re: [External] Re: [PATCH 2/7] mm: memcontrol: bail out early when !mm in get_mem_cgroup_from_mm Message-ID: References: <20210413065153.63431-1-songmuchun@bytedance.com> <20210413065153.63431-3-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 Wed 14-04-21 18:04:35, Muchun Song wrote: > On Wed, Apr 14, 2021 at 5:24 PM Michal Hocko wrote: > > > > On Tue 13-04-21 14:51:48, Muchun Song wrote: > > > When mm is NULL, we do not need to hold rcu lock and call css_tryget for > > > the root memcg. And we also do not need to check !mm in every loop of > > > while. So bail out early when !mm. > > > > mem_cgroup_charge and other callers unconditionally drop the reference > > so how come this does not underflow reference count? > > For the root memcg, the CSS_NO_REF flag is set, so css_get > and css_put do not get or put reference. Ohh, right you are. I must have forgot about that special case. I am pretty sure I (and likely few more) will stumble over that in the future again. A small comment explaining that the reference can be safely ignore would be helpful. Anyway Acked-by: Michal Hocko Thanks! -- Michal Hocko SUSE Labs