Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp322281ybx; Wed, 6 Nov 2019 17:47:04 -0800 (PST) X-Google-Smtp-Source: APXvYqxKgjdirQxmKHYNVpU136O8oz+el5Y9s4xkotOdnUGwDRKe7+SFs+hE0FbuhB0voLLS+jXY X-Received: by 2002:a17:906:2e52:: with SMTP id r18mr722228eji.178.1573091224455; Wed, 06 Nov 2019 17:47:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573091224; cv=none; d=google.com; s=arc-20160816; b=wTt2npbvB9/dVKBCNI8kHxbiNcZG5MwdWHJT/HWkGEmIDT71DNAXeBeENm5vt8q5mk 67AcdRwLQyuDnuQxXRpxjqgGUJrdxjFjIy4Qgogg89HkMFbhJXswU5hCs27hYfnFqnjr xjOsWBNCRIFVR29LmRApC3Pb+KO1wkWmFvMFFdRNBfhlqmXVtCqhnpqZMi99A4A4wjwa cYszIwiyc2zNUtgmCm0TiZsvcG1Q8mH7Ep4Lz2St5LiiR802KbBu+hAT30jlAWvjbkk2 3g28WWv5Udyu9WHuiezCEL4Tta4RrUMl8OtSM9PwJKYWvjP+U+VfrI7lj6XZ+4wWtJ3/ I5OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=9VO4sGrknxbUDh30qhuG3KUeNeC1A4Tt2xPDsLEp5fM=; b=tMqmHnDIPXMHkM01eItoNs3lfJ5eXP8TKHhZ2EEh7vRgjOV2bF4uboXjZY2vnNauhY CU4AhmQq1qfU6cGHtU36xkculNsh0wGaqUbI1pXwRvO4VScD7I0+KyLdjVWnWqOPUY0f XriPivuhti+BG7ERmP8m/VqkInC79vlFIG+ICo7zpWyc7Wi+4nSuwog3qDeFZao8VJaf /MHFQ9oaCp3teXsyld91HZZc47ZKgmb/8I2uHQ4ZOuKujGNLqFajjQp1knTGNPrMu1Kn q+WWT4m2XeYkqLl6nxGoTSwsuA+ukWuyxMCchpnFGThCYcJKU4Ro6P92TnF+6H27mMT2 C75A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=rXc2aBAZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h18si284463edh.352.2019.11.06.17.46.40; Wed, 06 Nov 2019 17:47:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=rXc2aBAZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732732AbfKGBnK (ORCPT + 99 others); Wed, 6 Nov 2019 20:43:10 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:45966 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728306AbfKGBnK (ORCPT ); Wed, 6 Nov 2019 20:43:10 -0500 Received: by mail-pf1-f195.google.com with SMTP id z4so971617pfn.12 for ; Wed, 06 Nov 2019 17:43:08 -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=UT6JK19dMKMagMun3U0sMlKrvqmEa0yaVYu4SwtbdTjjhIMlD6zo4AAM+/o+QFa53y 4u925V5RU6I490Dr0NRqQipXLalkMztYotOHacnIo5JxN3CJ7J9hQU6vdICnJBYQsrP5 Pryh8IJ4B5/nvoObptb/ilLWEDqPF29Pk5j1lzxJGIYlxpcDJOyW0KeV/P0iQJP5pDUo PBRsiaq6j7N91LKFJoP8sE9Gh4t2GL0yv0C5uSBYneyJpiMSXmHXQruOVAgaxp10hQ+B gY74NZCFTq9z4Cb2rl9mA3ik7s8+/WnRqjr2rOTUZp4MTsFzpsTY3FBBwrsJKDQL28QN HEUA== X-Gm-Message-State: APjAAAVC0ma4CN9O68CBT7Nt2L0r961+0qTSRg58kDCJW+kDtYvfOxXJ qMeT5njTzBNjl/BMEDLlFgYwBw== 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) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.