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.2 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 DA49EFC6194 for ; Thu, 7 Nov 2019 01:43:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 988452187F for ; Thu, 7 Nov 2019 01:43:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="rXc2aBAZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 988452187F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3062C6B0003; Wed, 6 Nov 2019 20:43:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 28FEC6B0006; Wed, 6 Nov 2019 20:43:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 157C46B0007; Wed, 6 Nov 2019 20:43:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0176.hostedemail.com [216.40.44.176]) by kanga.kvack.org (Postfix) with ESMTP id EFD1A6B0003 for ; Wed, 6 Nov 2019 20:43:10 -0500 (EST) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id A944518C9 for ; Thu, 7 Nov 2019 01:43:10 +0000 (UTC) X-FDA: 76127783340.02.bag56_900b8273c8528 X-HE-Tag: bag56_900b8273c8528 X-Filterd-Recvd-Size: 5953 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Thu, 7 Nov 2019 01:43:09 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id c184so1041987pfb.0 for ; Wed, 06 Nov 2019 17:43:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=9VO4sGrknxbUDh30qhuG3KUeNeC1A4Tt2xPDsLEp5fM=; b=rXc2aBAZzYFknfwCG04vRP6mmQavmHkErS2hQWqXtresgzruUmJgRYIhy6QRzdzu0j QSqFg22DcPwXm3nS5X1Gbk0909scC7T/V5BMU4hictwJB/67vP3qk5XsOrlE+0Hlo1cy jjymQS7NDLdu3FJObNkukz/ZH4eSVMaZZDYsaIwqPf3teBONwlO5/a4rlJI0TatOQQ8B HlXT7D47UujAzQ55gjBWfO57fKa53rtqKHjRaq0x/A3uEnfzeqVxsxciArSUp862pHFM XNh/DBn71FT4u/BADAFKkClTmUpxDd2bvIdlztxBewEA5bt/tDY+hMtLfh6MIE4Jt0zs d5bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=9VO4sGrknxbUDh30qhuG3KUeNeC1A4Tt2xPDsLEp5fM=; b=lJL6hqxk6qqy6T+DpNA/Yr5glI4h6ABc6MNnRvPqjaemf4dKqikvnf1xr+0Ez60UK2 7PQbnQIyuSR7/nAnKnOdkeR7Ux8tcjdT6UCHUeqYkIwKyM1V0qBmqKrhybUH9j+XEb8j a9EISHqyhBftOG5pmEsvUe/KdvdAWQIQZFTnDQbSLm7jayqowv/qs4Eyo7/Nenugwkkp mAq+x4MEZSQ5zcgCPAeJoesFbg6gMJfE+aCVx7IBR7ilteDQZenJzCAeUY5rx9nnOVaM gP4Vy/5G1OZpiMMjZPB+lsVaDr+MMKNEdXS8DKEVI50BPkfvX1jlN2wGHxW7OVW2FHsQ jE9A== X-Gm-Message-State: APjAAAUei8yRsaW0p1AsLNu7AJbtdksZu2T5U5flZZX/eVNT/TwN9Ewl SEIW4NUOE1AQ8EU4EzHVng3o+Q== X-Google-Smtp-Source: APXvYqyCUj+4VEd7NMm6AGfG0FVKEdooHVpzlCAYsRZh4cpIqYfwEevcYEmaRsySPTUu75BpVUGTcw== X-Received: by 2002:a62:1ad6:: with SMTP id a205mr594141pfa.64.1573090987977; Wed, 06 Nov 2019 17:43:07 -0800 (PST) Received: from localhost ([2620:10d:c090:200::2:deb0]) by smtp.gmail.com with ESMTPSA id c19sm274837pfn.44.2019.11.06.17.43.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2019 17:43:06 -0800 (PST) Date: Wed, 6 Nov 2019 17:43:05 -0800 From: Johannes Weiner To: Shakeel Butt Cc: Roman Gushchin , Linux MM , Andrew Morton , Michal Hocko , LKML , Kernel Team , stable@vger.kernel.org, Tejun Heo Subject: Re: [PATCH 1/2] mm: memcg: switch to css_tryget() in get_mem_cgroup_from_mm() Message-ID: <20191107014305.GC96548@cmpxchg.org> References: <20191106225131.3543616-1-guro@fb.com> <20191107002204.GA96548@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) 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: On Wed, Nov 06, 2019 at 05:25:26PM -0800, Shakeel Butt wrote: > On Wed, Nov 6, 2019 at 4:22 PM Johannes Weiner wrote: > > > > On Wed, Nov 06, 2019 at 02:51:30PM -0800, Roman Gushchin wrote: > > > We've encountered a rcu stall in get_mem_cgroup_from_mm(): > > > > > > rcu: INFO: rcu_sched self-detected stall on CPU > > > rcu: 33-....: (21000 ticks this GP) idle=6c6/1/0x4000000000000002 softirq=35441/35441 fqs=5017 > > > (t=21031 jiffies g=324821 q=95837) NMI backtrace for cpu 33 > > > <...> > > > RIP: 0010:get_mem_cgroup_from_mm+0x2f/0x90 > > > <...> > > > __memcg_kmem_charge+0x55/0x140 > > > __alloc_pages_nodemask+0x267/0x320 > > > pipe_write+0x1ad/0x400 > > > new_sync_write+0x127/0x1c0 > > > __kernel_write+0x4f/0xf0 > > > dump_emit+0x91/0xc0 > > > writenote+0xa0/0xc0 > > > elf_core_dump+0x11af/0x1430 > > > do_coredump+0xc65/0xee0 > > > ? unix_stream_sendmsg+0x37d/0x3b0 > > > get_signal+0x132/0x7c0 > > > do_signal+0x36/0x640 > > > ? recalc_sigpending+0x17/0x50 > > > exit_to_usermode_loop+0x61/0xd0 > > > do_syscall_64+0xd4/0x100 > > > entry_SYSCALL_64_after_hwframe+0x44/0xa9 > > > > > > The problem is caused by an exiting task which is associated with > > > an offline memcg. We're iterating over and over in the > > > do {} while (!css_tryget_online()) loop, but obviously the memcg won't > > > become online and the exiting task won't be migrated to a live memcg. > > > > > > Let's fix it by switching from css_tryget_online() to css_tryget(). > > > > > > As css_tryget_online() cannot guarantee that the memcg won't go > > > offline, the check is usually useless, except some rare cases > > > when for example it determines if something should be presented > > > to a user. > > > > > > A similar problem is described by commit 18fa84a2db0e ("cgroup: Use > > > css_tryget() instead of css_tryget_online() in task_get_css()"). > > > > > > Signed-off-by: Roman Gushchin > > > Cc: stable@vger.kernel.org > > > Cc: Tejun Heo > > > > Acked-by: Johannes Weiner > > > > The bug aside, it doesn't matter whether the cgroup is online for the > > callers. It used to matter when offlining needed to evacuate all > > charges from the memcg, and so needed to prevent new ones from showing > > up, but we don't care now. > > Should get_mem_cgroup_from_current() and get_mem_cgroup_from_page() be > switched to css_tryget() as well then? Yes. Looking at the remaining css_tryget_online() in memcontrol.c, I don't think the online/offline distinction is meaningful for any of them anymore.