Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp305061ybx; Wed, 6 Nov 2019 17:26:49 -0800 (PST) X-Google-Smtp-Source: APXvYqwJqlgXRKSJQjawiPNWvx3dFobXV3GhWnUwa00kJXVO++s+aXtNrM07iaOdo9zPqo5Iu4bw X-Received: by 2002:a05:6402:713:: with SMTP id w19mr845101edx.239.1573090009678; Wed, 06 Nov 2019 17:26:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573090009; cv=none; d=google.com; s=arc-20160816; b=ejhEsNjNaCp+bIK4KthKPA8u4gBPy6aIeJcp1PTFOzH0KLk1iSqbcazcG1rg6Ju8/A lnjhXUORXrK+9dLbPIu4HmD1Kj4amjVmvIKmVoG0D3K0IeqgJO2Omo6jWR/md2MoHefs RdfzShBRiUEJlLhl5ZAzeZJ92M8SzS8Q24QIk5X6T+8IUxoHqKSkK1Vr9q3FMfbDfLb/ LEwNHbEjdPiDqNsUejacSSgLwzlhm8prQ9W+L+v0dvB+Mrp3s9uy5bmkR9XsY8utTk7b mdWcvEYFPIGUKIld5PvtLQYX343a4PFXLDf1FQ5ASGYN3NI8GH2453LdCrSn5AIaUcVj K67w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=MGf1G/Idf98+jw/3Ou5BEwGK66KdVONOwSI1GdIY6gk=; b=LNKcVWqclZ03QNHtYvIyK1u3hy0MANPEzkXxZJ6/e3tPVlY52pHcyhE8l8Vn2lSC0h TVzmwWOflMxWmdJJTTUVSwvUqDAYCMeDpL0EAXLE6H7Dpozgg3nDrh0xwJh3HhTv5q6K 9Wp3foCYLn3CJjSoL5R6ETGDIxxkRAjqCBXiN6LmpHG5Ojs5FXnctO1rkiQKF0qg76qX kJi0132WGCCyPkASidjpARYqG64jq3SHtOctSWlTSKJt6j5Chsi86dYRGKU2WC+5pwS0 kfKDjhj8sBOAKeGWVxxOPRFNfs012b+FphtxU1P3J7ZnFLyFjRcxLRuSocvJ5TUfEaDG gYaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=M0ssWjRB; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 18si449355ejz.321.2019.11.06.17.26.23; Wed, 06 Nov 2019 17:26:49 -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=@google.com header.s=20161025 header.b=M0ssWjRB; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728091AbfKGBZi (ORCPT + 99 others); Wed, 6 Nov 2019 20:25:38 -0500 Received: from mail-oi1-f195.google.com ([209.85.167.195]:46093 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727798AbfKGBZi (ORCPT ); Wed, 6 Nov 2019 20:25:38 -0500 Received: by mail-oi1-f195.google.com with SMTP id n14so470804oie.13 for ; Wed, 06 Nov 2019 17:25:38 -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=MGf1G/Idf98+jw/3Ou5BEwGK66KdVONOwSI1GdIY6gk=; b=M0ssWjRBobxfWKaBwwLCqTSQ0mWBLINVZ7SKXHwBkJpuz65tBoHNLZG1DdIpEeMsrZ lt+bf1gcUy8X8L+EQ/pamaZKRrbvJzyG5+w6Hf40F+cVHayFBaFbvoPdK/kxs3TiQ9Rd ALuFh7usFL1WUkHc9qPwfJHpVQIuM124Tq7/2PYOrfjEmgnTxWl7UVh0jbvc7W2EV3PL Mg8Yt0EyO4vCpfw45aQqv4J4fXyRNDu4mV0gVVfMBiPK3OBKumk8sZ/oh6C+uBoRd55K yOWfkpzem5vEpHy0RPtOnHVxe+YSgPuRHXEHVhGEN4cEcX/d/gPEHHDQkiSnuhZDy6Kz DIyg== 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=MGf1G/Idf98+jw/3Ou5BEwGK66KdVONOwSI1GdIY6gk=; b=kUxvNw0FUNCQIvFjdpTwHu6yx86+DWu8RDWghkNy/YPA0bGM+25mv47vZSqyI2mhJb Q4l4Y/uGfuVAzgeApGHu+7/wsWZh9V35nIOJ7pcKcePpKdpIb/JNXCpJC3nQ50/bDPKw SpsDKmDGYaE84h0ihELj9/6EzcOZnXdrp/MInE8WdzNOveRrX20PLmiGDM639FUS4/a5 BKcrFGNd0XEucSZgNwgp6AvWMqZThPYecajv492Mhnc9R3Y21aiSc0ays9DmEk4XQnkz R/wFILqPipPA7bCvemesy39XAEThBYDcd+BRsU5VHreVhXFWhl38pCznOMqyBdKoMSN+ dGuQ== X-Gm-Message-State: APjAAAXWNdjm+rfFUWg/Pr4qYMP1BgYXmUiV5lbFC6VQ4ywWC8FhBi+o cYEvNC5Yi54m4tY2XYZar2AuBCi3c5I0jHmDSxLZSw== X-Received: by 2002:aca:4fce:: with SMTP id d197mr959325oib.142.1573089937164; Wed, 06 Nov 2019 17:25:37 -0800 (PST) MIME-Version: 1.0 References: <20191106225131.3543616-1-guro@fb.com> <20191107002204.GA96548@cmpxchg.org> In-Reply-To: <20191107002204.GA96548@cmpxchg.org> From: Shakeel Butt Date: Wed, 6 Nov 2019 17:25:26 -0800 Message-ID: Subject: Re: [PATCH 1/2] mm: memcg: switch to css_tryget() in get_mem_cgroup_from_mm() To: Johannes Weiner Cc: Roman Gushchin , Linux MM , Andrew Morton , Michal Hocko , LKML , Kernel Team , stable@vger.kernel.org, Tejun Heo Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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?