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=-2.4 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 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 70417C433DF for ; Mon, 15 Jun 2020 15:10:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2EBD520739 for ; Mon, 15 Jun 2020 15:10:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chrisdown.name header.i=@chrisdown.name header.b="aPeEzEq8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2EBD520739 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chrisdown.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BAF056B000D; Mon, 15 Jun 2020 11:10:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B5FF96B000E; Mon, 15 Jun 2020 11:10:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A9D076B0010; Mon, 15 Jun 2020 11:10:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0112.hostedemail.com [216.40.44.112]) by kanga.kvack.org (Postfix) with ESMTP id 928F66B000D for ; Mon, 15 Jun 2020 11:10:33 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 12841184B3570 for ; Mon, 15 Jun 2020 15:10:33 +0000 (UTC) X-FDA: 76931782746.26.low84_501731a26df7 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id E39FB18027FCF for ; Mon, 15 Jun 2020 15:09:14 +0000 (UTC) X-HE-Tag: low84_501731a26df7 X-Filterd-Recvd-Size: 5094 Received: from mail-ej1-f67.google.com (mail-ej1-f67.google.com [209.85.218.67]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Mon, 15 Jun 2020 15:09:14 +0000 (UTC) Received: by mail-ej1-f67.google.com with SMTP id y13so17846730eju.2 for ; Mon, 15 Jun 2020 08:09:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=I3pYBTJCH1fWxzUVivyIxWA31KHjVQXjnfV1c/iHSQ8=; b=aPeEzEq8Bmncf5GDxG4bKMbLMmpAo3LrvR3mDRIGWrMYi8m0weo1We6uJeEyp/OCdf /K4tB062Vr1+uzaRvdUPls1EMMG+6mqPlTcGG+J0AVYmUhkuQd4uuhW8AEwLZcc4EZoB CSGBuXP88a9JMP/xuTmLWTkbgT6ick7fAsj5k= 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=I3pYBTJCH1fWxzUVivyIxWA31KHjVQXjnfV1c/iHSQ8=; b=eHecK2jnORQ0OxifOTDthEGUvprwevJjlXHx0jB/8Rl0bMKhzToUVDvdT4tXPXzdzK zgSchQGF5iSXVoiOPYFfD4no9E2v/USFxCXz1DZOvX0gFA6P7Eiyt8X/vKSvQqceG9xv X461VPSVog5nJ9pew3OFwntByghvjaxam9kBpvNlfQn5r9IJXUgVDqg2W3Lm8E3gt5gb hDpXpTdqKjXHL+YDGI/vaJBDssD9OQhLZGHlGaD3sf/TU+pUhtFVJLSm7NTTGddih9Qi YJkO81kNP2KJujJRsfwkDb04ObrgcqmqliUSUC32X17e3jIMYErHekw4Mxz3cXG4//Ol LN/g== X-Gm-Message-State: AOAM532kzItoxsAAAZM30iMbUADjv6gtHqFDwNB+gIQ/r5VrTeFW1cBV 04rssiVEFal1KRjulDlwvnDE2Q== X-Google-Smtp-Source: ABdhPJzeW4+2+GixiCcm6tt6aIOT33friuuTwTXSJQgxiQ6xtbaI4m513By7G/zR8apVHeGwbGMnMg== X-Received: by 2002:a17:906:edb6:: with SMTP id sa22mr14094332ejb.393.1592233752926; Mon, 15 Jun 2020 08:09:12 -0700 (PDT) Received: from localhost ([2620:10d:c093:400::5:3c3c]) by smtp.gmail.com with ESMTPSA id s17sm9134265eju.80.2020.06.15.08.09.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jun 2020 08:09:12 -0700 (PDT) Date: Mon, 15 Jun 2020 16:09:11 +0100 From: Chris Down To: Johannes Weiner Cc: Andrew Morton , Tejun Heo , Michal Hocko , Roman Gushchin , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH] mm: memcontrol: handle div0 crash race condition in memory.low Message-ID: <20200615150911.GD157916@chrisdown.name> References: <20200615140658.601684-1-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20200615140658.601684-1-hannes@cmpxchg.org> User-Agent: Mutt/1.14.2 (2020-05-25) X-Rspamd-Queue-Id: E39FB18027FCF X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: Johannes Weiner writes: >Tejun reports seeing rare div0 crashes in memory.low stress testing: > >[37228.504582] RIP: 0010:mem_cgroup_calculate_protection+0xed/0x150 >[37228.505059] Code: 0f 46 d1 4c 39 d8 72 57 f6 05 16 d6 42 01 40 74 1f 4c 39 d8 76 1a 4c 39 d1 76 15 4c 29 d1 4c 29 d8 4d 29 d9 31 d2 48 0f af c1 <49> f7 f1 49 01 c2 4c 89 96 38 01 00 00 5d c3 48 0f af c7 31 d2 49 >[37228.506254] RSP: 0018:ffffa14e01d6fcd0 EFLAGS: 00010246 >[37228.506769] RAX: 000000000243e384 RBX: 0000000000000000 RCX: 0000000000008f4b >[37228.507319] RDX: 0000000000000000 RSI: ffff8b89bee84000 RDI: 0000000000000000 >[37228.507869] RBP: ffffa14e01d6fcd0 R08: ffff8b89ca7d40f8 R09: 0000000000000000 >[37228.508376] R10: 0000000000000000 R11: 00000000006422f7 R12: 0000000000000000 >[37228.508881] R13: ffff8b89d9617000 R14: ffff8b89bee84000 R15: ffffa14e01d6fdb8 >[37228.509397] FS: 0000000000000000(0000) GS:ffff8b8a1f1c0000(0000) knlGS:0000000000000000 >[37228.509917] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 >[37228.510442] CR2: 00007f93b1fc175b CR3: 000000016100a000 CR4: 0000000000340ea0 >[37228.511076] Call Trace: >[37228.511561] shrink_node+0x1e5/0x6c0 >[37228.512044] balance_pgdat+0x32d/0x5f0 >[37228.512521] kswapd+0x1d7/0x3d0 >[37228.513346] ? wait_woken+0x80/0x80 >[37228.514170] kthread+0x11c/0x160 >[37228.514983] ? balance_pgdat+0x5f0/0x5f0 >[37228.515797] ? kthread_park+0x90/0x90 >[37228.516593] ret_from_fork+0x1f/0x30 > >This happens when parent_usage == siblings_protected. We check that >usage is bigger than protected, which should imply parent_usage being >bigger than siblings_protected. However, we don't read (or even >update) these values atomically, and they can be out of sync as the >memory state changes under us. A bit of fluctuation around the target >protection isn't a big deal, but we need to handle the div0 case. > >Check the parent state explicitly to make sure we have a reasonable >positive value for the divisor. > >Fixes: 8a931f801340 ("mm: memcontrol: recursive memory.low protection") >Reported-by: Tejun Heo Acked-by: Chris Down