Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1739763ybt; Mon, 15 Jun 2020 08:13:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxR4X3+3u3Hwwluqo4LMt3ckVDWN/7HVdT/6Jvu5IF/iHnk1ch0Z0w13gU9klujrkC+Mjif X-Received: by 2002:a50:fe07:: with SMTP id f7mr24723388edt.315.1592234008594; Mon, 15 Jun 2020 08:13:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592234008; cv=none; d=google.com; s=arc-20160816; b=skIBNH4nchZ+9riJIVrHtSoEIsPpbBozXcc5P3O6LA6bFm9tG9j+gNh4DkSW81AaJ9 2ivYJf+6aSt3jUgAstTjbDPsyjLUAr1CKYjiNT0KPUYaauepSJKBsKiuhMt3czHjpdez rzWP8v6mB+XQZ1zqdDHeBMvbteiS0vHjKiLKMgAGktExCvqQqBRYIvCHWQz9DoQjXYSo yvamdA0pLknd9qIK6sYGrpBVKqnDg+Xb/LBYgN98OKiH101Oy8AjHHCVhpAhILBD97A7 dtH9mklsTJV6Ya4f8Mqrkjj006M19wh5RccjW6zZkH/Id0z9c4sbgDaPmoU98zDi98c1 7lXg== 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=I3pYBTJCH1fWxzUVivyIxWA31KHjVQXjnfV1c/iHSQ8=; b=ykdUZPwHnJs/wZ0hmzIaIVcH+MCgDlzHN+ddvMFG888ZSYqSTdsJx3AgqtPNILpCEh mzu/+BVNLOUegpmdC5mhMlbWVA+lsT2T7fmzK7UYGlcDSuVkZZSpxeaev52VgeKvj1qR 8Yg6pt8yvA4lRcCWsLD+VdBUvJ7YiltPrxUjdUpUOVMivtsNzJKHsatEzrLxyoIxWBLm vuwCFGwPxwIWwT4pwqjnuYuQyHTgoI/FeF0qgrK/nOrn3CzWX/J4mwnJxZ6FdR3P1Zt8 rUlLZna4NVIMnCEzGLKtZ5b3jKpw8xERvExj+YChAMiHIPxAvJvlRwpiWicCCSKwogHA s4CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b=aPeEzEq8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chrisdown.name Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i7si11265969ejo.473.2020.06.15.08.13.06; Mon, 15 Jun 2020 08:13:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b=aPeEzEq8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chrisdown.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730903AbgFOPJR (ORCPT + 99 others); Mon, 15 Jun 2020 11:09:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730794AbgFOPJQ (ORCPT ); Mon, 15 Jun 2020 11:09:16 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCC4CC05BD43 for ; Mon, 15 Jun 2020 08:09:14 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id f7so17830630ejq.6 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=O5bRwUEXRqUprctV4cUVyF2Gdf4EjESRcoPWfHfIQnVOeUNp2vwMk4Jrx8nc9F5G6X QxUsZJDAXa+tP/Ce/NOgSVZJwJKs8HLf0Kuk/sPYp+MDQqvREMGOvDp4TAr0Z/WCTO43 HDi/hkCo9J8fZRA4SpVIQcTMiGKsNnQ8UHo3JvL9kti6cuwYje4ZArHGIAFIFeOum8l5 mbzD6qNgVydO4VGUs1koVsorV9z0XYw0Swg9K+U/RdD98eVwxdi0pQqLpa65g/xIZ7EI OYfqwwwQpsTDNRwIiIH2BSthIJo4ZRw6uEcGkNTdIkE/A2uvgXF3f76yciukfRdCNP2X zdvw== X-Gm-Message-State: AOAM531fBq2OXtjAy7N4S1Q1urxGLi8YCTfy8R4RzC6Xn+CflZK9OVYq Lsc2/z0UUqD1xAyoAPPyadWtbg== 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) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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