Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp992478rdg; Fri, 13 Oct 2023 07:17:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF+OI6UxJaDr+hdDC3n8hf4XbPd74T6QsNOvfZkI9nd7xCoP4QzgOPPyldQg6yox/+NbchL X-Received: by 2002:a05:6358:9998:b0:133:595:1c with SMTP id j24-20020a056358999800b001330595001cmr29376368rwb.31.1697206665084; Fri, 13 Oct 2023 07:17:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697206665; cv=none; d=google.com; s=arc-20160816; b=PTXNRS6Ex4TpVcnVMBzM8+3zVnRccGfiKF2shn/IrE6Nu5qCP06V+m7K+y3ExBtA+h eAeoY/0hOgoI6ok3X2b7CTg2X00MtlTfHyMEato81cq65riMH4mZREDP8QWHy+JntdjZ pQ8OJA/eDxgQ+WQOrXxiCFVgnhPNKvvjiH63I3npoFF2LLX1+V4WINkCNDQ3mWzfwL+F LVD+jdPqlSxuHcE59KLrOenrpnAyZKf/J+51LTsROmCi6dpwFXQPAcOCkZ0ZKpm66qX/ gnor0s1qMWFvpod2llkv79okOXBsDpDMLfCoMgLu7142vu+iaKDSIrFKT8TrLPdd1B13 hgaA== 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=3I7xUNHL0g2s71bMvgTRR/Ie+t515rJ/kQMEyfshuUM=; fh=ypOBljvv37JabNdBdS1eVVloiK/Dvaqlg/sZ/wTBnzY=; b=KjV3SEi5kHpcOYt6zLf1o6vwNrqpbPPLhM6fBtmMy8eQ5kY78p8UX6hLJ5HkNUiLbk dzISj3gfR50kaL/vut1vG4H5G6pWxf50umpLARCw9t70k7+XD3TV1Vun6Y20JCCqTbFJ TXDvWZN945+DtW5MbvlaWYeMuDXnBnuuIhWGkHUqOByVEXRNBxGtXyI/zWTqK7h+V+eX L7WoxyU8Elhmcmcir+KNsmnt5AnA/tP84olOyfVulqWNsnlm8oi/NQQHfrQ3HGMmDOQ4 4JPq2WXF37TBcpdmRAiY3YQW3ofvjerqmY6WubqCaf5DzEVlNtlH5ednt2xpuGnXEG+q go8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=iVLBWv20; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id m6-20020a63ed46000000b00563d9ff5157si4512701pgk.547.2023.10.13.07.17.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 07:17:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=iVLBWv20; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 4C3F681C8D9A; Fri, 13 Oct 2023 07:17:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232072AbjJMOR3 (ORCPT + 99 others); Fri, 13 Oct 2023 10:17:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231194AbjJMOR2 (ORCPT ); Fri, 13 Oct 2023 10:17:28 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA426D8; Fri, 13 Oct 2023 07:17:23 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3B7C221A01; Fri, 13 Oct 2023 14:17:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1697206642; 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=3I7xUNHL0g2s71bMvgTRR/Ie+t515rJ/kQMEyfshuUM=; b=iVLBWv20wJKQHkXhK9SNTttjnhi31pxi8zFlNZRK2AZYglALFIKehB6KDPZh2/expdfzzt Ek8ejiZnD0WPOL1tmNBzhczTPX8rpk3sWeDGQog/mH3cONil8PCI9ozk46KpZHESX+wr8u uikMF7qfzdl8DLvE7gINhulI715Pp8M= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 17C741358F; Fri, 13 Oct 2023 14:17:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8dB4A3JRKWUjLAAAMHmgww (envelope-from ); Fri, 13 Oct 2023 14:17:22 +0000 Date: Fri, 13 Oct 2023 16:17:21 +0200 From: Michal Hocko To: Waiman Long Cc: Johannes Weiner , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] mm: memcontrol: Don't css_get() on root_mem_cgroup in get_mem_cgroup_from_mm() Message-ID: References: <20231012161504.3445042-1-longman@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231012161504.3445042-1-longman@redhat.com> Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -8.10 X-Spamd-Result: default: False [-8.10 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-3.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; REPLY(-4.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-1.00)[-1.000]; RCPT_COUNT_SEVEN(0.00)[9]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 13 Oct 2023 07:17:40 -0700 (PDT) On Thu 12-10-23 12:15:04, Waiman Long wrote: > As reference counting in the root memcg is disabled, there is no need > to get a reference if root memcg is to be returned. Does this give any measurable wins? > Signed-off-by: Waiman Long > --- > mm/memcontrol.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index 5b009b233ab8..2b3864194042 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -1060,8 +1060,10 @@ struct mem_cgroup *get_mem_cgroup_from_mm(struct mm_struct *mm) > rcu_read_lock(); > do { > memcg = mem_cgroup_from_task(rcu_dereference(mm->owner)); > - if (unlikely(!memcg)) > + if (unlikely(!memcg)) { > memcg = root_mem_cgroup; > + break; > + } > } while (!css_tryget(&memcg->css)); > rcu_read_unlock(); > return memcg; > -- > 2.39.3 -- Michal Hocko SUSE Labs