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=-11.3 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=no 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 9B9FCFA372C for ; Thu, 7 Nov 2019 01:25:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2CA31217D7 for ; Thu, 7 Nov 2019 01:25:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="M0ssWjRB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2CA31217D7 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 92E4F6B0003; Wed, 6 Nov 2019 20:25:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8B7F86B0006; Wed, 6 Nov 2019 20:25:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 77ED76B0007; Wed, 6 Nov 2019 20:25:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0247.hostedemail.com [216.40.44.247]) by kanga.kvack.org (Postfix) with ESMTP id 5F1116B0003 for ; Wed, 6 Nov 2019 20:25:39 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 078A9180AD82F for ; Thu, 7 Nov 2019 01:25:39 +0000 (UTC) X-FDA: 76127739198.03.bath07_8894e9a7c5e10 X-HE-Tag: bath07_8894e9a7c5e10 X-Filterd-Recvd-Size: 5123 Received: from mail-oi1-f193.google.com (mail-oi1-f193.google.com [209.85.167.193]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Thu, 7 Nov 2019 01:25:38 +0000 (UTC) Received: by mail-oi1-f193.google.com with SMTP id k2so477307oij.12 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=dWUW+Ebv4PVlX8YfmjWEoh8tTHKVd3Ks5RfzX/HR6x7F0LVkUKt4xTp6Eonqf2PClz OtN4pqpGeCnyUAtQWQ7IO222z+PNMlRkkqo64AOwwibKVrw9C5pINk4W+ZRluO2OFxN2 0Jd5kJSddo6d8N2OzZKm2czt9bFdTzhJQR3pHJ0euSSdnkwRfHxdLEi8csvVoHxSynQ2 R3dWVM1/MDBBMu2wWQQm8/RR6GxhlI7RkQVyzB72CCOZ8XVgn//5OXiNsdd7SpfiFtRe 7CRhGLUNOMldS91ixL3sknU3teTIXJiyinaIuQfS/HEREDzc1V2hDEBmRsX6ypYvfHUN 21rg== X-Gm-Message-State: APjAAAVnTPfRZoEBwLUPwVJ+qc1U6Onq2V0PZ01BLG14MJ9Dn7e8Z5fT h4RuFz6QsVqHpzI8wA+QSaIdSVMlvDVJg7hTxgy1MQ== X-Google-Smtp-Source: APXvYqw6efiJ0PRxdXQPobN4uLlaNjVFitxn3Vfc1xdL/4tlbdvE69PO+yIpW5h94B0crbZydjt09kDflTuKR59Nq9c= 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" 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 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?